Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-06-16 02:18:25 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-06-16 02:18:25 +0400
commit004e38a44eff3b2987771aef8c7427f8c15a6494 (patch)
tree9ee104822b10f65cfd629d8243b61e65b941abf6 /source/blender
parent295976b7791e8005f82bb8644835b6feed10c861 (diff)
parenta2d4fddfd38ce0795d21ec9c5b5cc51fc50f3bd1 (diff)
Merged changes in the trunk up to revision 47977.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/BKE_colortools.h3
-rw-r--r--source/blender/blenkernel/BKE_mask.h3
-rw-r--r--source/blender/blenkernel/BKE_node.h12
-rw-r--r--source/blender/blenkernel/BKE_object.h20
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h4
-rw-r--r--source/blender/blenkernel/BKE_tracking.h267
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c8
-rw-r--r--source/blender/blenkernel/intern/armature.c2
-rw-r--r--source/blender/blenkernel/intern/colortools.c56
-rw-r--r--source/blender/blenkernel/intern/constraint.c55
-rw-r--r--source/blender/blenkernel/intern/curve.c8
-rw-r--r--source/blender/blenkernel/intern/mask.c59
-rw-r--r--source/blender/blenkernel/intern/movieclip.c33
-rw-r--r--source/blender/blenkernel/intern/multires.c70
-rw-r--r--source/blender/blenkernel/intern/node.c15
-rw-r--r--source/blender/blenkernel/intern/object.c133
-rw-r--r--source/blender/blenkernel/intern/sequencer.c6
-rw-r--r--source/blender/blenkernel/intern/tracking.c3202
-rw-r--r--source/blender/blenlib/BLI_math_color.h5
-rw-r--r--source/blender/blenlib/BLI_math_vector.h4
-rw-r--r--source/blender/blenlib/BLI_pbvh.h10
-rw-r--r--source/blender/blenlib/BLI_voronoi.h70
-rw-r--r--source/blender/blenlib/CMakeLists.txt1
-rw-r--r--source/blender/blenlib/intern/math_color.c38
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c33
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c32
-rw-r--r--source/blender/blenlib/intern/pbvh.c80
-rw-r--r--source/blender/blenlib/intern/voronoi.c833
-rw-r--r--source/blender/blenloader/intern/readfile.c65
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.h3
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c1
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c4
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c11
-rw-r--r--source/blender/collada/AnimationExporter.cpp241
-rw-r--r--source/blender/collada/AnimationImporter.cpp639
-rw-r--r--source/blender/collada/AnimationImporter.h2
-rw-r--r--source/blender/collada/ArmatureExporter.cpp110
-rw-r--r--source/blender/collada/ArmatureImporter.cpp106
-rw-r--r--source/blender/collada/CameraExporter.cpp67
-rw-r--r--source/blender/collada/CameraExporter.h2
-rw-r--r--source/blender/collada/DocumentExporter.cpp109
-rw-r--r--source/blender/collada/DocumentExporter.h4
-rw-r--r--source/blender/collada/DocumentImporter.cpp358
-rw-r--r--source/blender/collada/EffectExporter.cpp52
-rw-r--r--source/blender/collada/ErrorHandler.cpp22
-rw-r--r--source/blender/collada/ExportSettings.h8
-rw-r--r--source/blender/collada/ExtraHandler.cpp44
-rw-r--r--source/blender/collada/ExtraTags.cpp12
-rw-r--r--source/blender/collada/GeometryExporter.cpp71
-rw-r--r--source/blender/collada/GeometryExporter.h18
-rw-r--r--source/blender/collada/ImageExporter.cpp14
-rw-r--r--source/blender/collada/InstanceWriter.cpp6
-rw-r--r--source/blender/collada/LightExporter.cpp20
-rw-r--r--source/blender/collada/MaterialExporter.cpp16
-rw-r--r--source/blender/collada/MaterialExporter.h4
-rw-r--r--source/blender/collada/MeshImporter.cpp316
-rw-r--r--source/blender/collada/SceneExporter.cpp179
-rw-r--r--source/blender/collada/SkinInfo.cpp56
-rw-r--r--source/blender/collada/TransformReader.cpp19
-rw-r--r--source/blender/collada/TransformWriter.cpp14
-rw-r--r--source/blender/collada/collada.cpp95
-rw-r--r--source/blender/collada/collada.h5
-rw-r--r--source/blender/collada/collada_internal.cpp164
-rw-r--r--source/blender/collada/collada_internal.h4
-rw-r--r--source/blender/collada/collada_utils.cpp107
-rw-r--r--source/blender/collada/collada_utils.h25
-rw-r--r--source/blender/compositor/CMakeLists.txt27
-rw-r--r--source/blender/compositor/COM_compositor.h486
-rw-r--r--source/blender/compositor/COM_defines.h50
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp4
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.h14
-rw-r--r--source/blender/compositor/intern/COM_ChannelInfo.cpp4
-rw-r--r--source/blender/compositor/intern/COM_ChannelInfo.h72
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.cpp2
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.h10
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp6
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp1
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h115
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp572
-rw-r--r--source/blender/compositor/intern/COM_Converter.h54
-rw-r--r--source/blender/compositor/intern/COM_Device.h24
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp252
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h444
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp151
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h260
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp157
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.h144
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.cpp150
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.h105
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp204
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h103
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.h82
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp46
-rw-r--r--source/blender/compositor/intern/COM_Node.h101
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.cpp53
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.h150
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp80
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h321
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp6
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.h54
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.cpp82
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.h58
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp60
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h60
-rw-r--r--source/blender/compositor/intern/COM_Socket.cpp13
-rw-r--r--source/blender/compositor/intern/COM_Socket.h58
-rw-r--r--source/blender/compositor/intern/COM_SocketConnection.cpp12
-rw-r--r--source/blender/compositor/intern/COM_SocketConnection.h102
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.h58
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.h34
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp52
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h90
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp1
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.h12
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.cpp8
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.cpp18
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp13
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.cpp16
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.cpp8
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_CombineHSVANode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_CombineHSVANode.h8
-rw-r--r--source/blender/compositor/nodes/COM_CombineRGBANode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_CombineRGBANode.h8
-rw-r--r--source/blender/compositor/nodes/COM_CombineYCCANode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_CombineYCCANode.h6
-rw-r--r--source/blender/compositor/nodes/COM_CombineYUVANode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_CombineYUVANode.h6
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.h12
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp17
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.cpp8
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cpp69
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.cpp27
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.cpp157
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_GroupNode.cpp27
-rw-r--r--source/blender/compositor/nodes/COM_GroupNode.h34
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp13
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp13
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp76
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.cpp232
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.h42
-rw-r--r--source/blender/compositor/nodes/COM_KeyingScreenNode.cpp58
-rw-r--r--source/blender/compositor/nodes/COM_KeyingScreenNode.h36
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp8
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.cpp16
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.h12
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.cpp118
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp25
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_MuteNode.cpp74
-rw-r--r--source/blender/compositor/nodes/COM_MuteNode.h12
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.cpp95
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_SeparateHSVANode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_SeparateHSVANode.h8
-rw-r--r--source/blender/compositor/nodes/COM_SeparateRGBANode.cpp5
-rw-r--r--source/blender/compositor/nodes/COM_SeparateRGBANode.h8
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYCCANode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYCCANode.h6
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYUVANode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYUVANode.h6
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.h12
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.cpp69
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.cpp20
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cpp11
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.cpp29
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.cpp11
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp11
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.cpp8
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.h12
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp23
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp25
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.h28
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp31
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp38
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h22
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp64
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp36
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.h28
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp42
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.h28
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp55
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h12
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.h26
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h51
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h32
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp33
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.h26
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.cpp17
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.h24
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.h22
-rw-r--r--source/blender/compositor/operations/COM_CombineChannelsOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CombineChannelsOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp54
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.h42
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToBWOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertColourToValueProg.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp22
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h36
-rw-r--r--source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h38
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToColourProg.h18
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h38
-rw-r--r--source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp71
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp81
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h14
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.h20
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp222
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.h98
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp19
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_DistanceMatteOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_DistanceMatteOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp1067
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h26
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp46
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.h28
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp130
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.h8
-rw-r--r--source/blender/compositor/operations/COM_FogGlowImageOperation.cpp51
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.h40
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.h20
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp65
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h10
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp38
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.h14
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp36
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.h14
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.h82
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp405
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.h36
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.cpp113
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.h7
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp70
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.h7
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.cpp67
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.h7
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.h42
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h20
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.h20
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp52
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h40
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.h26
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.cpp88
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_KeyingClipOperation.cpp123
-rw-r--r--source/blender/compositor/operations/COM_KeyingClipOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.cpp89
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.h49
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.cpp131
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cpp220
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.h79
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp26
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp72
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.h38
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp17
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h104
-rw-r--r--source/blender/compositor/operations/COM_MixAddOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixAddOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixBaseOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_MixBaseOperation.h32
-rw-r--r--source/blender/compositor/operations/COM_MixBlendOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixBlendOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixBurnOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixBurnOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixColorOperation.cpp19
-rw-r--r--source/blender/compositor/operations/COM_MixColorOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixDarkenOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixDarkenOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixDifferenceOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixDifferenceOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixDivideOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixDivideOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixDodgeOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixDodgeOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixGlareOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_MixGlareOperation.h (renamed from source/blender/compositor/operations/COM_FogGlowImageOperation.h)30
-rw-r--r--source/blender/compositor/operations/COM_MixHueOperation.cpp19
-rw-r--r--source/blender/compositor/operations/COM_MixHueOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixLightenOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixLightenOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixLinearLightOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_MixLinearLightOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixMultiplyOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixMultiplyOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixOverlayOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_MixOverlayOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixSaturationOperation.cpp11
-rw-r--r--source/blender/compositor/operations/COM_MixSaturationOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixScreenOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixScreenOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixSoftLightOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_MixSoftLightOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixSubtractOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixSubtractOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MixValueOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MixValueOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h24
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp24
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.h22
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp40
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h26
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cpp22
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.h34
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl66
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl.h70
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp92
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h14
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp32
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h12
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h26
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.cpp64
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.h10
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h24
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp8
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersAlphaProg.h2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp26
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersBaseProg.h55
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersImageProg.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp66
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.h9
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp143
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h29
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp98
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h26
-rw-r--r--source/blender/compositor/operations/COM_SeparateChannelOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SeparateChannelOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.h22
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h34
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_SplitViewerOperation.cpp24
-rw-r--r--source/blender/compositor/operations/COM_SplitViewerOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp26
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h28
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.h60
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.h24
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h20
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.h32
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.h20
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.h30
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp24
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp55
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h23
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.h20
-rw-r--r--source/blender/editors/animation/keyframes_general.c14
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c52
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c30
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c34
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c310
-rw-r--r--source/blender/editors/include/ED_clip.h4
-rw-r--r--source/blender/editors/include/ED_gpencil.h8
-rw-r--r--source/blender/editors/include/ED_sequencer.h2
-rw-r--r--source/blender/editors/interface/interface_draw.c15
-rw-r--r--source/blender/editors/interface/interface_handlers.c4
-rw-r--r--source/blender/editors/interface/interface_ops.c125
-rw-r--r--source/blender/editors/interface/interface_utils.c8
-rw-r--r--source/blender/editors/mask/mask_draw.c45
-rw-r--r--source/blender/editors/mask/mask_edit.c2
-rw-r--r--source/blender/editors/mask/mask_intern.h1
-rw-r--r--source/blender/editors/mask/mask_ops.c88
-rw-r--r--source/blender/editors/mask/mask_relationships.c4
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.c4
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.h4
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c2
-rw-r--r--source/blender/editors/mesh/editmesh_select.c3
-rw-r--r--source/blender/editors/mesh/meshtools.c3
-rw-r--r--source/blender/editors/object/object_add.c13
-rw-r--r--source/blender/editors/object/object_constraint.c6
-rw-r--r--source/blender/editors/object/object_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c188
-rw-r--r--source/blender/editors/space_action/space_action.c18
-rw-r--r--source/blender/editors/space_clip/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c71
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c58
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_ops.c20
-rw-r--r--source/blender/editors/space_clip/clip_draw.c335
-rw-r--r--source/blender/editors/space_clip/clip_editor.c56
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c28
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c70
-rw-r--r--source/blender/editors/space_clip/clip_intern.h50
-rw-r--r--source/blender/editors/space_clip/clip_ops.c4
-rw-r--r--source/blender/editors/space_clip/clip_utils.c88
-rw-r--r--source/blender/editors/space_clip/space_clip.c54
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c1406
-rw-r--r--source/blender/editors/space_clip/tracking_select.c783
-rw-r--r--source/blender/editors/space_image/image_draw.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c49
-rw-r--r--source/blender/editors/space_image/space_image.c3
-rw-r--r--source/blender/editors/space_node/drawnode.c49
-rw-r--r--source/blender/editors/space_node/node_draw.c8
-rw-r--r--source/blender/editors/space_node/node_edit.c626
-rw-r--r--source/blender/editors/space_node/node_intern.h1
-rw-r--r--source/blender/editors/space_node/node_ops.c2
-rw-r--r--source/blender/editors/space_node/space_node.c13
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c67
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h1
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c1
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c30
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_sequencer/SConscript2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c18
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c11
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h2
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c42
-rw-r--r--source/blender/editors/space_view3d/drawobject.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c78
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c6
-rw-r--r--source/blender/editors/transform/transform.c1510
-rw-r--r--source/blender/editors/transform/transform_constraints.c208
-rw-r--r--source/blender/editors/transform/transform_conversions.c1938
-rw-r--r--source/blender/editors/transform/transform_generics.c558
-rw-r--r--source/blender/editors/transform/transform_input.c170
-rw-r--r--source/blender/editors/transform/transform_manipulator.c769
-rw-r--r--source/blender/editors/transform/transform_ops.c136
-rw-r--r--source/blender/editors/transform/transform_orientations.c165
-rw-r--r--source/blender/editors/transform/transform_snap.c218
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c12
-rw-r--r--source/blender/gpu/GPU_draw.h3
-rw-r--r--source/blender/gpu/intern/gpu_draw.c31
-rw-r--r--source/blender/imbuf/intern/divers.c20
-rw-r--r--source/blender/imbuf/intern/jp2.c447
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp733
-rw-r--r--source/blender/makesdna/DNA_ID.h4
-rw-r--r--source/blender/makesdna/DNA_action_types.h2
-rw-r--r--source/blender/makesdna/DNA_anim_types.h30
-rw-r--r--source/blender/makesdna/DNA_armature_types.h16
-rw-r--r--source/blender/makesdna/DNA_boid_types.h56
-rw-r--r--source/blender/makesdna/DNA_brush_types.h28
-rw-r--r--source/blender/makesdna/DNA_color_types.h14
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h144
-rw-r--r--source/blender/makesdna/DNA_curve_types.h20
-rw-r--r--source/blender/makesdna/DNA_mask_types.h6
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h110
-rw-r--r--source/blender/makesdna/DNA_movieclip_types.h122
-rw-r--r--source/blender/makesdna/DNA_node_types.h14
-rw-r--r--source/blender/makesdna/DNA_object_force.h28
-rw-r--r--source/blender/makesdna/DNA_packedFile_types.h20
-rw-r--r--source/blender/makesdna/DNA_scene_types.h2
-rw-r--r--source/blender/makesdna/DNA_screen_types.h14
-rw-r--r--source/blender/makesdna/DNA_sound_types.h4
-rw-r--r--source/blender/makesdna/DNA_space_types.h533
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h228
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h2
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h18
-rw-r--r--source/blender/makesrna/RNA_access.h16
-rw-r--r--source/blender/makesrna/intern/rna_color.c2
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c7
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c2
-rw-r--r--source/blender/makesrna/intern/rna_mask.c1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c8
-rw-r--r--source/blender/makesrna/intern/rna_movieclip.c10
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c189
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_pose.c1
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c22
-rw-r--r--source/blender/makesrna/intern/rna_space.c106
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c369
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c10
-rw-r--r--source/blender/modifiers/intern/MOD_array.c10
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c76
-rw-r--r--source/blender/nodes/CMakeLists.txt2
-rw-r--r--source/blender/nodes/NOD_composite.h2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c2
-rw-r--r--source/blender/nodes/composite/node_composite_util.c12
-rw-r--r--source/blender/nodes/composite/node_composite_util.h22
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.c146
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_blur.c622
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehblur.c20
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_dilate.c91
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_directionalblur.c74
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_glare.c50
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_keying.c96
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_keyingscreen.c202
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mask.c30
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_movieclip.c3
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_moviedistortion.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_scale.c138
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_stabilize2d.c3
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_tonemap.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_vecBlur.c48
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.c60
-rw-r--r--source/blender/nodes/intern/node_common.c312
-rw-r--r--source/blender/nodes/intern/node_common.h2
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c9
-rw-r--r--source/blender/render/intern/source/convertblender.c2
-rw-r--r--source/blender/render/intern/source/occlusion.c13
-rw-r--r--source/blender/render/intern/source/pipeline.c914
-rw-r--r--source/blender/render/intern/source/render_result.c606
-rw-r--r--source/blender/render/intern/source/strand.c2
-rw-r--r--source/blender/render/intern/source/volumetric.c16
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c1
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c5
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c128
716 files changed, 23910 insertions, 18494 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index b833bc44201..faa996b9888 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -49,7 +49,7 @@ extern "C" {
/* used by packaging tools */
/* can be left blank, otherwise a,b,c... etc with no quotes */
-#define BLENDER_VERSION_CHAR a
+#define BLENDER_VERSION_CHAR a
/* alpha/beta/rc/release, docs use this */
#define BLENDER_VERSION_CYCLE alpha
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index d67e1a9118e..f58af8f39a0 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -35,6 +35,7 @@ struct CurveMapping;
struct CurveMap;
struct CurveMapPoint;
struct Scopes;
+struct Histogram;
struct ImBuf;
struct rctf;
@@ -74,7 +75,7 @@ void curvemapping_premultiply(struct CurveMapping *cumap, int res
int curvemapping_RGBA_does_something(struct CurveMapping *cumap);
void curvemapping_initialize(struct CurveMapping *cumap);
void curvemapping_table_RGBA(struct CurveMapping *cumap, float **array, int *size);
-
+void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const short use_color_management);
void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management);
void scopes_free(struct Scopes *scopes);
void scopes_new(struct Scopes *scopes);
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index ec2eb82a9eb..0e93869a8b0 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -48,6 +48,7 @@ struct MaskLayer *BKE_mask_layer_active(struct Mask *mask);
void BKE_mask_layer_active_set(struct Mask *mask, struct MaskLayer *masklay);
void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay);
+void BKE_mask_layer_free_shapes(struct MaskLayer *masklay);
void BKE_mask_layer_free(struct MaskLayer *masklay);
void BKE_mask_spline_free(struct MaskSpline *spline);
struct MaskSpline *BKE_mask_spline_copy(struct MaskSpline *spline);
@@ -169,7 +170,7 @@ void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, i
/* rasterization */
int BKE_mask_get_duration(struct Mask *mask);
void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer,
- const short do_aspect_correct, const short do_linear);
+ const short do_aspect_correct, int do_mask_aa);
#define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT)
#define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT)
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index b1e5fabc456..b3f17c06d5c 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -339,7 +339,7 @@ struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode *node
void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock);
void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node);
-void nodeAddToPreview(struct bNode *, float *, int, int, int);
+void nodeAddToPreview(struct bNode *node, float col[4], int x, int y, int do_manage);
struct bNode *nodeAddNode(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
@@ -372,6 +372,7 @@ void nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
struct bNode *nodeGetActive(struct bNodeTree *ntree);
struct bNode *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
+void nodeClearActive(struct bNodeTree *ntree);
void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree);
@@ -447,9 +448,7 @@ struct bNodeSocket *node_group_add_socket(struct bNodeTree *ngroup, const char *
struct bNodeSocket *node_group_expose_socket(struct bNodeTree *ngroup, struct bNodeSocket *sock, int in_out);
void node_group_expose_all_sockets(struct bNodeTree *ngroup);
void node_group_remove_socket(struct bNodeTree *ngroup, struct bNodeSocket *gsock, int in_out);
-
-struct bNode *node_group_make_from_selected(struct bNodeTree *ntree);
-int node_group_ungroup(struct bNodeTree *ntree, struct bNode *gnode);
+struct bNodeSocket *node_group_add_extern_socket(struct bNodeTree *ntree, ListBase *lb, int in_out, struct bNodeSocket *gsock);
/* in node_common.c */
void register_node_type_frame(struct bNodeTreeType *ttype);
@@ -659,6 +658,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
#define CMP_NODE_DOUBLEEDGEMASK 266
#define CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED 267 /* DEPRECATED multi file node has been merged into regular CMP_NODE_OUTPUT_FILE */
#define CMP_NODE_MASK 268
+#define CMP_NODE_KEYINGSCREEN 269
+#define CMP_NODE_KEYING 270
#define CMP_NODE_GLARE 301
#define CMP_NODE_TONEMAP 302
@@ -692,6 +693,9 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
#define CMP_SCALE_ABSOLUTE 1
#define CMP_SCALE_SCENEPERCENT 2
#define CMP_SCALE_RENDERPERCENT 3
+/* custom2 */
+#define CMP_SCALE_RENDERSIZE_FRAME_ASPECT (1 << 0)
+#define CMP_SCALE_RENDERSIZE_FRAME_CROP (1 << 1)
/* API */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 890fc40c284..b8ba3095905 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -158,6 +158,26 @@ void BKE_object_relink(struct Object *ob);
struct MovieClip *BKE_object_movieclip_get(struct Scene *scene, struct Object *ob, int use_default);
+/* this function returns a superset of the scenes selection based on relationships */
+
+typedef enum eObRelationTypes {
+ OB_REL_NONE = 0, /* just the selection as is */
+ OB_REL_PARENT = (1 << 0), /* immediate parent */
+ OB_REL_PARENT_RECURSIVE = (1 << 1), /* parents up to root of selection tree*/
+ OB_REL_CHILDREN = (1 << 2), /* immediate children */
+ OB_REL_CHILDREN_RECURSIVE = (1 << 3), /* All children */
+ OB_REL_MOD_ARMATURE = (1 << 4), /* Armatures related to the selected objects */
+ OB_REL_SCENE_CAMERA = (1 << 5), /* you might want the scene camera too even if unselected? */
+} eObRelationTypes;
+
+typedef enum eObjectSet {
+ OB_SET_SELECTED, /* Selected Objects */
+ OB_SET_VISIBLE, /* Visible Objects */
+ OB_SET_ALL /* All Objects */
+} eObjectSet;
+
+struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet objectSet, eObRelationTypes includeFilter);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 5b09f8fdf3d..a7b03cef933 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -72,8 +72,8 @@ typedef struct SpaceTransform {
} SpaceTransform;
void space_transform_from_matrixs(struct SpaceTransform *data, float local[4][4], float target[4][4]);
-void space_transform_apply(const struct SpaceTransform *data, float *co);
-void space_transform_invert(const struct SpaceTransform *data, float *co);
+void space_transform_apply(const struct SpaceTransform *data, float co[3]);
+void space_transform_invert(const struct SpaceTransform *data, float co[3]);
#define space_transform_setup(data, local, target) space_transform_from_matrixs(data, (local)->obmat, (target)->obmat)
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 8c28dd93a5e..2b30c845754 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -47,164 +47,191 @@ struct Camera;
struct Object;
struct Scene;
-void BKE_tracking_init_settings(struct MovieTracking *tracking);
-void BKE_tracking_clamp_marker(struct MovieTrackingMarker *marker, int event);
-void BKE_tracking_track_flag(struct MovieTrackingTrack *track, int area, int flag, int clear);
+/* **** Common functions **** */
-struct MovieTrackingTrack *BKE_tracking_add_track(struct MovieTracking *tracking, struct ListBase *tracksbase,
- float x, float y, int framenr, int width, int height);
-struct MovieTrackingMarker *BKE_tracking_insert_marker(struct MovieTrackingTrack *track,
- struct MovieTrackingMarker *marker);
-void BKE_tracking_delete_marker(struct MovieTrackingTrack *track, int framenr);
+void BKE_tracking_free(struct MovieTracking *tracking);
-void BKE_tracking_marker_pattern_minmax(struct MovieTrackingMarker *marker, float min[2], float max[2]);
-struct MovieTrackingMarker *BKE_tracking_get_marker(struct MovieTrackingTrack *track, int framenr);
-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_settings_init(struct MovieTracking *tracking);
-void BKE_tracking_free_track(struct MovieTrackingTrack *track);
+struct ListBase *BKE_tracking_get_active_tracks(struct MovieTracking *tracking);
+struct MovieTrackingReconstruction *BKE_tracking_get_active_reconstruction(struct MovieTracking *tracking);
-void BKE_tracking_clear_path(struct MovieTrackingTrack *track, int ref_frame, int action);
+/* matrices for constraints and drawing */
+void BKE_tracking_get_camera_object_matrix(struct Scene *scene, struct Object *ob, float mat[4][4]);
+void BKE_tracking_get_projection_matrix(struct MovieTracking *tracking, struct MovieTrackingObject *object,
+ int framenr, int winx, int winy, float mat[4][4]);
-void BKE_tracking_join_tracks(struct MovieTrackingTrack *dst_track, struct MovieTrackingTrack *src_track);
-void BKE_tracking_free(struct MovieTracking *tracking);
+/* **** Clipboard **** */
+void BKE_tracking_clipboard_free(void);
+void BKE_tracking_clipboard_copy_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
+int BKE_tracking_clipboard_has_tracks(void);
+void BKE_tracking_clipboard_paste_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
-struct ImBuf *BKE_tracking_sample_pattern_imbuf(int frame_width, int frame_height,
- struct ImBuf *struct_ibuf, struct MovieTrackingMarker *marker,
- int num_samples_x, int num_samples_y, float pos[2]);
-struct ImBuf *BKE_tracking_get_pattern_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
- struct MovieTrackingMarker *marker, int anchored, int disable_channels);
-struct ImBuf *BKE_tracking_get_search_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
- struct MovieTrackingMarker *marker, int anchored, int disable_channels);
-struct ImBuf *BKE_tracking_track_mask_get(struct MovieTracking *tracking, struct MovieTrackingTrack *track,
- struct MovieTrackingMarker *marker, int width, int height);
+/* **** Track **** */
+struct MovieTrackingTrack *BKE_tracking_track_add(struct MovieTracking *tracking, struct ListBase *tracksbase,
+ float x, float y, int framenr, int width, int height);
+void BKE_tracking_track_unique_name(struct ListBase *tracksbase, struct MovieTrackingTrack *track);
+void BKE_tracking_track_free(struct MovieTrackingTrack *track);
-void BKE_track_unique_name(struct ListBase *tracksbase, struct MovieTrackingTrack *track);
+void BKE_tracking_track_flag_set(struct MovieTrackingTrack *track, int area, int flag);
+void BKE_tracking_track_flag_clear(struct MovieTrackingTrack *track, int area, int flag);
-struct MovieTrackingTrack *BKE_tracking_named_track(struct MovieTracking *tracking, struct MovieTrackingObject *object, const char *name);
-struct MovieTrackingTrack *BKE_tracking_indexed_track(struct MovieTracking *tracking, int tracknr, struct ListBase **tracksbase_r);
+int BKE_tracking_track_has_marker_at_frame(struct MovieTrackingTrack *track, int framenr);
+int BKE_tracking_track_has_enabled_marker_at_frame(struct MovieTrackingTrack *track, int framenr);
-void BKE_tracking_camera_shift(struct MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty);
-void BKE_tracking_camera_to_blender(struct MovieTracking *tracking, struct Scene *scene, struct Camera *camera, int width, int height);
+void BKE_tracking_track_path_clear(struct MovieTrackingTrack *track, int ref_frame, int action);
+void BKE_tracking_tracks_join(struct MovieTrackingTrack *dst_track, struct MovieTrackingTrack *src_track);
-void BKE_get_tracking_mat(struct Scene *scene, struct Object *ob, float mat[4][4]);
-void BKE_tracking_projection_matrix(struct MovieTracking *tracking, struct MovieTrackingObject *object,
- int framenr, int winx, int winy, float mat[4][4]);
+struct MovieTrackingTrack *BKE_tracking_track_get_named(struct MovieTracking *tracking,
+ struct MovieTrackingObject *object,
+ const char *name);
+struct MovieTrackingTrack *BKE_tracking_track_get_indexed(struct MovieTracking *tracking, int tracknr,
+ struct ListBase **tracksbase_r);
-struct ListBase *BKE_tracking_get_tracks(struct MovieTracking *tracking);
-struct MovieTrackingReconstruction *BKE_tracking_get_reconstruction(struct MovieTracking *tracking);
+struct MovieTrackingTrack *BKE_tracking_track_get_active(struct MovieTracking *tracking);
-struct MovieTrackingTrack *BKE_tracking_active_track(struct MovieTracking *tracking);
-struct MovieTrackingObject *BKE_tracking_active_object(struct MovieTracking *tracking);
-struct MovieTrackingObject *BKE_tracking_get_camera_object(struct MovieTracking *tracking);
-struct ListBase *BKE_tracking_object_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
-struct MovieTrackingReconstruction *BKE_tracking_object_reconstruction(struct MovieTracking *tracking,
- struct MovieTrackingObject *object);
+float *BKE_tracking_track_get_mask(int frame_width, int frame_height, struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker);
-void BKE_tracking_disable_imbuf_channels(struct ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, int grayscale);
+/* selection */
+void BKE_tracking_track_select(struct ListBase *tracksbase, struct MovieTrackingTrack *track, int area, int extend);
+void BKE_tracking_track_deselect(struct MovieTrackingTrack *track, int area);
-/* clipboard */
-void BKE_tracking_free_clipboard(void);
-void BKE_tracking_clipboard_copy_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
-int BKE_tracking_clipboard_has_tracks(void);
-void BKE_tracking_clipboard_paste_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
+/* **** Marker **** */
+struct MovieTrackingMarker *BKE_tracking_marker_insert(struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker);
+void BKE_tracking_marker_delete(struct MovieTrackingTrack *track, int framenr);
-/* 2D tracking */
-struct MovieTrackingContext *BKE_tracking_context_new(struct MovieClip *clip, struct MovieClipUser *user,
- short backwards, short sequence);
-void BKE_tracking_context_free(struct MovieTrackingContext *context);
-void BKE_tracking_sync(struct MovieTrackingContext *context);
-void BKE_tracking_sync_user(struct MovieClipUser *user, struct MovieTrackingContext *context);
-int BKE_tracking_next(struct MovieTrackingContext *context);
+void BKE_tracking_marker_clamp(struct MovieTrackingMarker *marker, int event);
-/* Camera solving */
-int BKE_tracking_can_reconstruct(struct MovieTracking *tracking, struct MovieTrackingObject *object,
- char *error_msg, int error_size);
+struct MovieTrackingMarker *BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr);
+struct MovieTrackingMarker *BKE_tracking_marker_get_exact(struct MovieTrackingTrack *track, int framenr);
+struct MovieTrackingMarker *BKE_tracking_marker_ensure(struct MovieTrackingTrack *track, int framenr);
-struct MovieReconstructContext* BKE_tracking_reconstruction_context_new(struct MovieTracking *tracking,
- struct MovieTrackingObject *object, int keyframe1, int keyframe2, int width, int height);
-void BKE_tracking_reconstruction_context_free(struct MovieReconstructContext *context);
-void BKE_tracking_solve_reconstruction(struct MovieReconstructContext *context, short *stop, short *do_update,
- float *progress, char *stats_message, int message_size);
-int BKE_tracking_finish_reconstruction(struct MovieReconstructContext *context, struct MovieTracking *tracking);
+void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2]);
-struct MovieReconstructedCamera *BKE_tracking_get_reconstructed_camera(struct MovieTracking *tracking,
- struct MovieTrackingObject *object, int framenr);
-void BKE_tracking_get_interpolated_camera(struct MovieTracking *tracking, struct MovieTrackingObject *object,
- int framenr, float mat[4][4]);
+/* **** Object **** */
+struct MovieTrackingObject *BKE_tracking_object_add(struct MovieTracking *tracking, const char *name);
+void BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object);
-/* Feature detection */
-void BKE_tracking_detect_fast(struct MovieTracking *tracking, struct ListBase *tracksbase, struct ImBuf *imbuf,
- int framenr, int margin, int min_trackness, int min_distance, struct bGPDlayer *layer,
- int place_outside_layer);
+void BKE_tracking_object_unique_name(struct MovieTracking *tracking, struct MovieTrackingObject *object);
+
+struct MovieTrackingObject *BKE_tracking_object_get_named(struct MovieTracking *tracking, const char *name);
-/* 2D stabilization */
-void BKE_tracking_stabilization_data(struct MovieTracking *tracking, int framenr, int width, int height, float loc[2], float *scale, float *angle);
-struct ImBuf *BKE_tracking_stabilize(struct MovieTracking *tracking, int framenr, struct ImBuf *ibuf, float loc[2], float *scale, float *angle);
-void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect, float loc[2], float scale, float angle, float mat[4][4]);
+struct MovieTrackingObject *BKE_tracking_object_get_active(struct MovieTracking *tracking);
+struct MovieTrackingObject *BKE_tracking_object_get_camera(struct MovieTracking *tracking);
-/* Distortion/Undistortion */
-void BKE_tracking_apply_intrinsics(struct MovieTracking *tracking, float co[2], float nco[2]);
-void BKE_tracking_invert_intrinsics(struct MovieTracking *tracking, float co[2], float nco[2]);
+struct ListBase *BKE_tracking_object_get_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
+struct MovieTrackingReconstruction *BKE_tracking_object_get_reconstruction(struct MovieTracking *tracking,
+ struct MovieTrackingObject *object);
-struct MovieDistortion *BKE_tracking_distortion_create(void);
+/* **** Camera **** */
+void BKE_tracking_camera_shift_get(struct MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty);
+void BKE_tracking_camera_to_blender(struct MovieTracking *tracking, struct Scene *scene,
+ struct Camera *camera, int width, int height);
+
+struct MovieReconstructedCamera *BKE_tracking_camera_get_reconstructed(struct MovieTracking *tracking,
+ struct MovieTrackingObject *object,
+ int framenr);
+void BKE_tracking_camera_get_reconstructed_interpolate(struct MovieTracking *tracking,
+ struct MovieTrackingObject *object,
+ int framenr, float mat[4][4]);
+
+/* **** Distortion/Undistortion **** */
+struct MovieDistortion *BKE_tracking_distortion_new(void);
+void BKE_tracking_distortion_update(struct MovieDistortion *distortion, struct MovieTracking *tracking,
+ int calibration_width, int calibration_height);
struct MovieDistortion *BKE_tracking_distortion_copy(struct MovieDistortion *distortion);
struct ImBuf *BKE_tracking_distortion_exec(struct MovieDistortion *distortion, struct MovieTracking *tracking,
struct ImBuf *ibuf, int width, int height, float overscan, int undistort);
-void BKE_tracking_distortion_destroy(struct MovieDistortion *distortion);
+void BKE_tracking_distortion_free(struct MovieDistortion *distortion);
-struct ImBuf *BKE_tracking_undistort(struct MovieTracking *tracking, struct ImBuf *ibuf, int width, int height, float overscan);
-struct ImBuf *BKE_tracking_distort(struct MovieTracking *tracking, struct ImBuf *ibuf, int width, int height, float overscan);
+void BKE_tracking_distort_v2(struct MovieTracking *tracking, float co[2], float nco[2]);
+void BKE_tracking_undistort_v2(struct MovieTracking *tracking, float co[2], float nco[2]);
-/* Object tracking */
-struct MovieTrackingObject *BKE_tracking_new_object(struct MovieTracking *tracking, const char *name);
-void BKE_tracking_remove_object(struct MovieTracking *tracking, struct MovieTrackingObject *object);
-void BKE_tracking_object_unique_name(struct MovieTracking *tracking, struct MovieTrackingObject *object);
-struct MovieTrackingObject *BKE_tracking_named_object(struct MovieTracking *tracking, const char *name);
+struct ImBuf *BKE_tracking_undistort_frame(struct MovieTracking *tracking, struct ImBuf *ibuf,
+ int calibration_width, int calibration_height, float overscan);
+struct ImBuf *BKE_tracking_distort_frame(struct MovieTracking *tracking, struct ImBuf *ibuf,
+ int calibration_width, int calibration_height, float overscan);
+
+/* **** Image sampling **** */
+struct ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height,
+ struct ImBuf *struct_ibuf, struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker, int use_mask,
+ int num_samples_x, int num_samples_y, float pos[2]);
+struct ImBuf *BKE_tracking_get_pattern_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker, int anchored, int disable_channels);
+struct ImBuf *BKE_tracking_get_search_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker, int anchored, int disable_channels);
-/* Select */
-void BKE_tracking_select_track(struct ListBase *tracksbase, struct MovieTrackingTrack *track, int area, int extend);
-void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area);
+void BKE_tracking_disable_channels(struct ImBuf *ibuf, int disable_red, int disable_green,
+ int disable_blue, int grayscale);
+
+/* **** 2D tracking **** */
+struct MovieTrackingContext *BKE_tracking_context_new(struct MovieClip *clip, struct MovieClipUser *user,
+ short backwards, short sequence);
+void BKE_tracking_context_free(struct MovieTrackingContext *context);
+void BKE_tracking_context_sync(struct MovieTrackingContext *context);
+void BKE_tracking_context_sync_user(const struct MovieTrackingContext *context, struct MovieClipUser *user);
+int BKE_tracking_context_step(struct MovieTrackingContext *context);
+
+/* **** Camera solving **** */
+int BKE_tracking_reconstruction_check(struct MovieTracking *tracking, struct MovieTrackingObject *object,
+ char *error_msg, int error_size);
+
+struct MovieReconstructContext *BKE_tracking_reconstruction_context_new(struct MovieTracking *tracking,
+ struct MovieTrackingObject *object,
+ int keyframe1, int keyframe2,
+ int width, int height);
+void BKE_tracking_reconstruction_context_free(struct MovieReconstructContext *context);
+void BKE_tracking_reconstruction_solve(struct MovieReconstructContext *context, short *stop, short *do_update,
+ float *progress, char *stats_message, int message_size);
+int BKE_tracking_reconstruction_finish(struct MovieReconstructContext *context, struct MovieTracking *tracking);
+
+/* **** Feature detection **** */
+void BKE_tracking_detect_fast(struct MovieTracking *tracking, struct ListBase *tracksbase, struct ImBuf *imbuf,
+ int framenr, int margin, int min_trackness, int min_distance, struct bGPDlayer *layer,
+ int place_outside_layer);
+
+/* **** 2D stabilization **** */
+void BKE_tracking_stabilization_data_get(struct MovieTracking *tracking, int framenr, int width, int height,
+ float loc[2], float *scale, float *angle);
+struct ImBuf *BKE_tracking_stabilize_frame(struct MovieTracking *tracking, int framenr, struct ImBuf *ibuf,
+ float loc[2], float *scale, float *angle);
+void BKE_tracking_stabilization_data_to_mat4(int width, int height, float aspect, float loc[2],
+ float scale, float angle, float mat[4][4]);
/* Dopesheet */
void BKE_tracking_dopesheet_tag_update(struct MovieTracking *tracking);
-void BKE_tracking_dopesheet_update(struct MovieTracking *tracking, int sort_method, int inverse);
-
-#define TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT)
+void BKE_tracking_dopesheet_update(struct MovieTracking *tracking);
-#define TRACK_AREA_SELECTED(track, area) ((area)==TRACK_AREA_POINT ? (track)->flag&SELECT : \
- ((area)==TRACK_AREA_PAT ? (track)->pat_flag&SELECT : \
- (track)->search_flag&SELECT))
+#define TRACK_SELECTED(track) ((track)->flag & SELECT || (track)->pat_flag & SELECT || (track)->search_flag & SELECT)
-#define TRACK_VIEW_SELECTED(sc, track) ((((track)->flag & TRACK_HIDDEN)==0) && \
- ( TRACK_AREA_SELECTED(track, TRACK_AREA_POINT) || \
- (((sc)->flag & SC_SHOW_MARKER_PATTERN) && TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) || \
- (((sc)->flag & SC_SHOW_MARKER_SEARCH) && TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))))
+#define TRACK_AREA_SELECTED(track, area) ((area) == TRACK_AREA_POINT ? (track)->flag & SELECT : \
+ ((area) == TRACK_AREA_PAT ? (track)->pat_flag & SELECT : \
+ (track)->search_flag & SELECT))
-#define MARKER_VISIBLE(sc, track, marker) (((marker)->flag & MARKER_DISABLED)==0 || ((sc)->flag & SC_HIDE_DISABLED)==0 || (sc->clip->tracking.act_track == track))
+#define TRACK_VIEW_SELECTED(sc, track) ((((track)->flag & TRACK_HIDDEN) == 0) && \
+ (TRACK_AREA_SELECTED(track, TRACK_AREA_POINT) || \
+ (((sc)->flag & SC_SHOW_MARKER_PATTERN) && TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) || \
+ (((sc)->flag & SC_SHOW_MARKER_SEARCH) && TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))))
-#define TRACK_CLEAR_UPTO 0
-#define TRACK_CLEAR_REMAINED 1
-#define TRACK_CLEAR_ALL 2
+#define MARKER_VISIBLE(sc, track, marker) (((marker)->flag & MARKER_DISABLED) == 0 || ((sc)->flag & SC_HIDE_DISABLED) == 0 || (sc->clip->tracking.act_track == track))
-#define CLAMP_PAT_DIM 1
-#define CLAMP_PAT_POS 2
-#define CLAMP_SEARCH_DIM 3
-#define CLAMP_SEARCH_POS 4
+#define TRACK_CLEAR_UPTO 0
+#define TRACK_CLEAR_REMAINED 1
+#define TRACK_CLEAR_ALL 2
-#define TRACK_AREA_NONE -1
-#define TRACK_AREA_POINT 1
-#define TRACK_AREA_PAT 2
-#define TRACK_AREA_SEARCH 4
+#define CLAMP_PAT_DIM 1
+#define CLAMP_PAT_POS 2
+#define CLAMP_SEARCH_DIM 3
+#define CLAMP_SEARCH_POS 4
-#define TRACK_AREA_ALL (TRACK_AREA_POINT|TRACK_AREA_PAT|TRACK_AREA_SEARCH)
+#define TRACK_AREA_NONE -1
+#define TRACK_AREA_POINT 1
+#define TRACK_AREA_PAT 2
+#define TRACK_AREA_SEARCH 4
-#define TRACK_SORT_NONE -1
-#define TRACK_SORT_NAME 0
-#define TRACK_SORT_LONGEST 1
-#define TRACK_SORT_TOTAL 2
-#define TRACK_SORT_AVERAGE_ERROR 3
+#define TRACK_AREA_ALL (TRACK_AREA_POINT | TRACK_AREA_PAT | TRACK_AREA_SEARCH)
#endif
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index ec2b8a04c9a..e5701927b07 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1294,9 +1294,11 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime
/* check if this driver's curve should be skipped */
if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
/* check if driver itself is tagged for recalculation */
- if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) { // XXX driver recalc flag is not set yet by depsgraph!
- /* evaluate this using values set already in other places */
- // NOTE: for 'layering' option later on, we should check if we should remove old value before adding new to only be done when drivers only changed
+ /* XXX driver recalc flag is not set yet by depsgraph! */
+ if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) {
+ /* evaluate this using values set already in other places
+ * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
+ * new to only be done when drivers only changed */
calculate_fcurve(fcu, ctime);
ok = animsys_execute_fcurve(ptr, NULL, fcu);
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 5ad81db1979..9af1d5f52c4 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -986,7 +986,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
for (j = dvert->totweight; j != 0; j--, dw++) {
const int index = dw->def_nr;
- if (index < defbase_tot && (pchan = defnrToPC[index])) {
+ if (index >= 0 && index < defbase_tot && (pchan = defnrToPC[index])) {
float weight = dw->weight;
Bone *bone = pchan->bone;
pdef_info = pdef_info_array + defnrToPCIndex[index];
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 12dee600532..6879ec506f0 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -946,6 +946,62 @@ static void save_sample_line(Scopes *scopes, const int idx, const float fx, cons
}
}
+void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short use_color_management)
+{
+ int i, x, y;
+ float *fp;
+ float rgb[3];
+ unsigned char *cp;
+
+ int x1 = 0.5f + hist->co[0][0] * ibuf->x;
+ int x2 = 0.5f + hist->co[1][0] * ibuf->x;
+ int y1 = 0.5f + hist->co[0][1] * ibuf->y;
+ int y2 = 0.5f + hist->co[1][1] * ibuf->y;
+
+ hist->channels = 3;
+ hist->x_resolution = 256;
+ hist->xmax = 1.0f;
+ hist->ymax = 1.0f;
+
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) return;
+
+ /* persistent draw */
+ hist->flag |= HISTO_FLAG_SAMPLELINE; /* keep drawing the flag after */
+
+ for (i = 0; i < 256; i++) {
+ x = (int)(0.5f + x1 + (float)i * (x2 - x1) / 255.0f);
+ y = (int)(0.5f + y1 + (float)i * (y2 - y1) / 255.0f);
+
+ if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
+ hist->data_luma[i] = hist->data_r[i] = hist->data_g[i] = hist->data_b[i] = hist->data_a[i] = 0.0f;
+ }
+ else {
+ if (ibuf->rect_float) {
+ fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
+
+ if (use_color_management)
+ linearrgb_to_srgb_v3_v3(rgb, fp);
+ else
+ copy_v3_v3(rgb, fp);
+
+ hist->data_luma[i] = rgb_to_luma(rgb);
+ hist->data_r[i] = rgb[0];
+ hist->data_g[i] = rgb[1];
+ hist->data_b[i] = rgb[2];
+ hist->data_a[i] = fp[3];
+ }
+ else if (ibuf->rect) {
+ cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+ hist->data_luma[i] = (float)rgb_to_luma_byte(cp) / 255.0f;
+ hist->data_r[i] = (float)cp[0] / 255.0f;
+ hist->data_g[i] = (float)cp[1] / 255.0f;
+ hist->data_b[i] = (float)cp[2] / 255.0f;
+ hist->data_a[i] = (float)cp[3] / 255.0f;
+ }
+ }
+ }
+}
+
void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
{
int x, y, c;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 0150646a96c..c12e740958c 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -822,12 +822,12 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
if (data->flag == CHILDOF_ALL) {
/* multiply target (parent matrix) by offset (parent inverse) to get
- * the effect of the parent that will be exherted on the owner
+ * the effect of the parent that will be exerted on the owner
*/
mult_m4_m4m4(parmat, ct->matrix, data->invmat);
/* now multiply the parent matrix by the owner matrix to get the
- * the effect of this constraint (i.e. owner is 'parented' to parent)
+ * the effect of this constraint (i.e. owner is 'parented' to parent)
*/
mult_m4_m4m4(cob->matrix, parmat, cob->matrix);
}
@@ -864,7 +864,7 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder);
/* multiply target (parent matrix) by offset (parent inverse) to get
- * the effect of the parent that will be exherted on the owner
+ * the effect of the parent that will be exerted on the owner
*/
mult_m4_m4m4(parmat, ct->matrix, invmat);
@@ -1620,7 +1620,7 @@ static void rotlike_new_data(void *cdata)
static void rotlike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
{
- bChildOfConstraint *data = con->data;
+ bRotateLikeConstraint *data = con->data;
/* target only */
func(con, (ID **)&data->tar, FALSE, userdata);
@@ -2159,7 +2159,15 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT
printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name + 2, (cob->pchan) ? cob->pchan->name : NULL);
/* Get the appropriate information from the action */
- if (cob->type == CONSTRAINT_OBTYPE_BONE) {
+ if (cob->type == CONSTRAINT_OBTYPE_OBJECT || (data->flag & ACTCON_BONE_USE_OBJECT_ACTION)) {
+ Object workob;
+
+ /* evaluate using workob */
+ // FIXME: we don't have any consistent standards on limiting effects on object...
+ what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t);
+ BKE_object_to_mat4(&workob, ct->matrix);
+ }
+ else if (cob->type == CONSTRAINT_OBTYPE_BONE) {
Object workob;
bPose *pose;
bPoseChannel *pchan, *tchan;
@@ -2185,14 +2193,6 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT
/* Clean up */
BKE_pose_free(pose);
}
- else if (cob->type == CONSTRAINT_OBTYPE_OBJECT) {
- Object workob;
-
- /* evaluate using workob */
- // FIXME: we don't have any consistent standards on limiting effects on object...
- what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t);
- BKE_object_to_mat4(&workob, ct->matrix);
- }
else {
/* behavior undefined... */
puts("Error: unknown owner type for Action Constraint");
@@ -3278,6 +3278,15 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
switch (data->from) {
case 2: /* scale */
mat4_to_size(dvec, ct->matrix);
+
+ if (is_negative_m4(ct->matrix)) {
+ /* Bugfix [#27886]
+ * We can't be sure which axis/axes are negative, though we know that something is negative.
+ * Assume we don't care about negativity of separate axes. <--- This is a limitation that
+ * riggers will have to live with for now.
+ */
+ negate_v3(dvec);
+ }
break;
case 1: /* rotation (convert to degrees first) */
mat4_to_eulO(dvec, cob->rotOrder, ct->matrix);
@@ -3908,14 +3917,14 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
tracking = &clip->tracking;
if (data->object[0])
- tracking_object = BKE_tracking_named_object(tracking, data->object);
+ tracking_object = BKE_tracking_object_get_named(tracking, data->object);
else
- tracking_object = BKE_tracking_get_camera_object(tracking);
+ tracking_object = BKE_tracking_object_get_camera(tracking);
if (!tracking_object)
return;
- track = BKE_tracking_named_track(tracking, tracking_object, data->track);
+ track = BKE_tracking_track_get_named(tracking, tracking_object, data->track);
if (!track)
return;
@@ -3933,14 +3942,14 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
copy_m4_m4(mat, camob->obmat);
- BKE_tracking_get_interpolated_camera(tracking, tracking_object, framenr, imat);
+ BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, imat);
invert_m4(imat);
mul_serie_m4(cob->matrix, obmat, mat, imat, NULL, NULL, NULL, NULL, NULL);
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
}
else {
- BKE_get_tracking_mat(cob->scene, camob, mat);
+ BKE_tracking_get_camera_object_matrix(cob->scene, camob, mat);
mult_m4_m4m4(cob->matrix, obmat, mat);
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
@@ -3972,7 +3981,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
CameraParams params;
float pos[2], rmat[4][4];
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
add_v2_v2v2(pos, marker->pos, track->offset);
@@ -4094,10 +4103,10 @@ static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
if (clip) {
float mat[4][4], obmat[4][4];
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object = BKE_tracking_get_camera_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_camera(tracking);
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
- BKE_tracking_get_interpolated_camera(tracking, object, framenr, mat);
+ BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
copy_m4_m4(obmat, cob->matrix);
@@ -4156,7 +4165,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *object;
- object = BKE_tracking_named_object(tracking, data->object);
+ object = BKE_tracking_object_get_named(tracking, data->object);
if (object) {
float mat[4][4], obmat[4][4], imat[4][4], cammat[4][4], camimat[4][4], parmat[4][4];
@@ -4164,7 +4173,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
BKE_object_where_is_calc_mat4(scene, camob, cammat);
- BKE_tracking_get_interpolated_camera(tracking, object, framenr, mat);
+ BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
invert_m4_m4(camimat, cammat);
mult_m4_m4m4(parmat, cammat, data->invmat);
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index ce62b9c10dc..623d4b8a931 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -1002,9 +1002,7 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu,
bp++;
if (*fp != 0.0f) {
- in[0] += (*fp) * bp->vec[0];
- in[1] += (*fp) * bp->vec[1];
- in[2] += (*fp) * bp->vec[2];
+ madd_v3_v3fl(in, bp->vec, *fp);
}
}
}
@@ -1106,9 +1104,7 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *
bp++;
if (*fp != 0.0f) {
- coord_fp[0] += (*fp) * bp->vec[0];
- coord_fp[1] += (*fp) * bp->vec[1];
- coord_fp[2] += (*fp) * bp->vec[2];
+ madd_v3_v3fl(coord_fp, bp->vec, *fp);
if (tilt_fp)
(*tilt_fp) += (*fp) * bp->alfa;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index bb2940091e4..48db916b4ba 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1029,10 +1029,27 @@ void BKE_mask_layer_shape_free(MaskLayerShape *masklay_shape)
MEM_freeN(masklay_shape);
}
+/** \brief Free all animation keys for a mask layer
+ */
+void BKE_mask_layer_free_shapes(MaskLayer *masklay)
+{
+ MaskLayerShape *masklay_shape;
+
+ /* free animation data */
+ masklay_shape = masklay->splines_shapes.first;
+ while (masklay_shape) {
+ MaskLayerShape *next_masklay_shape = masklay_shape->next;
+
+ BLI_remlink(&masklay->splines_shapes, masklay_shape);
+ BKE_mask_layer_shape_free(masklay_shape);
+
+ masklay_shape = next_masklay_shape;
+ }
+}
+
void BKE_mask_layer_free(MaskLayer *masklay)
{
MaskSpline *spline;
- MaskLayerShape *masklay_shape;
/* free splines */
spline = masklay->splines.first;
@@ -1046,15 +1063,7 @@ void BKE_mask_layer_free(MaskLayer *masklay)
}
/* free animation data */
- masklay_shape = masklay->splines_shapes.first;
- while (masklay_shape) {
- MaskLayerShape *next_masklay_shape = masklay_shape->next;
-
- BLI_remlink(&masklay->splines_shapes, masklay_shape);
- BKE_mask_layer_shape_free(masklay_shape);
-
- masklay_shape = next_masklay_shape;
- }
+ BKE_mask_layer_free_shapes(masklay);
MEM_freeN(masklay);
}
@@ -1147,16 +1156,16 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[
if (parent->id) {
MovieClip *clip = (MovieClip *) parent->id;
MovieTracking *tracking = (MovieTracking *) &clip->tracking;
- MovieTrackingObject *ob = BKE_tracking_named_object(tracking, parent->parent);
+ MovieTrackingObject *ob = BKE_tracking_object_get_named(tracking, parent->parent);
if (ob) {
- MovieTrackingTrack *track = BKE_tracking_named_track(tracking, ob, parent->sub_parent);
+ MovieTrackingTrack *track = BKE_tracking_track_get_named(tracking, ob, parent->sub_parent);
MovieClipUser user = {0};
user.framenr = ctime;
if (track) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, ctime);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, ctime);
float marker_pos_ofs[2];
add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset);
BKE_mask_coord_from_movieclip(clip, &user, r_co, marker_pos_ofs);
@@ -2061,19 +2070,6 @@ static void m_invert_vn_vn(float *array, const float f, const int size)
}
}
-static void clamp_vn_vn_linear(float *array, const int size)
-{
- float *arr = array + (size - 1);
-
- int i = size;
- while (i--) {
- if (*arr <= 0.0f) *arr = 0.0f;
- else if (*arr >= 1.0f) *arr = 1.0f;
- else *arr = srgb_to_linearrgb(*arr);
- arr--;
- }
-}
-
static void clamp_vn_vn(float *array, const int size)
{
float *arr = array + (size - 1);
@@ -2093,7 +2089,7 @@ int BKE_mask_get_duration(Mask *mask)
/* rasterization */
void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer,
- const short do_aspect_correct, const short do_linear)
+ const short do_aspect_correct, int do_mask_aa)
{
MaskLayer *masklay;
@@ -2158,7 +2154,7 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer,
if (tot_diff_point) {
PLX_raskterize(diff_points, tot_diff_point,
- buffer_tmp, width, height);
+ buffer_tmp, width, height, do_mask_aa);
if (tot_diff_feather_points) {
PLX_raskterize_feather(diff_points, tot_diff_point,
@@ -2213,12 +2209,7 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer,
}
/* clamp at the end */
- if (do_linear) {
- clamp_vn_vn_linear(buffer, buffer_size);
- }
- else {
- clamp_vn_vn(buffer, buffer_size);
- }
+ clamp_vn_vn(buffer, buffer_size);
}
MEM_freeN(buffer_tmp);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 8b91ee29c59..68adb599c6c 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -159,7 +159,7 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name)
offset = sequence_guess_offset(clip->name, strlen(head), numlen);
if (numlen)
- BLI_stringenc(name, head, tail, numlen, offset + framenr - clip->start_frame);
+ BLI_stringenc(name, head, tail, numlen, offset + framenr - clip->start_frame + clip->frame_offset);
else
BLI_strncpy(name, clip->name, sizeof(clip->name));
@@ -171,7 +171,7 @@ static void get_proxy_fname(MovieClip *clip, int proxy_render_size, int undistor
{
int size = rendersize_to_number(proxy_render_size);
char dir[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX];
- int proxynr = framenr - clip->start_frame + 1;
+ int proxynr = framenr - clip->start_frame + 1 + clip->frame_offset;
BLI_split_dirfile(clip->name, clipdir, clipfile, FILE_MAX, FILE_MAX);
@@ -250,7 +250,7 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
int fra;
dur = IMB_anim_get_duration(clip->anim, tc);
- fra = framenr - clip->start_frame;
+ fra = framenr - clip->start_frame + clip->frame_offset;
if (fra < 0)
fra = 0;
@@ -436,7 +436,7 @@ static MovieClip *movieclip_alloc(const char *name)
clip->aspx = clip->aspy = 1.0f;
- BKE_tracking_init_settings(&clip->tracking);
+ BKE_tracking_settings_init(&clip->tracking);
clip->proxy.build_size_flag = IMB_PROXY_25;
clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN |
@@ -446,6 +446,7 @@ static MovieClip *movieclip_alloc(const char *name)
clip->proxy.quality = 90;
clip->start_frame = 1;
+ clip->frame_offset = 0;
return clip;
}
@@ -547,7 +548,7 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip, struct MovieDistortion *dist
if (distortion)
undistibuf = BKE_tracking_distortion_exec(distortion, &clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f, 1);
else
- undistibuf = BKE_tracking_undistort(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
+ undistibuf = BKE_tracking_undistort_frame(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
if (undistibuf->userflags & IB_RECT_INVALID) {
ibuf->userflags &= ~IB_RECT_INVALID;
@@ -677,7 +678,7 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
postproc_ibuf = IMB_dupImBuf(ibuf);
if (disable_red || disable_green || disable_blue || grayscale)
- BKE_tracking_disable_imbuf_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
+ BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
}
IMB_refImBuf(postproc_ibuf);
@@ -772,6 +773,7 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
float tloc[2], tscale, tangle;
short proxy = IMB_PROXY_NONE;
int render_flag = 0;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr);
if (clip->flag & MCLIP_USE_PROXY) {
proxy = rendersize_to_proxy(user, clip->flag);
@@ -798,7 +800,7 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
stableibuf = cache->stabilized.ibuf;
- BKE_tracking_stabilization_data(&clip->tracking, framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle);
+ BKE_tracking_stabilization_data_get(&clip->tracking, clip_framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle);
/* check for stabilization parameters */
if (tscale != cache->stabilized.scale ||
@@ -820,11 +822,12 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user
MovieTracking *tracking = &clip->tracking;
ImBuf *stableibuf;
float tloc[2], tscale, tangle;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr);
if (cache->stabilized.ibuf)
IMB_freeImBuf(cache->stabilized.ibuf);
- stableibuf = BKE_tracking_stabilize(&clip->tracking, framenr, ibuf, tloc, &tscale, &tangle);
+ stableibuf = BKE_tracking_stabilize_frame(&clip->tracking, clip_framenr, ibuf, tloc, &tscale, &tangle);
cache->stabilized.ibuf = stableibuf;
@@ -1039,14 +1042,15 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
scopes->marker = NULL;
scopes->track = NULL;
+ scopes->track_locked = TRUE;
if (clip) {
- MovieTrackingTrack *act_track = BKE_tracking_active_track(&clip->tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(&clip->tracking);
if (act_track) {
MovieTrackingTrack *track = act_track;
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (marker->flag & MARKER_DISABLED) {
scopes->track_disabled = TRUE;
@@ -1055,6 +1059,8 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
scopes->track_disabled = FALSE;
+ scopes->marker = marker;
+ scopes->track = track;
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
ImBuf *search_ibuf;
@@ -1069,7 +1075,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
undist_marker.pos[0] *= width;
undist_marker.pos[1] *= height * aspy;
- BKE_tracking_invert_intrinsics(&clip->tracking, undist_marker.pos, undist_marker.pos);
+ BKE_tracking_undistort_v2(&clip->tracking, undist_marker.pos, undist_marker.pos);
undist_marker.pos[0] /= width;
undist_marker.pos[1] /= height * aspy;
@@ -1087,6 +1093,8 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
scopes->frame_width = ibuf->x;
scopes->frame_height = ibuf->y;
+
+ scopes->use_track_mask = track->flag & TRACK_PREVIEW_ALPHA;
}
IMB_freeImBuf(ibuf);
@@ -1095,8 +1103,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
if ((track->flag & TRACK_LOCKED) == 0) {
float pat_min[2], pat_max[2];
- scopes->marker = marker;
- scopes->track = track;
+ scopes->track_locked = FALSE;
/* XXX: would work fine with non-transformed patterns, but would likely fail
* with transformed patterns, but that would be easier to debug when
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 4cbfb4f0f3e..cb6f6823f48 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -548,13 +548,6 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
}
}
-static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3])
-{
- copy_v3_v3(mat[0], v1);
- copy_v3_v3(mat[1], v2);
- copy_v3_v3(mat[2], v3);
-}
-
static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA, int sizeB)
{
int x, y, j, skip;
@@ -962,7 +955,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updat
multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple);
}
-void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3])
+static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3])
{
if (axis == 0) {
if (x == key->grid_size - 1) {
@@ -986,6 +979,19 @@ void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, floa
}
}
+/* Construct 3x3 tangent-space matrix in 'mat' */
+static void grid_tangent_matrix(float mat[3][3], const CCGKey *key,
+ int x, int y, CCGElem *grid)
+{
+ grid_tangent(key, x, y, 0, grid, mat[0]);
+ normalize_v3(mat[0]);
+
+ grid_tangent(key, x, y, 1, grid, mat[1]);
+ normalize_v3(mat[1]);
+
+ copy_v3_v3(mat[2], CCG_grid_elem_no(key, grid, x, y));
+}
+
static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, CCGElem **oldGridData, int totlvl)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
@@ -1067,22 +1073,11 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
for (x = 0; x < gridSize; x++) {
float *co = CCG_grid_elem_co(&key, grid, x, y);
float *sco = CCG_grid_elem_co(&key, subgrid, x, y);
- float *no = CCG_grid_elem_no(&key, subgrid, x, y);
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
- float mat[3][3], tx[3], ty[3], disp[3], d[3], mask;
+ float mat[3][3], disp[3], d[3], mask;
/* construct tangent space matrix */
- grid_tangent(&key, x, y, 0, subGridData[gIndex], tx);
- normalize_v3(tx);
-
- grid_tangent(&key, x, y, 1, subGridData[gIndex], ty);
- normalize_v3(ty);
-
- //mul_v3_fl(tx, 1.0f/(gridSize-1));
- //mul_v3_fl(ty, 1.0f/(gridSize-1));
- //cross_v3_v3v3(no, tx, ty);
-
- column_vectors_to_mat3(mat, tx, ty, no);
+ grid_tangent_matrix(mat, &key, x, y, subgrid);
switch (op) {
case APPLY_DISPLACEMENTS:
@@ -1344,17 +1339,11 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
for (y = 0; y < gridSize; y++) {
for (x = 0; x < gridSize; x++) {
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
- float *no = CCG_grid_elem_no(&key, subgrid, x, y);
float *co = CCG_grid_elem_co(&key, subgrid, x, y);
- float mat[3][3], tx[3], ty[3], dco[3];
+ float mat[3][3], dco[3];
/* construct tangent space matrix */
- grid_tangent(&key, x, y, 0, subGridData[gIndex], tx);
- normalize_v3(tx);
-
- grid_tangent(&key, x, y, 1, subGridData[gIndex], ty);
- normalize_v3(ty);
- column_vectors_to_mat3(mat, tx, ty, no);
+ grid_tangent_matrix(mat, &key, x, y, subgrid);
/* convert to absolute coordinates in space */
if (from == MULTIRES_SPACE_TANGENT) {
@@ -1368,8 +1357,6 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
copy_v3_v3(dco, data);
}
- column_vectors_to_mat3(mat, tx, ty, no);
-
/*now, convert to desired displacement type*/
if (to == MULTIRES_SPACE_TANGENT) {
invert_m3(mat);
@@ -2142,7 +2129,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
{
DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
CCGElem **gridData, **subGridData;
- CCGKey key;
+ CCGKey dm_key, subdm_key;
Mesh *me = (Mesh *)ob->data;
MPoly *mpoly = me->mpoly;
/* MLoop *mloop = me->mloop; */ /* UNUSED */
@@ -2180,12 +2167,12 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
cddm->release(cddm);
- /*numGrids = dm->getNumGrids(dm);*/ /*UNUSED*/
gridSize = dm->getGridSize(dm);
gridData = dm->getGridData(dm);
gridOffset = dm->getGridOffset(dm);
- dm->getGridKey(dm, &key);
+ dm->getGridKey(dm, &dm_key);
subGridData = subdm->getGridData(subdm);
+ subdm->getGridKey(subdm, &subdm_key);
dGridSize = multires_side_tot[high_mmd.totlvl];
dSkip = (dGridSize - 1) / (gridSize - 1);
@@ -2203,20 +2190,13 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
for (y = 0; y < gridSize; y++) {
for (x = 0; x < gridSize; x++) {
- float *co = CCG_grid_elem_co(&key, grid, x, y);
- float *sco = CCG_grid_elem_co(&key, subgrid, x, y);
- float *no = CCG_grid_elem_no(&key, grid, x, y);
+ float *co = CCG_grid_elem_co(&dm_key, grid, x, y);
+ float *sco = CCG_grid_elem_co(&subdm_key, subgrid, x, y);
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
- float mat[3][3], tx[3], ty[3], disp[3];
+ float mat[3][3], disp[3];
/* construct tangent space matrix */
- grid_tangent(&key, x, y, 0, gridData[gIndex], tx);
- normalize_v3(tx);
-
- grid_tangent(&key, x, y, 1, gridData[gIndex], ty);
- normalize_v3(ty);
-
- column_vectors_to_mat3(mat, tx, ty, no);
+ grid_tangent_matrix(mat, &dm_key, x, y, grid);
/* scale subgrid coord and calculate displacement */
mul_m3_v3(smat, sco);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index d62e91dbde5..bd3690e2174 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -802,7 +802,7 @@ void ntreeClearPreview(bNodeTree *ntree)
/* hack warning! this function is only used for shader previews, and
* since it gets called multiple times per pixel for Ztransp we only
* add the color once. Preview gets cleared before it starts render though */
-void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage)
+void nodeAddToPreview(bNode *node, float col[4], int x, int y, int do_manage)
{
bNodePreview *preview= node->preview;
if (preview) {
@@ -1313,6 +1313,17 @@ void nodeClearActiveID(bNodeTree *ntree, short idtype)
node->flag &= ~NODE_ACTIVE_ID;
}
+void nodeClearActive(bNodeTree *ntree)
+{
+ bNode *node;
+
+ if (ntree==NULL) return;
+
+ for (node= ntree->nodes.first; node; node= node->next)
+ node->flag &= ~(NODE_ACTIVE | NODE_ACTIVE_ID);
+}
+
+
/* two active flags, ID nodes have special flag for buttons display */
void nodeSetActive(bNodeTree *ntree, bNode *node)
{
@@ -1889,6 +1900,8 @@ static void registerCompositNodes(bNodeTreeType *ttype)
register_node_type_cmp_color_spill(ttype);
register_node_type_cmp_luma_matte(ttype);
register_node_type_cmp_doubleedgemask(ttype);
+ register_node_type_cmp_keyingscreen(ttype);
+ register_node_type_cmp_keying(ttype);
register_node_type_cmp_translate(ttype);
register_node_type_cmp_rotate(ttype);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index b656cb6d8de..1d045d4142d 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -63,6 +63,7 @@
#include "BLI_math.h"
#include "BLI_pbvh.h"
#include "BLI_utildefines.h"
+#include "BLI_linklist.h"
#include "BKE_main.h"
#include "BKE_global.h"
@@ -3086,3 +3087,135 @@ MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, int use_default)
return clip;
}
+
+
+/*
+ * Find an associated Armature object
+ */
+static Object *obrel_armature_find(Object *ob)
+{
+ Object *ob_arm = NULL;
+
+ if (ob->parent && ob->partype == PARSKEL && ob->parent->type == OB_ARMATURE) {
+ ob_arm = ob->parent;
+ }
+ else {
+ ModifierData *mod;
+ for (mod = (ModifierData *)ob->modifiers.first; mod; mod = mod->next) {
+ if (mod->type == eModifierType_Armature) {
+ ob_arm = ((ArmatureModifierData *)mod)->object;
+ }
+ }
+ }
+
+ return ob_arm;
+}
+
+static int obrel_is_recursive_child(Object *ob, Object *child) {
+ Object *par;
+ for (par = child->parent; par; par = par->parent) {
+ if (par == ob) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+static int obrel_list_test(Object *ob)
+{
+ return ob && !(ob->id.flag & LIB_DOIT);
+}
+
+static void obrel_list_add(LinkNode **links, Object *ob)
+{
+ BLI_linklist_prepend(links, ob);
+ ob->id.flag |= LIB_DOIT;
+}
+
+/*
+ * Iterates over all objects of the given scene.
+ * Depending on the eObjectSet flag:
+ * collect either OB_SET_ALL, OB_SET_VISIBLE or OB_SET_SELECTED objects.
+ * If OB_SET_VISIBLE or OB_SET_SELECTED are collected,
+ * then also add related objects according to the given includeFilters.
+ */
+struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet objectSet, eObRelationTypes includeFilter)
+{
+ LinkNode *links = NULL;
+
+ Base *base;
+
+ /* Remove markers from all objects */
+ for (base = scene->base.first; base; base = base->next) {
+ base->object->id.flag &= ~LIB_DOIT;
+ }
+
+ /* iterate over all selected and visible objects */
+ for (base = scene->base.first; base; base = base->next) {
+ if (objectSet == OB_SET_ALL) {
+ // as we get all anyways just add it
+ Object *ob = base->object;
+ obrel_list_add(&links, ob);
+ }
+ else {
+ if ((objectSet == OB_SET_SELECTED && TESTBASELIB_BGMODE(((View3D *)NULL), scene, base)) ||
+ (objectSet == OB_SET_VISIBLE && BASE_EDITABLE_BGMODE(((View3D *)NULL), scene, base)))
+ {
+ Object *ob = base->object;
+
+ if (obrel_list_test(ob))
+ obrel_list_add(&links, ob);
+
+ /* parent relationship */
+ if (includeFilter & (OB_REL_PARENT | OB_REL_PARENT_RECURSIVE)) {
+ Object *parent = ob->parent;
+ if (obrel_list_test(parent)) {
+
+ obrel_list_add(&links, parent);
+
+ /* recursive parent relationship */
+ if (includeFilter & OB_REL_PARENT_RECURSIVE) {
+ parent = parent->parent;
+ while (obrel_list_test(parent)) {
+
+ obrel_list_add(&links, parent);
+ parent = parent->parent;
+ }
+ }
+ }
+ }
+
+ /* child relationship */
+ if (includeFilter & (OB_REL_CHILDREN | OB_REL_CHILDREN_RECURSIVE)) {
+ Base *local_base;
+ for (local_base = scene->base.first; local_base; local_base = local_base->next) {
+ if (BASE_EDITABLE_BGMODE(((View3D *)NULL), scene, local_base)) {
+
+ Object *child = local_base->object;
+ if (obrel_list_test(child)) {
+ if ((includeFilter & OB_REL_CHILDREN_RECURSIVE && obrel_is_recursive_child(ob, child)) ||
+ (includeFilter & OB_REL_CHILDREN && child->parent && child->parent == ob))
+ {
+ obrel_list_add(&links, child);
+ }
+ }
+ }
+ }
+ }
+
+
+ /* include related armatures */
+ if (includeFilter & OB_REL_MOD_ARMATURE) {
+ Object *arm = obrel_armature_find(ob);
+ if (obrel_list_test(arm)) {
+ obrel_list_add(&links, arm);
+ }
+ }
+
+ }
+ }
+ }
+
+ return links;
+}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index af5b7716bbc..ddf30ecfa81 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -2081,7 +2081,8 @@ static ImBuf *seq_render_mask_strip(
BKE_mask_rasterize(seq->mask,
context.rectx, context.recty,
maskbuf,
- TRUE, FALSE);
+ TRUE,
+ FALSE /*XXX- TODO: make on/off for anti-aliasing*/);
fp_src = maskbuf;
fp_dst = ibuf->rect_float;
@@ -2104,7 +2105,8 @@ static ImBuf *seq_render_mask_strip(
BKE_mask_rasterize(seq->mask,
context.rectx, context.recty,
maskbuf,
- TRUE, FALSE);
+ TRUE,
+ FALSE /*XXX- TODO: mask on/off for anti-aliasing*/);
fp_src = maskbuf;
ub_dst = (unsigned char *)ibuf->rect;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index bbb70bb77ff..b32400586a8 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -39,7 +39,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_camera_types.h"
#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
@@ -76,7 +76,191 @@ static struct {
ListBase tracks;
} tracking_clipboard;
-/*********************** space transformation functions *************************/
+/*********************** Common functions *************************/
+
+static MovieTrackingTrack *tracking_track_duplicate(MovieTrackingTrack *track)
+{
+ MovieTrackingTrack *new_track;
+
+ new_track = MEM_callocN(sizeof(MovieTrackingTrack), "tracksMapMerge new_track");
+
+ *new_track = *track;
+ new_track->next = new_track->prev = NULL;
+
+ new_track->markers = MEM_dupallocN(new_track->markers);
+
+ return new_track;
+}
+
+static void tracking_tracks_free(ListBase *tracks)
+{
+ MovieTrackingTrack *track;
+
+ for (track = tracks->first; track; track = track->next) {
+ BKE_tracking_track_free(track);
+ }
+
+ BLI_freelistN(tracks);
+}
+
+static void tracking_reconstruction_free(MovieTrackingReconstruction *reconstruction)
+{
+ if (reconstruction->cameras)
+ MEM_freeN(reconstruction->cameras);
+}
+
+static void tracking_object_free(MovieTrackingObject *object)
+{
+ tracking_tracks_free(&object->tracks);
+ tracking_reconstruction_free(&object->reconstruction);
+}
+
+static void tracking_objects_free(ListBase *objects)
+{
+ MovieTrackingObject *object;
+
+ for (object = objects->first; object; object = object->next)
+ tracking_object_free(object);
+
+ BLI_freelistN(objects);
+}
+
+static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet)
+{
+ MovieTrackingDopesheetChannel *channel;
+
+ channel = dopesheet->channels.first;
+ while (channel) {
+ if (channel->segments) {
+ MEM_freeN(channel->segments);
+ }
+
+ channel = channel->next;
+ }
+
+ BLI_freelistN(&dopesheet->channels);
+
+ dopesheet->channels.first = dopesheet->channels.last = NULL;
+ dopesheet->tot_channel = 0;
+}
+
+void BKE_tracking_free(MovieTracking *tracking)
+{
+ tracking_tracks_free(&tracking->tracks);
+ tracking_reconstruction_free(&tracking->reconstruction);
+ tracking_objects_free(&tracking->objects);
+
+ if (tracking->stabilization.scaleibuf)
+ IMB_freeImBuf(tracking->stabilization.scaleibuf);
+
+ if (tracking->camera.intrinsics)
+ BKE_tracking_distortion_free(tracking->camera.intrinsics);
+
+ tracking_dopesheet_free(&tracking->dopesheet);
+}
+
+void BKE_tracking_settings_init(MovieTracking *tracking)
+{
+ tracking->camera.sensor_width = 35.0f;
+ tracking->camera.pixel_aspect = 1.0f;
+ tracking->camera.units = CAMERA_UNITS_MM;
+
+ tracking->settings.default_motion_model = TRACK_MOTION_MODEL_TRANSLATION;
+ tracking->settings.default_minimum_correlation = 0.75;
+ tracking->settings.default_pattern_size = 11;
+ tracking->settings.default_search_size = 61;
+ tracking->settings.keyframe1 = 1;
+ tracking->settings.keyframe2 = 30;
+ tracking->settings.dist = 1;
+ tracking->settings.object_distance = 1;
+
+ tracking->stabilization.scaleinf = 1.0f;
+ tracking->stabilization.locinf = 1.0f;
+ tracking->stabilization.rotinf = 1.0f;
+ tracking->stabilization.maxscale = 2.0f;
+
+ BKE_tracking_object_add(tracking, "Camera");
+}
+
+ListBase *BKE_tracking_get_active_tracks(MovieTracking *tracking)
+{
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
+
+ if (object && (object->flag & TRACKING_OBJECT_CAMERA) == 0) {
+ return &object->tracks;
+ }
+
+ return &tracking->tracks;
+}
+
+MovieTrackingReconstruction *BKE_tracking_get_active_reconstruction(MovieTracking *tracking)
+{
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
+
+ return BKE_tracking_object_get_reconstruction(tracking, object);
+}
+
+void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4][4])
+{
+ if (!ob) {
+ if (scene->camera)
+ ob = scene->camera;
+ else
+ ob = BKE_scene_camera_find(scene);
+ }
+
+ if (ob)
+ BKE_object_where_is_calc_mat4(scene, ob, mat);
+ else
+ unit_m4(mat);
+}
+
+void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingObject *object,
+ int framenr, int winx, int winy, float mat[4][4])
+{
+ MovieReconstructedCamera *camera;
+ float lens = tracking->camera.focal * tracking->camera.sensor_width / (float)winx;
+ float viewfac, pixsize, left, right, bottom, top, clipsta, clipend;
+ float winmat[4][4];
+ float ycor = 1.0f / tracking->camera.pixel_aspect;
+ float shiftx, shifty, winside = MAX2(winx, winy);
+
+ BKE_tracking_camera_shift_get(tracking, winx, winy, &shiftx, &shifty);
+
+ clipsta = 0.1f;
+ clipend = 1000.0f;
+
+ if (winx >= winy)
+ viewfac = (lens * winx) / tracking->camera.sensor_width;
+ else
+ viewfac = (ycor * lens * winy) / tracking->camera.sensor_width;
+
+ pixsize = clipsta / viewfac;
+
+ left = -0.5f * (float)winx + shiftx * winside;
+ bottom = -0.5f * (ycor) * (float)winy + shifty * winside;
+ right = 0.5f * (float)winx + shiftx * winside;
+ top = 0.5f * (ycor) * (float)winy + shifty * winside;
+
+ left *= pixsize;
+ right *= pixsize;
+ bottom *= pixsize;
+ top *= pixsize;
+
+ perspective_m4(winmat, left, right, bottom, top, clipsta, clipend);
+
+ camera = BKE_tracking_camera_get_reconstructed(tracking, object, framenr);
+
+ if (camera) {
+ float imat[4][4];
+
+ invert_m4_m4(imat, camera->mat);
+ mult_m4_m4m4(mat, winmat, imat);
+ }
+ else copy_m4_m4(mat, winmat);
+}
+
+/* **** space transformation functions **** */
/* Three coordinate frames: Frame, Search, and Marker
* Two units: Pixels, Unified
@@ -100,7 +284,8 @@ static void marker_to_frame_unified(const MovieTrackingMarker *marker, const flo
static void marker_unified_to_frame_pixel_coordinates(int frame_width, int frame_height,
const MovieTrackingMarker *marker,
- const float marker_unified_coords[2], float frame_pixel_coords[2])
+ const float marker_unified_coords[2],
+ float frame_pixel_coords[2])
{
marker_to_frame_unified(marker, marker_unified_coords, frame_pixel_coords);
unified_to_pixel(frame_width, frame_height, frame_pixel_coords, frame_pixel_coords);
@@ -168,6 +353,7 @@ static void get_marker_coords_for_tracking(int frame_width, int frame_height,
search_pixel_x[i] = pixel_coords[0];
search_pixel_y[i] = pixel_coords[1];
}
+
/* Convert the center position (aka "pos"); this is the origin */
unified_coords[0] = 0.0;
unified_coords[1] = 0.0;
@@ -211,121 +397,81 @@ static void set_marker_coords_from_tracking(int frame_width, int frame_height, M
}
#endif
-/*********************** common functions *************************/
+/*********************** clipboard *************************/
-void BKE_tracking_init_settings(MovieTracking *tracking)
+void BKE_tracking_clipboard_free(void)
{
- tracking->camera.sensor_width = 35.0f;
- tracking->camera.pixel_aspect = 1.0f;
- tracking->camera.units = CAMERA_UNITS_MM;
+ MovieTrackingTrack *track = tracking_clipboard.tracks.first, *next_track;
- tracking->settings.default_motion_model = TRACK_MOTION_MODEL_TRANSLATION;
- tracking->settings.default_minimum_correlation = 0.75;
- tracking->settings.default_pattern_size = 11;
- tracking->settings.default_search_size = 61;
- tracking->settings.keyframe1 = 1;
- tracking->settings.keyframe2 = 30;
- tracking->settings.dist = 1;
- tracking->settings.object_distance = 1;
+ while (track) {
+ next_track = track->next;
- tracking->stabilization.scaleinf = 1.0f;
- tracking->stabilization.locinf = 1.0f;
- tracking->stabilization.rotinf = 1.0f;
- tracking->stabilization.maxscale = 2.0f;
+ BKE_tracking_track_free(track);
+ MEM_freeN(track);
- BKE_tracking_new_object(tracking, "Camera");
+ track = next_track;
+ }
}
-void BKE_tracking_clamp_marker(MovieTrackingMarker *marker, int event)
+void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingObject *object)
{
- int a;
- float pat_min[2], pat_max[2];
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
+ MovieTrackingTrack *track = tracksbase->first;
- BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
+ BKE_tracking_clipboard_free();
- if (event == CLAMP_PAT_DIM) {
- for (a = 0; a < 2; a++) {
- /* search shouldn't be resized smaller than pattern */
- marker->search_min[a] = MIN2(pat_min[a], marker->search_min[a]);
- marker->search_max[a] = MAX2(pat_max[a], marker->search_max[a]);
+ while (track) {
+ if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) {
+ MovieTrackingTrack *new_track = tracking_track_duplicate(track);
+
+ BLI_addtail(&tracking_clipboard.tracks, new_track);
}
+
+ track = track->next;
}
- else if (event == CLAMP_PAT_POS) {
- float dim[2];
+}
- sub_v2_v2v2(dim, pat_max, pat_min);
+int BKE_tracking_clipboard_has_tracks(void)
+{
+ return tracking_clipboard.tracks.first != NULL;
+}
- for (a = 0; a < 2; a++) {
- int b;
- /* pattern shouldn't be moved outside of search */
- if (pat_min[a] < marker->search_min[a]) {
- for (b = 0; b < 4; b++)
- marker->pattern_corners[b][a] += marker->search_min[a] - pat_min[a];
- }
- if (pat_max[a] > marker->search_max[a]) {
- for (b = 0; b < 4; b++)
- marker->pattern_corners[b][a] -= pat_max[a] - marker->search_max[a];
- }
- }
- }
- else if (event == CLAMP_SEARCH_DIM) {
- for (a = 0; a < 2; a++) {
- /* search shouldn't be resized smaller than pattern */
- marker->search_min[a] = MIN2(pat_min[a], marker->search_min[a]);
- marker->search_max[a] = MAX2(pat_max[a], marker->search_max[a]);
- }
- }
- else if (event == CLAMP_SEARCH_POS) {
- float dim[2];
+void BKE_tracking_clipboard_paste_tracks(MovieTracking *tracking, MovieTrackingObject *object)
+{
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
+ MovieTrackingTrack *track = tracking_clipboard.tracks.first;
- sub_v2_v2v2(dim, marker->search_max, marker->search_min);
+ while (track) {
+ MovieTrackingTrack *new_track = tracking_track_duplicate(track);
- for (a = 0; a < 2; a++) {
- /* search shouldn't be moved inside pattern */
- if (marker->search_min[a] > pat_min[a]) {
- marker->search_min[a] = pat_min[a];
- marker->search_max[a] = marker->search_min[a] + dim[a];
- }
- if (marker->search_max[a] < pat_max[a]) {
- marker->search_max[a] = pat_max[a];
- marker->search_min[a] = marker->search_max[a] - dim[a];
- }
- }
- }
- else if (event == CLAMP_SEARCH_DIM) {
- float dim[2];
- sub_v2_v2v2(dim, pat_max, pat_min);
- for (a = 0; a < 2; a++) {
- marker->search_min[a] = pat_min[a];
- marker->search_max[a] = pat_max[a];
- }
+ BLI_addtail(tracksbase, new_track);
+ BKE_tracking_track_unique_name(tracksbase, new_track);
+
+ track = track->next;
}
}
-void BKE_tracking_track_flag(MovieTrackingTrack *track, int area, int flag, int clear)
+/*********************** Tracks *************************/
+
+static void tracking_marker_insert_disabled(MovieTrackingTrack *track, MovieTrackingMarker *ref_marker,
+ int before, int overwrite)
{
- if (area == TRACK_AREA_NONE)
- return;
+ MovieTrackingMarker marker_new;
- if (clear) {
- if (area & TRACK_AREA_POINT)
- track->flag &= ~flag;
- if (area & TRACK_AREA_PAT)
- track->pat_flag &= ~flag;
- if (area & TRACK_AREA_SEARCH)
- track->search_flag &= ~flag;
- }
- else {
- if (area & TRACK_AREA_POINT)
- track->flag |= flag;
- if (area & TRACK_AREA_PAT)
- track->pat_flag |= flag;
- if (area & TRACK_AREA_SEARCH)
- track->search_flag |= flag;
- }
+ marker_new = *ref_marker;
+ marker_new.flag &= ~MARKER_TRACKED;
+ marker_new.flag |= MARKER_DISABLED;
+
+ if (before)
+ marker_new.framenr--;
+ else
+ marker_new.framenr++;
+
+ if (overwrite || !BKE_tracking_track_has_marker_at_frame(track, marker_new.framenr))
+ BKE_tracking_marker_insert(track, &marker_new);
}
-MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tracksbase, float x, float y,
+MovieTrackingTrack *BKE_tracking_track_add(MovieTracking *tracking, ListBase *tracksbase, float x, float y,
int framenr, int width, int height)
{
MovieTrackingTrack *track;
@@ -345,6 +491,7 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tr
track = MEM_callocN(sizeof(MovieTrackingTrack), "add_marker_exec track");
strcpy(track->name, "Track");
+ /* fill track's settings from default settings */
track->motion_model = settings->default_motion_model;
track->minimum_correlation = settings->default_minimum_correlation;
track->margin = settings->default_margin;
@@ -370,22 +517,416 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tr
copy_v2_v2(marker.search_max, search);
negate_v2_v2(marker.search_min, search);
- BKE_tracking_insert_marker(track, &marker);
+ BKE_tracking_marker_insert(track, &marker);
BLI_addtail(tracksbase, track);
- BKE_track_unique_name(tracksbase, track);
+ BKE_tracking_track_unique_name(tracksbase, track);
return track;
}
-MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, MovieTrackingMarker *marker)
+void BKE_tracking_track_unique_name(ListBase *tracksbase, MovieTrackingTrack *track)
+{
+ BLI_uniquename(tracksbase, track, "Track", '.', offsetof(MovieTrackingTrack, name), sizeof(track->name));
+}
+
+void BKE_tracking_track_free(MovieTrackingTrack *track)
+{
+ if (track->markers)
+ MEM_freeN(track->markers);
+}
+
+void BKE_tracking_track_flag_set(MovieTrackingTrack *track, int area, int flag)
+{
+ if (area == TRACK_AREA_NONE)
+ return;
+
+ if (area & TRACK_AREA_POINT)
+ track->flag |= flag;
+ if (area & TRACK_AREA_PAT)
+ track->pat_flag |= flag;
+ if (area & TRACK_AREA_SEARCH)
+ track->search_flag |= flag;
+}
+
+void BKE_tracking_track_flag_clear(MovieTrackingTrack *track, int area, int flag)
+{
+ if (area == TRACK_AREA_NONE)
+ return;
+
+ if (area & TRACK_AREA_POINT)
+ track->flag &= ~flag;
+ if (area & TRACK_AREA_PAT)
+ track->pat_flag &= ~flag;
+ if (area & TRACK_AREA_SEARCH)
+ track->search_flag &= ~flag;
+}
+
+int BKE_tracking_track_has_marker_at_frame(MovieTrackingTrack *track, int framenr)
+{
+ return BKE_tracking_marker_get_exact(track, framenr) != 0;
+}
+
+int BKE_tracking_track_has_enabled_marker_at_frame(MovieTrackingTrack *track, int framenr)
+{
+ MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
+
+ return marker && (marker->flag & MARKER_DISABLED) == 0;
+}
+
+void BKE_tracking_track_path_clear(MovieTrackingTrack *track, int ref_frame, int action)
+{
+ int a;
+
+ if (action == TRACK_CLEAR_REMAINED) {
+ a = 1;
+
+ while (a < track->markersnr) {
+ if (track->markers[a].framenr > ref_frame) {
+ track->markersnr = a;
+ track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr);
+
+ break;
+ }
+
+ a++;
+ }
+
+ if (track->markersnr)
+ tracking_marker_insert_disabled(track, &track->markers[track->markersnr - 1], FALSE, TRUE);
+ }
+ else if (action == TRACK_CLEAR_UPTO) {
+ a = track->markersnr - 1;
+
+ while (a >= 0) {
+ if (track->markers[a].framenr <= ref_frame) {
+ memmove(track->markers, track->markers + a, (track->markersnr - a) * sizeof(MovieTrackingMarker));
+
+ track->markersnr = track->markersnr - a;
+ track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr);
+
+ break;
+ }
+
+ a--;
+ }
+
+ if (track->markersnr)
+ tracking_marker_insert_disabled(track, &track->markers[0], TRUE, TRUE);
+ }
+ else if (action == TRACK_CLEAR_ALL) {
+ MovieTrackingMarker *marker, marker_new;
+
+ marker = BKE_tracking_marker_get(track, ref_frame);
+ marker_new = *marker;
+
+ MEM_freeN(track->markers);
+ track->markers = NULL;
+ track->markersnr = 0;
+
+ BKE_tracking_marker_insert(track, &marker_new);
+
+ tracking_marker_insert_disabled(track, &marker_new, TRUE, TRUE);
+ tracking_marker_insert_disabled(track, &marker_new, FALSE, TRUE);
+ }
+}
+
+void BKE_tracking_tracks_join(MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
+{
+ int i = 0, a = 0, b = 0, tot;
+ MovieTrackingMarker *markers;
+
+ tot = dst_track->markersnr + src_track->markersnr;
+ markers = MEM_callocN(tot * sizeof(MovieTrackingMarker), "tmp tracking joined tracks");
+
+ while (a < src_track->markersnr || b < dst_track->markersnr) {
+ if (b >= dst_track->markersnr) {
+ markers[i] = src_track->markers[a++];
+ }
+ else if (a >= src_track->markersnr) {
+ markers[i] = dst_track->markers[b++];
+ }
+ else if (src_track->markers[a].framenr < dst_track->markers[b].framenr) {
+ markers[i] = src_track->markers[a++];
+ }
+ else if (src_track->markers[a].framenr > dst_track->markers[b].framenr) {
+ markers[i] = dst_track->markers[b++];
+ }
+ else {
+ if ((src_track->markers[a].flag & MARKER_DISABLED) == 0) {
+ if ((dst_track->markers[b].flag & MARKER_DISABLED) == 0) {
+ /* both tracks are enabled on this frame, so find the whole segment
+ * on which tracks are intersecting and blend tracks using linear
+ * interpolation to prevent jumps
+ */
+
+ MovieTrackingMarker *marker_a, *marker_b;
+ int start_a = a, start_b = b, len = 0, frame = src_track->markers[a].framenr;
+ int j, inverse = 0;
+
+ inverse = (b == 0) ||
+ (dst_track->markers[b - 1].flag & MARKER_DISABLED) ||
+ (dst_track->markers[b - 1].framenr != frame - 1);
+
+ /* find length of intersection */
+ while (a < src_track->markersnr && b < dst_track->markersnr) {
+ marker_a = &src_track->markers[a];
+ marker_b = &dst_track->markers[b];
+
+ if (marker_a->flag & MARKER_DISABLED || marker_b->flag & MARKER_DISABLED)
+ break;
+
+ if (marker_a->framenr != frame || marker_b->framenr != frame)
+ break;
+
+ frame++;
+ len++;
+ a++;
+ b++;
+ }
+
+ a = start_a;
+ b = start_b;
+
+ /* linear interpolation for intersecting frames */
+ for (j = 0; j < len; j++) {
+ float fac = 0.5f;
+
+ if (len > 1)
+ fac = 1.0f / (len - 1) * j;
+
+ if (inverse)
+ fac = 1.0f - fac;
+
+ marker_a = &src_track->markers[a];
+ marker_b = &dst_track->markers[b];
+
+ markers[i] = dst_track->markers[b];
+ interp_v2_v2v2(markers[i].pos, marker_b->pos, marker_a->pos, fac);
+ a++;
+ b++;
+ i++;
+ }
+
+ /* this values will be incremented at the end of the loop cycle */
+ a--; b--; i--;
+ }
+ else {
+ markers[i] = src_track->markers[a];
+ }
+ }
+ else {
+ markers[i] = dst_track->markers[b];
+ }
+
+ a++;
+ b++;
+ }
+
+ i++;
+ }
+
+ MEM_freeN(dst_track->markers);
+
+ dst_track->markers = MEM_callocN(i * sizeof(MovieTrackingMarker), "tracking joined tracks");
+ memcpy(dst_track->markers, markers, i * sizeof(MovieTrackingMarker));
+
+ dst_track->markersnr = i;
+
+ MEM_freeN(markers);
+}
+
+MovieTrackingTrack *BKE_tracking_track_get_named(MovieTracking *tracking, MovieTrackingObject *object, const char *name)
+{
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
+ MovieTrackingTrack *track = tracksbase->first;
+
+ while (track) {
+ if (!strcmp(track->name, name))
+ return track;
+
+ track = track->next;
+ }
+
+ return NULL;
+}
+
+MovieTrackingTrack *BKE_tracking_track_get_indexed(MovieTracking *tracking, int tracknr, ListBase **tracksbase_r)
+{
+ MovieTrackingObject *object;
+ int cur = 1;
+
+ object = tracking->objects.first;
+ while (object) {
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
+ MovieTrackingTrack *track = tracksbase->first;
+
+ while (track) {
+ if (track->flag & TRACK_HAS_BUNDLE) {
+ if (cur == tracknr) {
+ *tracksbase_r = tracksbase;
+ return track;
+ }
+
+ cur++;
+ }
+
+ track = track->next;
+ }
+
+ object = object->next;
+ }
+
+ *tracksbase_r = NULL;
+
+ return NULL;
+}
+
+MovieTrackingTrack *BKE_tracking_track_get_active(MovieTracking *tracking)
+{
+ ListBase *tracksbase;
+
+ if (!tracking->act_track)
+ return NULL;
+
+ tracksbase = BKE_tracking_get_active_tracks(tracking);
+
+ /* check that active track is in current tracks list */
+ if (BLI_findindex(tracksbase, tracking->act_track) >= 0)
+ return tracking->act_track;
+
+ return NULL;
+}
+
+static bGPDlayer *track_mask_gpencil_layer_get(MovieTrackingTrack *track)
+{
+ bGPDlayer *layer;
+
+ if (!track->gpd)
+ return NULL;
+
+ layer = track->gpd->layers.first;
+
+ while (layer) {
+ if (layer->flag & GP_LAYER_ACTIVE) {
+ bGPDframe *frame = layer->frames.first;
+ int ok = FALSE;
+
+ while (frame) {
+ if (frame->strokes.first) {
+ ok = TRUE;
+ }
+
+ frame = frame->next;
+ }
+
+ if (ok)
+ return layer;
+ }
+
+ layer = layer->next;
+ }
+
+ return NULL;
+}
+
+static void track_mask_gpencil_layer_rasterize(int frame_width, int frame_height,
+ MovieTrackingMarker *marker, bGPDlayer *layer,
+ float *mask, int mask_width, int mask_height)
+{
+ bGPDframe *frame = layer->frames.first;
+
+ while (frame) {
+ bGPDstroke *stroke = frame->strokes.first;
+
+ while (stroke) {
+ bGPDspoint *stroke_points = stroke->points;
+ float *mask_points, *fp;
+ int i;
+
+ if (stroke->flag & GP_STROKE_2DSPACE) {
+ fp = mask_points = MEM_callocN(2 * stroke->totpoints * sizeof(float),
+ "track mask rasterization points");
+
+ for (i = 0; i < stroke->totpoints; i++, fp += 2) {
+ fp[0] = (stroke_points[i].x - marker->search_min[0]) * frame_width / mask_width;
+ fp[1] = (stroke_points[i].y - marker->search_min[1]) * frame_height / mask_height;
+ }
+
+ /* TODO: add an option to control wether AA is enabled or not */
+ PLX_raskterize((float (*)[2])mask_points, stroke->totpoints, mask, mask_width, mask_height, FALSE);
+
+ MEM_freeN(mask_points);
+ }
+
+ stroke = stroke->next;
+ }
+
+ frame = frame->next;
+ }
+}
+
+float *BKE_tracking_track_get_mask(int frame_width, int frame_height,
+ MovieTrackingTrack *track, MovieTrackingMarker *marker)
+{
+ float *mask = NULL;
+ bGPDlayer *layer = track_mask_gpencil_layer_get(track);
+ int mask_width, mask_height;
+
+ mask_width = (marker->search_max[0] - marker->search_min[0]) * frame_width;
+ mask_height = (marker->search_max[1] - marker->search_min[1]) * frame_height;
+
+ if (layer) {
+ mask = MEM_callocN(mask_width * mask_height * sizeof(float), "track mask");
+
+ track_mask_gpencil_layer_rasterize(frame_width, frame_height, marker, layer,
+ mask, mask_width, mask_height);
+ }
+
+ return mask;
+}
+
+/* area - which part of marker should be selected. see TRACK_AREA_* constants */
+void BKE_tracking_track_select(ListBase *tracksbase, MovieTrackingTrack *track, int area, int extend)
+{
+ if (extend) {
+ BKE_tracking_track_flag_set(track, area, SELECT);
+ }
+ else {
+ MovieTrackingTrack *cur = tracksbase->first;
+
+ while (cur) {
+ if ((cur->flag & TRACK_HIDDEN) == 0) {
+ if (cur == track) {
+ BKE_tracking_track_flag_clear(cur, TRACK_AREA_ALL, SELECT);
+ BKE_tracking_track_flag_set(cur, area, SELECT);
+ }
+ else {
+ BKE_tracking_track_flag_clear(cur, TRACK_AREA_ALL, SELECT);
+ }
+ }
+
+ cur = cur->next;
+ }
+ }
+}
+
+void BKE_tracking_track_deselect(MovieTrackingTrack *track, int area)
+{
+ BKE_tracking_track_flag_clear(track, area, SELECT);
+}
+
+/*********************** Marker *************************/
+
+MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track, MovieTrackingMarker *marker)
{
MovieTrackingMarker *old_marker = NULL;
if (track->markersnr)
- old_marker = BKE_tracking_exact_marker(track, marker->framenr);
+ old_marker = BKE_tracking_marker_get_exact(track, marker->framenr);
if (old_marker) {
+ /* simply replace settings for already allocated marker */
*old_marker = *marker;
return old_marker;
@@ -393,6 +934,7 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie
else {
int a = track->markersnr;
+ /* find position in array where to add new marker */
while (a--) {
if (track->markers[a].framenr < marker->framenr)
break;
@@ -401,12 +943,15 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie
track->markersnr++;
if (track->markers)
- track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr);
+ track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr);
else
track->markers = MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers");
+ /* shift array to "free" space for new marker */
memmove(track->markers + a + 2, track->markers + a + 1,
(track->markersnr - a - 2) * sizeof(MovieTrackingMarker));
+
+ /* put new marker */
track->markers[a + 1] = *marker;
track->last_marker = a + 1;
@@ -415,7 +960,7 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie
}
}
-void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr)
+void BKE_tracking_marker_delete(MovieTrackingTrack *track, int framenr)
{
int a = 0;
@@ -440,17 +985,73 @@ void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr)
}
}
-void BKE_tracking_marker_pattern_minmax(MovieTrackingMarker *marker, float min[2], float max[2])
+void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event)
{
- INIT_MINMAX2(min, max);
+ int a;
+ float pat_min[2], pat_max[2];
- DO_MINMAX2(marker->pattern_corners[0], min, max);
- DO_MINMAX2(marker->pattern_corners[1], min, max);
- DO_MINMAX2(marker->pattern_corners[2], min, max);
- DO_MINMAX2(marker->pattern_corners[3], min, max);
+ BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
+
+ if (event == CLAMP_PAT_DIM) {
+ for (a = 0; a < 2; a++) {
+ /* search shouldn't be resized smaller than pattern */
+ marker->search_min[a] = MIN2(pat_min[a], marker->search_min[a]);
+ marker->search_max[a] = MAX2(pat_max[a], marker->search_max[a]);
+ }
+ }
+ else if (event == CLAMP_PAT_POS) {
+ float dim[2];
+
+ sub_v2_v2v2(dim, pat_max, pat_min);
+
+ for (a = 0; a < 2; a++) {
+ int b;
+ /* pattern shouldn't be moved outside of search */
+ if (pat_min[a] < marker->search_min[a]) {
+ for (b = 0; b < 4; b++)
+ marker->pattern_corners[b][a] += marker->search_min[a] - pat_min[a];
+ }
+ if (pat_max[a] > marker->search_max[a]) {
+ for (b = 0; b < 4; b++)
+ marker->pattern_corners[b][a] -= pat_max[a] - marker->search_max[a];
+ }
+ }
+ }
+ else if (event == CLAMP_SEARCH_DIM) {
+ for (a = 0; a < 2; a++) {
+ /* search shouldn't be resized smaller than pattern */
+ marker->search_min[a] = MIN2(pat_min[a], marker->search_min[a]);
+ marker->search_max[a] = MAX2(pat_max[a], marker->search_max[a]);
+ }
+ }
+ else if (event == CLAMP_SEARCH_POS) {
+ float dim[2];
+
+ sub_v2_v2v2(dim, marker->search_max, marker->search_min);
+
+ for (a = 0; a < 2; a++) {
+ /* search shouldn't be moved inside pattern */
+ if (marker->search_min[a] > pat_min[a]) {
+ marker->search_min[a] = pat_min[a];
+ marker->search_max[a] = marker->search_min[a] + dim[a];
+ }
+ if (marker->search_max[a] < pat_max[a]) {
+ marker->search_max[a] = pat_max[a];
+ marker->search_min[a] = marker->search_max[a] - dim[a];
+ }
+ }
+ }
+ else if (event == CLAMP_SEARCH_DIM) {
+ float dim[2];
+ sub_v2_v2v2(dim, pat_max, pat_min);
+ for (a = 0; a < 2; a++) {
+ marker->search_min[a] = pat_min[a];
+ marker->search_max[a] = pat_max[a];
+ }
+ }
}
-MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int framenr)
+MovieTrackingMarker *BKE_tracking_marker_get(MovieTrackingTrack *track, int framenr)
{
int a = track->markersnr - 1;
@@ -495,9 +1096,19 @@ MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int fram
return NULL;
}
-MovieTrackingMarker *BKE_tracking_ensure_marker(MovieTrackingTrack *track, int framenr)
+MovieTrackingMarker *BKE_tracking_marker_get_exact(MovieTrackingTrack *track, int framenr)
+{
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+
+ if (marker->framenr != framenr)
+ return NULL;
+
+ return marker;
+}
+
+MovieTrackingMarker *BKE_tracking_marker_ensure(MovieTrackingTrack *track, int framenr)
{
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (marker->framenr != framenr) {
MovieTrackingMarker marker_new;
@@ -505,352 +1116,663 @@ MovieTrackingMarker *BKE_tracking_ensure_marker(MovieTrackingTrack *track, int f
marker_new = *marker;
marker_new.framenr = framenr;
- BKE_tracking_insert_marker(track, &marker_new);
- marker = BKE_tracking_get_marker(track, framenr);
+ BKE_tracking_marker_insert(track, &marker_new);
+ marker = BKE_tracking_marker_get(track, framenr);
}
return marker;
}
-MovieTrackingMarker *BKE_tracking_exact_marker(MovieTrackingTrack *track, int framenr)
+void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float min[2], float max[2])
{
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
-
- if (marker->framenr != framenr)
- return NULL;
+ INIT_MINMAX2(min, max);
- return marker;
+ DO_MINMAX2(marker->pattern_corners[0], min, max);
+ DO_MINMAX2(marker->pattern_corners[1], min, max);
+ DO_MINMAX2(marker->pattern_corners[2], min, max);
+ DO_MINMAX2(marker->pattern_corners[3], min, max);
}
-int BKE_tracking_has_marker(MovieTrackingTrack *track, int framenr)
+/*********************** Object *************************/
+
+MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char *name)
{
- return BKE_tracking_exact_marker(track, framenr) != 0;
+ MovieTrackingObject *object = MEM_callocN(sizeof(MovieTrackingObject), "tracking object");
+
+ if (tracking->tot_object == 0) {
+ /* first object is always camera */
+ BLI_strncpy(object->name, "Camera", sizeof(object->name));
+
+ object->flag |= TRACKING_OBJECT_CAMERA;
+ }
+ else {
+ BLI_strncpy(object->name, name, sizeof(object->name));
+ }
+
+ BLI_addtail(&tracking->objects, object);
+
+ tracking->tot_object++;
+ tracking->objectnr = BLI_countlist(&tracking->objects) - 1;
+
+ object->scale = 1.0f;
+
+ BKE_tracking_object_unique_name(tracking, object);
+
+ return object;
}
-int BKE_tracking_has_enabled_marker(MovieTrackingTrack *track, int framenr)
+void BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *object)
{
- MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+ MovieTrackingTrack *track;
+ int index = BLI_findindex(&tracking->objects, object);
- return marker && (marker->flag & MARKER_DISABLED) == 0;
+ if (index < 0)
+ return;
+
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
+ /* object used for camera solving can't be deleted */
+ return;
+ }
+
+ track = object->tracks.first;
+ while (track) {
+ if (track == tracking->act_track)
+ tracking->act_track = NULL;
+
+ track = track->next;
+ }
+
+ tracking_object_free(object);
+ BLI_freelinkN(&tracking->objects, object);
+
+ tracking->tot_object--;
+
+ if (index > 0)
+ tracking->objectnr = index - 1;
+ else
+ tracking->objectnr = 0;
}
-void BKE_tracking_free_track(MovieTrackingTrack *track)
+void BKE_tracking_object_unique_name(MovieTracking *tracking, MovieTrackingObject *object)
{
- if (track->markers)
- MEM_freeN(track->markers);
+ BLI_uniquename(&tracking->objects, object, "Object", '.',
+ offsetof(MovieTrackingObject, name), sizeof(object->name));
}
-static void put_disabled_marker(MovieTrackingTrack *track, MovieTrackingMarker *ref_marker, int before, int overwrite)
+MovieTrackingObject *BKE_tracking_object_get_named(MovieTracking *tracking, const char *name)
{
- MovieTrackingMarker marker_new;
+ MovieTrackingObject *object = tracking->objects.first;
- marker_new = *ref_marker;
- marker_new.flag &= ~MARKER_TRACKED;
- marker_new.flag |= MARKER_DISABLED;
+ while (object) {
+ if (!strcmp(object->name, name))
+ return object;
- if (before)
- marker_new.framenr--;
- else
- marker_new.framenr++;
+ object = object->next;
+ }
- if (!BKE_tracking_has_marker(track, marker_new.framenr) || overwrite)
- BKE_tracking_insert_marker(track, &marker_new);
+ return NULL;
}
-void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int action)
+MovieTrackingObject *BKE_tracking_object_get_active(MovieTracking *tracking)
{
- int a;
+ return BLI_findlink(&tracking->objects, tracking->objectnr);
+}
- if (action == TRACK_CLEAR_REMAINED) {
- a = 1;
+MovieTrackingObject *BKE_tracking_object_get_camera(MovieTracking *tracking)
+{
+ MovieTrackingObject *object = tracking->objects.first;
- while (a < track->markersnr) {
- if (track->markers[a].framenr > ref_frame) {
- track->markersnr = a;
- track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr);
+ while (object) {
+ if (object->flag & TRACKING_OBJECT_CAMERA)
+ return object;
- break;
- }
+ object = object->next;
+ }
- a++;
- }
+ return NULL;
+}
- if (track->markersnr)
- put_disabled_marker(track, &track->markers[track->markersnr - 1], 0, 1);
+ListBase *BKE_tracking_object_get_tracks(MovieTracking *tracking, MovieTrackingObject *object)
+{
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
+ return &tracking->tracks;
}
- else if (action == TRACK_CLEAR_UPTO) {
- a = track->markersnr - 1;
-
- while (a >= 0) {
- if (track->markers[a].framenr <= ref_frame) {
- memmove(track->markers, track->markers + a, (track->markersnr - a) * sizeof(MovieTrackingMarker));
- track->markersnr = track->markersnr - a;
- track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr);
+ return &object->tracks;
+}
- break;
- }
+MovieTrackingReconstruction *BKE_tracking_object_get_reconstruction(MovieTracking *tracking,
+ MovieTrackingObject *object)
+{
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
+ return &tracking->reconstruction;
+ }
- a--;
- }
+ return &object->reconstruction;
+}
- if (track->markersnr)
- put_disabled_marker(track, &track->markers[0], 1, 1);
- }
- else if (action == TRACK_CLEAR_ALL) {
- MovieTrackingMarker *marker, marker_new;
+/*********************** Camera *************************/
- marker = BKE_tracking_get_marker(track, ref_frame);
- marker_new = *marker;
+static int reconstructed_camera_index_get(MovieTrackingReconstruction *reconstruction, int framenr, int nearest)
+{
+ MovieReconstructedCamera *cameras = reconstruction->cameras;
+ int a = 0, d = 1;
- MEM_freeN(track->markers);
- track->markers = NULL;
- track->markersnr = 0;
+ if (!reconstruction->camnr)
+ return -1;
- BKE_tracking_insert_marker(track, &marker_new);
+ if (framenr < cameras[0].framenr) {
+ if (nearest)
+ return 0;
+ else
+ return -1;
+ }
- put_disabled_marker(track, &marker_new, 1, 1);
- put_disabled_marker(track, &marker_new, 0, 1);
+ if (framenr > cameras[reconstruction->camnr - 1].framenr) {
+ if (nearest)
+ return reconstruction->camnr - 1;
+ else
+ return -1;
}
-}
-void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
-{
- int i = 0, a = 0, b = 0, tot;
- MovieTrackingMarker *markers;
+ if (reconstruction->last_camera < reconstruction->camnr)
+ a = reconstruction->last_camera;
- tot = dst_track->markersnr + src_track->markersnr;
- markers = MEM_callocN(tot * sizeof(MovieTrackingMarker), "tmp tracking joined tracks");
+ if (cameras[a].framenr >= framenr)
+ d = -1;
- while (a < src_track->markersnr || b < dst_track->markersnr) {
- if (b >= dst_track->markersnr) {
- markers[i] = src_track->markers[a++];
- }
- else if (a >= src_track->markersnr) {
- markers[i] = dst_track->markers[b++];
+ while (a >= 0 && a < reconstruction->camnr) {
+ int cfra = cameras[a].framenr;
+
+ /* check if needed framenr was "skipped" -- no data for requested frame */
+
+ if (d > 0 && cfra > framenr) {
+ /* interpolate with previous position */
+ if (nearest)
+ return a - 1;
+ else
+ break;
}
- else if (src_track->markers[a].framenr < dst_track->markers[b].framenr) {
- markers[i] = src_track->markers[a++];
+
+ if (d < 0 && cfra < framenr) {
+ /* interpolate with next position */
+ if (nearest)
+ return a;
+ else
+ break;
}
- else if (src_track->markers[a].framenr > dst_track->markers[b].framenr) {
- markers[i] = dst_track->markers[b++];
+
+ if (cfra == framenr) {
+ reconstruction->last_camera = a;
+
+ return a;
}
- else {
- if ((src_track->markers[a].flag & MARKER_DISABLED) == 0) {
- if ((dst_track->markers[b].flag & MARKER_DISABLED) == 0) {
- /* both tracks are enabled on this frame, so find the whole segment
- * on which tracks are intersecting and blend tracks using linear
- * interpolation to prevent jumps
- */
- MovieTrackingMarker *marker_a, *marker_b;
- int start_a = a, start_b = b, len = 0, frame = src_track->markers[a].framenr;
- int j, inverse = 0;
+ a += d;
+ }
- inverse = (b == 0) ||
- (dst_track->markers[b - 1].flag & MARKER_DISABLED) ||
- (dst_track->markers[b - 1].framenr != frame - 1);
+ return -1;
+}
- /* find length of intersection */
- while (a < src_track->markersnr && b < dst_track->markersnr) {
- marker_a = &src_track->markers[a];
- marker_b = &dst_track->markers[b];
+static void reconstructed_camera_scale_set(MovieTrackingObject *object, float mat[4][4])
+{
+ if ((object->flag & TRACKING_OBJECT_CAMERA) == 0) {
+ float smat[4][4];
- if (marker_a->flag & MARKER_DISABLED || marker_b->flag & MARKER_DISABLED)
- break;
+ scale_m4_fl(smat, 1.0f / object->scale);
+ mult_m4_m4m4(mat, mat, smat);
+ }
+}
- if (marker_a->framenr != frame || marker_b->framenr != frame)
- break;
- frame++;
- len++;
- a++;
- b++;
- }
+/* converts principal offset from center to offset of blender's camera */
+void BKE_tracking_camera_shift_get(MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty)
+{
+ /* indeed in both of cases it should be winx -- it's just how camera shift works for blender's camera */
+ *shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx;
+ *shifty = (0.5f * winy - tracking->camera.principal[1]) / winx;
+}
- a = start_a;
- b = start_b;
+void BKE_tracking_camera_to_blender(MovieTracking *tracking, Scene *scene, Camera *camera, int width, int height)
+{
+ float focal = tracking->camera.focal;
- /* linear interpolation for intersecting frames */
- for (j = 0; j < len; j++) {
- float fac = 0.5f;
+ camera->sensor_x = tracking->camera.sensor_width;
+ camera->sensor_fit = CAMERA_SENSOR_FIT_AUTO;
+ camera->lens = focal * camera->sensor_x / width;
- if (len > 1)
- fac = 1.0f / (len - 1) * j;
+ scene->r.xsch = width * tracking->camera.pixel_aspect;
+ scene->r.ysch = height;
- if (inverse)
- fac = 1.0f - fac;
+ scene->r.xasp = 1.0f;
+ scene->r.yasp = 1.0f;
- marker_a = &src_track->markers[a];
- marker_b = &dst_track->markers[b];
+ BKE_tracking_camera_shift_get(tracking, width, height, &camera->shiftx, &camera->shifty);
+}
- markers[i] = dst_track->markers[b];
- interp_v2_v2v2(markers[i].pos, marker_b->pos, marker_a->pos, fac);
- a++;
- b++;
- i++;
- }
+MovieReconstructedCamera *BKE_tracking_camera_get_reconstructed(MovieTracking *tracking,
+ MovieTrackingObject *object, int framenr)
+{
+ MovieTrackingReconstruction *reconstruction;
+ int a;
- /* this values will be incremented at the end of the loop cycle */
- a--; b--; i--;
- }
- else markers[i] = src_track->markers[a];
- }
- else markers[i] = dst_track->markers[b];
+ reconstruction = BKE_tracking_object_get_reconstruction(tracking, object);
+ a = reconstructed_camera_index_get(reconstruction, framenr, FALSE);
- a++;
- b++;
- }
+ if (a == -1)
+ return NULL;
- i++;
- }
+ return &reconstruction->cameras[a];
+}
- MEM_freeN(dst_track->markers);
+void BKE_tracking_camera_get_reconstructed_interpolate(MovieTracking *tracking, MovieTrackingObject *object,
+ int framenr, float mat[4][4])
+{
+ MovieTrackingReconstruction *reconstruction;
+ MovieReconstructedCamera *cameras;
+ int a;
- dst_track->markers = MEM_callocN(i*sizeof(MovieTrackingMarker), "tracking joined tracks");
- memcpy(dst_track->markers, markers, i*sizeof(MovieTrackingMarker));
+ reconstruction = BKE_tracking_object_get_reconstruction(tracking, object);
+ cameras = reconstruction->cameras;
+ a = reconstructed_camera_index_get(reconstruction, framenr, 1);
- dst_track->markersnr = i;
+ if (a == -1) {
+ unit_m4(mat);
- MEM_freeN(markers);
-}
+ return;
+ }
-static void tracking_tracks_free(ListBase *tracks)
-{
- MovieTrackingTrack *track;
+ if (cameras[a].framenr != framenr && a > 0 && a < reconstruction->camnr - 1) {
+ float t = ((float)framenr - cameras[a].framenr) / (cameras[a + 1].framenr - cameras[a].framenr);
- for (track = tracks->first; track; track = track->next) {
- BKE_tracking_free_track(track);
+ blend_m4_m4m4(mat, cameras[a].mat, cameras[a + 1].mat, t);
+ }
+ else {
+ copy_m4_m4(mat, cameras[a].mat);
}
- BLI_freelistN(tracks);
+ reconstructed_camera_scale_set(object, mat);
}
-static void tracking_reconstruction_free(MovieTrackingReconstruction *reconstruction)
+/*********************** Distortion/Undistortion *************************/
+
+MovieDistortion *BKE_tracking_distortion_new(void)
{
- if (reconstruction->cameras)
- MEM_freeN(reconstruction->cameras);
+ MovieDistortion *distortion;
+
+ distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
+
+ return distortion;
}
-static void tracking_object_free(MovieTrackingObject *object)
+void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking *tracking,
+ int calibration_width, int calibration_height)
{
- tracking_tracks_free(&object->tracks);
- tracking_reconstruction_free(&object->reconstruction);
+ MovieTrackingCamera *camera = &tracking->camera;
+ float aspy = 1.0f / tracking->camera.pixel_aspect;
+
+#ifdef WITH_LIBMV
+ if (!distortion->intrinsics) {
+ distortion->intrinsics = libmv_CameraIntrinsicsNew(camera->focal,
+ camera->principal[0], camera->principal[1] * aspy,
+ camera->k1, camera->k2, camera->k3,
+ calibration_width, calibration_height * aspy);
+ }
+ else {
+ libmv_CameraIntrinsicsUpdate(distortion->intrinsics, camera->focal,
+ camera->principal[0], camera->principal[1] * aspy,
+ camera->k1, camera->k2, camera->k3,
+ calibration_width, calibration_height * aspy);
+ }
+#else
+ (void) distortion;
+ (void) calibration_width;
+ (void) calibration_height;
+ (void) camera;
+ (void) aspy;
+#endif
}
-static void tracking_objects_free(ListBase *objects)
+MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion)
{
- MovieTrackingObject *object;
+ MovieDistortion *new_distortion;
- for (object = objects->first; object; object = object->next)
- tracking_object_free(object);
+ new_distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
- BLI_freelistN(objects);
+#ifdef WITH_LIBMV
+ new_distortion->intrinsics = libmv_CameraIntrinsicsCopy(distortion->intrinsics);
+#else
+ (void) distortion;
+#endif
+
+ return new_distortion;
}
-static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet)
+ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *tracking, ImBuf *ibuf,
+ int calibration_width, int calibration_height, float overscan, int undistort)
{
- MovieTrackingDopesheetChannel *channel;
+ ImBuf *resibuf;
- channel = dopesheet->channels.first;
- while (channel) {
- if (channel->segments) {
- MEM_freeN(channel->segments);
+ BKE_tracking_distortion_update(distortion, tracking, calibration_width, calibration_height);
+
+ resibuf = IMB_dupImBuf(ibuf);
+
+#ifdef WITH_LIBMV
+ if (ibuf->rect_float) {
+ if (undistort) {
+ libmv_CameraIntrinsicsUndistortFloat(distortion->intrinsics,
+ ibuf->rect_float, resibuf->rect_float,
+ ibuf->x, ibuf->y, overscan, ibuf->channels);
+ }
+ else {
+ libmv_CameraIntrinsicsDistortFloat(distortion->intrinsics,
+ ibuf->rect_float, resibuf->rect_float,
+ ibuf->x, ibuf->y, overscan, ibuf->channels);
}
- channel = channel->next;
+ resibuf->userflags |= IB_RECT_INVALID;
+ }
+ else {
+ if (undistort) {
+ libmv_CameraIntrinsicsUndistortByte(distortion->intrinsics,
+ (unsigned char *)ibuf->rect, (unsigned char *)resibuf->rect,
+ ibuf->x, ibuf->y, overscan, ibuf->channels);
+ }
+ else {
+ libmv_CameraIntrinsicsDistortByte(distortion->intrinsics,
+ (unsigned char *)ibuf->rect, (unsigned char *)resibuf->rect,
+ ibuf->x, ibuf->y, overscan, ibuf->channels);
+ }
}
+#else
+ (void) overscan;
+ (void) undistort;
- BLI_freelistN(&dopesheet->channels);
+ if (ibuf->rect_float) {
+ resibuf->userflags |= IB_RECT_INVALID;
+ }
+#endif
- dopesheet->channels.first = dopesheet->channels.last = NULL;
- dopesheet->tot_channel = 0;
+ return resibuf;
}
-void BKE_tracking_free(MovieTracking *tracking)
+void BKE_tracking_distortion_free(MovieDistortion *distortion)
{
- tracking_tracks_free(&tracking->tracks);
- tracking_reconstruction_free(&tracking->reconstruction);
- tracking_objects_free(&tracking->objects);
+#ifdef WITH_LIBMV
+ libmv_CameraIntrinsicsDestroy(distortion->intrinsics);
+#endif
- if (tracking->stabilization.scaleibuf)
- IMB_freeImBuf(tracking->stabilization.scaleibuf);
+ MEM_freeN(distortion);
+}
- if (tracking->camera.intrinsics)
- BKE_tracking_distortion_destroy(tracking->camera.intrinsics);
+void BKE_tracking_distort_v2(MovieTracking *tracking, float co[2], float nco[2])
+{
+ MovieTrackingCamera *camera = &tracking->camera;
- tracking_dopesheet_free(&tracking->dopesheet);
+#ifdef WITH_LIBMV
+ double x, y;
+ float aspy = 1.0f / tracking->camera.pixel_aspect;
+
+ /* normalize coords */
+ x = (co[0] - camera->principal[0]) / camera->focal;
+ y = (co[1] - camera->principal[1] * aspy) / camera->focal;
+
+ libmv_applyCameraIntrinsics(camera->focal, camera->principal[0], camera->principal[1] * aspy,
+ camera->k1, camera->k2, camera->k3, x, y, &x, &y);
+
+ /* result is in image coords already */
+ nco[0] = x;
+ nco[1] = y;
+#else
+ (void) camera;
+ (void) co;
+ (void) nco;
+#endif
}
-static MovieTrackingTrack *duplicate_track(MovieTrackingTrack *track)
+void BKE_tracking_undistort_v2(MovieTracking *tracking, float co[2], float nco[2])
{
- MovieTrackingTrack *new_track;
+ MovieTrackingCamera *camera = &tracking->camera;
- new_track = MEM_callocN(sizeof(MovieTrackingTrack), "tracksMapMerge new_track");
+#ifdef WITH_LIBMV
+ double x = co[0], y = co[1];
+ float aspy = 1.0f / tracking->camera.pixel_aspect;
- *new_track = *track;
- new_track->next = new_track->prev = NULL;
+ libmv_InvertIntrinsics(camera->focal, camera->principal[0], camera->principal[1] * aspy,
+ camera->k1, camera->k2, camera->k3, x, y, &x, &y);
- new_track->markers = MEM_dupallocN(new_track->markers);
+ nco[0] = x * camera->focal + camera->principal[0];
+ nco[1] = y * camera->focal + camera->principal[1] * aspy;
+#else
+ (void) camera;
+ (void) co;
+ (void) nco;
+#endif
+}
- return new_track;
+ImBuf *BKE_tracking_undistort_frame(MovieTracking *tracking, ImBuf *ibuf, int calibration_width,
+ int calibration_height, float overscan)
+{
+ MovieTrackingCamera *camera = &tracking->camera;
+
+ if (camera->intrinsics == NULL)
+ camera->intrinsics = BKE_tracking_distortion_new();
+
+ return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, calibration_width,
+ calibration_height, overscan, TRUE);
}
-/*********************** clipboard *************************/
+ImBuf *BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int calibration_width,
+ int calibration_height, float overscan)
+{
+ MovieTrackingCamera *camera = &tracking->camera;
+
+ if (camera->intrinsics == NULL)
+ camera->intrinsics = BKE_tracking_distortion_new();
-void BKE_tracking_free_clipboard(void)
+ return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, calibration_width,
+ calibration_height, overscan, FALSE);
+}
+
+/*********************** Image sampling *************************/
+
+static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int grayscale)
{
- MovieTrackingTrack *track = tracking_clipboard.tracks.first, *next_track;
+ BKE_tracking_disable_channels(ibuf, track->flag & TRACK_DISABLE_RED,
+ track->flag & TRACK_DISABLE_GREEN,
+ track->flag & TRACK_DISABLE_BLUE, grayscale);
+}
- while (track) {
- next_track = track->next;
+ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *search_ibuf,
+ MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int use_mask, int num_samples_x, int num_samples_y,
+ float pos[2])
+{
+#ifdef WITH_LIBMV
+ ImBuf *pattern_ibuf;
+ double src_pixel_x[5], src_pixel_y[5];
+ double warped_position_x, warped_position_y;
+ float *mask = NULL;
- BKE_tracking_free_track(track);
- MEM_freeN(track);
+ pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
+ pattern_ibuf->profile = IB_PROFILE_LINEAR_RGB;
- track = next_track;
+ if (!search_ibuf->rect_float) {
+ IMB_float_from_rect(search_ibuf);
+ }
+
+ get_marker_coords_for_tracking(frame_width, frame_height, marker, src_pixel_x, src_pixel_y);
+
+ if (use_mask) {
+ mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker);
+ }
+
+ libmv_samplePlanarPatch(search_ibuf->rect_float, search_ibuf->x, search_ibuf->y, 4,
+ src_pixel_x, src_pixel_y, num_samples_x,
+ num_samples_y, mask, pattern_ibuf->rect_float,
+ &warped_position_x, &warped_position_y);
+
+ if (pos) {
+ pos[0] = warped_position_x;
+ pos[1] = warped_position_y;
+ }
+
+ if (mask) {
+ MEM_freeN(mask);
}
+
+ return pattern_ibuf;
+#else
+ ImBuf *pattern_ibuf;
+
+ /* real sampling requires libmv, but areas are supposing pattern would be
+ * sampled if search area does exists, so we'll need to create empty
+ * pattern area here to prevent adding NULL-checks all over just to deal
+ * with situation when lubmv is disabled
+ */
+
+ (void) frame_width;
+ (void) frame_height;
+ (void) search_ibuf;
+ (void) marker;
+ (void) track;
+ (void) use_mask;
+
+ pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
+
+ pos[0] = num_samples_x / 2.0f;
+ pos[1] = num_samples_y / 2.0f;
+
+ return pattern_ibuf;
+#endif
}
-void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingObject *object)
+ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int anchored, int disable_channels)
{
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
- MovieTrackingTrack *track = tracksbase->first;
+ ImBuf *pattern_ibuf, *search_ibuf;
+ float pat_min[2], pat_max[2];
+ int num_samples_x, num_samples_y;
- BKE_tracking_free_clipboard();
+ BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
- while (track) {
- if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) {
- MovieTrackingTrack *new_track = duplicate_track(track);
+ num_samples_x = (pat_max[0] - pat_min[0]) * ibuf->x;
+ num_samples_y = (pat_max[1] - pat_min[1]) * ibuf->y;
- BLI_addtail(&tracking_clipboard.tracks, new_track);
- }
+ search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, anchored, disable_channels);
- track = track->next;
- }
+ pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker,
+ FALSE, num_samples_x, num_samples_y, NULL);
+
+ IMB_freeImBuf(search_ibuf);
+
+ return pattern_ibuf;
}
-int BKE_tracking_clipboard_has_tracks(void)
+ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int anchored, int disable_channels)
{
- return tracking_clipboard.tracks.first != NULL;
+ ImBuf *searchibuf;
+ int x, y, w, h;
+ float search_origin[2];
+
+ get_search_origin_frame_pixel(ibuf->x, ibuf->y, marker, search_origin);
+
+ x = search_origin[0];
+ y = search_origin[1];
+
+ if (anchored) {
+ x += track->offset[0] * ibuf->x;
+ y += track->offset[1] * ibuf->y;
+ }
+
+ w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x;
+ h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
+
+ searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
+ searchibuf->profile = ibuf->profile;
+
+ IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h);
+
+ if (disable_channels) {
+ if ((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
+ (track->flag & TRACK_DISABLE_RED) ||
+ (track->flag & TRACK_DISABLE_GREEN) ||
+ (track->flag & TRACK_DISABLE_BLUE))
+ {
+ disable_imbuf_channels(searchibuf, track, TRUE);
+ }
+ }
+
+ return searchibuf;
}
-void BKE_tracking_clipboard_paste_tracks(MovieTracking *tracking, MovieTrackingObject *object)
+/* zap channels from the imbuf that are disabled by the user. this can lead to
+ * better tracks sometimes. however, instead of simply zeroing the channels
+ * out, do a partial grayscale conversion so the display is better.
+ */
+void BKE_tracking_disable_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue,
+ int grayscale)
{
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
- MovieTrackingTrack *track = tracking_clipboard.tracks.first;
+ int x, y;
+ float scale;
- while (track) {
- MovieTrackingTrack *new_track = duplicate_track(track);
+ if (!disable_red && !disable_green && !disable_blue && !grayscale)
+ return;
- BLI_addtail(tracksbase, new_track);
- BKE_track_unique_name(tracksbase, new_track);
+ /* if only some components are selected, it's important to rescale the result
+ * appropriately so that e.g. if only blue is selected, it's not zeroed out.
+ */
+ scale = (disable_red ? 0.0f : 0.2126f) +
+ (disable_green ? 0.0f : 0.7152f) +
+ (disable_blue ? 0.0f : 0.0722f);
- track = track->next;
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ int pixel = ibuf->x * y + x;
+
+ if (ibuf->rect_float) {
+ float *rrgbf = ibuf->rect_float + pixel * 4;
+ float r = disable_red ? 0.0f : rrgbf[0];
+ float g = disable_green ? 0.0f : rrgbf[1];
+ float b = disable_blue ? 0.0f : rrgbf[2];
+
+ if (grayscale) {
+ float gray = (0.2126f * r + 0.7152f * g + 0.0722f * b) / scale;
+
+ rrgbf[0] = rrgbf[1] = rrgbf[2] = gray;
+ }
+ else {
+ rrgbf[0] = r;
+ rrgbf[1] = g;
+ rrgbf[2] = b;
+ }
+ }
+ else {
+ char *rrgb = (char *)ibuf->rect + pixel * 4;
+ char r = disable_red ? 0 : rrgb[0];
+ char g = disable_green ? 0 : rrgb[1];
+ char b = disable_blue ? 0 : rrgb[2];
+
+ if (grayscale) {
+ float gray = (0.2126f * r + 0.7152f * g + 0.0722f * b) / scale;
+
+ rrgb[0] = rrgb[1] = rrgb[2] = gray;
+ }
+ else {
+ rrgb[0] = r;
+ rrgb[1] = g;
+ rrgb[2] = b;
+ }
+ }
+ }
}
+
+ if (ibuf->rect_float)
+ ibuf->userflags |= IB_RECT_INVALID;
}
-/*********************** tracks map *************************/
+/*********************** Tracks map *************************/
typedef struct TracksMap {
char object_name[MAX_NAME];
@@ -877,27 +1799,27 @@ static TracksMap *tracks_map_new(const char *object_name, int is_camera, int num
map->num_tracks = num_tracks;
map->customdata_size = customdata_size;
- map->tracks = MEM_callocN(sizeof(MovieTrackingTrack)*num_tracks, "TrackingsMap tracks");
+ map->tracks = MEM_callocN(sizeof(MovieTrackingTrack) * num_tracks, "TrackingsMap tracks");
if (customdata_size)
- map->customdata = MEM_callocN(customdata_size*num_tracks, "TracksMap customdata");
+ map->customdata = MEM_callocN(customdata_size * num_tracks, "TracksMap customdata");
map->hash = BLI_ghash_ptr_new("TracksMap hash");
return map;
}
-static int tracks_map_size(TracksMap *map)
+static int tracks_map_get_size(TracksMap *map)
{
return map->num_tracks;
}
-static void tracks_map_get(TracksMap *map, int index, MovieTrackingTrack **track, void **customdata)
+static void tracks_map_get_indexed_element(TracksMap *map, int index, MovieTrackingTrack **track, void **customdata)
{
*track = &map->tracks[index];
if (map->customdata)
- *customdata = &map->customdata[index*map->customdata_size];
+ *customdata = &map->customdata[index * map->customdata_size];
}
static void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *customdata)
@@ -909,7 +1831,7 @@ static void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *c
map->tracks[map->ptr] = new_track;
if (customdata)
- memcpy(&map->customdata[map->ptr*map->customdata_size], customdata, map->customdata_size);
+ memcpy(&map->customdata[map->ptr * map->customdata_size], customdata, map->customdata_size);
BLI_ghash_insert(map->hash, &map->tracks[map->ptr], track);
@@ -919,7 +1841,7 @@ static void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *c
static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
{
MovieTrackingTrack *track;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
MovieTrackingTrack *rot_track = tracking->stabilization.rot_track;
ListBase tracks = {NULL, NULL}, new_tracks = {NULL, NULL};
ListBase *old_tracks;
@@ -929,11 +1851,11 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
old_tracks = &tracking->tracks;
}
else {
- MovieTrackingObject *object = BKE_tracking_named_object(tracking, map->object_name);
+ MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, map->object_name);
if (!object) {
/* object was deleted by user, create new one */
- object = BKE_tracking_new_object(tracking, map->object_name);
+ object = BKE_tracking_object_add(tracking, map->object_name);
}
old_tracks = &object->tracks;
@@ -972,20 +1894,20 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
track->pat_flag = cur->pat_flag;
track->search_flag = cur->search_flag;
- BKE_tracking_free_track(cur);
+ BKE_tracking_track_free(cur);
BLI_freelinkN(old_tracks, cur);
}
}
- new_track = duplicate_track(track);
+ new_track = tracking_track_duplicate(track);
BLI_ghash_remove(map->hash, track, NULL, NULL); /* XXX: are we actually need this */
BLI_ghash_insert(map->hash, track, new_track);
- if (replace_sel) /* update current selection in clip */
+ if (replace_sel) /* update current selection in clip */
tracking->act_track = new_track;
- if (replace_rot) /* update track used for rotation stabilization */
+ if (replace_rot) /* update track used for rotation stabilization */
tracking->stabilization.rot_track = new_track;
BLI_addtail(&tracks, new_track);
@@ -1020,7 +1942,7 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
*old_tracks = new_tracks;
}
-static void tracks_map_free(TracksMap *map, void (*customdata_free) (void *customdata))
+static void tracks_map_free(TracksMap *map, void (*customdata_free)(void *customdata))
{
int i = 0;
@@ -1028,9 +1950,9 @@ static void tracks_map_free(TracksMap *map, void (*customdata_free) (void *custo
for (i = 0; i < map->num_tracks; i++) {
if (map->customdata && customdata_free)
- customdata_free(&map->customdata[i*map->customdata_size]);
+ customdata_free(&map->customdata[i * map->customdata_size]);
- BKE_tracking_free_track(&map->tracks[i]);
+ BKE_tracking_track_free(&map->tracks[i]);
}
if (map->customdata)
@@ -1040,7 +1962,7 @@ static void tracks_map_free(TracksMap *map, void (*customdata_free) (void *custo
MEM_freeN(map);
}
-/*********************** tracking *************************/
+/*********************** 2D tracking *************************/
typedef struct TrackContext {
#ifdef WITH_LIBMV
@@ -1052,6 +1974,8 @@ typedef struct TrackContext {
int search_area_height;
int search_area_width;
int framenr;
+
+ float *mask;
#else
int pad;
#endif
@@ -1071,16 +1995,33 @@ typedef struct MovieTrackingContext {
int sync_frame;
} MovieTrackingContext;
+static void track_context_free(void *customdata)
+{
+ TrackContext *track_context = (TrackContext *)customdata;
+
+#if WITH_LIBMV
+ if (track_context->search_area)
+ MEM_freeN(track_context->search_area);
+
+ if (track_context->mask)
+ MEM_freeN(track_context->mask);
+
+#else
+ (void)track_context;
+#endif
+}
+
MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *user, short backwards, short sequence)
{
MovieTrackingContext *context = MEM_callocN(sizeof(MovieTrackingContext), "trackingContext");
MovieTracking *tracking = &clip->tracking;
MovieTrackingSettings *settings = &tracking->settings;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
int num_tracks = 0;
+ context->clip = clip;
context->settings = *settings;
context->backwards = backwards;
context->sync_frame = user->framenr;
@@ -1092,7 +2033,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
while (track) {
if (TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN)) == 0) {
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if ((marker->flag & MARKER_DISABLED) == 0)
num_tracks++;
@@ -1101,6 +2042,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
track = track->next;
}
+ /* create tracking contextx for all tracks which would be tracked */
if (num_tracks) {
int width, height;
@@ -1114,7 +2056,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
while (track) {
if (TRACK_SELECTED(track) && (track->flag & (TRACK_HIDDEN | TRACK_LOCKED)) == 0) {
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if ((marker->flag & MARKER_DISABLED) == 0) {
TrackContext track_context;
@@ -1127,8 +2069,6 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
}
}
- context->clip = clip;
-
/* store needed clip flags passing to get_buffer functions
* - MCLIP_USE_PROXY is needed to because timecode affects on movie clip
* only in case Proxy/Timecode flag is set, so store this flag to use
@@ -1150,19 +2090,6 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
return context;
}
-static void track_context_free(void *customdata)
-{
- TrackContext *track_context = (TrackContext *)customdata;
-
-#if WITH_LIBMV
- if (track_context->search_area)
- MEM_freeN(track_context->search_area);
-
-#else
- (void) track_context;
-#endif
-}
-
void BKE_tracking_context_free(MovieTrackingContext *context)
{
if (!context->sequence)
@@ -1173,289 +2100,32 @@ void BKE_tracking_context_free(MovieTrackingContext *context)
MEM_freeN(context);
}
-/* zap channels from the imbuf that are disabled by the user. this can lead to
- * better tracks sometimes. however, instead of simply zeroing the channels
- * out, do a partial grayscale conversion so the display is better.
- */
-void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue,
- int grayscale)
-{
- int x, y;
- float scale;
-
- if (!disable_red && !disable_green && !disable_blue && !grayscale)
- return;
-
- /* If only some components are selected, it's important to rescale the result
- * appropriately so that e.g. if only blue is selected, it's not zeroed out.
- */
- scale = (disable_red ? 0.0f : 0.2126f) +
- (disable_green ? 0.0f : 0.7152f) +
- (disable_blue ? 0.0f : 0.0722f);
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- int pixel = ibuf->x*y + x;
-
- if (ibuf->rect_float) {
- float *rrgbf = ibuf->rect_float + pixel*4;
- float r = disable_red ? 0.0f : rrgbf[0];
- float g = disable_green ? 0.0f : rrgbf[1];
- float b = disable_blue ? 0.0f : rrgbf[2];
-
- if (grayscale) {
- float gray = (0.2126f*r + 0.7152f*g + 0.0722f*b) / scale;
-
- rrgbf[0] = rrgbf[1] = rrgbf[2] = gray;
- }
- else {
- rrgbf[0] = r;
- rrgbf[1] = g;
- rrgbf[2] = b;
- }
- }
- else {
- char *rrgb = (char*)ibuf->rect + pixel*4;
- char r = disable_red ? 0 : rrgb[0];
- char g = disable_green ? 0 : rrgb[1];
- char b = disable_blue ? 0 : rrgb[2];
-
- if (grayscale) {
- float gray = (0.2126f*r + 0.7152f*g + 0.0722f*b) / scale;
-
- rrgb[0] = rrgb[1] = rrgb[2] = gray;
- }
- else {
- rrgb[0] = r;
- rrgb[1] = g;
- rrgb[2] = b;
- }
- }
- }
- }
-
- if (ibuf->rect_float)
- ibuf->userflags |= IB_RECT_INVALID;
-}
-
-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_BLUE, grayscale);
-}
-
-ImBuf *BKE_tracking_sample_pattern_imbuf(int frame_width, int frame_height,
- ImBuf *search_ibuf, MovieTrackingMarker *marker,
- int num_samples_x, int num_samples_y, float pos[2])
+void BKE_tracking_context_sync(MovieTrackingContext *context)
{
-#ifdef WITH_LIBMV
- ImBuf *pattern_ibuf;
- double src_pixel_x[5], src_pixel_y[5];
- double warped_position_x, warped_position_y;
-
- pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
- pattern_ibuf->profile = IB_PROFILE_LINEAR_RGB;
-
- if (!search_ibuf->rect_float) {
- IMB_float_from_rect(search_ibuf);
- }
-
- get_marker_coords_for_tracking(frame_width, frame_height, marker, src_pixel_x, src_pixel_y);
-
- libmv_samplePlanarPatch(search_ibuf->rect_float, search_ibuf->x, search_ibuf->y, 4,
- src_pixel_x, src_pixel_y, num_samples_x,
- num_samples_y, pattern_ibuf->rect_float,
- &warped_position_x, &warped_position_y);
-
- if (pos) {
- pos[0] = warped_position_x;
- pos[1] = warped_position_y;
- }
-
- return pattern_ibuf;
-#else
- ImBuf *pattern_ibuf;
-
- /* real sampling requires libmv, but areas are supposing pattern would be
- * sampled if search area does exists, so we'll need to create empty
- * pattern area here to prevent adding NULL-checks all over just to deal
- * with situation when lubmv is disabled
- */
-
- (void) frame_width;
- (void) frame_height;
- (void) search_ibuf;
- (void) marker;
-
- pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
-
- pos[0] = num_samples_x / 2.0f;
- pos[1] = num_samples_y / 2.0f;
-
- return pattern_ibuf;
-#endif
-}
-
-ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- int anchored, int disable_channels)
-{
- ImBuf *pattern_ibuf, *search_ibuf;
- float pat_min[2], pat_max[2];
- int num_samples_x, num_samples_y;
-
- BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
-
- num_samples_x = (pat_max[0] - pat_min[0]) * ibuf->x;
- num_samples_y = (pat_max[1] - pat_min[1]) * ibuf->y;
-
- search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, anchored, disable_channels);
-
- pattern_ibuf = BKE_tracking_sample_pattern_imbuf(ibuf->x, ibuf->y, search_ibuf, marker,
- num_samples_x, num_samples_y, NULL);
-
- IMB_freeImBuf(search_ibuf);
-
- return pattern_ibuf;
-}
-
-ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- int anchored, int disable_channels)
-{
- ImBuf *searchibuf;
- int x, y, w, h;
- float search_origin[2];
-
- get_search_origin_frame_pixel(ibuf->x, ibuf->y, marker, search_origin);
-
- x = search_origin[0];
- y = search_origin[1];
-
- if (anchored) {
- x += track->offset[0] * ibuf->x;
- y += track->offset[1] * ibuf->y;
- }
-
- w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x;
- h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
-
- searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
- searchibuf->profile = ibuf->profile;
-
- IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h);
-
- if (disable_channels) {
- if ((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
- (track->flag & TRACK_DISABLE_RED) ||
- (track->flag & TRACK_DISABLE_GREEN) ||
- (track->flag & TRACK_DISABLE_BLUE))
- {
- disable_imbuf_channels(searchibuf, track, TRUE);
- }
- }
-
- return searchibuf;
-}
-
-static bGPDlayer *track_mask_gpencil_layer_get(MovieTrackingTrack *track)
-{
- bGPDlayer *layer;
-
- if (!track->gpd)
- return NULL;
-
- layer = track->gpd->layers.first;
-
- while (layer) {
- if (layer->flag & GP_LAYER_ACTIVE)
- return layer;
-
- layer = layer->next;
- }
-
- return NULL;
-}
-
-static void track_mask_gpencil_layer_rasterize(MovieTracking *tracking, MovieTrackingMarker *marker,
- bGPDlayer *layer, ImBuf *ibuf, int width, int height)
-{
- bGPDframe *frame = layer->frames.first;
- float *mask;
- int x, y;
- float aspy = 1.0f / tracking->camera.pixel_aspect;
-
- mask = MEM_callocN(ibuf->x * ibuf->y * sizeof(float), "track mask");
-
- while (frame) {
- bGPDstroke *stroke = frame->strokes.first;
-
- while (stroke) {
- bGPDspoint *stroke_points = stroke->points;
- float *mask_points, *fp;
- int i;
-
- if (stroke->flag & GP_STROKE_2DSPACE) {
- fp = mask_points = MEM_callocN(2 * stroke->totpoints * sizeof(float),
- "track mask rasterization points");
-
- for (i = 0; i < stroke->totpoints; i++, fp += 2) {
- fp[0] = stroke_points[i].x * width / ibuf->x - marker->search_min[0];
- fp[1] = stroke_points[i].y * height * aspy / ibuf->x - marker->search_min[1];
- }
-
- PLX_raskterize((float (*)[2])mask_points, stroke->totpoints, mask, ibuf->x, ibuf->y);
-
- MEM_freeN(mask_points);
- }
-
- stroke = stroke->next;
- }
-
- frame = frame->next;
- }
+ MovieTracking *tracking = &context->clip->tracking;
+ int newframe;
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- float *pixel = &ibuf->rect_float[4 * (y * ibuf->x + x)];
- float val = mask[y * ibuf->x + x];
+ tracks_map_merge(context->tracks_map, tracking);
- pixel[0] = val;
- pixel[1] = val;
- pixel[2] = val;
- pixel[3] = 1.0f;
- }
- }
+ if (context->backwards)
+ newframe = context->user.framenr + 1;
+ else
+ newframe = context->user.framenr - 1;
- MEM_freeN(mask);
+ context->sync_frame = newframe;
- IMB_rect_from_float(ibuf);
+ tracking->dopesheet.ok = FALSE;
}
-ImBuf *BKE_tracking_track_mask_get(MovieTracking *tracking, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- int width, int height)
+void BKE_tracking_context_sync_user(const MovieTrackingContext *context, MovieClipUser *user)
{
- ImBuf *ibuf;
- bGPDlayer *layer = track_mask_gpencil_layer_get(track);
- int mask_width, mask_height;
-
- mask_width = (marker->search_max[0] - marker->search_min[0]) * width;
- mask_height = (marker->search_max[1] - marker->search_min[1]) * height;
-
- ibuf = IMB_allocImBuf(mask_width, mask_height, 32, IB_rect | IB_rectfloat);
-
- if (layer) {
- track_mask_gpencil_layer_rasterize(tracking, marker, layer, ibuf, width, height);
- }
- else {
- float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- IMB_rectfill(ibuf, white);
- }
-
- return ibuf;
+ user->framenr = context->sync_frame;
}
#ifdef WITH_LIBMV
+/* **** utility functions for tracking **** */
-/* Convert from float and byte RGBA to grayscale. Supports different coefficients for RGB. */
+/* convert from float and byte RGBA to grayscale. Supports different coefficients for RGB. */
static void float_rgba_to_gray(const float *rgba, float *gray, int num_pixels,
float weight_red, float weight_green, float weight_blue)
{
@@ -1476,12 +2146,12 @@ static void uint8_rgba_to_float_gray(const unsigned char *rgba, float *gray, int
for (i = 0; i < num_pixels; i++) {
const unsigned char *pixel = rgba + i * 4;
- *gray++ = (weight_red * pixel[0] + weight_green * pixel[1] + weight_blue * pixel[2]) / 255.0f;
+ gray[i] = (weight_red * pixel[0] + weight_green * pixel[1] + weight_blue * pixel[2]) / 255.0f;
}
}
-static float *get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- int *width_r, int *height_r)
+static float *track_get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int *width_r, int *height_r)
{
ImBuf *searchibuf;
float *gray_pixels;
@@ -1492,55 +2162,26 @@ static float *get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieT
width = searchibuf->x;
height = searchibuf->y;
- *width_r = searchibuf->x;
- *height_r = searchibuf->y;
-
gray_pixels = MEM_callocN(width * height * sizeof(float), "tracking floatBuf");
if (searchibuf->rect_float) {
float_rgba_to_gray(searchibuf->rect_float, gray_pixels, width * height,
- 0.2126f, 0.7152f, 0.0722f);
+ 0.2126f, 0.7152f, 0.0722f);
}
else {
uint8_rgba_to_float_gray((unsigned char *)searchibuf->rect, gray_pixels, width * height,
- 0.2126f, 0.7152f, 0.0722f);
+ 0.2126f, 0.7152f, 0.0722f);
}
IMB_freeImBuf(searchibuf);
- return gray_pixels;
-}
-
-static unsigned char *get_ucharbuf(ImBuf *ibuf)
-{
- int x, y;
- unsigned char *pixels, *cp;
-
- cp = pixels = MEM_callocN(ibuf->x * ibuf->y * sizeof(unsigned char), "tracking ucharBuf");
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- int pixel = ibuf->x * y + x;
-
- if (ibuf->rect_float) {
- const float *rrgbf = ibuf->rect_float + pixel*4;
- const float grey_f = 0.2126f * rrgbf[0] + 0.7152f * rrgbf[1] + 0.0722f * rrgbf[2];
-
- *cp = FTOCHAR(grey_f);
- }
- else {
- const unsigned char *rrgb = (unsigned char*)ibuf->rect + pixel * 4;
-
- *cp = 0.2126f * rrgb[0] + 0.7152f * rrgb[1] + 0.0722f * rrgb[2];
- }
-
- cp++;
- }
- }
+ *width_r = width;
+ *height_r = height;
- return pixels;
+ return gray_pixels;
}
-static ImBuf *get_frame_ibuf(MovieTrackingContext *context, int framenr)
+static ImBuf *tracking_context_get_frame_ibuf(MovieTrackingContext *context, int framenr)
{
ImBuf *ibuf;
MovieClipUser user = context->user;
@@ -1552,13 +2193,11 @@ static ImBuf *get_frame_ibuf(MovieTrackingContext *context, int framenr)
return ibuf;
}
-static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTrack *track,
- MovieTrackingMarker *marker, MovieTrackingMarker **marker_keyed)
+MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingContext *context, MovieTrackingTrack *track,
+ MovieTrackingMarker *marker)
{
- int framenr = marker->framenr;
int a = marker - track->markers;
-
- *marker_keyed = marker;
+ MovieTrackingMarker *marker_keyed = marker;
while (a >= 0 && a < track->markersnr) {
int next = (context->backwards) ? a + 1 : a - 1;
@@ -1576,8 +2215,7 @@ static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTra
is_keyframed |= (cur_marker->flag & MARKER_TRACKED) == 0;
if (is_keyframed) {
- framenr = cur_marker->framenr;
- *marker_keyed = cur_marker;
+ marker_keyed = cur_marker;
break;
}
@@ -1585,19 +2223,34 @@ static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTra
a = next;
}
- return get_frame_ibuf(context, framenr);
+ return marker_keyed;
+}
+
+static ImBuf *tracking_context_get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTrack *track,
+ MovieTrackingMarker *marker, MovieTrackingMarker **marker_keyed_r)
+{
+ MovieTrackingMarker *marker_keyed;
+ int keyed_framenr;
+
+ marker_keyed = tracking_context_get_keyframed_marker(context, track, marker);
+ keyed_framenr = marker_keyed->framenr;
+
+ *marker_keyed_r = marker_keyed;
+
+ return tracking_context_get_frame_ibuf(context, keyed_framenr);
}
-static ImBuf *get_adjust_ibuf(MovieTrackingContext *context, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- int curfra, MovieTrackingMarker **marker_keyed)
+static ImBuf *tracking_context_get_reference_ibuf(MovieTrackingContext *context, MovieTrackingTrack *track,
+ MovieTrackingMarker *marker, int curfra,
+ MovieTrackingMarker **marker_keyed)
{
ImBuf *ibuf = NULL;
if (track->pattern_match == TRACK_MATCH_KEYFRAME) {
- ibuf = get_keyframed_ibuf(context, track, marker, marker_keyed);
+ ibuf = tracking_context_get_keyframed_ibuf(context, track, marker, marker_keyed);
}
else {
- ibuf = get_frame_ibuf(context, curfra);
+ ibuf = tracking_context_get_frame_ibuf(context, curfra);
/* use current marker as keyframed position */
*marker_keyed = marker;
@@ -1606,54 +2259,163 @@ static ImBuf *get_adjust_ibuf(MovieTrackingContext *context, MovieTrackingTrack
return ibuf;
}
-#endif
+static void track_context_update_reference(MovieTrackingContext *context, TrackContext *track_context,
+ MovieTrackingTrack *track, MovieTrackingMarker *marker, int curfra,
+ int frame_width, int frame_height)
+{
+ MovieTrackingMarker *marker_keyed = NULL;
+ ImBuf *reference_ibuf = NULL;
+ int width, height;
+
+ /* calculate patch for keyframed position */
+ reference_ibuf = tracking_context_get_reference_ibuf(context, track, marker, curfra, &marker_keyed);
+ track_context->marker = *marker_keyed;
-void BKE_tracking_sync(MovieTrackingContext *context)
+ if (track_context->search_area) {
+ MEM_freeN(track_context->search_area);
+ }
+
+ track_context->search_area = track_get_search_floatbuf(reference_ibuf, track, marker_keyed, &width, &height);
+ track_context->search_area_height = height;
+ track_context->search_area_width = width;
+
+ if ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_MASK) != 0) {
+ if (track_context->mask)
+ MEM_freeN(track_context->mask);
+
+ track_context->mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker);
+ }
+
+ IMB_freeImBuf(reference_ibuf);
+}
+
+static void tracking_configure_tracker(TrackContext *track_context, MovieTrackingTrack *track,
+ struct libmv_trackRegionOptions *options)
{
- MovieTracking *tracking = &context->clip->tracking;
- int newframe;
+ options->motion_model = track->motion_model;
- tracks_map_merge(context->tracks_map, tracking);
+ options->use_brute = ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_BRUTE) != 0);
- if (context->backwards)
- newframe = context->user.framenr + 1;
- else
- newframe = context->user.framenr - 1;
+ options->use_normalization = ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_NORMALIZATION) != 0);
- context->sync_frame = newframe;
+ options->num_iterations = 50;
+ options->minimum_correlation = track->minimum_correlation;
+ options->sigma = 0.9;
- tracking->dopesheet.ok = FALSE;
+ if ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_MASK) != 0)
+ options->image1_mask = track_context->mask;
}
-void BKE_tracking_sync_user(MovieClipUser *user, MovieTrackingContext *context)
+/* returns FALSE if marker crossed margin area from frame bounds */
+static int tracking_check_marker_margin(MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int frame_width, int frame_height)
{
- user->framenr = context->sync_frame;
+ float pat_min[2], pat_max[2], dim[2], margin[2];
+
+ /* margin from frame boundaries */
+ BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
+ sub_v2_v2v2(dim, pat_max, pat_min);
+ margin[0] = margin[1] = MAX2(dim[0], dim[1]) / 2.0f;
+
+ margin[0] = MAX2(margin[0], (float)track->margin / frame_width);
+ margin[1] = MAX2(margin[1], (float)track->margin / frame_height);
+
+ /* do not track markers which are too close to boundary */
+ if (marker->pos[0] < margin[0] || marker->pos[0] > 1.0f - margin[0] ||
+ marker->pos[1] < margin[1] || marker->pos[1] > 1.0f - margin[1])
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void tracking_scale_marker_search(const MovieTrackingMarker *old_marker, MovieTrackingMarker *new_marker)
+{
+ float old_pat_min[2], old_pat_max[2];
+ float new_pat_min[2], new_pat_max[2];
+ float scale_x, scale_y;
+
+ BKE_tracking_marker_pattern_minmax(old_marker, old_pat_min, old_pat_max);
+ BKE_tracking_marker_pattern_minmax(new_marker, new_pat_min, new_pat_max);
+
+ scale_x = (new_pat_max[0] - new_pat_min[0]) / (old_pat_max[0] - old_pat_min[0]);
+ scale_y = (new_pat_max[1] - new_pat_min[1]) / (old_pat_max[1] - old_pat_min[1]);
+
+ new_marker->search_min[0] *= scale_x;
+ new_marker->search_min[1] *= scale_y;
+
+ new_marker->search_max[0] *= scale_x;
+ new_marker->search_max[1] *= scale_y;
+}
+
+static void tracking_insert_new_marker(MovieTrackingContext *context, MovieTrackingTrack *track,
+ const MovieTrackingMarker *old_marker, int curfra, int tracked,
+ int frame_width, int frame_height,
+ double dst_pixel_x[5], double dst_pixel_y[5])
+{
+ MovieTrackingMarker new_marker;
+ int frame_delta = context->backwards ? -1 : 1;
+ int nextfra = curfra + frame_delta;
+
+ new_marker = *old_marker;
+
+ if (tracked) {
+ set_marker_coords_from_tracking(frame_width, frame_height, &new_marker, dst_pixel_x, dst_pixel_y);
+ new_marker.flag |= MARKER_TRACKED;
+ new_marker.framenr = nextfra;
+
+ tracking_scale_marker_search(old_marker, &new_marker);
+
+ if (context->first_time) {
+ /* check if there's no keyframe/tracked markers before tracking marker.
+ * if so -- create disabled marker before currently tracking "segment"
+ */
+
+ tracking_marker_insert_disabled(track, &new_marker, !context->backwards, FALSE);
+ }
+
+ /* insert currently tracked marker */
+ BKE_tracking_marker_insert(track, &new_marker);
+
+ /* make currently tracked segment be finished with disabled marker */
+ tracking_marker_insert_disabled(track, &new_marker, context->backwards, FALSE);
+ }
+ else {
+ new_marker.framenr = nextfra;
+ new_marker.flag |= MARKER_DISABLED;
+
+ BKE_tracking_marker_insert(track, &new_marker);
+ }
}
-int BKE_tracking_next(MovieTrackingContext *context)
+#endif
+
+int BKE_tracking_context_step(MovieTrackingContext *context)
{
ImBuf *destination_ibuf;
+ int frame_delta = context->backwards ? -1 : 1;
int curfra = BKE_movieclip_remap_scene_to_clip_frame(context->clip, context->user.framenr);
+ int nextfra;
int a, ok = FALSE, map_size;
int frame_width, frame_height;
- map_size = tracks_map_size(context->tracks_map);
+ map_size = tracks_map_get_size(context->tracks_map);
/* nothing to track, avoid unneeded frames reading to save time and memory */
if (!map_size)
return FALSE;
- if (context->backwards)
- context->user.framenr--;
- else
- context->user.framenr++;
+ context->user.framenr += frame_delta;
destination_ibuf = BKE_movieclip_get_ibuf_flag(context->clip, &context->user,
context->clip_flag, MOVIECLIP_CACHE_SKIP);
if (!destination_ibuf)
return FALSE;
+ nextfra = curfra + frame_delta;
+
frame_width = destination_ibuf->x;
frame_height = destination_ibuf->y;
@@ -1663,16 +2425,13 @@ int BKE_tracking_next(MovieTrackingContext *context)
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
- tracks_map_get(context->tracks_map, a, &track, (void **)&track_context);
+ tracks_map_get_indexed_element(context->tracks_map, a, &track, (void **)&track_context);
- marker = BKE_tracking_exact_marker(track, curfra);
+ marker = BKE_tracking_marker_get_exact(track, curfra);
if (marker && (marker->flag & MARKER_DISABLED) == 0) {
#ifdef WITH_LIBMV
- int width, height, tracked = 0, need_readjust = 0;
- float margin[2], dim[2], pat_min[2], pat_max[2];
- MovieTrackingMarker marker_new, *marker_keyed;
- int onbound = FALSE, nextfra;
+ int width, height, tracked = FALSE, need_readjust;
double dst_pixel_x[5], dst_pixel_y[5];
if (track->pattern_match == TRACK_MATCH_KEYFRAME)
@@ -1680,127 +2439,57 @@ int BKE_tracking_next(MovieTrackingContext *context)
else
need_readjust = TRUE;
- if (context->backwards)
- nextfra = curfra - 1;
- else
- nextfra = curfra + 1;
-
- /* margin from frame boundaries */
- BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
- sub_v2_v2v2(dim, pat_max, pat_min);
- margin[0] = margin[1] = MAX2(dim[0], dim[1]) / 2.0f;
-
- margin[0] = MAX2(margin[0], (float)track->margin / destination_ibuf->x);
- margin[1] = MAX2(margin[1], (float)track->margin / destination_ibuf->y);
-
/* do not track markers which are too close to boundary */
- if (marker->pos[0] < margin[0] || marker->pos[0] > 1.0f - margin[0] ||
- marker->pos[1] < margin[1] || marker->pos[1] > 1.0f - margin[1])
- {
- onbound = TRUE;
- }
- else {
+ if (tracking_check_marker_margin(track, marker, frame_width, frame_height)) {
/* to convert to the x/y split array format for libmv. */
- double src_pixel_x[5];
- double src_pixel_y[5];
+ double src_pixel_x[5], src_pixel_y[5];
/* settings for the tracker */
- struct libmv_trackRegionOptions options;
+ struct libmv_trackRegionOptions options = {0};
struct libmv_trackRegionResult result;
float *patch_new;
if (need_readjust) {
- ImBuf *reference_ibuf = NULL;
- /* calculate patch for keyframed position */
- reference_ibuf = get_adjust_ibuf(context, track, marker, curfra, &marker_keyed);
- track_context->marker = *marker_keyed;
-
- if (track_context->search_area)
- MEM_freeN(track_context->search_area);
-
- track_context->search_area = get_search_floatbuf(reference_ibuf, track,
- marker_keyed, &width, &height);
- track_context->search_area_height = height;
- track_context->search_area_width = width;
-
- IMB_freeImBuf(reference_ibuf);
+ track_context_update_reference(context, track_context, track, marker,
+ curfra, frame_width, frame_height);
}
/* for now track to the same search area dimension as marker has got for current frame
* will make all tracked markers in currently tracked segment have the same search area
* size, but it's quite close to what is actually needed
*/
- patch_new = get_search_floatbuf(destination_ibuf, track, marker, &width, &height);
-
- /* Configure the tracker */
- options.motion_model = track->motion_model;
-
- options.use_brute =
- ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_BRUTE) != 0);
-
- options.use_normalization =
- ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_NORMALIZATION) != 0);
+ patch_new = track_get_search_floatbuf(destination_ibuf, track, marker, &width, &height);
- options.num_iterations = 50;
- options.minimum_correlation = track->minimum_correlation;
- options.sigma = 0.9;
+ /* configure the tracker */
+ tracking_configure_tracker(track_context, track, &options);
- /* Convert the marker corners and center into pixel coordinates in the search/destination images. */
+ /* convert the marker corners and center into pixel coordinates in the search/destination images. */
get_marker_coords_for_tracking(frame_width, frame_height, &track_context->marker, src_pixel_x, src_pixel_y);
get_marker_coords_for_tracking(frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
- /* Run the tracker! */
+ /* run the tracker! */
tracked = libmv_trackRegion(&options,
- track_context->search_area, patch_new,
- width, height,
+ track_context->search_area,
+ track_context->search_area_width,
+ track_context->search_area_height,
+ patch_new, width, height,
src_pixel_x, src_pixel_y,
&result,
dst_pixel_x, dst_pixel_y);
MEM_freeN(patch_new);
}
- if (tracked && !onbound) {
- memset(&marker_new, 0, sizeof(marker_new));
- marker_new = *marker;
- set_marker_coords_from_tracking(frame_width, frame_height, &marker_new, dst_pixel_x, dst_pixel_y);
- marker_new.flag |= MARKER_TRACKED;
- marker_new.framenr = nextfra;
-
- if (context->first_time) {
- #pragma omp critical
- {
- /* check if there's no keyframe/tracked markers before tracking marker.
- * if so -- create disabled marker before currently tracking "segment"
- */
- put_disabled_marker(track, &marker_new, !context->backwards, 0);
- }
- }
-
- #pragma omp critical
- {
- BKE_tracking_insert_marker(track, &marker_new);
- }
-
- /* make currently tracked segment be finished with disabled marker */
- #pragma omp critical
- {
- put_disabled_marker(track, &marker_new, context->backwards, 0);
- }
- }
- else {
- marker_new = *marker;
-
- marker_new.framenr = nextfra;
- marker_new.flag |= MARKER_DISABLED;
-
- //#pragma omp critical
- {
- BKE_tracking_insert_marker(track, &marker_new);
- }
+ #pragma omp critical
+ {
+ tracking_insert_new_marker(context, track, marker, curfra, tracked,
+ frame_width, frame_height, dst_pixel_x, dst_pixel_y);
}
ok = TRUE;
+#else
+ (void)frame_height;
+ (void)frame_width;
#endif
}
}
@@ -1813,7 +2502,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
return ok;
}
-/*********************** camera solving *************************/
+/*********************** Camera solving *************************/
typedef struct MovieReconstructContext {
#ifdef WITH_LIBMV
@@ -1846,8 +2535,8 @@ typedef struct ReconstructProgressData {
int message_size;
} ReconstructProgressData;
-#if WITH_LIBMV
-static struct libmv_Tracks *create_libmv_tracks(ListBase *tracksbase, int width, int height)
+#ifdef WITH_LIBMV
+static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, int height)
{
int tracknr = 0;
MovieTrackingTrack *track;
@@ -1862,7 +2551,7 @@ static struct libmv_Tracks *create_libmv_tracks(ListBase *tracksbase, int width,
if ((marker->flag & MARKER_DISABLED) == 0) {
libmv_tracksInsert(tracks, marker->framenr, tracknr,
- marker->pos[0] * width, marker->pos[1] * height);
+ marker->pos[0] * width, marker->pos[1] * height);
}
}
@@ -1873,7 +2562,7 @@ static struct libmv_Tracks *create_libmv_tracks(ListBase *tracksbase, int width,
return tracks;
}
-static void retrieve_libmv_reconstruct_intrinscis(MovieReconstructContext *context, MovieTracking *tracking)
+static void reconstruct_retrieve_libmv_intrinscis(MovieReconstructContext *context, MovieTracking *tracking)
{
struct libmv_Reconstruction *libmv_reconstruction = context->reconstruction;
struct libmv_CameraIntrinsics *libmv_intrinsics = libmv_ReconstructionExtractIntrinsics(libmv_reconstruction);
@@ -1894,7 +2583,7 @@ static void retrieve_libmv_reconstruct_intrinscis(MovieReconstructContext *conte
tracking->camera.k2 = k2;
}
-static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, MovieTracking *tracking)
+static int reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, MovieTracking *tracking)
{
struct libmv_Reconstruction *libmv_reconstruction = context->reconstruction;
MovieTrackingReconstruction *reconstruction = NULL;
@@ -1910,7 +2599,7 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
reconstruction = &tracking->reconstruction;
}
else {
- MovieTrackingObject *object = BKE_tracking_named_object(tracking, context->object_name);
+ MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, context->object_name);
tracksbase = &object->tracks;
reconstruction = &object->reconstruction;
@@ -2002,15 +2691,15 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
return ok;
}
-static int retrieve_libmv_reconstruct(MovieReconstructContext *context, MovieTracking *tracking)
+static int reconstruct_retrieve_libmv(MovieReconstructContext *context, MovieTracking *tracking)
{
/* take the intrinscis back from libmv */
- retrieve_libmv_reconstruct_intrinscis(context, tracking);
+ reconstruct_retrieve_libmv_intrinscis(context, tracking);
- return retrieve_libmv_reconstruct_tracks(context, tracking);
+ return reconstruct_retrieve_libmv_tracks(context, tracking);
}
-static int get_refine_intrinsics_flags(MovieTracking *tracking, MovieTrackingObject *object)
+static int reconstruct_refine_intrinsics_get_flags(MovieTracking *tracking, MovieTrackingObject *object)
{
int refine = tracking->settings.refine_camera_intrinsics;
int flags = 0;
@@ -2033,7 +2722,7 @@ static int get_refine_intrinsics_flags(MovieTracking *tracking, MovieTrackingObj
return flags;
}
-static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tracksbase)
+static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tracksbase)
{
int tot = 0;
int frame1 = tracking->settings.keyframe1, frame2 = tracking->settings.keyframe2;
@@ -2041,9 +2730,11 @@ static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tra
track = tracksbase->first;
while (track) {
- if (BKE_tracking_has_enabled_marker(track, frame1))
- if (BKE_tracking_has_enabled_marker(track, frame2))
+ if (BKE_tracking_track_has_enabled_marker_at_frame(track, frame1)) {
+ if (BKE_tracking_track_has_enabled_marker_at_frame(track, frame2)) {
tot++;
+ }
+ }
track = track->next;
}
@@ -2052,16 +2743,16 @@ static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tra
}
#endif
-int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *object, char *error_msg, int error_size)
+int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObject *object, char *error_msg, int error_size)
{
#if WITH_LIBMV
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
if (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) {
/* TODO: check for number of tracks? */
return TRUE;
}
- else if (count_tracks_on_both_keyframes(tracking, tracksbase) < 8) {
+ else if (reconstruct_count_tracks_on_both_keyframes(tracking, tracksbase) < 8) {
BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction",
error_size);
@@ -2079,12 +2770,12 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o
#endif
}
-MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *tracking, MovieTrackingObject *object,
+MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *tracking, MovieTrackingObject *object,
int keyframe1, int keyframe2, int width, int height)
{
MovieReconstructContext *context = MEM_callocN(sizeof(MovieReconstructContext), "MovieReconstructContext data");
MovieTrackingCamera *camera = &tracking->camera;
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
float aspy = 1.0f / tracking->camera.pixel_aspect;
int num_tracks = BLI_countlist(tracksbase);
int sfra = INT_MAX, efra = INT_MIN;
@@ -2094,6 +2785,14 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
context->is_camera = object->flag & TRACKING_OBJECT_CAMERA;
context->motion_flag = tracking->settings.motion_flag;
+ context->focal_length = camera->focal;
+ context->principal_point[0] = camera->principal[0];
+ context->principal_point[1] = camera->principal[1] * aspy;
+
+ context->k1 = camera->k1;
+ context->k2 = camera->k2;
+ context->k3 = camera->k3;
+
context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
track = tracksbase->first;
@@ -2129,10 +2828,10 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
context->efra = efra;
#ifdef WITH_LIBMV
- context->tracks = create_libmv_tracks(tracksbase, width, height*aspy);
+ context->tracks = libmv_tracks_new(tracksbase, width, height * aspy);
context->keyframe1 = keyframe1;
context->keyframe2 = keyframe2;
- context->refine_flags = get_refine_intrinsics_flags(tracking, object);
+ context->refine_flags = reconstruct_refine_intrinsics_get_flags(tracking, object);
#else
(void) width;
(void) height;
@@ -2140,14 +2839,6 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
(void) keyframe2;
#endif
- context->focal_length = camera->focal;
- context->principal_point[0] = camera->principal[0];
- context->principal_point[1] = camera->principal[1] * aspy;
-
- context->k1 = camera->k1;
- context->k2 = camera->k2;
- context->k3 = camera->k3;
-
return context;
}
@@ -2155,7 +2846,7 @@ void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context)
{
#ifdef WITH_LIBMV
if (context->reconstruction)
- libmv_destroyReconstruction(context->reconstruction);
+ libmv_destroyReconstruction(context->reconstruction);
libmv_tracksDestroy(context->tracks);
#endif
@@ -2166,7 +2857,7 @@ void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context)
}
#ifdef WITH_LIBMV
-static void solve_reconstruction_update_cb(void *customdata, double progress, const char *message)
+static void reconstruct_update_solve_cb(void *customdata, double progress, const char *message)
{
ReconstructProgressData *progressdata = customdata;
@@ -2179,19 +2870,7 @@ static void solve_reconstruction_update_cb(void *customdata, double progress, co
}
#endif
-#if 0
-static int solve_reconstruction_testbreak_cb(void *customdata)
-{
- ReconstructProgressData *progressdata = customdata;
-
- if (progressdata->stop && *progressdata->stop)
- return TRUE;
-
- return G.afbreek;
-}
-#endif
-
-void BKE_tracking_solve_reconstruction(MovieReconstructContext *context, short *stop, short *do_update,
+void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, short *stop, short *do_update,
float *progress, char *stats_message, int message_size)
{
#ifdef WITH_LIBMV
@@ -2207,19 +2886,19 @@ void BKE_tracking_solve_reconstruction(MovieReconstructContext *context, short *
if (context->motion_flag & TRACKING_MOTION_MODAL) {
context->reconstruction = libmv_solveModal(context->tracks,
- context->focal_length,
- context->principal_point[0], context->principal_point[1],
- context->k1, context->k2, context->k3,
- solve_reconstruction_update_cb, &progressdata);
+ context->focal_length,
+ context->principal_point[0], context->principal_point[1],
+ context->k1, context->k2, context->k3,
+ reconstruct_update_solve_cb, &progressdata);
}
else {
context->reconstruction = libmv_solveReconstruction(context->tracks,
- context->keyframe1, context->keyframe2,
- context->refine_flags,
- context->focal_length,
- context->principal_point[0], context->principal_point[1],
- context->k1, context->k2, context->k3,
- solve_reconstruction_update_cb, &progressdata);
+ context->keyframe1, context->keyframe2,
+ context->refine_flags,
+ context->focal_length,
+ context->principal_point[0], context->principal_point[1],
+ context->k1, context->k2, context->k3,
+ reconstruct_update_solve_cb, &progressdata);
}
error = libmv_reprojectionError(context->reconstruction);
@@ -2235,7 +2914,7 @@ void BKE_tracking_solve_reconstruction(MovieReconstructContext *context, short *
#endif
}
-int BKE_tracking_finish_reconstruction(MovieReconstructContext *context, MovieTracking *tracking)
+int BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieTracking *tracking)
{
MovieTrackingReconstruction *reconstruction;
@@ -2247,7 +2926,7 @@ int BKE_tracking_finish_reconstruction(MovieReconstructContext *context, MovieTr
else {
MovieTrackingObject *object;
- object = BKE_tracking_named_object(tracking, context->object_name);
+ object = BKE_tracking_object_get_named(tracking, context->object_name);
reconstruction = &object->reconstruction;
}
@@ -2255,350 +2934,17 @@ int BKE_tracking_finish_reconstruction(MovieReconstructContext *context, MovieTr
reconstruction->flag |= TRACKING_RECONSTRUCTED;
#ifdef WITH_LIBMV
- if (!retrieve_libmv_reconstruct(context, tracking))
+ if (!reconstruct_retrieve_libmv(context, tracking))
return FALSE;
#endif
return TRUE;
}
-void BKE_track_unique_name(ListBase *tracksbase, MovieTrackingTrack *track)
-{
- BLI_uniquename(tracksbase, track, "Track", '.', offsetof(MovieTrackingTrack, name), sizeof(track->name));
-}
-
-MovieTrackingTrack *BKE_tracking_named_track(MovieTracking *tracking, MovieTrackingObject *object, const char *name)
-{
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
- MovieTrackingTrack *track = tracksbase->first;
-
- while (track) {
- if (!strcmp(track->name, name))
- return track;
-
- track = track->next;
- }
-
- return NULL;
-}
-
-static int reconstruction_camera_index(MovieTrackingReconstruction *reconstruction, int framenr, int nearest)
-{
- MovieReconstructedCamera *cameras = reconstruction->cameras;
- int a = 0, d = 1;
-
- if (!reconstruction->camnr)
- return -1;
-
- if (framenr < cameras[0].framenr) {
- if (nearest)
- return 0;
- else
- return -1;
- }
-
- if (framenr > cameras[reconstruction->camnr - 1].framenr) {
- if (nearest)
- return reconstruction->camnr - 1;
- else
- return -1;
- }
-
- if (reconstruction->last_camera < reconstruction->camnr)
- a = reconstruction->last_camera;
-
- if (cameras[a].framenr >= framenr)
- d = -1;
-
- while (a >= 0 && a < reconstruction->camnr) {
- int cfra = cameras[a].framenr;
-
- /* check if needed framenr was "skipped" -- no data for requested frame */
-
- if (d > 0 && cfra > framenr) {
- /* interpolate with previous position */
- if (nearest)
- return a - 1;
- else
- break;
- }
-
- if (d < 0 && cfra < framenr) {
- /* interpolate with next position */
- if (nearest)
- return a;
- else
- break;
- }
-
- if (cfra == framenr) {
- reconstruction->last_camera = a;
-
- return a;
- }
-
- a += d;
- }
-
- return -1;
-}
-
-static void scale_reconstructed_camera(MovieTrackingObject *object, float mat[4][4])
-{
- if ((object->flag & TRACKING_OBJECT_CAMERA) == 0) {
- float smat[4][4];
-
- scale_m4_fl(smat, 1.0f / object->scale);
- mult_m4_m4m4(mat, mat, smat);
- }
-}
-
-MovieReconstructedCamera *BKE_tracking_get_reconstructed_camera(MovieTracking *tracking,
- MovieTrackingObject *object, int framenr)
-{
- MovieTrackingReconstruction *reconstruction;
- int a;
-
- reconstruction = BKE_tracking_object_reconstruction(tracking, object);
- a = reconstruction_camera_index(reconstruction, framenr, FALSE);
-
- if (a ==-1)
- return NULL;
-
- return &reconstruction->cameras[a];
-}
-
-void BKE_tracking_get_interpolated_camera(MovieTracking *tracking, MovieTrackingObject *object,
- int framenr, float mat[4][4])
-{
- MovieTrackingReconstruction *reconstruction;
- MovieReconstructedCamera *cameras;
- int a;
-
- reconstruction = BKE_tracking_object_reconstruction(tracking, object);
- cameras = reconstruction->cameras;
- a = reconstruction_camera_index(reconstruction, framenr, 1);
-
- if (a == -1) {
- unit_m4(mat);
-
- return;
- }
-
- if (cameras[a].framenr != framenr && a > 0 && a < reconstruction->camnr - 1) {
- float t = ((float)framenr - cameras[a].framenr) / (cameras[a + 1].framenr - cameras[a].framenr);
-
- blend_m4_m4m4(mat, cameras[a].mat, cameras[a + 1].mat, t);
- }
- else {
- copy_m4_m4(mat, cameras[a].mat);
- }
-
- scale_reconstructed_camera(object, mat);
-}
-
-void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4])
-{
- if (!ob) {
- if (scene->camera)
- ob = scene->camera;
- else
- ob = BKE_scene_camera_find(scene);
- }
-
- if (ob)
- BKE_object_where_is_calc_mat4(scene, ob, mat);
- else
- unit_m4(mat);
-}
-
-void BKE_tracking_camera_shift(MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty)
-{
- /* indeed in both of cases it should be winx -- it's just how camera shift works for blender's camera */
- *shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx;
- *shifty = (0.5f * winy - tracking->camera.principal[1]) / winx;
-}
-
-void BKE_tracking_camera_to_blender(MovieTracking *tracking, Scene *scene, Camera *camera, int width, int height)
-{
- float focal = tracking->camera.focal;
-
- camera->sensor_x = tracking->camera.sensor_width;
- camera->sensor_fit = CAMERA_SENSOR_FIT_AUTO;
- camera->lens = focal * camera->sensor_x / width;
-
- scene->r.xsch = width * tracking->camera.pixel_aspect;
- scene->r.ysch = height;
-
- scene->r.xasp = 1.0f;
- scene->r.yasp = 1.0f;
-
- BKE_tracking_camera_shift(tracking, width, height, &camera->shiftx, &camera->shifty);
-}
-
-void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject *object,
- int framenr, int winx, int winy, float mat[4][4])
-{
- MovieReconstructedCamera *camera;
- float lens = tracking->camera.focal * tracking->camera.sensor_width / (float)winx;
- float viewfac, pixsize, left, right, bottom, top, clipsta, clipend;
- float winmat[4][4];
- float ycor = 1.0f / tracking->camera.pixel_aspect;
- float shiftx, shifty, winside = MAX2(winx, winy);
-
- BKE_tracking_camera_shift(tracking, winx, winy, &shiftx, &shifty);
-
- clipsta = 0.1f;
- clipend = 1000.0f;
-
- if (winx >= winy)
- viewfac = (lens * winx) / tracking->camera.sensor_width;
- else
- viewfac = (ycor * lens * winy) / tracking->camera.sensor_width;
-
- pixsize = clipsta / viewfac;
-
- left = -0.5f * (float)winx + shiftx * winside;
- bottom = -0.5f * (ycor) * (float)winy + shifty * winside;
- right = 0.5f * (float)winx + shiftx * winside;
- top = 0.5f * (ycor) * (float)winy + shifty * winside;
-
- left *= pixsize;
- right *= pixsize;
- bottom *= pixsize;
- top *= pixsize;
-
- perspective_m4(winmat, left, right, bottom, top, clipsta, clipend);
-
- camera = BKE_tracking_get_reconstructed_camera(tracking, object, framenr);
-
- if (camera) {
- float imat[4][4];
-
- invert_m4_m4(imat, camera->mat);
- mult_m4_m4m4(mat, winmat, imat);
- }
- else copy_m4_m4(mat, winmat);
-}
-
-ListBase *BKE_tracking_get_tracks(MovieTracking *tracking)
-{
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
-
- if (object && (object->flag & TRACKING_OBJECT_CAMERA) == 0) {
- return &object->tracks;
- }
-
- return &tracking->tracks;
-}
-
-MovieTrackingTrack *BKE_tracking_active_track(MovieTracking *tracking)
-{
- ListBase *tracksbase;
-
- if (!tracking->act_track)
- return NULL;
-
- tracksbase = BKE_tracking_get_tracks(tracking);
-
- /* check that active track is in current tracks list */
- if (BLI_findindex(tracksbase, tracking->act_track) >= 0)
- return tracking->act_track;
-
- return NULL;
-}
-
-MovieTrackingObject *BKE_tracking_active_object(MovieTracking *tracking)
-{
- return BLI_findlink(&tracking->objects, tracking->objectnr);
-}
-
-MovieTrackingObject *BKE_tracking_get_camera_object(MovieTracking *tracking)
-{
- MovieTrackingObject *object = tracking->objects.first;
-
- while (object) {
- if (object->flag & TRACKING_OBJECT_CAMERA)
- return object;
-
- object = object->next;
- }
-
- return NULL;
-}
-
-ListBase *BKE_tracking_object_tracks(MovieTracking *tracking, MovieTrackingObject *object)
-{
- if (object->flag & TRACKING_OBJECT_CAMERA) {
- return &tracking->tracks;
- }
-
- return &object->tracks;
-}
-
-MovieTrackingReconstruction *BKE_tracking_object_reconstruction(MovieTracking *tracking, MovieTrackingObject *object)
-{
- if (object->flag & TRACKING_OBJECT_CAMERA) {
- return &tracking->reconstruction;
- }
-
- return &object->reconstruction;
-}
-
-MovieTrackingReconstruction *BKE_tracking_get_reconstruction(MovieTracking *tracking)
-{
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
-
- return BKE_tracking_object_reconstruction(tracking, object);
-}
-
-void BKE_tracking_apply_intrinsics(MovieTracking *tracking, float co[2], float nco[2])
-{
- MovieTrackingCamera *camera = &tracking->camera;
+/*********************** Feature detection *************************/
#ifdef WITH_LIBMV
- double x, y;
- float aspy = 1.0f / tracking->camera.pixel_aspect;
-
- /* normalize coords */
- x = (co[0] - camera->principal[0]) / camera->focal;
- y = (co[1] - camera->principal[1] * aspy) / camera->focal;
-
- libmv_applyCameraIntrinsics(camera->focal, camera->principal[0], camera->principal[1] * aspy,
- camera->k1, camera->k2, camera->k3, x, y, &x, &y);
-
- /* result is in image coords already */
- nco[0] = x;
- nco[1] = y;
-#else
- (void) camera;
- (void) co;
- (void) nco;
-#endif
-}
-
-void BKE_tracking_invert_intrinsics(MovieTracking *tracking, float co[2], float nco[2])
-{
- MovieTrackingCamera *camera = &tracking->camera;
-
-#ifdef WITH_LIBMV
- double x = co[0], y = co[1];
- float aspy = 1.0f / tracking->camera.pixel_aspect;
-
- libmv_InvertIntrinsics(camera->focal, camera->principal[0], camera->principal[1] * aspy,
- camera->k1, camera->k2, camera->k3, x, y, &x, &y);
-
- nco[0] = x * camera->focal + camera->principal[0];
- nco[1] = y * camera->focal + camera->principal[1] * aspy;
-#else
- (void) camera;
- (void) co;
- (void) nco;
-#endif
-}
-
-#ifdef WITH_LIBMV
-static int point_in_stroke(bGPDstroke *stroke, float x, float y)
+static int check_point_in_stroke(bGPDstroke *stroke, float x, float y)
{
int i, prev;
int count = 0;
@@ -2620,7 +2966,7 @@ static int point_in_stroke(bGPDstroke *stroke, float x, float y)
return count % 2;
}
-static int point_in_layer(bGPDlayer *layer, float x, float y)
+static int check_point_in_layer(bGPDlayer *layer, float x, float y)
{
bGPDframe *frame = layer->frames.first;
@@ -2628,7 +2974,7 @@ static int point_in_layer(bGPDlayer *layer, float x, float y)
bGPDstroke *stroke = frame->strokes.first;
while (stroke) {
- if (point_in_stroke(stroke, x, y))
+ if (check_point_in_stroke(stroke, x, y))
return TRUE;
stroke = stroke->next;
@@ -2639,9 +2985,9 @@ static int point_in_layer(bGPDlayer *layer, float x, float y)
return FALSE;
}
-static void retrieve_libmv_features(MovieTracking *tracking, ListBase *tracksbase,
- struct libmv_Features *features, int framenr, int width, int height,
- bGPDlayer *layer, int place_outside_layer)
+static void detect_retrieve_libmv_features(MovieTracking *tracking, ListBase *tracksbase,
+ struct libmv_Features *features, int framenr, int width, int height,
+ bGPDlayer *layer, int place_outside_layer)
{
int a;
@@ -2658,16 +3004,45 @@ static void retrieve_libmv_features(MovieTracking *tracking, ListBase *tracksbas
yu = y / height;
if (layer)
- ok = point_in_layer(layer, xu, yu) != place_outside_layer;
+ ok = check_point_in_layer(layer, xu, yu) != place_outside_layer;
if (ok) {
- track = BKE_tracking_add_track(tracking, tracksbase, xu, yu, framenr, width, height);
+ track = BKE_tracking_track_add(tracking, tracksbase, xu, yu, framenr, width, height);
track->flag |= SELECT;
track->pat_flag |= SELECT;
track->search_flag |= SELECT;
}
}
}
+
+static unsigned char *detect_get_frame_ucharbuf(ImBuf *ibuf)
+{
+ int x, y;
+ unsigned char *pixels, *cp;
+
+ cp = pixels = MEM_callocN(ibuf->x * ibuf->y * sizeof(unsigned char), "tracking ucharBuf");
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ int pixel = ibuf->x * y + x;
+
+ if (ibuf->rect_float) {
+ const float *rrgbf = ibuf->rect_float + pixel * 4;
+ const float grey_f = 0.2126f * rrgbf[0] + 0.7152f * rrgbf[1] + 0.0722f * rrgbf[2];
+
+ *cp = FTOCHAR(grey_f);
+ }
+ else {
+ const unsigned char *rrgb = (unsigned char *)ibuf->rect + pixel * 4;
+
+ *cp = 0.2126f * rrgb[0] + 0.7152f * rrgb[1] + 0.0722f * rrgb[2];
+ }
+
+ cp++;
+ }
+ }
+
+ return pixels;
+}
#endif
void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImBuf *ibuf,
@@ -2676,14 +3051,14 @@ void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImB
{
#ifdef WITH_LIBMV
struct libmv_Features *features;
- unsigned char *pixels = get_ucharbuf(ibuf);
+ unsigned char *pixels = detect_get_frame_ucharbuf(ibuf);
features = libmv_detectFeaturesFAST(pixels, ibuf->x, ibuf->y, ibuf->x,
margin, min_trackness, min_distance);
MEM_freeN(pixels);
- retrieve_libmv_features(tracking, tracksbase, features, framenr,
+ detect_retrieve_libmv_features(tracking, tracksbase, features, framenr,
ibuf->x, ibuf->y, layer, place_outside_layer);
libmv_destroyFeatures(features);
@@ -2700,38 +3075,9 @@ void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImB
#endif
}
-MovieTrackingTrack *BKE_tracking_indexed_track(MovieTracking *tracking, int tracknr, ListBase **tracksbase_r)
-{
- MovieTrackingObject *object;
- int cur = 1;
-
- object = tracking->objects.first;
- while (object) {
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
- MovieTrackingTrack *track = tracksbase->first;
-
- while (track) {
- if (track->flag & TRACK_HAS_BUNDLE) {
- if (cur == tracknr) {
- *tracksbase_r = tracksbase;
- return track;
- }
-
- cur++;
- }
-
- track = track->next;
- }
-
- object = object->next;
- }
-
- *tracksbase_r = NULL;
-
- return NULL;
-}
+/*********************** 2D stabilization *************************/
-static int stabilization_median_point(MovieTracking *tracking, int framenr, float median[2])
+static int stabilization_median_point_get(MovieTracking *tracking, int framenr, float median[2])
{
int ok = FALSE;
float min[2], max[2];
@@ -2742,7 +3088,7 @@ static int stabilization_median_point(MovieTracking *tracking, int framenr, floa
track = tracking->tracks.first;
while (track) {
if (track->flag & TRACK_USE_2D_STAB) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
DO_MINMAX2(marker->pos, min, max);
@@ -2758,16 +3104,17 @@ static int stabilization_median_point(MovieTracking *tracking, int framenr, floa
return ok;
}
-static void calculate_stabdata(MovieTracking *tracking, int framenr, float width, float height,
- float firstmedian[2], float median[2], float loc[2], float *scale, float *angle)
+static void stabilization_calculate_data(MovieTracking *tracking, int framenr, float width, float height,
+ float firstmedian[2], float median[2], float loc[2],
+ float *scale, float *angle)
{
MovieTrackingStabilization *stab = &tracking->stabilization;
*scale = (stab->scale - 1.0f) * stab->scaleinf + 1.0f;
*angle = 0.0f;
- loc[0] = (firstmedian[0] - median[0]) *width * (*scale);
- loc[1] = (firstmedian[1] - median[1]) *height * (*scale);
+ loc[0] = (firstmedian[0] - median[0]) * width * (*scale);
+ loc[1] = (firstmedian[1] - median[1]) * height * (*scale);
mul_v2_fl(loc, stab->locinf);
@@ -2777,12 +3124,12 @@ static void calculate_stabdata(MovieTracking *tracking, int framenr, float width
float x0 = (float)width / 2.0f, y0 = (float)height / 2.0f;
float x = median[0] * width, y = median[1] * height;
- marker = BKE_tracking_get_marker(stab->rot_track, 1);
+ marker = BKE_tracking_marker_get(stab->rot_track, 1);
sub_v2_v2v2(a, marker->pos, firstmedian);
a[0] *= width;
a[1] *= height;
- marker = BKE_tracking_get_marker(stab->rot_track, framenr);
+ marker = BKE_tracking_marker_get(stab->rot_track, framenr);
sub_v2_v2v2(b, marker->pos, median);
b[0] *= width;
b[1] *= height;
@@ -2796,7 +3143,7 @@ static void calculate_stabdata(MovieTracking *tracking, int framenr, float width
}
}
-static float stabilization_auto_scale_factor(MovieTracking *tracking, int width, int height)
+static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, int width, int height)
{
float firstmedian[2];
MovieTrackingStabilization *stab = &tracking->stabilization;
@@ -2805,7 +3152,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
if (stab->ok)
return stab->scale;
- if (stabilization_median_point(tracking, 1, firstmedian)) {
+ if (stabilization_median_point_get(tracking, 1, firstmedian)) {
int sfra = INT_MAX, efra = INT_MIN, cfra;
float scale = 1.0f;
MovieTrackingTrack *track;
@@ -2815,7 +3162,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
track = tracking->tracks.first;
while (track) {
if (track->flag & TRACK_USE_2D_STAB ||
- ((stab->flag & TRACKING_STABILIZE_ROTATION) && track == stab->rot_track))
+ ((stab->flag & TRACKING_STABILIZE_ROTATION) && track == stab->rot_track))
{
sfra = MIN2(sfra, track->markers[0].framenr);
efra = MAX2(efra, track->markers[track->markersnr - 1].framenr);
@@ -2832,11 +3179,11 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
float points[4][2] = {{0.0f, 0.0f}, {0.0f, height}, {width, height}, {width, 0.0f}};
float si, co;
- stabilization_median_point(tracking, cfra, median);
+ stabilization_median_point_get(tracking, cfra, median);
- calculate_stabdata(tracking, cfra, width, height, firstmedian, median, loc, &tmp_scale, &angle);
+ stabilization_calculate_data(tracking, cfra, width, height, firstmedian, median, loc, &tmp_scale, &angle);
- BKE_tracking_stabdata_to_mat4(width, height, aspect, loc, 1.0f, angle, mat);
+ BKE_tracking_stabilization_data_to_mat4(width, height, aspect, loc, 1.0f, angle, mat);
si = sin(angle);
co = cos(angle);
@@ -2876,23 +3223,23 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
h = (float)height / 2.0f;
}
- E = -w*co + h*si;
- F = -h*co - w*si;
+ E = -w * co + h * si;
+ F = -h * co - w * si;
if ((i % 2) == (j % 2)) {
- G = -w*co - h*si;
- H = h*co - w*si;
+ G = -w * co - h * si;
+ H = h * co - w * si;
}
else {
- G = w*co + h*si;
- H = -h*co + w*si;
+ G = w * co + h * si;
+ H = -h * co + w * si;
}
I = F - H;
J = G - E;
- K = G*F - E*H;
+ K = G * F - E * H;
- S = (-w*I - h*J) / (dx*I + dy*J + K);
+ S = (-w * I - h * J) / (dx * I + dy * J + K);
scale = MAX2(scale, S);
}
@@ -2914,7 +3261,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
return stab->scale;
}
-static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill)
+static ImBuf *stabilization_allocate_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill)
{
int flags;
@@ -2943,8 +3290,9 @@ static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill)
return cacheibuf;
}
-void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int width, int height,
- float loc[2], float *scale, float *angle)
+/* NOTE: frame number should be in clip space, not scene space */
+void BKE_tracking_stabilization_data_get(MovieTracking *tracking, int framenr, int width, int height,
+ float loc[2], float *scale, float *angle)
{
float firstmedian[2], median[2];
MovieTrackingStabilization *stab = &tracking->stabilization;
@@ -2957,22 +3305,22 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w
return;
}
- if (stabilization_median_point(tracking, 1, firstmedian)) {
- stabilization_median_point(tracking, framenr, median);
+ if (stabilization_median_point_get(tracking, 1, firstmedian)) {
+ stabilization_median_point_get(tracking, framenr, median);
if ((stab->flag & TRACKING_AUTOSCALE) == 0)
stab->scale = 1.0f;
if (!stab->ok) {
if (stab->flag & TRACKING_AUTOSCALE)
- stabilization_auto_scale_factor(tracking, width, height);
+ stabilization_calculate_autoscale_factor(tracking, width, height);
- calculate_stabdata(tracking, framenr, width, height, firstmedian, median, loc, scale, angle);
+ stabilization_calculate_data(tracking, framenr, width, height, firstmedian, median, loc, scale, angle);
stab->ok = TRUE;
}
else {
- calculate_stabdata(tracking, framenr, width, height, firstmedian, median, loc, scale, angle);
+ stabilization_calculate_data(tracking, framenr, width, height, firstmedian, median, loc, scale, angle);
}
}
else {
@@ -2982,8 +3330,9 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w
}
}
-ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
- float loc[2], float *scale, float *angle)
+/* NOTE: frame number should be in clip space, not scene space */
+ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf *ibuf,
+ float loc[2], float *scale, float *angle)
{
float tloc[2], tscale, tangle;
MovieTrackingStabilization *stab = &tracking->stabilization;
@@ -3007,21 +3356,21 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
return ibuf;
}
- BKE_tracking_stabilization_data(tracking, framenr, width, height, tloc, &tscale, &tangle);
+ BKE_tracking_stabilization_data_get(tracking, framenr, width, height, tloc, &tscale, &tangle);
- tmpibuf = stabilize_alloc_ibuf(NULL, ibuf, TRUE);
+ tmpibuf = stabilization_allocate_ibuf(NULL, ibuf, TRUE);
/* scale would be handled by matrix transformation when angle is non-zero */
if (tscale != 1.0f && tangle == 0.0f) {
ImBuf *scaleibuf;
- stabilization_auto_scale_factor(tracking, width, height);
+ stabilization_calculate_autoscale_factor(tracking, width, height);
- scaleibuf = stabilize_alloc_ibuf(stab->scaleibuf, ibuf, 0);
+ scaleibuf = stabilization_allocate_ibuf(stab->scaleibuf, ibuf, 0);
stab->scaleibuf = scaleibuf;
IMB_rectcpy(scaleibuf, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
- IMB_scalefastImBuf(scaleibuf, ibuf->x*tscale, ibuf->y*tscale);
+ IMB_scalefastImBuf(scaleibuf, ibuf->x * tscale, ibuf->y * tscale);
ibuf = scaleibuf;
}
@@ -3038,9 +3387,9 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
else {
float mat[4][4];
int i, j, filter = tracking->stabilization.filter;
- void (*interpolation) (struct ImBuf*, struct ImBuf*, float, float, int, int) = NULL;
+ void (*interpolation)(struct ImBuf *, struct ImBuf *, float, float, int, int) = NULL;
- BKE_tracking_stabdata_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
+ BKE_tracking_stabilization_data_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
invert_m4(mat);
if (filter == TRACKING_FILTER_NEAREAST)
@@ -3054,7 +3403,7 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
interpolation = neareast_interpolation;
for (j = 0; j < tmpibuf->y; j++) {
- for (i = 0; i < tmpibuf->x;i++) {
+ for (i = 0; i < tmpibuf->x; i++) {
float vec[3] = {i, j, 0};
mul_v3_m4v3(vec, mat, vec);
@@ -3081,8 +3430,8 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
return tmpibuf;
}
-void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect,
- float loc[2], float scale, float angle, float mat[4][4])
+void BKE_tracking_stabilization_data_to_mat4(int width, int height, float aspect, float loc[2],
+ float scale, float angle, float mat[4][4])
{
float lmat[4][4], rmat[4][4], smat[4][4], cmat[4][4], icmat[4][4], amat[4][4], iamat[4][4];
float svec[3] = {scale, scale, scale};
@@ -3102,249 +3451,15 @@ void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect,
cmat[3][1] = (float)height / 2.0f;
invert_m4_m4(icmat, cmat);
- size_to_mat4(smat, svec); /* scale matrix */
- add_v2_v2(lmat[3], loc); /* translation matrix */
- rotate_m4(rmat, 'Z', angle); /* rotation matrix */
+ size_to_mat4(smat, svec); /* scale matrix */
+ add_v2_v2(lmat[3], loc); /* translation matrix */
+ rotate_m4(rmat, 'Z', angle); /* rotation matrix */
/* compose transformation matrix */
mul_serie_m4(mat, lmat, cmat, amat, rmat, iamat, smat, icmat, NULL);
}
-MovieDistortion *BKE_tracking_distortion_create(void)
-{
- MovieDistortion *distortion;
-
- distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
-
- return distortion;
-}
-
-MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion)
-{
- MovieDistortion *new_distortion;
-
- new_distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
-
-#ifdef WITH_LIBMV
- new_distortion->intrinsics = libmv_CameraIntrinsicsCopy(distortion->intrinsics);
-#else
- (void) distortion;
-#endif
-
- return new_distortion;
-}
-
-void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking *tracking, int width, int height)
-{
- MovieTrackingCamera *camera = &tracking->camera;
- float aspy = 1.0f / tracking->camera.pixel_aspect;
-
-#ifdef WITH_LIBMV
- if (!distortion->intrinsics) {
- distortion->intrinsics = libmv_CameraIntrinsicsNew(camera->focal,
- camera->principal[0], camera->principal[1] * aspy,
- camera->k1, camera->k2, camera->k3, width, height * aspy);
- }
- else {
- libmv_CameraIntrinsicsUpdate(distortion->intrinsics, camera->focal,
- camera->principal[0], camera->principal[1] * aspy,
- camera->k1, camera->k2, camera->k3, width, height * aspy);
- }
-#else
- (void) distortion;
- (void) width;
- (void) height;
- (void) camera;
- (void) aspy;
-#endif
-}
-
-ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *tracking,
- ImBuf *ibuf, int width, int height, float overscan, int undistort)
-{
- ImBuf *resibuf;
-
- BKE_tracking_distortion_update(distortion, tracking, width, height);
-
- resibuf = IMB_dupImBuf(ibuf);
-
- if (ibuf->rect_float) {
-#ifdef WITH_LIBMV
- if (undistort) {
- libmv_CameraIntrinsicsUndistortFloat(distortion->intrinsics,
- ibuf->rect_float, resibuf->rect_float,
- ibuf->x, ibuf->y, overscan, ibuf->channels);
- }
- else {
- libmv_CameraIntrinsicsDistortFloat(distortion->intrinsics,
- ibuf->rect_float, resibuf->rect_float,
- ibuf->x, ibuf->y, overscan, ibuf->channels);
- }
-#endif
-
- resibuf->userflags |= IB_RECT_INVALID;
- }
- else {
-#ifdef WITH_LIBMV
- if (undistort) {
- libmv_CameraIntrinsicsUndistortByte(distortion->intrinsics,
- (unsigned char*)ibuf->rect, (unsigned char*)resibuf->rect,
- ibuf->x, ibuf->y, overscan, ibuf->channels);
- }
- else {
- libmv_CameraIntrinsicsDistortByte(distortion->intrinsics,
- (unsigned char*)ibuf->rect, (unsigned char*)resibuf->rect,
- ibuf->x, ibuf->y, overscan, ibuf->channels);
- }
-#endif
- }
-
-#ifndef WITH_LIBMV
- (void) overscan;
- (void) undistort;
-#endif
-
- return resibuf;
-}
-
-void BKE_tracking_distortion_destroy(MovieDistortion *distortion)
-{
-#ifdef WITH_LIBMV
- libmv_CameraIntrinsicsDestroy(distortion->intrinsics);
-#endif
-
- MEM_freeN(distortion);
-}
-
-ImBuf *BKE_tracking_undistort(MovieTracking *tracking, ImBuf *ibuf, int width, int height, float overscan)
-{
- MovieTrackingCamera *camera = &tracking->camera;
-
- if (camera->intrinsics == NULL)
- camera->intrinsics = BKE_tracking_distortion_create();
-
- return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, width, height, overscan, 1);
-}
-
-ImBuf *BKE_tracking_distort(MovieTracking *tracking, ImBuf *ibuf, int width, int height, float overscan)
-{
- MovieTrackingCamera *camera = &tracking->camera;
-
- if (camera->intrinsics == NULL)
- camera->intrinsics = BKE_tracking_distortion_create();
-
- return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, width, height, overscan, 0);
-}
-
-/* area - which part of marker should be selected. see TRACK_AREA_* constants */
-void BKE_tracking_select_track(ListBase *tracksbase, MovieTrackingTrack *track, int area, int extend)
-{
- if (extend) {
- BKE_tracking_track_flag(track, area, SELECT, 0);
- }
- else {
- MovieTrackingTrack *cur = tracksbase->first;
-
- while (cur) {
- if ((cur->flag & TRACK_HIDDEN) == 0) {
- if (cur == track) {
- BKE_tracking_track_flag(cur, TRACK_AREA_ALL, SELECT, 1);
- BKE_tracking_track_flag(cur, area, SELECT, 0);
- }
- else {
- BKE_tracking_track_flag(cur, TRACK_AREA_ALL, SELECT, 1);
- }
- }
-
- cur = cur->next;
- }
- }
-}
-
-void BKE_tracking_deselect_track(MovieTrackingTrack *track, int area)
-{
- BKE_tracking_track_flag(track, area, SELECT, 1);
-}
-
-MovieTrackingObject *BKE_tracking_new_object(MovieTracking *tracking, const char *name)
-{
- MovieTrackingObject *object = MEM_callocN(sizeof(MovieTrackingObject), "tracking object");
-
- if (tracking->tot_object == 0) {
- /* first object is always camera */
- BLI_strncpy(object->name, "Camera", sizeof(object->name));
-
- object->flag |= TRACKING_OBJECT_CAMERA;
- }
- else {
- BLI_strncpy(object->name, name, sizeof(object->name));
- }
-
- BLI_addtail(&tracking->objects, object);
-
- tracking->tot_object++;
- tracking->objectnr = BLI_countlist(&tracking->objects) - 1;
-
- object->scale = 1.0f;
-
- BKE_tracking_object_unique_name(tracking, object);
-
- return object;
-}
-
-void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *object)
-{
- MovieTrackingTrack *track;
- int index = BLI_findindex(&tracking->objects, object);
-
- if (index < 0)
- return;
-
- if (object->flag & TRACKING_OBJECT_CAMERA) {
- /* object used for camera solving can't be deleted */
- return;
- }
-
- track = object->tracks.first;
- while (track) {
- if (track == tracking->act_track)
- tracking->act_track = NULL;
-
- track = track->next;
- }
-
- tracking_object_free(object);
- BLI_freelinkN(&tracking->objects, object);
-
- tracking->tot_object--;
-
- if (index > 0)
- tracking->objectnr = index - 1;
- else
- tracking->objectnr = 0;
-}
-
-void BKE_tracking_object_unique_name(MovieTracking *tracking, MovieTrackingObject *object)
-{
- BLI_uniquename(&tracking->objects, object, "Object", '.',
- offsetof(MovieTrackingObject, name), sizeof(object->name));
-}
-
-MovieTrackingObject *BKE_tracking_named_object(MovieTracking *tracking, const char *name)
-{
- MovieTrackingObject *object = tracking->objects.first;
-
- while (object) {
- if (!strcmp(object->name, name))
- return object;
-
- object = object->next;
- }
-
- return NULL;
-}
-
-/*********************** dopesheet functions *************************/
+/*********************** Dopesheet functions *************************/
static int channels_alpha_sort(void *a, void *b)
{
@@ -3507,40 +3622,34 @@ static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, i
{
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
- if (dopesheet->sort_method == sort_method && dopesheet->sort_inverse == inverse)
- return;
-
if (inverse) {
- if (sort_method == TRACK_SORT_NAME) {
+ if (sort_method == TRACKING_DOPE_SORT_NAME) {
BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort);
}
- else if (sort_method == TRACK_SORT_LONGEST) {
+ else if (sort_method == TRACKING_DOPE_SORT_LONGEST) {
BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort);
}
- else if (sort_method == TRACK_SORT_TOTAL) {
+ else if (sort_method == TRACKING_DOPE_SORT_TOTAL) {
BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort);
}
- else if (sort_method == TRACK_SORT_AVERAGE_ERROR) {
+ else if (sort_method == TRACKING_DOPE_SORT_AVERAGE_ERROR) {
BLI_sortlist(&dopesheet->channels, channels_average_error_inverse_sort);
}
}
else {
- if (sort_method == TRACK_SORT_NAME) {
+ if (sort_method == TRACKING_DOPE_SORT_NAME) {
BLI_sortlist(&dopesheet->channels, channels_alpha_sort);
}
- else if (sort_method == TRACK_SORT_LONGEST) {
+ else if (sort_method == TRACKING_DOPE_SORT_LONGEST) {
BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort);
}
- else if (sort_method == TRACK_SORT_TOTAL) {
+ else if (sort_method == TRACKING_DOPE_SORT_TOTAL) {
BLI_sortlist(&dopesheet->channels, channels_total_track_sort);
}
- else if (sort_method == TRACK_SORT_AVERAGE_ERROR) {
+ else if (sort_method == TRACKING_DOPE_SORT_AVERAGE_ERROR) {
BLI_sortlist(&dopesheet->channels, channels_average_error_sort);
}
}
-
- dopesheet->sort_method = sort_method;
- dopesheet->sort_inverse = inverse;
}
void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking)
@@ -3550,35 +3659,50 @@ void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking)
dopesheet->ok = FALSE;
}
-void BKE_tracking_dopesheet_update(MovieTracking *tracking, int sort_method, int inverse)
+void BKE_tracking_dopesheet_update(MovieTracking *tracking)
{
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
MovieTrackingTrack *track;
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
+ MovieTrackingReconstruction *reconstruction;
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
- if (dopesheet->ok) {
- tracking_dopesheet_sort(tracking, sort_method, inverse);
+ short sort_method = dopesheet->sort_method;
+ short inverse = dopesheet->flag & TRACKING_DOPE_SORT_INVERSE;
+ short sel_only = dopesheet->flag & TRACKING_DOPE_SELECTED_ONLY;
+ short show_hidden = dopesheet->flag & TRACKING_DOPE_SHOW_HIDDEN;
+
+ if (dopesheet->ok)
return;
- }
tracking_dopesheet_free(dopesheet);
+ reconstruction = BKE_tracking_object_get_reconstruction(tracking, object);
+
for (track = tracksbase->first; track; track = track->next) {
- if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) {
- MovieTrackingDopesheetChannel *channel;
+ MovieTrackingDopesheetChannel *channel;
- channel = MEM_callocN(sizeof(MovieTrackingDopesheetChannel), "tracking dopesheet channel");
- channel->track = track;
+ if (!show_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ continue;
- channels_segments_calc(channel);
+ if (sel_only && !TRACK_SELECTED(track))
+ continue;
- BLI_addtail(&dopesheet->channels, channel);
- dopesheet->tot_channel++;
+ channel = MEM_callocN(sizeof(MovieTrackingDopesheetChannel), "tracking dopesheet channel");
+ channel->track = track;
+
+ if (reconstruction->flag & TRACKING_RECONSTRUCTED) {
+ BLI_snprintf(channel->name, sizeof(channel->name), "%s (%.4f)", track->name, track->error);
+ }
+ else {
+ BLI_strncpy(channel->name, track->name, sizeof(channel->name));
}
- }
- dopesheet->sort_method = TRACK_SORT_NONE;
+ channels_segments_calc(channel);
+
+ BLI_addtail(&dopesheet->channels, channel);
+ dopesheet->tot_channel++;
+ }
tracking_dopesheet_sort(tracking, sort_method, inverse);
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 44f54c41129..7520f09fe95 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -74,10 +74,7 @@ void rgb_to_xyz(float r, float g, float b, float *x, float *y, float *z);
unsigned int rgb_to_cpack(float r, float g, float b);
unsigned int hsv_to_cpack(float h, float s, float v);
-float rgb_to_grayscale(const float rgb[3]);
-unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]);
-float rgb_to_luma(const float rgb[3]);
-unsigned char rgb_to_luma_byte(const unsigned char rgb[3]);
+/* rgb_to_grayscale & rgb_to_luma functions moved to math_color_inline.c */
/**************** Profile Transformations *****************/
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 7ff52a5824f..be492fb6fdd 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -87,6 +87,8 @@ MINLINE void add_v2_v2(float r[2], const float a[2]);
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2]);
MINLINE void add_v3_v3(float r[3], const float a[3]);
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void add_v4_v4(float r[4], const float a[4]);
+MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4]);
MINLINE void sub_v2_v2(float r[2], const float a[2]);
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2]);
@@ -103,6 +105,7 @@ MINLINE void mul_v2_v2(float r[2], const float a[2]);
MINLINE void mul_v3_v3(float r[3], const float a[3]);
MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
MINLINE void mul_v4_fl(float r[4], float f);
+MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
@@ -110,6 +113,7 @@ MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], floa
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f);
MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
+MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
MINLINE void negate_v2(float r[2]);
MINLINE void negate_v2_v2(float r[2], const float a[2]);
diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h
index dbfa08219bd..6c0d547fe6f 100644
--- a/source/blender/blenlib/BLI_pbvh.h
+++ b/source/blender/blenlib/BLI_pbvh.h
@@ -82,13 +82,13 @@ void BLI_pbvh_search_gather(PBVH *bvh,
* it's up to the callback to find the primitive within the leaves that is
* hit first */
-void BLI_pbvh_raycast(PBVH * bvh, BLI_pbvh_HitOccludedCallback cb, void *data,
+void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data,
const float ray_start[3], const float ray_normal[3],
- int original);
+ int original);
-int BLI_pbvh_node_raycast(PBVH * bvh, PBVHNode * node, float (*origco)[3],
+int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
const float ray_start[3], const float ray_normal[3],
- float *dist);
+ float *dist);
/* Drawing */
@@ -214,7 +214,7 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
#define BLI_pbvh_vertex_iter_begin(bvh, node, vi, mode) \
pbvh_vertex_iter_init(bvh, node, &vi, mode); \
- \
+ \
for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
if (vi.grids) { \
vi.width = vi.gridsize; \
diff --git a/source/blender/blenlib/BLI_voronoi.h b/source/blender/blenlib/BLI_voronoi.h
new file mode 100644
index 00000000000..a67b01c5175
--- /dev/null
+++ b/source/blender/blenlib/BLI_voronoi.h
@@ -0,0 +1,70 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_VORONOI_H__
+#define __BLI_VORONOI_H__
+
+struct ListBase;
+
+/** \file BLI_voronoi.h
+ * \ingroup bli
+ */
+
+typedef struct VoronoiSite {
+ float co[2];
+ float color[3];
+} VoronoiSite;
+
+typedef struct VoronoiEdge {
+ struct VoronoiEdge *next, *prev;
+
+ float start[2], end[2]; /* start and end points */
+
+ /* this fields are used during diagram computation only */
+
+ float direction[2]; /* directional vector, from "start", points to "end", normal of |left, right| */
+
+ float left[2]; /* point on Voronoi place on the left side of edge */
+ float right[2]; /* point on Voronoi place on the right side of edge */
+
+ float f, g; /* directional coeffitients satisfying equation y = f*x + g (edge lies on this line) */
+
+ /* some edges consist of two parts, so we add the pointer to another part to connect them at the end of an algorithm */
+ struct VoronoiEdge *neighbour;
+} VoronoiEdge;
+
+typedef struct VoronoiTriangulationPoint {
+ float co[2];
+ float color[3];
+ int power;
+} VoronoiTriangulationPoint;
+
+void BLI_voronoi_compute(const VoronoiSite *sites, int sites_total, int width, int height, struct ListBase *edges);
+
+void BLI_voronoi_triangulate(const VoronoiSite *sites, int sites_total, struct ListBase *edges, int width, int height,
+ VoronoiTriangulationPoint **triangulated_points_r, int *triangulated_points_total_r,
+ int (**triangles_r)[3], int *triangles_total_r);
+
+#endif /* __BLI_VORONOI_H__ */
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index b6fc4da4e1b..7fba0a3fadc 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -90,6 +90,7 @@ set(SRC
intern/time.c
intern/uvproject.c
intern/voxel.c
+ intern/voronoi.c
intern/winstuff.c
BLI_args.h
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 5b034bd2872..b93597bf107 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -381,15 +381,9 @@ unsigned int rgb_to_cpack(float r, float g, float b)
void cpack_to_rgb(unsigned int col, float *r, float *g, float *b)
{
-
- *r = (float)((col) & 0xFF);
- *r /= 255.0f;
-
- *g = (float)(((col) >> 8) & 0xFF);
- *g /= 255.0f;
-
- *b = (float)(((col) >> 16) & 0xFF);
- *b /= 255.0f;
+ *r = ((float)(((col) ) & 0xFF)) * (1.0f / 255.0f);
+ *g = ((float)(((col) >> 8) & 0xFF)) * (1.0f / 255.0f);
+ *b = ((float)(((col) >> 16) & 0xFF)) * (1.0f / 255.0f);
}
void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3])
@@ -496,26 +490,6 @@ int constrain_rgb(float *r, float *g, float *b)
return 0; /* Color within RGB gamut */
}
-float rgb_to_grayscale(const float rgb[3])
-{
- return 0.3f * rgb[0] + 0.58f * rgb[1] + 0.12f * rgb[2];
-}
-
-unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
-{
- return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255;
-}
-
-float rgb_to_luma(const float rgb[3])
-{
- return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2];
-}
-
-unsigned char rgb_to_luma_byte(const unsigned char rgb[3])
-{
- return (76 * (unsigned short) rgb[0] + 150 * (unsigned short) rgb[1] + 29 * (unsigned short) rgb[2]) / 255;
-}
-
/* ********************************* lift/gamma/gain / ASC-CDL conversion ********************************* */
void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power)
@@ -648,9 +622,9 @@ void rgb_to_xyz(float r, float g, float b, float *x, float *y, float *z)
g = inverse_srgb_companding(g) * 100.0f;
b = inverse_srgb_companding(b) * 100.0f;
- *x = r * 0.4124 + g * 0.3576 + b * 0.1805;
- *y = r * 0.2126 + g * 0.7152 + b * 0.0722;
- *z = r * 0.0193 + g * 0.1192 + b * 0.9505;
+ *x = r * 0.412453f + g * 0.357580f + b * 0.180423f;
+ *y = r * 0.212671f + g * 0.715160f + b * 0.072169f;
+ *z = r * 0.019334f + g * 0.119193f + b * 0.950227f;
}
static float xyz_to_lab_component(float v)
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index b2a87a91433..417c557af8a 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -222,4 +222,37 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
r_col[2] = ((pack) >> 16) & 0xFF;
}
+
+MINLINE float rgb_to_grayscale(const float rgb[3])
+{
+ return 0.3f * rgb[0] + 0.58f * rgb[1] + 0.12f * rgb[2];
+}
+
+MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
+{
+ return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255;
+}
+
+MINLINE float rgb_to_luma(const float rgb[3])
+{
+ return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2];
+}
+
+MINLINE unsigned char rgb_to_luma_byte(const unsigned char rgb[3])
+{
+ return (76 * (unsigned short) rgb[0] + 150 * (unsigned short) rgb[1] + 29 * (unsigned short) rgb[2]) / 255;
+}
+
+/* gamma-corrected RGB --> CIE XYZ
+ * for this function we only get the Y component
+ * see: http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html
+ *
+ * also known as:
+ * luminance rec. 709 */
+MINLINE float rgb_to_luma_y(const float rgb[3])
+{
+ return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2];
+}
+
+
#endif /* __MATH_COLOR_INLINE_C__ */
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 56188048c02..e89b2ece467 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -272,6 +272,22 @@ MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
r[2] = a[2] + b[2];
}
+MINLINE void add_v4_v4(float r[4], const float a[4])
+{
+ r[0] += a[0];
+ r[1] += a[1];
+ r[2] += a[2];
+ r[3] += a[3];
+}
+
+MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4])
+{
+ r[0] = a[0] + b[0];
+ r[1] = a[1] + b[1];
+ r[2] = a[2] + b[2];
+ r[3] = a[3] + b[3];
+}
+
MINLINE void sub_v2_v2(float r[2], const float a[2])
{
r[0] -= a[0];
@@ -361,6 +377,14 @@ MINLINE void mul_v4_fl(float r[4], float f)
r[3] *= f;
}
+MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
+{
+ r[0] = a[0] * f;
+ r[1] = a[1] * f;
+ r[2] = a[2] * f;
+ r[3] = a[3] * f;
+}
+
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
{
r[0] += a[0] * f;
@@ -409,6 +433,14 @@ MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
r[3] += a[3] * f;
}
+MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4])
+{
+ r[0] += a[0] * b[0];
+ r[1] += a[1] * b[1];
+ r[2] += a[2] * b[2];
+ r[3] += a[3] * b[3];
+}
+
MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3])
{
r[0] = v1[0] * v2[0];
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index 5361682caa4..409a9f88f39 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -1140,17 +1140,17 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
switch (bvh->type) {
case PBVH_GRIDS:
node->draw_buffers =
- GPU_build_grid_buffers(node->prim_indices,
- node->totprim,
- bvh->grid_hidden,
- bvh->gridkey.grid_size);
+ GPU_build_grid_buffers(node->prim_indices,
+ node->totprim,
+ bvh->grid_hidden,
+ bvh->gridkey.grid_size);
break;
case PBVH_FACES:
node->draw_buffers =
- GPU_build_mesh_buffers(node->face_vert_indices,
- bvh->faces, bvh->verts,
- node->prim_indices,
- node->totprim);
+ GPU_build_mesh_buffers(node->face_vert_indices,
+ bvh->faces, bvh->verts,
+ node->prim_indices,
+ node->totprim);
break;
}
@@ -1478,7 +1478,7 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v)
void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data,
const float ray_start[3], const float ray_normal[3],
- int original)
+ int original)
{
RaycastData rcd;
@@ -1495,9 +1495,9 @@ void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data,
}
static int ray_face_intersection(const float ray_start[3],
- const float ray_normal[3],
+ const float ray_normal[3],
const float *t0, const float *t1,
- const float *t2, const float *t3,
+ const float *t2, const float *t3,
float *fdist)
{
float dist;
@@ -1514,9 +1514,9 @@ static int ray_face_intersection(const float ray_start[3],
}
static int pbvh_faces_node_raycast(PBVH *bvh, const PBVHNode *node,
- float (*origco)[3],
- const float ray_start[3],
- const float ray_normal[3], float *dist)
+ float (*origco)[3],
+ const float ray_start[3],
+ const float ray_normal[3], float *dist)
{
const MVert *vert = bvh->verts;
const int *faces = node->prim_indices;
@@ -1532,20 +1532,20 @@ static int pbvh_faces_node_raycast(PBVH *bvh, const PBVHNode *node,
if (origco) {
/* intersect with backuped original coordinates */
hit |= ray_face_intersection(ray_start, ray_normal,
- origco[face_verts[0]],
- origco[face_verts[1]],
- origco[face_verts[2]],
- f->v4 ? origco[face_verts[3]] : NULL,
- dist);
+ origco[face_verts[0]],
+ origco[face_verts[1]],
+ origco[face_verts[2]],
+ f->v4 ? origco[face_verts[3]] : NULL,
+ dist);
}
else {
/* intersect with current coordinates */
hit |= ray_face_intersection(ray_start, ray_normal,
- vert[f->v1].co,
- vert[f->v2].co,
- vert[f->v3].co,
- f->v4 ? vert[f->v4].co : NULL,
- dist);
+ vert[f->v1].co,
+ vert[f->v2].co,
+ vert[f->v3].co,
+ f->v4 ? vert[f->v4].co : NULL,
+ dist);
}
}
@@ -1553,9 +1553,9 @@ static int pbvh_faces_node_raycast(PBVH *bvh, const PBVHNode *node,
}
static int pbvh_grids_node_raycast(PBVH *bvh, PBVHNode *node,
- float (*origco)[3],
- const float ray_start[3],
- const float ray_normal[3], float *dist)
+ float (*origco)[3],
+ const float ray_start[3],
+ const float ray_normal[3], float *dist)
{
int totgrid = node->totprim;
int gridsize = bvh->gridkey.grid_size;
@@ -1580,19 +1580,19 @@ static int pbvh_grids_node_raycast(PBVH *bvh, PBVHNode *node,
if (origco) {
hit |= ray_face_intersection(ray_start, ray_normal,
- origco[y * gridsize + x],
- origco[y * gridsize + x + 1],
- origco[(y + 1) * gridsize + x + 1],
- origco[(y + 1) * gridsize + x],
- dist);
+ origco[y * gridsize + x],
+ origco[y * gridsize + x + 1],
+ origco[(y + 1) * gridsize + x + 1],
+ origco[(y + 1) * gridsize + x],
+ dist);
}
else {
hit |= ray_face_intersection(ray_start, ray_normal,
- CCG_grid_elem_co(&bvh->gridkey, grid, x, y),
- CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y),
- CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y + 1),
- CCG_grid_elem_co(&bvh->gridkey, grid, x, y + 1),
- dist);
+ CCG_grid_elem_co(&bvh->gridkey, grid, x, y),
+ CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y),
+ CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y + 1),
+ CCG_grid_elem_co(&bvh->gridkey, grid, x, y + 1),
+ dist);
}
}
}
@@ -1606,7 +1606,7 @@ static int pbvh_grids_node_raycast(PBVH *bvh, PBVHNode *node,
int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
const float ray_start[3], const float ray_normal[3],
- float *dist)
+ float *dist)
{
int hit = 0;
@@ -1616,11 +1616,11 @@ int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
switch (bvh->type) {
case PBVH_FACES:
hit |= pbvh_faces_node_raycast(bvh, node, origco,
- ray_start, ray_normal, dist);
+ ray_start, ray_normal, dist);
break;
case PBVH_GRIDS:
hit |= pbvh_grids_node_raycast(bvh, node, origco,
- ray_start, ray_normal, dist);
+ ray_start, ray_normal, dist);
break;
}
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c
new file mode 100644
index 00000000000..0088d24d741
--- /dev/null
+++ b/source/blender/blenlib/intern/voronoi.c
@@ -0,0 +1,833 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/*
+ * Fortune's algorithm implemented using explanation and some code snippets from
+ * http://blog.ivank.net/fortunes-algorithm-and-implementation.html
+ */
+
+/** \file blender/blenkernel/intern/tracking.c
+ * \ingroup bli
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_voronoi.h"
+#include "BLI_utildefines.h"
+
+#define VORONOI_EPS 1e-3
+
+enum {
+ voronoiEventType_Site = 0,
+ voronoiEventType_Circle = 1
+} voronoiEventType;
+
+typedef struct VoronoiEvent {
+ struct VoronoiEvent *next, *prev;
+
+ int type; /* type of event (site or circle) */
+ float site[2]; /* site for which event was generated */
+
+ struct VoronoiParabola *parabola; /* parabola for which event was generated */
+} VoronoiEvent;
+
+typedef struct VoronoiParabola {
+ struct VoronoiParabola *left, *right, *parent;
+ VoronoiEvent *event;
+ int is_leaf;
+ float site[2];
+ VoronoiEdge *edge;
+} VoronoiParabola;
+
+typedef struct VoronoiProcess {
+ ListBase queue, edges;
+ VoronoiParabola *root;
+ int width, height;
+ float current_y;
+} VoronoiProcess;
+
+/* event */
+
+static void voronoi_insertEvent(VoronoiProcess *process, VoronoiEvent *event)
+{
+ VoronoiEvent *current_event = process->queue.first;
+
+ while (current_event) {
+ if (current_event->site[1] < event->site[1]) {
+ break;
+ }
+ if (current_event->site[1] == event->site[1]) {
+ event->site[1] -= VORONOI_EPS;
+ }
+
+ current_event = current_event->next;
+ }
+
+ BLI_insertlinkbefore(&process->queue, current_event, event);
+}
+
+/* edge */
+static VoronoiEdge *voronoiEdge_new(float start[2], float left[2], float right[2])
+{
+ VoronoiEdge *edge = MEM_callocN(sizeof(VoronoiEdge), "voronoi edge");
+
+ copy_v2_v2(edge->start, start);
+ copy_v2_v2(edge->left, left);
+ copy_v2_v2(edge->right, right);
+
+ edge->neighbour = NULL;
+ edge->end[0] = 0;
+ edge->end[1] = 0;
+
+ edge->f = (right[0] - left[0]) / (left[1] - right[1]);
+ edge->g = start[1] - edge->f * start[0];
+
+ edge->direction[0] = right[1] - left[1];
+ edge->direction[1] = -(right[0] - left[0]);
+
+ return edge;
+}
+
+/* parabola */
+
+static VoronoiParabola *voronoiParabola_new(void)
+{
+ VoronoiParabola *parabola = MEM_callocN(sizeof(VoronoiParabola), "voronoi parabola");
+
+ parabola->is_leaf = FALSE;
+ parabola->event = NULL;
+ parabola->edge = NULL;
+ parabola->parent = 0;
+
+ return parabola;
+}
+
+static VoronoiParabola *voronoiParabola_newSite(float site[2])
+{
+ VoronoiParabola *parabola = MEM_callocN(sizeof(VoronoiParabola), "voronoi parabola site");
+
+ copy_v2_v2(parabola->site, site);
+ parabola->is_leaf = TRUE;
+ parabola->event = NULL;
+ parabola->edge = NULL;
+ parabola->parent = 0;
+
+ return parabola;
+}
+
+/* returns the closest leave which is on the left of current node */
+static VoronoiParabola *voronoiParabola_getLeftChild(VoronoiParabola *parabola)
+{
+ VoronoiParabola *current_parabola;
+
+ if (!parabola)
+ return NULL;
+
+ current_parabola = parabola->left;
+ while (!current_parabola->is_leaf) {
+ current_parabola = current_parabola->right;
+ }
+
+ return current_parabola;
+}
+
+/* returns the closest leave which is on the right of current node */
+static VoronoiParabola *voronoiParabola_getRightChild(VoronoiParabola *parabola)
+{
+ VoronoiParabola *current_parabola;
+
+ if (!parabola)
+ return NULL;
+
+ current_parabola = parabola->right;
+ while (!current_parabola->is_leaf) {
+ current_parabola = current_parabola->left;
+ }
+
+ return current_parabola;
+}
+
+/* returns the closest parent which is on the left */
+static VoronoiParabola *voronoiParabola_getLeftParent(VoronoiParabola *parabola)
+{
+ VoronoiParabola *current_par = parabola->parent;
+ VoronoiParabola *last_parabola = parabola;
+
+ while (current_par->left == last_parabola) {
+ if (!current_par->parent)
+ return NULL;
+
+ last_parabola = current_par;
+ current_par = current_par->parent;
+ }
+
+ return current_par;
+}
+
+/* returns the closest parent which is on the right */
+static VoronoiParabola *voronoiParabola_getRightParent(VoronoiParabola *parabola)
+{
+ VoronoiParabola *current_parabola = parabola->parent;
+ VoronoiParabola *last_parabola = parabola;
+
+ while (current_parabola->right == last_parabola) {
+ if (!current_parabola->parent)
+ return NULL;
+
+ last_parabola = current_parabola;
+ current_parabola = current_parabola->parent;
+ }
+
+ return current_parabola;
+}
+
+static void voronoiParabola_setLeft(VoronoiParabola *parabola, VoronoiParabola *left)
+{
+ parabola->left = left;
+ left->parent = parabola;
+}
+
+static void voronoiParabola_setRight(VoronoiParabola *parabola, VoronoiParabola *right)
+{
+ parabola->right = right;
+ right->parent = parabola;
+}
+
+static float voronoi_getY(VoronoiProcess *process, float p[2], float x)
+{
+ float ly = process->current_y;
+
+ float dp = 2 * (p[1] - ly);
+ float a1 = 1 / dp;
+ float b1 = -2 * p[0] / dp;
+ float c1 = ly + dp / 4 + p[0] * p[0] / dp;
+
+ return a1 * x * x + b1 * x + c1;
+}
+
+static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, float y)
+{
+ VoronoiParabola *left = voronoiParabola_getLeftChild(par);
+ VoronoiParabola *right = voronoiParabola_getRightChild(par);
+ float p[2], r[2];
+ float dp, a1, b1, c1, a2, b2, c2, a, b, c, disc, ry, x1, x2;
+ float ly = process->current_y;
+
+ copy_v2_v2(p, left->site);
+ copy_v2_v2(r, right->site);
+
+ dp = 2.0f * (p[1] - y);
+ a1 = 1.0f / dp;
+ b1 = -2.0f * p[0] / dp;
+ c1 = y + dp / 4 + p[0] * p[0] / dp;
+
+ dp = 2.0f * (r[1] - y);
+ a2 = 1.0f / dp;
+ b2 = -2.0f * r[0] / dp;
+ c2 = ly + dp / 4 + r[0] * r[0] / dp;
+
+ a = a1 - a2;
+ b = b1 - b2;
+ c = c1 - c2;
+
+ disc = b*b - 4 * a * c;
+ x1 = (-b + sqrtf(disc)) / (2*a);
+ x2 = (-b - sqrtf(disc)) / (2*a);
+
+ if (p[1] < r[1])
+ ry = MAX2(x1, x2);
+ else
+ ry = MIN2(x1, x2);
+
+ return ry;
+}
+
+static VoronoiParabola *voronoi_getParabolaByX(VoronoiProcess *process, float xx)
+{
+ VoronoiParabola * par = process->root;
+ float x = 0.0f;
+ float ly = process->current_y;
+
+ while (!par->is_leaf) {
+ x = voronoi_getXOfEdge(process, par, ly);
+
+ if (x > xx)
+ par = par->left;
+ else
+ par = par->right;
+ }
+
+ return par;
+}
+
+static int voronoi_getEdgeIntersection(VoronoiEdge *a, VoronoiEdge *b, float p[2])
+{
+ float x = (b->g - a->g) / (a->f - b->f);
+ float y = a->f * x + a->g;
+
+ if ((x - a->start[0]) / a->direction[0] < 0)
+ return 0;
+
+ if ((y - a->start[1]) / a->direction[1] < 0)
+ return 0;
+
+ if ((x - b->start[0]) / b->direction[0] < 0)
+ return 0;
+
+ if ((y - b->start[1]) / b->direction[1] < 0)
+ return 0;
+
+ p[0] = x;
+ p[1] = y;
+
+ return 1;
+}
+
+static void voronoi_checkCircle(VoronoiProcess *process, VoronoiParabola *b)
+{
+ VoronoiParabola *lp = voronoiParabola_getLeftParent(b);
+ VoronoiParabola *rp = voronoiParabola_getRightParent(b);
+
+ VoronoiParabola *a = voronoiParabola_getLeftChild(lp);
+ VoronoiParabola *c = voronoiParabola_getRightChild(rp);
+
+ VoronoiEvent *event;
+
+ float ly = process->current_y;
+ float s[2], dx, dy, d;
+
+ if (!a || !c || len_squared_v2v2(a->site, c->site) < VORONOI_EPS)
+ return;
+
+ if (!voronoi_getEdgeIntersection(lp->edge, rp->edge, s))
+ return;
+
+ dx = a->site[0] - s[0];
+ dy = a->site[1] - s[1];
+
+ d = sqrtf((dx * dx) + (dy * dy));
+
+ if (s[1] - d >= ly)
+ return;
+
+ event = MEM_callocN(sizeof(VoronoiEvent), "voronoi circle event");
+
+ event->type = voronoiEventType_Circle;
+
+ event->site[0] = s[0];
+ event->site[1] = s[1] - d;
+
+ b->event = event;
+ event->parabola = b;
+
+ voronoi_insertEvent(process, event);
+}
+
+static void voronoi_addParabola(VoronoiProcess *process, float site[2])
+{
+ VoronoiParabola *root = process->root;
+ VoronoiParabola *par, *p0, *p1, *p2;
+ VoronoiEdge *el, *er;
+ float start[2];
+
+ if (!process->root) {
+ process->root = voronoiParabola_newSite(site);
+
+ return;
+ }
+
+ if (root->is_leaf && root->site[1] - site[1] < 0) {
+ float *fp = root->site;
+ float s[2];
+
+ root->is_leaf = FALSE;
+ voronoiParabola_setLeft(root, voronoiParabola_newSite(fp));
+ voronoiParabola_setRight(root, voronoiParabola_newSite(site));
+
+ s[0] = (site[0] + fp[0]) / 2.0f;
+ s[1] = process->height;
+
+ if(site[0] > fp[0])
+ root->edge = voronoiEdge_new(s, fp, site);
+ else
+ root->edge = voronoiEdge_new(s, site, fp);
+
+ BLI_addtail(&process->edges, root->edge);
+
+ return;
+ }
+
+ par = voronoi_getParabolaByX(process, site[0]);
+
+ if (par->event) {
+ BLI_freelinkN(&process->queue, par->event);
+
+ par->event = NULL;
+ }
+
+ start[0] = site[0];
+ start[1] = voronoi_getY(process, par->site, site[0]);
+
+ el = voronoiEdge_new(start, par->site, site);
+ er = voronoiEdge_new(start, site, par->site);
+
+ el->neighbour = er;
+ BLI_addtail(&process->edges, el);
+
+ par->edge = er;
+ par->is_leaf = FALSE;
+
+ p0 = voronoiParabola_newSite(par->site);
+ p1 = voronoiParabola_newSite(site);
+ p2 = voronoiParabola_newSite(par->site);
+
+ voronoiParabola_setRight(par, p2);
+ voronoiParabola_setLeft(par, voronoiParabola_new());
+ par->left->edge = el;
+
+ voronoiParabola_setLeft(par->left, p0);
+ voronoiParabola_setRight(par->left, p1);
+
+ voronoi_checkCircle(process, p0);
+ voronoi_checkCircle(process, p2);
+}
+
+static void voronoi_removeParabola(VoronoiProcess *process, VoronoiEvent *event)
+{
+ VoronoiParabola *p1 = event->parabola;
+
+ VoronoiParabola *xl = voronoiParabola_getLeftParent(p1);
+ VoronoiParabola *xr = voronoiParabola_getRightParent(p1);
+
+ VoronoiParabola *p0 = voronoiParabola_getLeftChild(xl);
+ VoronoiParabola *p2 = voronoiParabola_getRightChild(xr);
+
+ VoronoiParabola *higher = NULL, *par, *gparent;
+
+ float p[2];
+
+ if (p0->event) {
+ BLI_freelinkN(&process->queue, p0->event);
+ p0->event = NULL;
+ }
+
+ if (p2->event) {
+ BLI_freelinkN(&process->queue, p2->event);
+ p2->event = NULL;
+ }
+
+ p[0] = event->site[0];
+ p[1] = voronoi_getY(process, p1->site, event->site[0]);
+
+ copy_v2_v2(xl->edge->end, p);
+ copy_v2_v2(xr->edge->end, p);
+
+ par = p1;
+ while (par != process->root) {
+ par = par->parent;
+
+ if (par == xl)
+ higher = xl;
+ if (par == xr)
+ higher = xr;
+ }
+
+ higher->edge = voronoiEdge_new(p, p0->site, p2->site);
+ BLI_addtail(&process->edges, higher->edge);
+
+ gparent = p1->parent->parent;
+ if (p1->parent->left == p1) {
+ if (gparent->left == p1->parent)
+ voronoiParabola_setLeft(gparent, p1->parent->right);
+ if (gparent->right == p1->parent)
+ voronoiParabola_setRight(gparent, p1->parent->right);
+ }
+ else {
+ if (gparent->left == p1->parent)
+ voronoiParabola_setLeft(gparent, p1->parent->left);
+ if (gparent->right == p1->parent)
+ voronoiParabola_setRight(gparent, p1->parent->left);
+ }
+
+ MEM_freeN(p1->parent);
+ MEM_freeN(p1);
+
+ voronoi_checkCircle(process, p0);
+ voronoi_checkCircle(process, p2);
+}
+
+void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola)
+{
+ float mx;
+
+ if (parabola->is_leaf) {
+ MEM_freeN(parabola);
+ return;
+ }
+
+ if (parabola->edge->direction[0] > 0.0f)
+ mx = MAX2(process->width, parabola->edge->start[0] + 10);
+ else
+ mx = MIN2(0.0, parabola->edge->start[0] - 10);
+
+ parabola->edge->end[0] = mx;
+ parabola->edge->end[1] = mx * parabola->edge->f + parabola->edge->g;
+
+ voronoi_finishEdge(process, parabola->left);
+ voronoi_finishEdge(process, parabola->right);
+
+ MEM_freeN(parabola);
+}
+
+void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord)
+{
+ const float corners[4][2] = {{0.0f, 0.0f},
+ {width - 1, 0.0f},
+ {width - 1, height - 1},
+ {0.0f, height - 1}};
+ int i;
+
+ if (IN_RANGE_INCL(coord[0], 0, width-1) && IN_RANGE_INCL(coord[1], 0, height-1)) {
+ return;
+ }
+
+ for (i = 0; i < 4; i++) {
+ float v1[2], v2[2];
+ float p[2];
+
+ copy_v2_v2(v1, corners[i]);
+
+ if (i == 3)
+ copy_v2_v2(v2, corners[0]);
+ else
+ copy_v2_v2(v2, corners[i + 1]);
+
+ if (isect_seg_seg_v2_point(v1, v2, coord, other_coord, p) == 1) {
+ if (i == 0 && coord[1] > p[1])
+ continue;
+ if (i == 1 && coord[0] < p[0])
+ continue;
+ if (i == 2 && coord[1] < p[1])
+ continue;
+ if (i == 3 && coord[0] > p[0])
+ continue;
+
+ copy_v2_v2(coord, p);
+ }
+ }
+}
+
+void voronoi_clampEdges(ListBase *edges, int width, int height, ListBase *clamped_edges)
+{
+ VoronoiEdge *edge;
+
+ edge = edges->first;
+ while (edge) {
+ VoronoiEdge *new_edge = MEM_callocN(sizeof(VoronoiEdge), "clamped edge");
+
+ *new_edge = *edge;
+ BLI_addtail(clamped_edges, new_edge);
+
+ voronoi_clampEdgeVertex(width, height, new_edge->start, new_edge->end);
+ voronoi_clampEdgeVertex(width, height, new_edge->end, new_edge->start);
+
+ edge = edge->next;
+ }
+}
+
+static int voronoi_getNextSideCoord(ListBase *edges, float coord[2], int dim, int dir, float next_coord[2])
+{
+ VoronoiEdge *edge = edges->first;
+ float distance = FLT_MAX;
+ int other_dim = dim ? 0 : 1;
+
+ while (edge) {
+ int ok = FALSE;
+ float co[2], cur_distance;
+
+ if (fabsf(edge->start[other_dim] - coord[other_dim]) < VORONOI_EPS &&
+ len_squared_v2v2(coord, edge->start) > VORONOI_EPS)
+ {
+ copy_v2_v2(co, edge->start);
+ ok = TRUE;
+ }
+
+ if (fabsf(edge->end[other_dim] - coord[other_dim]) < VORONOI_EPS &&
+ len_squared_v2v2(coord, edge->end) > VORONOI_EPS)
+ {
+ copy_v2_v2(co, edge->end);
+ ok = TRUE;
+ }
+
+ if (ok) {
+ if (dir > 0 && coord[dim] > co[dim]) {
+ ok = FALSE;
+ }
+ else if (dir < 0 && coord[dim] < co[dim]) {
+ ok = FALSE;
+ }
+ }
+
+ if (ok) {
+ cur_distance = len_squared_v2v2(coord, co);
+ if (cur_distance < distance) {
+ copy_v2_v2(next_coord, co);
+ distance = cur_distance;
+ }
+ }
+
+ edge = edge->next;
+ }
+
+ return distance < FLT_MAX;
+}
+
+static void voronoi_createBoundaryEdges(ListBase *edges, int width, int height)
+{
+ const float corners[4][2] = {{width - 1, 0.0f},
+ {width - 1, height - 1},
+ {0.0f, height - 1},
+ {0.0f, 0.0f}};
+ int i, dim = 0, dir = 1;
+
+ float coord[2] = {0.0f, 0.0f};
+ float next_coord[2] = {0.0f, 0.0f};
+
+ for (i = 0; i < 4; i++) {
+ while (voronoi_getNextSideCoord(edges, coord, dim, dir, next_coord)) {
+ VoronoiEdge *edge = MEM_callocN(sizeof(VoronoiEdge), "boundary edge");
+
+ copy_v2_v2(edge->start, coord);
+ copy_v2_v2(edge->end, next_coord);
+ BLI_addtail(edges, edge);
+
+ copy_v2_v2(coord, next_coord);
+ }
+
+ if (len_squared_v2v2(coord, corners[i]) > VORONOI_EPS) {
+ VoronoiEdge *edge = MEM_callocN(sizeof(VoronoiEdge), "boundary edge");
+
+ copy_v2_v2(edge->start, coord);
+ copy_v2_v2(edge->end, corners[i]);
+ BLI_addtail(edges, edge);
+ copy_v2_v2(coord, corners[i]);
+ }
+
+ dim = dim ? 0 : 1;
+ if (i == 1)
+ dir = -1;
+ }
+}
+
+void BLI_voronoi_compute(const VoronoiSite *sites, int sites_total, int width, int height, ListBase *edges)
+{
+ VoronoiProcess process;
+ VoronoiEdge *edge;
+ int i;
+
+ memset(&process, 0, sizeof(VoronoiProcess));
+
+ process.width = width;
+ process.height = height;
+
+ for (i = 0; i < sites_total; i++) {
+ VoronoiEvent *event = MEM_callocN(sizeof(VoronoiEvent), "voronoi site event");
+
+ event->type = voronoiEventType_Site;
+ copy_v2_v2(event->site, sites[i].co);
+
+ voronoi_insertEvent(&process, event);
+ }
+
+ while (process.queue.first) {
+ VoronoiEvent *event = process.queue.first;
+
+ process.current_y = event->site[1];
+
+ if (event->type == voronoiEventType_Site) {
+ voronoi_addParabola(&process, event->site);
+ }
+ else {
+ voronoi_removeParabola(&process, event);
+ }
+
+ BLI_freelinkN(&process.queue, event);
+ }
+
+ voronoi_finishEdge(&process, process.root);
+
+ edge = process.edges.first;
+ while (edge) {
+ if (edge->neighbour) {
+ copy_v2_v2(edge->start, edge->neighbour->end);
+ MEM_freeN(edge->neighbour);
+ }
+
+ edge = edge->next;
+ }
+
+ BLI_movelisttolist(edges, &process.edges);
+}
+
+static int testVoronoiEdge(const float site[2], const float point[2], const VoronoiEdge *edge)
+{
+ float p[2];
+
+ if (isect_seg_seg_v2_point(site, point, edge->start, edge->end, p) == 1) {
+ if (len_squared_v2v2(p, edge->start) > VORONOI_EPS &&
+ len_squared_v2v2(p, edge->end) > VORONOI_EPS)
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static int voronoi_addTriangulationPoint(const float coord[2], const float color[3],
+ VoronoiTriangulationPoint **triangulated_points,
+ int *triangulated_points_total)
+{
+ VoronoiTriangulationPoint *triangulation_point;
+ int i;
+
+ for (i = 0; i < *triangulated_points_total; i++) {
+ if (equals_v2v2(coord, (*triangulated_points)[i].co)) {
+ triangulation_point = &(*triangulated_points)[i];
+
+ add_v3_v3(triangulation_point->color, color);
+ triangulation_point->power++;
+
+ return i;
+ }
+ }
+
+ if (*triangulated_points) {
+ *triangulated_points = MEM_reallocN(*triangulated_points,
+ sizeof(VoronoiTriangulationPoint) * (*triangulated_points_total + 1));
+ }
+ else {
+ *triangulated_points = MEM_callocN(sizeof(VoronoiTriangulationPoint), "triangulation points");
+ }
+
+ triangulation_point = &(*triangulated_points)[(*triangulated_points_total)];
+ copy_v2_v2(triangulation_point->co, coord);
+ copy_v3_v3(triangulation_point->color, color);
+
+ triangulation_point->power = 1;
+
+ (*triangulated_points_total)++;
+
+ return (*triangulated_points_total) - 1;
+}
+
+static void voronoi_addTriangle(int v1, int v2, int v3, int (**triangles)[3], int *triangles_total)
+{
+ int *triangle;
+
+ if (*triangles) {
+ *triangles = MEM_reallocN(*triangles, sizeof(int[3]) * (*triangles_total + 1));
+ }
+ else {
+ *triangles = MEM_callocN(sizeof(int[3]), "trianglulation triangles");
+ }
+
+ triangle = (int*)&(*triangles)[(*triangles_total)];
+
+ triangle[0] = v1;
+ triangle[1] = v2;
+ triangle[2] = v3;
+
+ (*triangles_total)++;
+}
+
+void BLI_voronoi_triangulate(const VoronoiSite *sites, int sites_total, ListBase *edges, int width, int height,
+ VoronoiTriangulationPoint **triangulated_points_r, int *triangulated_points_total_r,
+ int (**triangles_r)[3], int *triangles_total_r)
+{
+ VoronoiTriangulationPoint *triangulated_points = NULL;
+ int (*triangles)[3] = NULL;
+ int triangulated_points_total = 0, triangles_total = 0;
+ int i;
+ ListBase boundary_edges = {NULL, NULL};
+
+ voronoi_clampEdges(edges, width, height, &boundary_edges);
+ voronoi_createBoundaryEdges(&boundary_edges, width, height);
+
+ for (i = 0; i < sites_total; i++) {
+ VoronoiEdge *edge;
+ int v1;
+
+ v1 = voronoi_addTriangulationPoint(sites[i].co, sites[i].color, &triangulated_points, &triangulated_points_total);
+
+ edge = boundary_edges.first;
+ while (edge) {
+ VoronoiEdge *test_edge = boundary_edges.first;
+ int ok_start = TRUE, ok_end = TRUE;
+
+ while (test_edge) {
+ float v1[2], v2[2];
+
+ sub_v2_v2v2(v1, edge->start, sites[i].co);
+ sub_v2_v2v2(v2, edge->end, sites[i].co);
+
+ if (ok_start && !testVoronoiEdge(sites[i].co, edge->start, test_edge))
+ ok_start = FALSE;
+
+ if (ok_end && !testVoronoiEdge(sites[i].co, edge->end, test_edge))
+ ok_end = FALSE;
+
+ test_edge = test_edge->next;
+ }
+
+ if (ok_start && ok_end) {
+ int v2, v3;
+
+ v2 = voronoi_addTriangulationPoint(edge->start, sites[i].color, &triangulated_points, &triangulated_points_total);
+ v3 = voronoi_addTriangulationPoint(edge->end, sites[i].color, &triangulated_points, &triangulated_points_total);
+
+ voronoi_addTriangle(v1, v2, v3, &triangles, &triangles_total);
+ }
+
+ edge = edge->next;
+ }
+ }
+
+ for (i = 0; i < triangulated_points_total; i++) {
+ VoronoiTriangulationPoint *triangulation_point = &triangulated_points[i];
+
+ mul_v3_fl(triangulation_point->color, 1.0f / triangulation_point->power);
+ }
+
+ *triangulated_points_r = triangulated_points;
+ *triangulated_points_total_r = triangulated_points_total;
+
+ *triangles_r = triangles;
+ *triangles_total_r = triangles_total;
+
+ BLI_freelistN(&boundary_edges);
+}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 95ac030a440..0dac27b13cc 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5302,6 +5302,14 @@ static void lib_link_screen(FileData *fd, Main *main)
*/
sima->gpd = newlibadr_us(fd, sc->id.lib, sima->gpd);
}
+ else if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so fingers crossed this works fine!
+ */
+ sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd);
+ }
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)sl;
bDopeSheet *ads= snla->ads;
@@ -5372,15 +5380,20 @@ static void lib_link_screen(FileData *fd, Main *main)
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
-
+
sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
sclip->mask = newlibadr_us(fd, sc->id.lib, sclip->mask);
-
+
sclip->scopes.track_search = NULL;
sclip->scopes.track_preview = NULL;
sclip->draw_context = NULL;
sclip->scopes.ok = 0;
}
+ else if (sl->spacetype == SPACE_LOGIC) {
+ SpaceLogic *slogic = (SpaceLogic *)sl;
+
+ slogic->gpd = newlibadr_us(fd, sc->id.lib, slogic->gpd);
+ }
}
}
sc->id.flag -= LIB_NEEDLINK;
@@ -5552,6 +5565,12 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
if (saction->ads.filter_grp)
saction->ads.filter_grp= restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0);
+
+
+ /* force recalc of list of channels, potentially updating the active action
+ * while we're at it (as it can only be updated that way) [#28962]
+ */
+ saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
@@ -5573,6 +5592,14 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
*/
sima->gpd = restore_pointer_by_name(newmain, (ID *)sima->gpd, 1);
}
+ else if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so assume that here we're doing for undo only...
+ */
+ sseq->gpd = restore_pointer_by_name(newmain, (ID *)sseq->gpd, 1);
+ }
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)sl;
bDopeSheet *ads = snla->ads;
@@ -5637,12 +5664,17 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
-
+
sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 1);
sclip->mask = restore_pointer_by_name(newmain, (ID *)sclip->mask, 1);
-
+
sclip->scopes.ok = 0;
}
+ else if (sl->spacetype == SPACE_LOGIC) {
+ SpaceLogic *slogic = (SpaceLogic *)sl;
+
+ slogic->gpd = restore_pointer_by_name(newmain, (ID *)slogic->gpd, 1);
+ }
}
}
}
@@ -5883,7 +5915,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
}
else if (sl->spacetype == SPACE_LOGIC) {
SpaceLogic *slogic = (SpaceLogic *)sl;
-
+
+ /* XXX: this is new stuff, which shouldn't be directly linking to gpd... */
if (slogic->gpd) {
slogic->gpd = newdataadr(fd, slogic->gpd);
direct_link_gpencil(fd, slogic->gpd);
@@ -7416,7 +7449,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
tracking->settings.object_distance = 1.0f;
if (tracking->objects.first == NULL)
- BKE_tracking_new_object(tracking, "Camera");
+ BKE_tracking_object_add(tracking, "Camera");
while (tracking_object) {
if (!tracking_object->scale)
@@ -8288,7 +8321,7 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
/* Update: the issue is that in file reading, the oldnewmap is OK, but for existing data, it has to be
* inserted in the map to be found! */
-
+
/* Update: previously it was checking for id->flag & LIB_PRE_EXISTING, however that does not affect file
* reading. For file reading we may need to insert it into the libmap as well, because you might have
* two files indirectly linking the same datablock, and in that case we need this in the libmap for the
@@ -8697,6 +8730,7 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb)
}
}
+#if 0 /* Disabled as it doesn't actually do anything except recurse... */
static void expand_bones(FileData *fd, Main *mainvar, Bone *bone)
{
Bone *curBone;
@@ -8705,6 +8739,7 @@ static void expand_bones(FileData *fd, Main *mainvar, Bone *bone)
expand_bones(fd, mainvar, curBone);
}
}
+#endif
static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
{
@@ -8720,15 +8755,19 @@ static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
}
static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
-{
- Bone *curBone;
-
+{
if (arm->adt)
expand_animdata(fd, mainvar, arm->adt);
- for (curBone = arm->bonebase.first; curBone; curBone=curBone->next) {
- expand_bones(fd, mainvar, curBone);
+#if 0 /* Disabled as this currently only recurses down the chain doing nothing */
+ {
+ Bone *curBone;
+
+ for (curBone = arm->bonebase.first; curBone; curBone=curBone->next) {
+ expand_bones(fd, mainvar, curBone);
+ }
}
+#endif
}
static void expand_object_expandModifiers(void *userData, Object *UNUSED(ob),
@@ -8945,7 +8984,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
#ifdef DURIAN_CAMERA_SWITCH
{
TimeMarker *marker;
-
+
for (marker = sce->markers.first; marker; marker = marker->next) {
if (marker->camera) {
expand_doit(fd, mainvar, marker->camera);
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index 1720ee4f55a..59817043eed 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -458,7 +458,7 @@ static int bm_mesh_flag_count(BMesh *bm, const char htype, const char hflag,
BMIter iter;
int tot = 0;
- BLI_assert(ELEM(TRUE, FALSE, test_for_enabled));
+ BLI_assert(ELEM(test_for_enabled, TRUE, FALSE));
if (htype & BM_VERT) {
for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) {
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 82ad5c1805b..65288522b3b 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -698,7 +698,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
BMOpSlot *output = BMO_slot_get(op, slotname);
int totelement = 0, i = 0;
- BLI_assert(ELEM(TRUE, FALSE, test_for_enabled));
+ BLI_assert(ELEM(test_for_enabled, TRUE, FALSE));
if (test_for_enabled)
totelement = BM_mesh_elem_hflag_count_enabled(bm, htype, hflag, TRUE);
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 4ddc19b2b9f..05113576ca4 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -74,7 +74,8 @@ enum {
enum {
SIMVERT_NORMAL = 0,
SIMVERT_FACE,
- SIMVERT_VGROUP
+ SIMVERT_VGROUP,
+ SIMVERT_EDGE
};
enum {
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index c1c5dd73bb7..3ec4c51bcb1 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -754,6 +754,7 @@ void BM_edge_ordered_verts_ex(BMEdge *edge, BMVert **r_v1, BMVert **r_v2,
BMLoop *edge_loop)
{
BLI_assert(edge_loop->e == edge);
+ (void)edge; /* quiet warning in release build */
*r_v1 = edge_loop->v;
*r_v2 = edge_loop->next->v;
}
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index ae001b2baf6..6e6037239b9 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -504,7 +504,9 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
BMO_op_finish(bm, &extop);
}
- if (usedvec)
+ if (usedvec) {
+ mul_m3_v3(rmat, dvec);
BMO_op_callf(bm, "translate vec=%v verts=%s", dvec, op, "lastout");
+ }
}
}
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index 1ec4d4ab6d4..b076d835ea1 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -887,6 +887,7 @@ typedef struct SimSel_VertExt {
BMVert *v;
union {
int num_faces; /* adjacent faces */
+ int num_edges; /* adjacent edges */
MDeformVert *dvert; /* deform vertex */
};
} SimSel_VertExt;
@@ -942,6 +943,9 @@ void bmo_similarverts_exec(BMesh *bm, BMOperator *op)
v_ext[i].dvert = NULL;
}
break;
+ case SIMVERT_EDGE:
+ v_ext[i].num_edges = BM_vert_edge_count(v);
+ break;
}
i++;
@@ -984,6 +988,13 @@ void bmo_similarverts_exec(BMesh *bm, BMOperator *op)
}
}
break;
+ case SIMVERT_EDGE:
+ /* number of adjacent edges */
+ if (v_ext[i].num_edges == v_ext[indices[idx]].num_edges) {
+ BMO_elem_flag_enable(bm, v, VERT_MARK);
+ cont = FALSE;
+ }
+ break;
}
}
}
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 5898d5da670..9582da4fe5c 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -25,16 +25,12 @@
#include "MaterialExporter.h"
template<class Functor>
-void forEachObjectInScene(Scene *sce, Functor &f)
+void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
- Base *base= (Base*) sce->base.first;
-
- while (base) {
- Object *ob = base->object;
-
+ LinkNode *node;
+ for (node = export_set; node; node = node->next) {
+ Object *ob = (Object *)node->link;
f(ob);
-
- base= base->next;
}
}
@@ -45,14 +41,14 @@ void AnimationExporter::exportAnimations(Scene *sce)
openLibrary();
- forEachObjectInScene(sce, *this);
+ forEachObjectInExportSet(sce, *this, this->export_settings->export_set);
closeLibrary();
}
}
// called for each exported object
-void AnimationExporter::operator() (Object *ob)
+void AnimationExporter::operator()(Object *ob)
{
FCurve *fcu;
char *transformName;
@@ -60,24 +56,24 @@ void AnimationExporter::operator() (Object *ob)
//Export transform animations
if (ob->adt && ob->adt->action) {
- fcu = (FCurve*)ob->adt->action->curves.first;
+ fcu = (FCurve *)ob->adt->action->curves.first;
//transform matrix export for bones are temporarily disabled here.
- if ( ob->type == OB_ARMATURE ) {
- bArmature *arm = (bArmature*)ob->data;
- for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
+ if (ob->type == OB_ARMATURE) {
+ bArmature *arm = (bArmature *)ob->data;
+ for (Bone *bone = (Bone *)arm->bonebase.first; bone; bone = bone->next)
write_bone_animation_matrix(ob, bone);
}
while (fcu) {
//for armature animations as objects
- if ( ob->type == OB_ARMATURE )
+ if (ob->type == OB_ARMATURE)
transformName = fcu->rna_path;
else
- transformName = extract_transform_name( fcu->rna_path );
+ transformName = extract_transform_name(fcu->rna_path);
if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
- (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
+ (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) ||
(!strcmp(transformName, "rotation_quaternion")))
{
dae_animation(ob, fcu, transformName, false);
@@ -88,12 +84,12 @@ void AnimationExporter::operator() (Object *ob)
}
//Export Lamp parameter animations
- if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) {
- fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
+ if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action) {
+ fcu = (FCurve *)(((Lamp *)ob->data)->adt->action->curves.first);
while (fcu) {
- transformName = extract_transform_name( fcu->rna_path );
+ transformName = extract_transform_name(fcu->rna_path);
- if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))||
+ if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size")) ||
(!strcmp(transformName, "spot_blend")) || (!strcmp(transformName, "distance")))
{
dae_animation(ob, fcu, transformName, true);
@@ -103,14 +99,14 @@ void AnimationExporter::operator() (Object *ob)
}
//Export Camera parameter animations
- if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) {
- fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
+ if ( (ob->type == OB_CAMERA) && ((Camera *)ob->data)->adt && ((Camera *)ob->data)->adt->action) {
+ fcu = (FCurve *)(((Camera *)ob->data)->adt->action->curves.first);
while (fcu) {
- transformName = extract_transform_name( fcu->rna_path );
+ transformName = extract_transform_name(fcu->rna_path);
- if ((!strcmp(transformName, "lens"))||
- (!strcmp(transformName, "ortho_scale"))||
- (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start")))
+ if ((!strcmp(transformName, "lens")) ||
+ (!strcmp(transformName, "ortho_scale")) ||
+ (!strcmp(transformName, "clip_end")) || (!strcmp(transformName, "clip_start")))
{
dae_animation(ob, fcu, transformName, true);
}
@@ -120,19 +116,19 @@ void AnimationExporter::operator() (Object *ob)
//Export Material parameter animations.
for (int a = 0; a < ob->totcol; a++) {
- Material *ma = give_current_material(ob, a+1);
+ Material *ma = give_current_material(ob, a + 1);
if (!ma) continue;
if (ma->adt && ma->adt->action) {
/* isMatAnim = true; */
- fcu = (FCurve*)ma->adt->action->curves.first;
+ fcu = (FCurve *)ma->adt->action->curves.first;
while (fcu) {
- transformName = extract_transform_name( fcu->rna_path );
+ transformName = extract_transform_name(fcu->rna_path);
- if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) ||
- (!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha")) ||
- (!strcmp(transformName, "ior")))
+ if ((!strcmp(transformName, "specular_hardness")) || (!strcmp(transformName, "specular_color")) ||
+ (!strcmp(transformName, "diffuse_color")) || (!strcmp(transformName, "alpha")) ||
+ (!strcmp(transformName, "ior")))
{
- dae_animation(ob, fcu, transformName, true, ma );
+ dae_animation(ob, fcu, transformName, true, ma);
}
fcu = fcu->next;
}
@@ -142,33 +138,33 @@ void AnimationExporter::operator() (Object *ob)
}
//euler sources from quternion sources
-float * AnimationExporter::get_eul_source_for_quat(Object *ob )
+float *AnimationExporter::get_eul_source_for_quat(Object *ob)
{
- FCurve *fcu = (FCurve*)ob->adt->action->curves.first;
+ FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
const int keys = fcu->totvert;
- float *quat = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values");
- float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
+ float *quat = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values");
+ float *eul = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
float temp_quat[4];
float temp_eul[3];
while (fcu) {
- char * transformName = extract_transform_name( fcu->rna_path );
+ char *transformName = extract_transform_name(fcu->rna_path);
- if ( !strcmp(transformName, "rotation_quaternion") ) {
- for ( int i = 0 ; i < fcu->totvert ; i++) {
- *(quat + ( i * 4 ) + fcu->array_index) = fcu->bezt[i].vec[1][1];
+ if (!strcmp(transformName, "rotation_quaternion") ) {
+ for (int i = 0; i < fcu->totvert; i++) {
+ *(quat + (i * 4) + fcu->array_index) = fcu->bezt[i].vec[1][1];
}
}
fcu = fcu->next;
}
- for ( int i = 0 ; i < keys ; i++) {
- for ( int j = 0;j<4;j++)
- temp_quat[j] = quat[(i*4)+j];
+ for (int i = 0; i < keys; i++) {
+ for (int j = 0; j < 4; j++)
+ temp_quat[j] = quat[(i * 4) + j];
quat_to_eul(temp_eul, temp_quat);
- for (int k = 0;k<3;k++)
- eul[i*3 + k] = temp_eul[k];
+ for (int k = 0; k < 3; k++)
+ eul[i * 3 + k] = temp_eul[k];
}
MEM_freeN(quat);
@@ -177,22 +173,22 @@ float * AnimationExporter::get_eul_source_for_quat(Object *ob )
}
//Get proper name for bones
-std::string AnimationExporter::getObjectBoneName( Object* ob, const FCurve* fcu )
+std::string AnimationExporter::getObjectBoneName(Object *ob, const FCurve *fcu)
{
//hard-way to derive the bone name from rna_path. Must find more compact method
std::string rna_path = std::string(fcu->rna_path);
- char* boneName = strtok((char *)rna_path.c_str(), "\"");
+ char *boneName = strtok((char *)rna_path.c_str(), "\"");
boneName = strtok(NULL, "\"");
- if ( boneName != NULL )
+ if (boneName != NULL)
return /*id_name(ob) + "_" +*/ std::string(boneName);
else
return id_name(ob);
}
//convert f-curves to animation curves and write
-void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName, bool is_param, Material * ma )
+void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma)
{
const char *axis_name = NULL;
char anim_id[200];
@@ -200,15 +196,15 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
bool has_tangents = false;
bool quatRotation = false;
- if ( !strcmp(transformName, "rotation_quaternion") ) {
+ if (!strcmp(transformName, "rotation_quaternion") ) {
fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n");
quatRotation = true;
return;
}
//axis names for colors
- else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")||
- (!strcmp(transformName, "alpha")))
+ else if (!strcmp(transformName, "color") || !strcmp(transformName, "specular_color") || !strcmp(transformName, "diffuse_color") ||
+ (!strcmp(transformName, "alpha")))
{
const char *axis_names[] = {"R", "G", "B"};
if (fcu->array_index < 3)
@@ -217,7 +213,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
//axis names for transforms
else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
- (!strcmp(transformName, "rotation_euler"))||(!strcmp(transformName, "rotation_quaternion")))
+ (!strcmp(transformName, "rotation_euler")) || (!strcmp(transformName, "rotation_quaternion")))
{
const char *axis_names[] = {"X", "Y", "Z"};
if (fcu->array_index < 3)
@@ -233,16 +229,16 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
//Create anim Id
if (ob->type == OB_ARMATURE) {
ob_name = getObjectBoneName(ob, fcu);
- BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(),
- transformName, axis_name);
+ BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char *)translate_id(ob_name).c_str(),
+ transformName, axis_name);
}
else {
if (ma)
ob_name = id_name(ob) + "_material";
else
ob_name = id_name(ob);
- BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
- fcu->rna_path, axis_name);
+ BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(),
+ fcu->rna_path, axis_name);
}
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
@@ -256,16 +252,16 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
//quat rotations are skipped for now, because of complications with determining axis.
if (quatRotation) {
float *eul = get_eul_source_for_quat(ob);
- float *eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values");
- for (int i = 0 ; i< fcu->totvert ; i++) {
- eul_axis[i] = eul[i*3 + fcu->array_index];
+ float *eul_axis = (float *)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values");
+ for (int i = 0; i < fcu->totvert; i++) {
+ eul_axis[i] = eul[i * 3 + fcu->array_index];
}
- output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis, fcu->totvert, quatRotation, anim_id, axis_name);
+ output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis, fcu->totvert, quatRotation, anim_id, axis_name);
MEM_freeN(eul);
MEM_freeN(eul_axis);
}
else {
- output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
+ output_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
}
// create interpolations source
std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents);
@@ -300,21 +296,21 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
std::string target;
- if ( !is_param )
+ if (!is_param)
target = translate_id(ob_name) +
"/" + get_transform_sid(fcu->rna_path, -1, axis_name, true);
else {
- if ( ob->type == OB_LAMP )
+ if (ob->type == OB_LAMP)
target = get_light_id(ob) +
"/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true);
- if ( ob->type == OB_CAMERA )
+ if (ob->type == OB_CAMERA)
target = get_camera_id(ob) +
"/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true);
- if ( ma )
+ if (ma)
target = translate_id(id_name(ma)) + "-effect" +
- "/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true);
+ "/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true);
}
addChannel(COLLADABU::URI(empty, sampler_id), target);
@@ -334,18 +330,18 @@ void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone)
sample_and_write_bone_animation_matrix(ob_arm, bone);
- for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next)
+ for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next)
write_bone_animation_matrix(ob_arm, child);
}
-bool AnimationExporter::is_bone_deform_group(Bone * bone)
+bool AnimationExporter::is_bone_deform_group(Bone *bone)
{
bool is_def;
//Check if current bone is deform
- if ((bone->flag & BONE_NO_DEFORM) == 0 ) return true;
+ if ((bone->flag & BONE_NO_DEFORM) == 0) return true;
//Check child bones
else {
- for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) {
+ for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
//loop through all the children until deform bone is found, and then return
is_def = is_bone_deform_group(child);
if (is_def) return true;
@@ -357,16 +353,16 @@ bool AnimationExporter::is_bone_deform_group(Bone * bone)
void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone)
{
- bArmature *arm = (bArmature*)ob_arm->data;
+ bArmature *arm = (bArmature *)ob_arm->data;
int flag = arm->flag;
std::vector<float> fra;
//char prefix[256];
- FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first;
+ FCurve *fcu = (FCurve *)ob_arm->adt->action->curves.first;
while (fcu) {
std::string bone_name = getObjectBoneName(ob_arm, fcu);
- int val = BLI_strcasecmp((char*)bone_name.c_str(), bone->name);
- if (val==0) break;
+ int val = BLI_strcasecmp((char *)bone_name.c_str(), bone->name);
+ if (val == 0) break;
fcu = fcu->next;
}
@@ -383,7 +379,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
}
if (fra.size()) {
- dae_baked_animation(fra, ob_arm, bone );
+ dae_baked_animation(fra, ob_arm, bone);
}
if (flag & ARM_RESTPOS)
@@ -400,8 +396,8 @@ void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_
if (!fra.size())
return;
- BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
- (char*)translate_id(bone_name).c_str(), "pose_matrix");
+ BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(),
+ (char *)translate_id(bone_name).c_str(), "pose_matrix");
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
@@ -410,7 +406,7 @@ void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_
// create output source
std::string output_id;
- output_id = create_4x4_source( fra, ob_arm, bone, anim_id);
+ output_id = create_4x4_source(fra, ob_arm, bone, anim_id);
// create interpolations source
std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, "");
@@ -448,15 +444,15 @@ void AnimationExporter::dae_bone_animation(std::vector<float> &fra, float *value
char rna_path[200];
BLI_snprintf(rna_path, sizeof(rna_path), "pose.bones[\"%s\"].%s", bone_name.c_str(),
- tm_type == 0 ? "rotation_quaternion" : (tm_type == 1 ? "scale" : "location"));
+ tm_type == 0 ? "rotation_quaternion" : (tm_type == 1 ? "scale" : "location"));
if (axis > -1)
axis_name = axis_names[axis];
std::string transform_sid = get_transform_sid(NULL, tm_type, axis_name, false);
- BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
- (char*)translate_id(bone_name).c_str(), (char*)transform_sid.c_str());
+ BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(),
+ (char *)translate_id(bone_name).c_str(), (char *)transform_sid.c_str());
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
@@ -522,7 +518,7 @@ std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Sem
}
void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
- COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform)
+ COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform)
{
switch (semantic) {
case COLLADASW::InputSemantic::INPUT:
@@ -537,14 +533,14 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
param.push_back(axis);
}
else
- if ( transform ) {
- param.push_back("TRANSFORM");
- }
- else { //assumes if axis isn't specified all axises are added
- param.push_back("X");
- param.push_back("Y");
- param.push_back("Z");
- }
+ if (transform) {
+ param.push_back("TRANSFORM");
+ }
+ else { //assumes if axis isn't specified all axises are added
+ param.push_back("X");
+ param.push_back("Y");
+ param.push_back("Z");
+ }
}
break;
case COLLADASW::InputSemantic::IN_TANGENT:
@@ -710,7 +706,7 @@ std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemanti
//if (semantic == COLLADASW::InputSemantic::INPUT)
val = convert_time(val);
/*else if (is_rot)
- val = convert_angle(val);*/
+ val = convert_angle(val);*/
source.appendValues(val);
}
@@ -719,7 +715,7 @@ std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemanti
return source_id;
}
-std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Object * ob_arm, Bone *bone, const std::string& anim_id)
+std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Object *ob_arm, Bone *bone, const std::string& anim_id)
{
COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
std::string source_id = anim_id + get_semantic_suffix(semantic);
@@ -847,11 +843,11 @@ std::string AnimationExporter::create_interpolation_source(FCurve *fcu, const st
*has_tangents = false;
for (unsigned int i = 0; i < fcu->totvert; i++) {
- if (fcu->bezt[i].ipo==BEZT_IPO_BEZ) {
+ if (fcu->bezt[i].ipo == BEZT_IPO_BEZ) {
source.appendValues(BEZIER_NAME);
*has_tangents = true;
}
- else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) {
+ else if (fcu->bezt[i].ipo == BEZT_IPO_CONST) {
source.appendValues(STEP_NAME);
}
else { // BEZT_IPO_LIN
@@ -991,7 +987,7 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type,
std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis)
{
std::string tm_name;
- bool is_rotation =false;
+ bool is_rotation = false;
// when given rna_path, determine tm_type from it
if (rna_path) {
char *name = extract_transform_name(rna_path);
@@ -1056,16 +1052,16 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co
if (is_rotation)
return tm_name + std::string(axis_name) + ".ANGLE";
else
- if (axis_name[0])
- return tm_name + "." + std::string(axis_name);
- else
- return tm_name;
+ if (axis_name[0])
+ return tm_name + "." + std::string(axis_name);
+ else
+ return tm_name;
}
return std::string("");
}
-char* AnimationExporter::extract_transform_name(char *rna_path)
+char *AnimationExporter::extract_transform_name(char *rna_path)
{
char *dot = strrchr(rna_path, '.');
return dot ? (dot + 1) : rna_path;
@@ -1074,7 +1070,7 @@ char* AnimationExporter::extract_transform_name(char *rna_path)
//find keyframes of all the objects animations
void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra)
{
- FCurve *fcu= (FCurve*)ob->adt->action->curves.first;
+ FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
for (; fcu; fcu = fcu->next) {
@@ -1101,7 +1097,7 @@ void AnimationExporter::enable_fcurves(bAction *act, char *bone_name)
if (bone_name)
BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name);
- for (fcu = (FCurve*)act->curves.first; fcu; fcu = fcu->next) {
+ for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) {
if (bone_name) {
if (!strncmp(fcu->rna_path, prefix, strlen(prefix)))
fcu->flag &= ~FCURVE_DISABLED;
@@ -1116,34 +1112,33 @@ void AnimationExporter::enable_fcurves(bAction *act, char *bone_name)
bool AnimationExporter::hasAnimations(Scene *sce)
{
- Base *base= (Base*) sce->base.first;
+ LinkNode *node;
- while (base) {
- Object *ob = base->object;
+ for(node=this->export_settings->export_set; node; node=node->next) {
+ Object *ob = (Object *)node->link;
FCurve *fcu = 0;
//Check for object transform animations
if (ob->adt && ob->adt->action)
- fcu = (FCurve*)ob->adt->action->curves.first;
+ fcu = (FCurve *)ob->adt->action->curves.first;
//Check for Lamp parameter animations
- else if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
- fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
+ else if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action)
+ fcu = (FCurve *)(((Lamp *)ob->data)->adt->action->curves.first);
//Check for Camera parameter animations
- else if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action )
- fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
+ else if ( (ob->type == OB_CAMERA) && ((Camera *)ob->data)->adt && ((Camera *)ob->data)->adt->action)
+ fcu = (FCurve *)(((Camera *)ob->data)->adt->action->curves.first);
//Check Material Effect parameter animations.
for (int a = 0; a < ob->totcol; a++) {
- Material *ma = give_current_material(ob, a+1);
+ Material *ma = give_current_material(ob, a + 1);
if (!ma) continue;
if (ma->adt && ma->adt->action) {
- fcu = (FCurve*)ma->adt->action->curves.first;
+ fcu = (FCurve *)ma->adt->action->curves.first;
}
}
- if ( fcu)
+ if (fcu)
return true;
- base= base->next;
}
return false;
}
@@ -1156,12 +1151,12 @@ void AnimationExporter::find_rotation_frames(Object *ob, std::vector<float> &fra
else if (rotmode == ROT_MODE_QUAT)
find_frames(ob, fra, prefix, "rotation_quaternion");
/*else if (rotmode == ROT_MODE_AXISANGLE)
- ;*/
+ ;*/
}
void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name)
{
- FCurve *fcu= (FCurve*)ob->adt->action->curves.first;
+ FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
for (; fcu; fcu = fcu->next) {
if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix)))
@@ -1193,13 +1188,13 @@ void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone)
for (int i = 0; i < 3; i++)
sample_and_write_bone_animation(ob_arm, bone, i);
- for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next)
+ for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next)
write_bone_animation(ob_arm, child);
}
void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type)
{
- bArmature *arm = (bArmature*)ob_arm->data;
+ bArmature *arm = (bArmature *)ob_arm->data;
int flag = arm->flag;
std::vector<float> fra;
char prefix[256];
@@ -1231,12 +1226,12 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
}
//v array will hold all values which will be exported.
if (fra.size()) {
- float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames");
+ float *values = (float *)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames");
sample_animation(values, fra, transform_type, bone, ob_arm, pchan);
if (transform_type == 0) {
// write x, y, z curves separately if it is rotation
- float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames");
+ float *axisValues = (float *)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames");
for (int i = 0; i < 3; i++) {
for (unsigned int j = 0; j < fra.size(); j++)
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 45d7d4a7684..625804e4ecd 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -62,8 +62,8 @@ static const char *bc_get_joint_name(T *node)
FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path)
{
- FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve");
- fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+ FCurve *fcu = (FCurve *)MEM_callocN(sizeof(FCurve), "FCurve");
+ fcu->flag = (FCURVE_VISIBLE | FCURVE_AUTO_HANDLES | FCURVE_SELECTED);
fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
fcu->array_index = array_index;
return fcu;
@@ -92,18 +92,18 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
size_t dim = curve->getOutDimension();
unsigned int i;
- std::vector<FCurve*>& fcurves = curve_map[curve->getUniqueId()];
+ std::vector<FCurve *>& fcurves = curve_map[curve->getUniqueId()];
switch (dim) {
- case 1: // X, Y, Z or angle
- case 3: // XYZ
- case 4:
- case 16: // matrix
+ case 1: // X, Y, Z or angle
+ case 3: // XYZ
+ case 4:
+ case 16: // matrix
{
- for (i = 0; i < dim; i++ ) {
- FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve");
+ for (i = 0; i < dim; i++) {
+ FCurve *fcu = (FCurve *)MEM_callocN(sizeof(FCurve), "FCurve");
- fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+ fcu->flag = (FCURVE_VISIBLE | FCURVE_AUTO_HANDLES | FCURVE_SELECTED);
// fcu->rna_path = BLI_strdupn(path, strlen(path));
fcu->array_index = 0;
fcu->totvert = curve->getKeyCount();
@@ -119,19 +119,19 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
- if ( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
- curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP)
+ if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
+ curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP)
{
COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues();
COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues();
// intangent
- bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim ) + (2 * i)) * fps;
- bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim )+ (2 * i) + 1);
+ bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i)) * fps;
+ bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i) + 1);
// outtangent
- bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps;
- bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1);
+ bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i)) * fps;
+ bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i) + 1);
if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER)
bez.ipo = BEZT_IPO_BEZ;
else
@@ -154,11 +154,11 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
}
}
break;
- default:
- fprintf(stderr, "Output dimension of %d is not yet supported (animation id = %s)\n", (int)dim, curve->getOriginalId().c_str());
+ default:
+ fprintf(stderr, "Output dimension of %d is not yet supported (animation id = %s)\n", (int)dim, curve->getOriginalId().c_str());
}
- for (std::vector<FCurve*>::iterator it = fcurves.begin(); it != fcurves.end(); it++)
+ for (std::vector<FCurve *>::iterator it = fcurves.begin(); it != fcurves.end(); it++)
unused_curves.push_back(*it);
}
@@ -174,14 +174,14 @@ void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
}
-void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated)
+void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated)
{
bAction *act;
- if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1);
+ if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
else act = ob->adt->action;
- std::vector<FCurve*>::iterator it;
+ std::vector<FCurve *>::iterator it;
int i;
#if 0
@@ -211,7 +211,7 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve*>&
/* no matching groups, so add one */
if (grp == NULL) {
/* Add a new group, and make it active */
- grp = (bActionGroup*)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
+ grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
grp->flag = AGRP_SELECTED;
BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
@@ -240,22 +240,23 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve*>&
}
AnimationImporter::AnimationImporter(UnitConverter *conv, ArmatureImporter *arm, Scene *scene) :
- TransformReader(conv), armature_importer(arm), scene(scene) { }
+ TransformReader(conv), armature_importer(arm), scene(scene) {
+}
AnimationImporter::~AnimationImporter()
{
// free unused FCurves
- for (std::vector<FCurve*>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
+ for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
free_fcurve(*it);
if (unused_curves.size())
fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size());
}
-bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim)
+bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
{
if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
- COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve*)anim;
+ COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim;
// XXX Don't know if it's necessary
// Should we check outPhysicalDimension?
@@ -270,15 +271,15 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim)
if (interp != COLLADAFW::AnimationCurve::INTERPOLATION_MIXED) {
switch (interp) {
- case COLLADAFW::AnimationCurve::INTERPOLATION_LINEAR:
- case COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER:
- case COLLADAFW::AnimationCurve::INTERPOLATION_STEP:
- animation_to_fcurves(curve);
- break;
- default:
- // TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types
- fprintf(stderr, "CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n");
- break;
+ case COLLADAFW::AnimationCurve::INTERPOLATION_LINEAR:
+ case COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER:
+ case COLLADAFW::AnimationCurve::INTERPOLATION_STEP:
+ animation_to_fcurves(curve);
+ break;
+ default:
+ // TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types
+ fprintf(stderr, "CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n");
+ break;
}
}
else {
@@ -294,7 +295,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim)
}
// called on post-process stage after writeVisualScenes
-bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* animlist)
+bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist)
{
const COLLADAFW::UniqueId& animlist_id = animlist->getUniqueId();
@@ -334,14 +335,14 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
bActionGroup *grp;
int i;
- for (grp = (bActionGroup*)act->groups.first; grp; grp = grp->next) {
+ for (grp = (bActionGroup *)act->groups.first; grp; grp = grp->next) {
FCurve *eulcu[3] = {NULL, NULL, NULL};
if (fcurves_actionGroup_map.find(grp) == fcurves_actionGroup_map.end())
continue;
- std::vector<FCurve*> &rot_fcurves = fcurves_actionGroup_map[grp];
+ std::vector<FCurve *> &rot_fcurves = fcurves_actionGroup_map[grp];
if (rot_fcurves.size() > 3) continue;
@@ -387,10 +388,10 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
/*eul_to_mat3(rot, eul);
- mul_m3_m3m3(rel, irest, rot);
+ mul_m3_m3m3(rel, irest, rot);
- mat3_to_quat(quat, rel);
- */
+ mat3_to_quat(quat, rel);
+ */
eul_to_quat(quat, eul);
@@ -415,7 +416,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
bPoseChannel *pchan;
- for (pchan = (bPoseChannel*)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
pchan->rotmode = ROT_MODE_QUAT;
}
}
@@ -423,9 +424,9 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
//sets the rna_path and array index to curve
-void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves, const char* rna_path, int array_index )
+void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves, const char *rna_path, int array_index)
{
- std::vector<FCurve*>::iterator it;
+ std::vector<FCurve *>::iterator it;
int i;
for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) {
FCurve *fcu = *it;
@@ -438,19 +439,19 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves, const char*
}
}
-void AnimationImporter::unused_fcurve(std::vector<FCurve*>* curves)
+void AnimationImporter::unused_fcurve(std::vector<FCurve *> *curves)
{
// when an error happens and we can't actually use curve remove it from unused_curves
- std::vector<FCurve*>::iterator it;
+ std::vector<FCurve *>::iterator it;
for (it = curves->begin(); it != curves->end(); it++) {
FCurve *fcu = *it;
unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
}
}
-void AnimationImporter::find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves)
+void AnimationImporter::find_frames(std::vector<float> *frames, std::vector<FCurve *> *curves)
{
- std::vector<FCurve*>::iterator iter;
+ std::vector<FCurve *>::iterator iter;
for (iter = curves->begin(); iter != curves->end(); iter++) {
FCurve *fcu = *iter;
@@ -466,16 +467,16 @@ void AnimationImporter::find_frames( std::vector<float>* frames, std::vector<FCu
}
//creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation.
-void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * transform,
- const COLLADAFW::AnimationList::AnimationBinding * binding,
- std::vector<FCurve*>* curves, bool is_joint, char * joint_path)
+void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *transform,
+ const COLLADAFW::AnimationList::AnimationBinding *binding,
+ std::vector<FCurve *> *curves, bool is_joint, char *joint_path)
{
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
//to check if the no of curves are valid
- bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
+ bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE || tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) {
@@ -488,85 +489,85 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
switch (tm_type) {
case COLLADAFW::Transformation::TRANSLATE:
case COLLADAFW::Transformation::SCALE:
- {
- bool loc = tm_type == COLLADAFW::Transformation::TRANSLATE;
- if (is_joint)
- BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, loc ? "location" : "scale");
- else
- BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path));
+ {
+ bool loc = tm_type == COLLADAFW::Transformation::TRANSLATE;
+ if (is_joint)
+ BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, loc ? "location" : "scale");
+ else
+ BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path));
- switch (binding->animationClass) {
- case COLLADAFW::AnimationList::POSITION_X:
- modify_fcurve(curves, rna_path, 0 );
- break;
- case COLLADAFW::AnimationList::POSITION_Y:
- modify_fcurve(curves, rna_path, 1 );
- break;
- case COLLADAFW::AnimationList::POSITION_Z:
- modify_fcurve(curves, rna_path, 2 );
- break;
- case COLLADAFW::AnimationList::POSITION_XYZ:
- modify_fcurve(curves, rna_path, -1 );
- break;
- default:
- unused_fcurve(curves);
- fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
- binding->animationClass, loc ? "TRANSLATE" : "SCALE");
- }
- break;
+ switch (binding->animationClass) {
+ case COLLADAFW::AnimationList::POSITION_X:
+ modify_fcurve(curves, rna_path, 0);
+ break;
+ case COLLADAFW::AnimationList::POSITION_Y:
+ modify_fcurve(curves, rna_path, 1);
+ break;
+ case COLLADAFW::AnimationList::POSITION_Z:
+ modify_fcurve(curves, rna_path, 2);
+ break;
+ case COLLADAFW::AnimationList::POSITION_XYZ:
+ modify_fcurve(curves, rna_path, -1);
+ break;
+ default:
+ unused_fcurve(curves);
+ fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
+ binding->animationClass, loc ? "TRANSLATE" : "SCALE");
}
+ break;
+ }
case COLLADAFW::Transformation::ROTATE:
- {
- if (is_joint)
- BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path);
- else
- BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path));
- std::vector<FCurve*>::iterator iter;
- for (iter = curves->begin(); iter != curves->end(); iter++) {
- FCurve* fcu = *iter;
-
- //if transform is rotation the fcurves values must be turned in to radian.
- if (is_rotation)
- fcurve_deg_to_rad(fcu);
- }
- COLLADAFW::Rotate* rot = (COLLADAFW::Rotate*)transform;
- COLLADABU::Math::Vector3& axis = rot->getRotationAxis();
-
- switch (binding->animationClass) {
- case COLLADAFW::AnimationList::ANGLE:
- if (COLLADABU::Math::Vector3::UNIT_X == axis) {
- modify_fcurve(curves, rna_path, 0 );
- }
- else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
- modify_fcurve(curves, rna_path, 1 );
+ {
+ if (is_joint)
+ BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path);
+ else
+ BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path));
+ std::vector<FCurve *>::iterator iter;
+ for (iter = curves->begin(); iter != curves->end(); iter++) {
+ FCurve *fcu = *iter;
+
+ //if transform is rotation the fcurves values must be turned in to radian.
+ if (is_rotation)
+ fcurve_deg_to_rad(fcu);
}
- else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
- modify_fcurve(curves, rna_path, 2 );
+ COLLADAFW::Rotate *rot = (COLLADAFW::Rotate *)transform;
+ COLLADABU::Math::Vector3& axis = rot->getRotationAxis();
+
+ switch (binding->animationClass) {
+ case COLLADAFW::AnimationList::ANGLE:
+ if (COLLADABU::Math::Vector3::UNIT_X == axis) {
+ modify_fcurve(curves, rna_path, 0);
+ }
+ else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
+ modify_fcurve(curves, rna_path, 1);
+ }
+ else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
+ modify_fcurve(curves, rna_path, 2);
+ }
+ else
+ unused_fcurve(curves);
+ break;
+ case COLLADAFW::AnimationList::AXISANGLE:
+ // TODO convert axis-angle to quat? or XYZ?
+ default:
+ unused_fcurve(curves);
+ fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n",
+ binding->animationClass);
}
- else
- unused_fcurve(curves);
break;
- case COLLADAFW::AnimationList::AXISANGLE:
- // TODO convert axis-angle to quat? or XYZ?
- default:
- unused_fcurve(curves);
- fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n",
- binding->animationClass);
- }
- break;
- }
+ }
case COLLADAFW::Transformation::MATRIX:
/*{
- COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform;
- COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
- switch (binding->animationClass) {
- case COLLADAFW::AnimationList::TRANSFORM:
+ COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform;
+ COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
+ switch (binding->animationClass) {
+ case COLLADAFW::AnimationList::TRANSFORM:
- }
- }*/
+ }
+ }*/
unused_fcurve(curves);
break;
case COLLADAFW::Transformation::SKEW:
@@ -579,7 +580,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
}
//creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation.
-void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char * anim_type)
+void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char *anim_type)
{
char rna_path[100];
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
@@ -587,35 +588,35 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
- std::vector<FCurve*> animcurves;
+ std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
switch (bindings[j].animationClass) {
- case COLLADAFW::AnimationList::COLOR_R:
- modify_fcurve(&animcurves, rna_path, 0 );
- break;
- case COLLADAFW::AnimationList::COLOR_G:
- modify_fcurve(&animcurves, rna_path, 1 );
- break;
- case COLLADAFW::AnimationList::COLOR_B:
- modify_fcurve(&animcurves, rna_path, 2 );
- break;
- case COLLADAFW::AnimationList::COLOR_RGB:
- case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity
- modify_fcurve(&animcurves, rna_path, -1 );
- break;
+ case COLLADAFW::AnimationList::COLOR_R:
+ modify_fcurve(&animcurves, rna_path, 0);
+ break;
+ case COLLADAFW::AnimationList::COLOR_G:
+ modify_fcurve(&animcurves, rna_path, 1);
+ break;
+ case COLLADAFW::AnimationList::COLOR_B:
+ modify_fcurve(&animcurves, rna_path, 2);
+ break;
+ case COLLADAFW::AnimationList::COLOR_RGB:
+ case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity
+ modify_fcurve(&animcurves, rna_path, -1);
+ break;
- default:
- unused_fcurve(&animcurves);
- fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
- bindings[j].animationClass, "COLOR" );
+ default:
+ unused_fcurve(&animcurves);
+ fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
+ bindings[j].animationClass, "COLOR");
}
- std::vector<FCurve*>::iterator iter;
+ std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve * fcu = *iter;
+ FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
}
}
@@ -623,7 +624,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list
}
-void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char * anim_type)
+void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char *anim_type)
{
char rna_path[100];
if (animlist_map.find(listid) == animlist_map.end()) {
@@ -634,16 +635,16 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
- std::vector<FCurve*> animcurves;
+ std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
- modify_fcurve(&animcurves, rna_path, 0 );
- std::vector<FCurve*>::iterator iter;
+ modify_fcurve(&animcurves, rna_path, 0);
+ std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve * fcu = *iter;
+ FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
}
}
@@ -651,13 +652,13 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
}
-void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
- COLLADAFW::Transformation * tm )
+void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node,
+ COLLADAFW::Transformation *tm)
{
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
char joint_path[200];
- if ( is_joint )
+ if (is_joint)
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
std::vector<float> frames;
@@ -670,7 +671,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
get_joint_rest_mat(irest_dae, root, node);
invert_m4(irest_dae);
- Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name);
+ Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name);
if (!bone) {
fprintf(stderr, "cannot find bone \"%s\"\n", bone_name);
return;
@@ -751,13 +752,13 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
copy_m4_m4(mat, matfra);
}
- float rot[4], loc[3], scale[3];
+ float rot[4], loc[3], scale[3];
mat4_to_quat(rot, mat);
/*for ( int i = 0 ; i < 4 ; i ++ )
- {
- rot[i] = RAD2DEGF(rot[i]);
- }*/
+ {
+ rot[i] = RAD2DEGF(rot[i]);
+ }*/
copy_v3_v3(loc, mat[3]);
mat4_to_size(scale, mat);
@@ -771,12 +772,12 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
add_bezt(newcu[i], fra, scale[i - 7]);
}
}
- verify_adt_action((ID*)&ob->id, 1);
+ verify_adt_action((ID *)&ob->id, 1);
ListBase *curves = &ob->adt->action->curves;
// add curves
- for (int i= 0; i < totcu; i++) {
+ for (int i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
else
@@ -795,12 +796,12 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
}
-void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
- std::multimap<COLLADAFW::UniqueId, Object*>& object_map,
- std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
+void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
+ std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
+ std::multimap<COLLADAFW::UniqueId, Object *>& object_map,
+ std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
{
- AnimationImporter::AnimMix* animType = get_animation_type(node, FW_object_map );
+ AnimationImporter::AnimMix *animType = get_animation_type(node, FW_object_map);
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
@@ -810,17 +811,17 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
return;
}
- bAction * act;
+ bAction *act;
- if ( (animType->transform) != 0 ) {
+ if ( (animType->transform) != 0) {
/* const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; */ /* UNUSED */
char joint_path[200];
- if ( is_joint )
+ if (is_joint)
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
- if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1);
+ if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
else act = ob->adt->action;
//Get the list of animation curves of the object
@@ -847,11 +848,11 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
- std::vector<FCurve*> animcurves;
+ std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
- if ( is_matrix ) {
- apply_matrix_curves(ob, animcurves, root, node, transform );
+ if (is_matrix) {
+ apply_matrix_curves(ob, animcurves, root, node, transform);
}
else {
@@ -861,12 +862,12 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
}
else {
//calculate rnapaths and array index of fcurves according to transformation and animation class
- Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path );
+ Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path);
- std::vector<FCurve*>::iterator iter;
+ std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve * fcu = *iter;
+ FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
}
@@ -882,9 +883,9 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
}
if ((animType->light) != 0) {
- Lamp * lamp = (Lamp*) ob->data;
+ Lamp *lamp = (Lamp *) ob->data;
- if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID*)&lamp->id, 1);
+ if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID *)&lamp->id, 1);
else act = lamp->adt->action;
ListBase *AnimCurves = &(act->curves);
@@ -899,63 +900,63 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
Assign_color_animations(listid, AnimCurves, "color");
}
- if ((animType->light & LIGHT_FOA) != 0 ) {
+ if ((animType->light & LIGHT_FOA) != 0) {
const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle());
const COLLADAFW::UniqueId& listid = foa->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "spot_size");
+ Assign_float_animations(listid, AnimCurves, "spot_size");
}
- if ( (animType->light & LIGHT_FOE) != 0 ) {
+ if ( (animType->light & LIGHT_FOE) != 0) {
const COLLADAFW::AnimatableFloat *foe = &(light->getFallOffExponent());
const COLLADAFW::UniqueId& listid = foe->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "spot_blend");
+ Assign_float_animations(listid, AnimCurves, "spot_blend");
}
}
}
if ( (animType->camera) != 0) {
- Camera * camera = (Camera*) ob->data;
+ Camera *camera = (Camera *) ob->data;
- if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID*)&camera->id, 1);
+ if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID *)&camera->id, 1);
else act = camera->adt->action;
ListBase *AnimCurves = &(act->curves);
- const COLLADAFW::InstanceCameraPointerArray& nodeCameras= node->getInstanceCameras();
+ const COLLADAFW::InstanceCameraPointerArray& nodeCameras = node->getInstanceCameras();
for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
- if ((animType->camera & CAMERA_XFOV) != 0 ) {
+ if ((animType->camera & CAMERA_XFOV) != 0) {
const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov());
const COLLADAFW::UniqueId& listid = xfov->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "lens");
+ Assign_float_animations(listid, AnimCurves, "lens");
}
- else if ((animType->camera & CAMERA_XMAG) != 0 ) {
+ else if ((animType->camera & CAMERA_XMAG) != 0) {
const COLLADAFW::AnimatableFloat *xmag = &(camera->getXMag());
const COLLADAFW::UniqueId& listid = xmag->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "ortho_scale");
+ Assign_float_animations(listid, AnimCurves, "ortho_scale");
}
- if ((animType->camera & CAMERA_ZFAR) != 0 ) {
+ if ((animType->camera & CAMERA_ZFAR) != 0) {
const COLLADAFW::AnimatableFloat *zfar = &(camera->getFarClippingPlane());
const COLLADAFW::UniqueId& listid = zfar->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "clip_end");
+ Assign_float_animations(listid, AnimCurves, "clip_end");
}
- if ((animType->camera & CAMERA_ZNEAR) != 0 ) {
+ if ((animType->camera & CAMERA_ZNEAR) != 0) {
const COLLADAFW::AnimatableFloat *znear = &(camera->getNearClippingPlane());
const COLLADAFW::UniqueId& listid = znear->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "clip_start");
+ Assign_float_animations(listid, AnimCurves, "clip_start");
}
}
}
- if ( animType->material != 0) {
+ if (animType->material != 0) {
Material *ma = give_current_material(ob, 1);
- if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1);
+ if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID *)&ma->id, 1);
else act = ma->adt->action;
ListBase *AnimCurves = &(act->curves);
@@ -972,25 +973,25 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
if ((animType->material & MATERIAL_SHININESS) != 0) {
const COLLADAFW::FloatOrParam *shin = &(efc->getShininess());
const COLLADAFW::UniqueId& listid = shin->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "specular_hardness" );
+ Assign_float_animations(listid, AnimCurves, "specular_hardness");
}
if ((animType->material & MATERIAL_IOR) != 0) {
const COLLADAFW::FloatOrParam *ior = &(efc->getIndexOfRefraction());
const COLLADAFW::UniqueId& listid = ior->getAnimationList();
- Assign_float_animations( listid, AnimCurves, "raytrace_transparency.ior" );
+ Assign_float_animations(listid, AnimCurves, "raytrace_transparency.ior");
}
if ((animType->material & MATERIAL_SPEC_COLOR) != 0) {
const COLLADAFW::ColorOrTexture *cot = &(efc->getSpecular());
const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList();
- Assign_color_animations( listid, AnimCurves, "specular_color" );
+ Assign_color_animations(listid, AnimCurves, "specular_color");
}
if ((animType->material & MATERIAL_DIFF_COLOR) != 0) {
const COLLADAFW::ColorOrTexture *cot = &(efc->getDiffuse());
const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList();
- Assign_color_animations( listid, AnimCurves, "diffuse_color" );
+ Assign_color_animations(listid, AnimCurves, "diffuse_color");
}
}
}
@@ -998,7 +999,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
}
}
-void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm)
+void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
{
const char *bone_name = bc_get_joint_name(node);
char joint_path[200];
@@ -1010,9 +1011,9 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
// convert degrees to radians
if (tm->getTransformationType() == COLLADAFW::Transformation::ROTATE) {
- std::vector<FCurve*>::iterator iter;
+ std::vector<FCurve *>::iterator iter;
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve* fcu = *iter;
+ FCurve *fcu = *iter;
fcurve_deg_to_rad(fcu);
}
@@ -1025,7 +1026,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
get_joint_rest_mat(irest_dae, root, node);
invert_m4(irest_dae);
- Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name);
+ Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name);
if (!bone) {
fprintf(stderr, "cannot find bone \"%s\"\n", bone_name);
return;
@@ -1100,7 +1101,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
// calc special matrix
mul_serie_m4(mat, irest, temp, irest_dae, rest, NULL, NULL, NULL, NULL);
- float rot[4], loc[3], scale[3];
+ float rot[4], loc[3], scale[3];
mat4_to_quat(rot, mat);
copy_v3_v3(loc, mat[3]);
@@ -1116,10 +1117,10 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
add_bezt(newcu[i], fra, scale[i - 7]);
}
}
- verify_adt_action((ID*)&ob->id, 1);
+ verify_adt_action((ID *)&ob->id, 1);
// add curves
- for (int i= 0; i < totcu; i++) {
+ for (int i = 0; i < totcu; i++) {
add_bone_fcurve(ob, node, newcu[i]);
}
@@ -1130,8 +1131,8 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
//Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
-AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLADAFW::Node * node,
- std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
+AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAFW::Node *node,
+ std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
{
AnimMix *types = new AnimMix();
@@ -1147,7 +1148,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
continue;
}
else {
- types->transform = types->transform|NODE_TRANSFORM;
+ types->transform = types->transform | NODE_TRANSFORM;
break;
}
}
@@ -1159,7 +1160,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
types->light = setAnimType(&(light->getFallOffAngle()), (types->light), LIGHT_FOA);
types->light = setAnimType(&(light->getFallOffExponent()), (types->light), LIGHT_FOE);
- if ( types->light != 0) break;
+ if (types->light != 0) break;
}
@@ -1167,7 +1168,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
- if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) {
+ if (camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE) {
types->camera = setAnimType(&(camera->getXMag()), (types->camera), CAMERA_XFOV);
}
else {
@@ -1176,7 +1177,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
types->camera = setAnimType(&(camera->getFarClippingPlane()), (types->camera), CAMERA_ZFAR);
types->camera = setAnimType(&(camera->getNearClippingPlane()), (types->camera), CAMERA_ZNEAR);
- if ( types->camera != 0) break;
+ if (types->camera != 0) break;
}
@@ -1202,16 +1203,16 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
return types;
}
-int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop, int types, int addition)
+int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types, int addition)
{
const COLLADAFW::UniqueId& listid = prop->getAnimationList();
if (animlist_map.find(listid) != animlist_map.end())
- return types|addition;
+ return types | addition;
else return types;
}
// Is not used anymore.
-void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::Node * node, COLLADAFW::Transformation::TransformationType tm_type)
+void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::Node *node, COLLADAFW::Transformation::TransformationType tm_type)
{
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
@@ -1237,11 +1238,11 @@ void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::
if (bindings.getCount()) {
//for each AnimationBinding get the fcurves which animate the transform
for (unsigned int j = 0; j < bindings.getCount(); j++) {
- std::vector<FCurve*>& curves = curve_map[bindings[j].animation];
+ std::vector<FCurve *>& curves = curve_map[bindings[j].animation];
bool xyz = ((nodeTmType == COLLADAFW::Transformation::TRANSLATE || nodeTmType == COLLADAFW::Transformation::SCALE) && bindings[j].animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
if ((!xyz && curves.size() == 1) || (xyz && curves.size() == 3) || is_matrix) {
- std::vector<FCurve*>::iterator iter;
+ std::vector<FCurve *>::iterator iter;
for (iter = curves.begin(); iter != curves.end(); iter++) {
FCurve *fcu = *iter;
@@ -1275,10 +1276,10 @@ void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::
// animlist_map - map animlist id -> animlist
// curve_map - map anim id -> curve(s)
Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
- std::map<COLLADAFW::UniqueId, Object*>& object_map,
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
- COLLADAFW::Transformation::TransformationType tm_type,
- Object *par_job)
+ std::map<COLLADAFW::UniqueId, Object *>& object_map,
+ std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
+ COLLADAFW::Transformation::TransformationType tm_type,
+ Object *par_job)
{
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
@@ -1307,7 +1308,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
get_joint_rest_mat(irest_dae, root, node);
invert_m4(irest_dae);
- Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name);
+ Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name);
if (!bone) {
fprintf(stderr, "cannot find bone \"%s\"\n", bone_name);
return NULL;
@@ -1332,19 +1333,19 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
const char *tm_str = NULL;
switch (tm_type) {
- case COLLADAFW::Transformation::ROTATE:
- tm_str = "rotation_quaternion";
- break;
- case COLLADAFW::Transformation::SCALE:
- tm_str = "scale";
- break;
- case COLLADAFW::Transformation::TRANSLATE:
- tm_str = "location";
- break;
- case COLLADAFW::Transformation::MATRIX:
- break;
- default:
- return job;
+ case COLLADAFW::Transformation::ROTATE:
+ tm_str = "rotation_quaternion";
+ break;
+ case COLLADAFW::Transformation::SCALE:
+ tm_str = "scale";
+ break;
+ case COLLADAFW::Transformation::TRANSLATE:
+ tm_str = "location";
+ break;
+ case COLLADAFW::Transformation::MATRIX:
+ break;
+ default:
+ return job;
}
char rna_path[200];
@@ -1425,22 +1426,22 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
float val[4], rot[4], loc[3], scale[3];
switch (tm_type) {
- case COLLADAFW::Transformation::ROTATE:
- mat4_to_quat(val, mat);
- break;
- case COLLADAFW::Transformation::SCALE:
- mat4_to_size(val, mat);
- break;
- case COLLADAFW::Transformation::TRANSLATE:
- copy_v3_v3(val, mat[3]);
- break;
- case COLLADAFW::Transformation::MATRIX:
- mat4_to_quat(rot, mat);
- copy_v3_v3(loc, mat[3]);
- mat4_to_size(scale, mat);
- break;
- default:
- break;
+ case COLLADAFW::Transformation::ROTATE:
+ mat4_to_quat(val, mat);
+ break;
+ case COLLADAFW::Transformation::SCALE:
+ mat4_to_size(val, mat);
+ break;
+ case COLLADAFW::Transformation::TRANSLATE:
+ copy_v3_v3(val, mat[3]);
+ break;
+ case COLLADAFW::Transformation::MATRIX:
+ mat4_to_quat(rot, mat);
+ copy_v3_v3(loc, mat[3]);
+ mat4_to_size(scale, mat);
+ break;
+ default:
+ break;
}
// add keys
@@ -1461,22 +1462,22 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
#ifdef ARMATURE_TEST
if (is_joint) {
switch (tm_type) {
- case COLLADAFW::Transformation::ROTATE:
- mat4_to_quat(val, matfra);
- break;
- case COLLADAFW::Transformation::SCALE:
- mat4_to_size(val, matfra);
- break;
- case COLLADAFW::Transformation::TRANSLATE:
- copy_v3_v3(val, matfra[3]);
- break;
- case MATRIX:
- mat4_to_quat(rot, matfra);
- copy_v3_v3(loc, matfra[3]);
- mat4_to_size(scale, matfra);
- break;
- default:
- break;
+ case COLLADAFW::Transformation::ROTATE:
+ mat4_to_quat(val, matfra);
+ break;
+ case COLLADAFW::Transformation::SCALE:
+ mat4_to_size(val, matfra);
+ break;
+ case COLLADAFW::Transformation::TRANSLATE:
+ copy_v3_v3(val, matfra[3]);
+ break;
+ case MATRIX:
+ mat4_to_quat(rot, matfra);
+ copy_v3_v3(loc, matfra[3]);
+ mat4_to_size(scale, matfra);
+ break;
+ default:
+ break;
}
for (i = 0; i < totcu; i++) {
@@ -1496,7 +1497,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
#endif
}
- verify_adt_action((ID*)&ob->id, 1);
+ verify_adt_action((ID *)&ob->id, 1);
ListBase *curves = &ob->adt->action->curves;
@@ -1545,20 +1546,20 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
if (!evaluate_animation(tm, m, fra, nodename.c_str())) {
switch (type) {
- case COLLADAFW::Transformation::ROTATE:
- dae_rotate_to_mat4(tm, m);
- break;
- case COLLADAFW::Transformation::TRANSLATE:
- dae_translate_to_mat4(tm, m);
- break;
- case COLLADAFW::Transformation::SCALE:
- dae_scale_to_mat4(tm, m);
- break;
- case COLLADAFW::Transformation::MATRIX:
- dae_matrix_to_mat4(tm, m);
- break;
- default:
- fprintf(stderr, "unsupported transformation type %d\n", type);
+ case COLLADAFW::Transformation::ROTATE:
+ dae_rotate_to_mat4(tm, m);
+ break;
+ case COLLADAFW::Transformation::TRANSLATE:
+ dae_translate_to_mat4(tm, m);
+ break;
+ case COLLADAFW::Transformation::SCALE:
+ dae_scale_to_mat4(tm, m);
+ break;
+ case COLLADAFW::Transformation::MATRIX:
+ dae_matrix_to_mat4(tm, m);
+ break;
+ default:
+ fprintf(stderr, "unsupported transformation type %d\n", type);
}
// dae_matrix_to_mat4(tm, m);
@@ -1578,9 +1579,9 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
COLLADAFW::Transformation::TransformationType type = tm->getTransformationType();
if (type != COLLADAFW::Transformation::ROTATE &&
- type != COLLADAFW::Transformation::SCALE &&
- type != COLLADAFW::Transformation::TRANSLATE &&
- type != COLLADAFW::Transformation::MATRIX) {
+ type != COLLADAFW::Transformation::SCALE &&
+ type != COLLADAFW::Transformation::TRANSLATE &&
+ type != COLLADAFW::Transformation::MATRIX) {
fprintf(stderr, "animation of transformation %d is not supported yet\n", type);
return false;
}
@@ -1604,25 +1605,25 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
for (unsigned int j = 0; j < bindings.getCount(); j++) {
const COLLADAFW::AnimationList::AnimationBinding& binding = bindings[j];
- std::vector<FCurve*>& curves = curve_map[binding.animation];
+ std::vector<FCurve *>& curves = curve_map[binding.animation];
COLLADAFW::AnimationList::AnimationClass animclass = binding.animationClass;
char path[100];
switch (type) {
- case COLLADAFW::Transformation::ROTATE:
- BLI_snprintf(path, sizeof(path), "%s.rotate (binding %u)", node_id, j);
- break;
- case COLLADAFW::Transformation::SCALE:
- BLI_snprintf(path, sizeof(path), "%s.scale (binding %u)", node_id, j);
- break;
- case COLLADAFW::Transformation::TRANSLATE:
- BLI_snprintf(path, sizeof(path), "%s.translate (binding %u)", node_id, j);
- break;
- case COLLADAFW::Transformation::MATRIX:
- BLI_snprintf(path, sizeof(path), "%s.matrix (binding %u)", node_id, j);
- break;
- default:
- break;
+ case COLLADAFW::Transformation::ROTATE:
+ BLI_snprintf(path, sizeof(path), "%s.rotate (binding %u)", node_id, j);
+ break;
+ case COLLADAFW::Transformation::SCALE:
+ BLI_snprintf(path, sizeof(path), "%s.scale (binding %u)", node_id, j);
+ break;
+ case COLLADAFW::Transformation::TRANSLATE:
+ BLI_snprintf(path, sizeof(path), "%s.translate (binding %u)", node_id, j);
+ break;
+ case COLLADAFW::Transformation::MATRIX:
+ BLI_snprintf(path, sizeof(path), "%s.matrix (binding %u)", node_id, j);
+ break;
+ default:
+ break;
}
if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
@@ -1642,7 +1643,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
return false;
}
- COLLADABU::Math::Vector3& axis = ((COLLADAFW::Rotate*)tm)->getRotationAxis();
+ COLLADABU::Math::Vector3& axis = ((COLLADAFW::Rotate *)tm)->getRotationAxis();
float ax[3] = {(float)axis[0], (float)axis[1], (float)axis[2]};
float angle = evaluate_fcurve(curves[0], fra);
@@ -1662,23 +1663,23 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
}
switch (animclass) {
- case COLLADAFW::AnimationList::POSITION_X:
- vec[0] = evaluate_fcurve(curves[0], fra);
- break;
- case COLLADAFW::AnimationList::POSITION_Y:
- vec[1] = evaluate_fcurve(curves[0], fra);
- break;
- case COLLADAFW::AnimationList::POSITION_Z:
- vec[2] = evaluate_fcurve(curves[0], fra);
- break;
- case COLLADAFW::AnimationList::POSITION_XYZ:
- vec[0] = evaluate_fcurve(curves[0], fra);
- vec[1] = evaluate_fcurve(curves[1], fra);
- vec[2] = evaluate_fcurve(curves[2], fra);
- break;
- default:
- fprintf(stderr, "%s: animation class %d is not supported yet\n", path, animclass);
- break;
+ case COLLADAFW::AnimationList::POSITION_X:
+ vec[0] = evaluate_fcurve(curves[0], fra);
+ break;
+ case COLLADAFW::AnimationList::POSITION_Y:
+ vec[1] = evaluate_fcurve(curves[0], fra);
+ break;
+ case COLLADAFW::AnimationList::POSITION_Z:
+ vec[2] = evaluate_fcurve(curves[0], fra);
+ break;
+ case COLLADAFW::AnimationList::POSITION_XYZ:
+ vec[0] = evaluate_fcurve(curves[0], fra);
+ vec[1] = evaluate_fcurve(curves[1], fra);
+ vec[2] = evaluate_fcurve(curves[2], fra);
+ break;
+ default:
+ fprintf(stderr, "%s: animation class %d is not supported yet\n", path, animclass);
+ break;
}
}
else if (type == COLLADAFW::Transformation::MATRIX) {
@@ -1691,7 +1692,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
COLLADABU::Math::Matrix4 matrix;
int i = 0, j = 0;
- for (std::vector<FCurve*>::iterator it = curves.begin(); it != curves.end(); it++) {
+ for (std::vector<FCurve *>::iterator it = curves.begin(); it != curves.end(); it++) {
matrix.setElement(i, j, evaluate_fcurve(*it, fra));
j++;
if (j == 4) {
@@ -1704,7 +1705,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
COLLADAFW::Matrix tm(matrix);
dae_matrix_to_mat4(&tm, mat);
- std::vector<FCurve*>::iterator it;
+ std::vector<FCurve *>::iterator it;
return true;
}
@@ -1770,14 +1771,14 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4]
Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::Node *node, Object *par_job)
{
if (joint_objects.find(node->getUniqueId()) == joint_objects.end()) {
- Object *job = bc_add_object(scene, OB_EMPTY, (char*)get_joint_name(node));
+ Object *job = bc_add_object(scene, OB_EMPTY, (char *)get_joint_name(node));
job->lay = BKE_scene_base_find(scene, job)->lay = 2;
mul_v3_fl(job->size, 0.5f);
job->recalc |= OB_RECALC_OB;
- verify_adt_action((ID*)&job->id, 1);
+ verify_adt_action((ID *)&job->id, 1);
job->rotmode = ROT_MODE_QUAT;
@@ -1854,7 +1855,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv
/* no matching groups, so add one */
if (grp == NULL) {
/* Add a new group, and make it active */
- grp = (bActionGroup*)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
+ grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
grp->flag = AGRP_SELECTED;
BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
@@ -1874,7 +1875,7 @@ void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value)
memset(&bez, 0, sizeof(BezTriple));
bez.vec[1][0] = fra;
bez.vec[1][1] = value;
- bez.ipo = BEZT_IPO_LIN ;/* use default interpolation mode here... */
+ bez.ipo = BEZT_IPO_LIN; /* use default interpolation mode here... */
bez.f1 = bez.f2 = bez.f3 = SELECT;
bez.h1 = bez.h2 = HD_AUTO;
insert_bezt_fcurve(fcu, &bez, 0);
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index 6324853d91c..d6a93a36c6e 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -41,11 +41,13 @@
#include "COLLADAFWEffect.h"
#include "COLLADAFWInstanceGeometry.h"
+extern "C" {
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_lamp_types.h"
#include "DNA_camera_types.h"
+}
//#include "ArmatureImporter.h"
#include "TransformReader.h"
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 107a3fc5796..98047df8aa4 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -58,16 +58,17 @@ extern "C" {
// XXX exporter writes wrong data for shared armatures. A separate
// controller should be written for each armature-mesh binding how do
// we make controller ids then?
-ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryControllers(sw), export_settings(export_settings) {}
+ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryControllers(sw), export_settings(export_settings) {
+}
// write bone nodes
-void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene* sce,
- SceneExporter* se,
- std::list<Object*>& child_objects)
+void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
+ SceneExporter *se,
+ std::list<Object *>& child_objects)
{
// write bone nodes
- bArmature *arm = (bArmature*)ob_arm->data;
- for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) {
+ bArmature *arm = (bArmature *)ob_arm->data;
+ for (Bone *bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
// start from root bones
if (!bone->parent)
add_bone_node(bone, ob_arm, sce, se, child_objects);
@@ -82,7 +83,7 @@ bool ArmatureExporter::is_skinned_mesh(Object *ob)
bool ArmatureExporter::add_instance_controller(Object *ob)
{
Object *ob_arm = bc_get_assigned_armature(ob);
- bArmature *arm = (bArmature*)ob_arm->data;
+ bArmature *arm = (bArmature *)ob_arm->data;
const std::string& controller_id = get_controller_id(ob_arm, ob);
@@ -94,7 +95,7 @@ bool ArmatureExporter::add_instance_controller(Object *ob)
// write root bone URLs
Bone *bone;
- for (bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) {
+ for (bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
if (!bone->parent)
ins.addSkeleton(COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_joint_id(bone, ob_arm)));
}
@@ -112,7 +113,7 @@ void ArmatureExporter::export_controllers(Scene *sce)
openLibrary();
GeometryFunctor gf;
- gf.forEachMeshObjectInScene<ArmatureExporter>(sce, *this, this->export_settings->selected);
+ gf.forEachMeshObjectInExportSet<ArmatureExporter>(sce, *this, this->export_settings->export_set);
closeLibrary();
}
@@ -140,7 +141,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
{
objects.clear();
- Base *base= (Base*) sce->base.first;
+ Base *base = (Base *) sce->base.first;
while (base) {
Object *ob = base->object;
@@ -148,7 +149,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
objects.push_back(ob);
}
- base= base->next;
+ base = base->next;
}
}
#endif
@@ -159,9 +160,9 @@ std::string ArmatureExporter::get_joint_sid(Bone *bone, Object *ob_arm)
}
// parent_mat is armature-space
-void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
- SceneExporter* se,
- std::list<Object*>& child_objects)
+void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
+ SceneExporter *se,
+ std::list<Object *>& child_objects)
{
std::string node_id = get_joint_id(bone, ob_arm);
std::string node_name = std::string(bone->name);
@@ -175,14 +176,14 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
node.setNodeSid(node_sid);
/*if ( bone->childbase.first == NULL || BLI_countlist(&(bone->childbase))>=2)
- add_blender_leaf_bone( bone, ob_arm , node );
- else{*/
+ add_blender_leaf_bone( bone, ob_arm , node );
+ else{*/
node.start();
add_bone_transform(ob_arm, bone, node);
// Write nodes of childobjects, remove written objects from list
- std::list<Object*>::iterator i = child_objects.begin();
+ std::list<Object *>::iterator i = child_objects.begin();
while (i != child_objects.end()) {
if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) {
@@ -219,29 +220,32 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
else i++;
}
- for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) {
+ for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects);
}
node.end();
//}
}
-/*void ArmatureExporter::add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node)
+#if 0
+void ArmatureExporter::add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node)
{
node.start();
add_bone_transform(ob_arm, bone, node);
- node.addExtraTechniqueParameter("blender", "tip_x", bone->tail[0] );
- node.addExtraTechniqueParameter("blender", "tip_y", bone->tail[1] );
- node.addExtraTechniqueParameter("blender", "tip_z", bone->tail[2] );
+ node.addExtraTechniqueParameter("blender", "tip_x", bone->tail[0]);
+ node.addExtraTechniqueParameter("blender", "tip_y", bone->tail[1]);
+ node.addExtraTechniqueParameter("blender", "tip_z", bone->tail[2]);
- for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) {
+ for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects);
}
node.end();
-}*/
+}
+#endif
+
void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node)
{
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
@@ -292,7 +296,7 @@ std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob)
// ob should be of type OB_MESH
// both args are required
-void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
+void ArmatureExporter::export_controller(Object *ob, Object *ob_arm)
{
// joint names
// joint inverse bind matrices
@@ -302,29 +306,29 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
// joint names: ob -> vertex group names
// vertex group weights: me->dvert -> groups -> index, weight
- /*
- me->dvert:
+#if 0
+ me->dvert :
typedef struct MDeformVert {
struct MDeformWeight *dw;
int totweight;
- int flag; // flag only in use for weightpaint now
+ int flag; // flag only in use for weightpaint now
} MDeformVert;
typedef struct MDeformWeight {
- int def_nr;
- float weight;
+ int def_nr;
+ float weight;
} MDeformWeight;
- */
+#endif
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
- if ( this->export_settings->apply_modifiers ) {
+ if (this->export_settings->apply_modifiers) {
me = bc_to_mesh_apply_modifiers(scene, ob);
}
else {
- me = (Mesh*)ob->data;
+ me = (Mesh *)ob->data;
}
BKE_mesh_tessface_ensure(me);
@@ -352,7 +356,7 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
std::vector<int> joint_index_by_def_index;
bDeformGroup *def;
- for (def = (bDeformGroup*)ob->defbase.first, i = 0, j = 0; def; def = def->next, i++) {
+ for (def = (bDeformGroup *)ob->defbase.first, i = 0, j = 0; def; def = def->next, i++) {
if (is_bone_defgroup(ob_arm, def))
joint_index_by_def_index.push_back(j++);
else
@@ -375,18 +379,20 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
}
if (sumw > 0.0f) {
- float invsumw = 1.0f/sumw;
+ float invsumw = 1.0f / sumw;
vcounts.push_back(jw.size());
for (std::map<int, float>::iterator m = jw.begin(); m != jw.end(); ++m) {
joints.push_back((*m).first);
- weights.push_back(invsumw*(*m).second);
+ weights.push_back(invsumw * (*m).second);
}
}
else {
vcounts.push_back(0);
- /*vcounts.push_back(1);
+#if 0
+ vcounts.push_back(1);
joints.push_back(-1);
- weights.push_back(1.0f);*/
+ weights.push_back(1.0f);
+#endif
}
}
}
@@ -404,15 +410,15 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
}
void ArmatureExporter::add_joints_element(ListBase *defbase,
- const std::string& joints_source_id, const std::string& inv_bind_mat_source_id)
+ const std::string& joints_source_id, const std::string& inv_bind_mat_source_id)
{
COLLADASW::JointsElement joints(mSW);
COLLADASW::InputList &input = joints.getInputList();
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
- COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id)));
+ COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id)));
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::BINDMATRIX,
- COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, inv_bind_mat_source_id)));
+ COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, inv_bind_mat_source_id)));
joints.add();
}
@@ -431,7 +437,7 @@ std::string ArmatureExporter::add_joints_source(Object *ob_arm, ListBase *defbas
int totjoint = 0;
bDeformGroup *def;
- for (def = (bDeformGroup*)defbase->first; def; def = def->next) {
+ for (def = (bDeformGroup *)defbase->first; def; def = def->next) {
if (is_bone_defgroup(ob_arm, def))
totjoint++;
}
@@ -447,7 +453,7 @@ std::string ArmatureExporter::add_joints_source(Object *ob_arm, ListBase *defbas
source.prepareToAppendValues();
- for (def = (bDeformGroup*)defbase->first; def; def = def->next) {
+ for (def = (bDeformGroup *)defbase->first; def; def = def->next) {
Bone *bone = get_bone_from_defgroup(ob_arm, def);
if (bone)
source.appendValues(get_joint_sid(bone, ob_arm));
@@ -463,7 +469,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
std::string source_id = controller_id + BIND_POSES_SOURCE_ID_SUFFIX;
int totjoint = 0;
- for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) {
+ for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) {
if (is_bone_defgroup(ob_arm, def))
totjoint++;
}
@@ -481,7 +487,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
source.prepareToAppendValues();
bPose *pose = ob_arm->pose;
- bArmature *arm = (bArmature*)ob_arm->data;
+ bArmature *arm = (bArmature *)ob_arm->data;
int flag = arm->flag;
@@ -491,7 +497,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
BKE_pose_where_is(scene, ob_arm);
}
- for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) {
+ for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) {
if (is_bone_defgroup(ob_arm, def)) {
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, def->name);
@@ -530,13 +536,13 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
return source_id;
}
-Bone *ArmatureExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def)
+Bone *ArmatureExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def)
{
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, def->name);
return pchan ? pchan->bone : NULL;
}
-bool ArmatureExporter::is_bone_defgroup(Object *ob_arm, bDeformGroup* def)
+bool ArmatureExporter::is_bone_defgroup(Object *ob_arm, bDeformGroup *def)
{
return get_bone_from_defgroup(ob_arm, def) != NULL;
}
@@ -566,17 +572,17 @@ std::string ArmatureExporter::add_weights_source(Mesh *me, const std::string& co
}
void ArmatureExporter::add_vertex_weights_element(const std::string& weights_source_id, const std::string& joints_source_id,
- const std::list<int>& vcounts,
- const std::list<int>& joints)
+ const std::list<int>& vcounts,
+ const std::list<int>& joints)
{
COLLADASW::VertexWeightsElement weightselem(mSW);
COLLADASW::InputList &input = weightselem.getInputList();
int offset = 0;
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
- COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id), offset++));
+ COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id), offset++));
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::WEIGHT,
- COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, weights_source_id), offset++));
+ COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, weights_source_id), offset++));
weightselem.setCount(vcounts.size());
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index f23b2bf4b02..115f129cb88 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -50,7 +50,8 @@ static const char *bc_get_joint_name(T *node)
}
ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, AnimationImporterBase *anim, Scene *sce) :
- TransformReader(conv), scene(sce), empty(NULL), mesh_importer(mesh), anim_importer(anim) {}
+ TransformReader(conv), scene(sce), empty(NULL), mesh_importer(mesh), anim_importer(anim) {
+}
ArmatureImporter::~ArmatureImporter()
{
@@ -68,7 +69,7 @@ JointData *ArmatureImporter::get_joint_data(COLLADAFW::Node *node);
if (joint_id_to_joint_index_map.find(joint_id) == joint_id_to_joint_index_map.end()) {
fprintf(stderr, "Cannot find a joint index by joint id for %s.\n",
- node->getOriginalId().c_str());
+ node->getOriginalId().c_str());
return NULL;
}
@@ -77,12 +78,12 @@ JointData *ArmatureImporter::get_joint_data(COLLADAFW::Node *node);
return &joint_index_to_joint_info_map[joint_index];
}
#endif
-void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *parent, int totchild,
- float parent_mat[][4], Object * ob_arm)
+void ArmatureImporter::create_unskinned_bone(COLLADAFW::Node *node, EditBone *parent, int totchild,
+ float parent_mat[][4], Object *ob_arm)
{
- std::vector<COLLADAFW::Node*>::iterator it;
+ std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
- if ( it != finished_joints.end()) return;
+ if (it != finished_joints.end()) return;
float mat[4][4];
float obmat[4][4];
@@ -90,7 +91,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
// object-space
get_node_mat(obmat, node, NULL, NULL);
- EditBone *bone = ED_armature_edit_bone_add((bArmature*)ob_arm->data, (char*)bc_get_joint_name(node));
+ EditBone *bone = ED_armature_edit_bone_add((bArmature *)ob_arm->data, (char *)bc_get_joint_name(node));
totbone++;
if (parent) bone->parent = parent;
@@ -107,9 +108,9 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
}
float loc[3], size[3], rot[3][3];
- mat4_to_loc_rot_size( loc, rot, size, obmat);
- mat3_to_vec_roll(rot, NULL, &angle );
- bone->roll=angle;
+ mat4_to_loc_rot_size(loc, rot, size, obmat);
+ mat3_to_vec_roll(rot, NULL, &angle);
+ bone->roll = angle;
// set head
copy_v3_v3(bone->head, mat[3]);
@@ -142,7 +143,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
COLLADAFW::NodePointerArray& children = node->getChildNodes();
for (unsigned int i = 0; i < children.getCount(); i++) {
- create_unskinned_bone( children[i], bone, children.getCount(), mat, ob_arm);
+ create_unskinned_bone(children[i], bone, children.getCount(), mat, ob_arm);
}
// in second case it's not a leaf bone, but we handle it the same way
@@ -155,12 +156,12 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
}
void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBone *parent, int totchild,
- float parent_mat[][4], bArmature *arm)
+ float parent_mat[][4], bArmature *arm)
{
//Checking if bone is already made.
- std::vector<COLLADAFW::Node*>::iterator it;
+ std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
- if ( it != finished_joints.end()) return;
+ if (it != finished_joints.end()) return;
float joint_inv_bind_mat[4][4];
@@ -169,7 +170,7 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
float mat[4][4];
// TODO rename from Node "name" attrs later
- EditBone *bone = ED_armature_edit_bone_add(arm, (char*)bc_get_joint_name(node));
+ EditBone *bone = ED_armature_edit_bone_add(arm, (char *)bc_get_joint_name(node));
totbone++;
if (skin.get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
@@ -190,9 +191,9 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
copy_m4_m4(mat, obmat);
float loc[3], size[3], rot[3][3], angle;
- mat4_to_loc_rot_size( loc, rot, size, obmat);
- mat3_to_vec_roll(rot, NULL, &angle );
- bone->roll=angle;
+ mat4_to_loc_rot_size(loc, rot, size, obmat);
+ mat3_to_vec_roll(rot, NULL, &angle);
+ bone->roll = angle;
}
@@ -267,7 +268,7 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
finished_joints.push_back(node);
}
-void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW::Node * node)
+void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW::Node *node)
{
LeafBone leaf;
@@ -337,7 +338,7 @@ void ArmatureImporter::set_euler_rotmode()
{
// just set rotmode = ROT_MODE_EUL on pose channel for each joint
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>::iterator it;
+ std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>::iterator it;
for (it = joint_by_uid.begin(); it != joint_by_uid.end(); it++) {
@@ -378,7 +379,7 @@ Object *ArmatureImporter::get_empty_for_leaves()
#if 0
Object *ArmatureImporter::find_armature(COLLADAFW::Node *node)
{
- JointData* jd = get_joint_data(node);
+ JointData *jd = get_joint_data(node);
if (jd) return jd->ob_arm;
COLLADAFW::NodePointerArray& children = node->getChildNodes();
@@ -408,10 +409,10 @@ ArmatureJoints& ArmatureImporter::get_armature_joints(Object *ob_arm)
#endif
void ArmatureImporter::create_armature_bones( )
{
- std::vector<COLLADAFW::Node*>::iterator ri;
+ std::vector<COLLADAFW::Node *>::iterator ri;
//if there is an armature created for root_joint next root_joint
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
- if ( get_armature_for_joint(*ri) != NULL ) continue;
+ if (get_armature_for_joint(*ri) != NULL) continue;
//add armature object for current joint
//Object *ob_arm = bc_add_object(scene, OB_ARMATURE, NULL);
@@ -428,9 +429,9 @@ void ArmatureImporter::create_armature_bones( )
// create unskinned bones
/*
- TODO:
- check if bones have already been created for a given joint
- */
+ * TODO:
+ * check if bones have already been created for a given joint
+ */
leaf_bone_length = FLT_MAX;
create_unskinned_bone(*ri, NULL, (*ri)->getChildNodes().getCount(), NULL, ob_arm);
@@ -442,10 +443,10 @@ void ArmatureImporter::create_armature_bones( )
ED_armature_from_edit(ob_arm);
- set_pose(ob_arm, *ri, NULL, NULL );
+ set_pose(ob_arm, *ri, NULL, NULL);
ED_armature_edit_free(ob_arm);
- DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB|OB_RECALC_DATA);
+ DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
}
@@ -496,7 +497,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
SkinInfo *a = &skin;
Object *shared = NULL;
- std::vector<COLLADAFW::Node*> skin_root_joints;
+ std::vector<COLLADAFW::Node *> skin_root_joints;
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
@@ -508,7 +509,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
b->find_root_joints(root_joints, joint_by_uid, skin_root_joints);
- std::vector<COLLADAFW::Node*>::iterator ri;
+ std::vector<COLLADAFW::Node *>::iterator ri;
for (ri = skin_root_joints.begin(); ri != skin_root_joints.end(); ri++) {
if (a->uses_joint_or_descendant(*ri)) {
shared = b->BKE_armature_from_object();
@@ -523,7 +524,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
if (shared)
ob_arm = skin.set_armature(shared);
else
- ob_arm = skin.create_armature(scene); //once for every armature
+ ob_arm = skin.create_armature(scene); //once for every armature
// enter armature edit mode
ED_armature_to_edit(ob_arm);
@@ -538,9 +539,9 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
/*
TODO:
check if bones have already been created for a given joint
- */
+ */
- std::vector<COLLADAFW::Node*>::iterator ri;
+ std::vector<COLLADAFW::Node *>::iterator ri;
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
// for shared armature check if bone tree is already created
if (shared && std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != skin_root_joints.end())
@@ -548,7 +549,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
// since root_joints may contain joints for multiple controllers, we need to filter
if (skin.uses_joint_or_descendant(*ri)) {
- create_bone(skin, *ri, NULL, (*ri)->getChildNodes().getCount(), NULL, (bArmature*)ob_arm->data);
+ create_bone(skin, *ri, NULL, (*ri)->getChildNodes().getCount(), NULL, (bArmature *)ob_arm->data);
if (joint_parent_map.find((*ri)->getUniqueId()) != joint_parent_map.end() && !skin.get_parent())
skin.set_parent(joint_parent_map[(*ri)->getUniqueId()]);
@@ -560,7 +561,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
// exit armature edit mode
ED_armature_from_edit(ob_arm);
ED_armature_edit_free(ob_arm);
- DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB|OB_RECALC_DATA);
+ DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
// set_leaf_bone_shapes(ob_arm);
// set_euler_rotmode();
@@ -571,9 +572,9 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
// is a child of a node (not joint), root should be true since
// this is where we build armature bones from
-void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, const char *parentname, float parent_mat[][4])
+void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, const char *parentname, float parent_mat[][4])
{
- char * bone_name = (char *) bc_get_joint_name ( root_node);
+ char *bone_name = (char *) bc_get_joint_name(root_node);
float mat[4][4];
float obmat[4][4];
@@ -584,7 +585,7 @@ void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, c
get_node_mat(obmat, root_node, NULL, NULL);
//if (*edbone)
- bPoseChannel * pchan = BKE_pose_channel_find_name(ob_arm -> pose, bone_name);
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone_name);
//else fprintf ( "",
// get world-space
@@ -592,7 +593,7 @@ void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, c
mult_m4_m4m4(mat, parent_mat, obmat);
bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, parentname);
- mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat );
+ mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat);
}
else {
@@ -631,7 +632,7 @@ void ArmatureImporter::add_root_joint(COLLADAFW::Node *node)
{
// root_joints.push_back(node);
Object *ob_arm = find_armature(node);
- if (ob_arm) {
+ if (ob_arm) {
get_armature_joints(ob_arm).root_joints.push_back(node);
}
#ifdef COLLADA_DEBUG
@@ -653,11 +654,17 @@ void ArmatureImporter::make_armatures(bContext *C)
create_armature_bones(skin);
// link armature with a mesh object
- Object *ob = mesh_importer->get_object_by_geom_uid(*get_geometry_uid(skin.get_controller_uid()));
- if (ob)
- skin.link_armature(C, ob, joint_by_uid, this);
+ const COLLADAFW::UniqueId &uid = skin.get_controller_uid();
+ const COLLADAFW::UniqueId *guid = get_geometry_uid(uid);
+ if (guid != NULL) {
+ Object *ob = mesh_importer->get_object_by_geom_uid(*guid);
+ if (ob)
+ skin.link_armature(C, ob, joint_by_uid, this);
+ else
+ fprintf(stderr, "Cannot find object to link armature with.\n");
+ }
else
- fprintf(stderr, "Cannot find object to link armature with.\n");
+ fprintf(stderr, "Cannot find geometry to link armature with.\n");
// set armature parent if any
Object *par = skin.get_parent();
@@ -694,7 +701,7 @@ void ArmatureImporter::link_armature(Object *ob_arm, const COLLADAFW::UniqueId&
}
#endif
-bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControllerData* data)
+bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControllerData *data)
{
// at this stage we get vertex influence info that should go into me->verts and ob->defbase
// there's no info to which object this should be long so we associate it with skin controller data UID
@@ -719,14 +726,14 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle
return true;
}
-bool ArmatureImporter::write_controller(const COLLADAFW::Controller* controller)
+bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
{
// - create and store armature object
const COLLADAFW::UniqueId& skin_id = controller->getUniqueId();
if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_SKIN) {
- COLLADAFW::SkinController *co = (COLLADAFW::SkinController*)controller;
+ COLLADAFW::SkinController *co = (COLLADAFW::SkinController *)controller;
// to be able to find geom id by controller id
geom_uid_by_controller_uid[skin_id] = co->getSource();
@@ -766,7 +773,7 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node)
return skin.BKE_armature_from_object();
}
- std::map<COLLADAFW::UniqueId, Object*>::iterator arm;
+ std::map<COLLADAFW::UniqueId, Object *>::iterator arm;
for (arm = unskinned_armature_map.begin(); arm != unskinned_armature_map.end(); arm++) {
if (arm->first == node->getUniqueId() )
return arm->second;
@@ -799,6 +806,3 @@ bool ArmatureImporter::get_joint_bind_mat(float m[][4], COLLADAFW::Node *joint)
return found;
}
-
-
-
diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp
index ce46c681c8c..be424fbbb4d 100644
--- a/source/blender/collada/CameraExporter.cpp
+++ b/source/blender/collada/CameraExporter.cpp
@@ -29,27 +29,27 @@
#include <string>
#include "COLLADASWCamera.h"
-#include "COLLADASWCameraOptic.h"
+extern "C" {
#include "DNA_camera_types.h"
-
+}
#include "CameraExporter.h"
#include "collada_internal.h"
-CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryCameras(sw), export_settings(export_settings) {}
+CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryCameras(sw), export_settings(export_settings) {
+}
template<class Functor>
-void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected)
+void forEachCameraObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
- Base *base = (Base*) sce->base.first;
- while (base) {
- Object *ob = base->object;
+ LinkNode *node;
+ for (node = export_set; node; node = node->next) {
+ Object *ob = (Object *)node->link;
- if (ob->type == OB_CAMERA && ob->data && !(export_selected && !(ob->flag & SELECT))) {
+ if (ob->type == OB_CAMERA && ob->data) {
f(ob, sce);
}
- base = base->next;
}
}
@@ -57,39 +57,40 @@ void CamerasExporter::exportCameras(Scene *sce)
{
openLibrary();
- forEachCameraObjectInScene(sce, *this, this->export_settings->selected);
+ forEachCameraObjectInExportSet(sce, *this, this->export_settings->export_set);
closeLibrary();
}
void CamerasExporter::operator()(Object *ob, Scene *sce)
{
// TODO: shiftx, shifty, YF_dofdist
- Camera *cam = (Camera*)ob->data;
+ Camera *cam = (Camera *)ob->data;
std::string cam_id(get_camera_id(ob));
std::string cam_name(id_name(cam));
switch (cam->type) {
- case CAM_PANO:
- case CAM_PERSP: {
- COLLADASW::PerspectiveOptic persp(mSW);
- persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov");
- persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio");
- persp.setZFar(cam->clipend, false, "zfar");
- persp.setZNear(cam->clipsta, false, "znear");
- COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name);
- addCamera(ccam);
- break;
+ case CAM_PANO:
+ case CAM_PERSP: {
+ COLLADASW::PerspectiveOptic persp(mSW);
+ persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov");
+ persp.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio");
+ persp.setZFar(cam->clipend, false, "zfar");
+ persp.setZNear(cam->clipsta, false, "znear");
+ COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name);
+ addCamera(ccam);
+ break;
+ }
+ case CAM_ORTHO:
+ default:
+ {
+ COLLADASW::OrthographicOptic ortho(mSW);
+ ortho.setXMag(cam->ortho_scale, "xmag");
+ ortho.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio");
+ ortho.setZFar(cam->clipend, false, "zfar");
+ ortho.setZNear(cam->clipsta, false, "znear");
+ COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name);
+ addCamera(ccam);
+ break;
+ }
}
- case CAM_ORTHO:
- default:
- {
- COLLADASW::OrthographicOptic ortho(mSW);
- ortho.setXMag(cam->ortho_scale, "xmag");
- ortho.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio");
- ortho.setZFar(cam->clipend, false, "zfar");
- ortho.setZNear(cam->clipsta, false, "znear");
- COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name);
- addCamera(ccam);
- break;
- }}
}
diff --git a/source/blender/collada/CameraExporter.h b/source/blender/collada/CameraExporter.h
index 1b5898984ba..5405df8ab9e 100644
--- a/source/blender/collada/CameraExporter.h
+++ b/source/blender/collada/CameraExporter.h
@@ -31,8 +31,10 @@
#include "COLLADASWStreamWriter.h"
#include "COLLADASWLibraryCameras.h"
+extern "C" {
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+}
#include "ExportSettings.h"
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 69f302eaec7..c47798ee804 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -27,6 +27,40 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
+#include <vector>
+#include <algorithm> // std::find
+
+#include "COLLADASWCamera.h"
+#include "COLLADASWAsset.h"
+#include "COLLADASWLibraryVisualScenes.h"
+#include "COLLADASWNode.h"
+#include "COLLADASWSource.h"
+#include "COLLADASWInstanceGeometry.h"
+#include "COLLADASWInputList.h"
+#include "COLLADASWPrimitves.h"
+#include "COLLADASWVertices.h"
+#include "COLLADASWLibraryAnimations.h"
+#include "COLLADASWLibraryImages.h"
+#include "COLLADASWLibraryEffects.h"
+#include "COLLADASWImage.h"
+#include "COLLADASWEffectProfile.h"
+#include "COLLADASWColorOrTexture.h"
+#include "COLLADASWParamTemplate.h"
+#include "COLLADASWParamBase.h"
+#include "COLLADASWSurfaceInitOption.h"
+#include "COLLADASWSampler.h"
+#include "COLLADASWScene.h"
+#include "COLLADASWTechnique.h"
+#include "COLLADASWTexture.h"
+#include "COLLADASWLibraryMaterials.h"
+#include "COLLADASWBindMaterial.h"
+#include "COLLADASWInstanceCamera.h"
+#include "COLLADASWInstanceLight.h"
+#include "COLLADASWConstants.h"
+#include "COLLADASWLibraryControllers.h"
+#include "COLLADASWInstanceController.h"
+#include "COLLADASWInstanceNode.h"
+#include "COLLADASWBaseInputElement.h"
extern "C"
{
@@ -54,7 +88,6 @@ extern "C"
#ifdef WITH_BUILDINFO
extern char build_rev[];
#endif
-}
#include "MEM_guardedalloc.h"
@@ -74,41 +107,12 @@ extern char build_rev[];
#include "BLI_listbase.h"
#include "RNA_access.h"
-
-#include "COLLADASWAsset.h"
-#include "COLLADASWLibraryVisualScenes.h"
-#include "COLLADASWNode.h"
-#include "COLLADASWSource.h"
-#include "COLLADASWInstanceGeometry.h"
-#include "COLLADASWInputList.h"
-#include "COLLADASWPrimitves.h"
-#include "COLLADASWVertices.h"
-#include "COLLADASWLibraryAnimations.h"
-#include "COLLADASWLibraryImages.h"
-#include "COLLADASWLibraryEffects.h"
-#include "COLLADASWImage.h"
-#include "COLLADASWEffectProfile.h"
-#include "COLLADASWColorOrTexture.h"
-#include "COLLADASWParamTemplate.h"
-#include "COLLADASWParamBase.h"
-#include "COLLADASWSurfaceInitOption.h"
-#include "COLLADASWSampler.h"
-#include "COLLADASWScene.h"
-#include "COLLADASWTechnique.h"
-#include "COLLADASWTexture.h"
-#include "COLLADASWLibraryMaterials.h"
-#include "COLLADASWBindMaterial.h"
-#include "COLLADASWInstanceCamera.h"
-#include "COLLADASWInstanceLight.h"
-#include "COLLADASWConstants.h"
-#include "COLLADASWLibraryControllers.h"
-#include "COLLADASWInstanceController.h"
-#include "COLLADASWInstanceNode.h"
-#include "COLLADASWBaseInputElement.h"
+}
#include "collada_internal.h"
#include "DocumentExporter.h"
-#include "ExportSettings.h"
+
+extern bool bc_has_object_type(LinkNode *export_set, short obtype);
// can probably go after refactor is complete
#include "InstanceWriter.h"
@@ -124,15 +128,13 @@ extern char build_rev[];
#include "LightExporter.h"
#include "MaterialExporter.h"
-#include <vector>
-#include <algorithm> // std::find
char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int n)
{
int layer_index = CustomData_get_layer_index(data, type);
if (layer_index < 0) return NULL;
- return data->layers[layer_index+n].name;
+ return data->layers[layer_index + n].name;
}
char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
@@ -144,7 +146,8 @@ char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
return data->layers[layer_index].name;
}
-DocumentExporter::DocumentExporter(const ExportSettings *export_settings) : export_settings(export_settings) {}
+DocumentExporter::DocumentExporter(const ExportSettings *export_settings) : export_settings(export_settings) {
+}
// TODO: it would be better to instantiate animations rather than create a new one per object
// COLLADA allows this through multiple <channel>s in <animation>.
@@ -158,7 +161,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
clear_global_id_map();
COLLADABU::NativeString native_filename =
- COLLADABU::NativeString(std::string(this->export_settings->filepath));
+ COLLADABU::NativeString(std::string(this->export_settings->filepath));
COLLADASW::StreamWriter sw(native_filename);
// open <collada>
@@ -219,21 +222,22 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
}
char version_buf[128];
#ifdef WITH_BUILDINFO
- sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION, build_rev);
+ sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_rev);
#else
- sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
+ sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
#endif
asset.getContributor().mAuthoringTool = version_buf;
asset.add();
+ LinkNode *export_set = this->export_settings->export_set;
// <library_cameras>
- if (has_object_type(sce, OB_CAMERA)) {
+ if (bc_has_object_type(export_set, OB_CAMERA)) {
CamerasExporter ce(&sw, this->export_settings);
ce.exportCameras(sce);
}
// <library_lights>
- if (has_object_type(sce, OB_LAMP)) {
+ if (bc_has_object_type(export_set, OB_LAMP)) {
LightsExporter le(&sw, this->export_settings);
le.exportLights(sce);
}
@@ -251,7 +255,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
me.exportMaterials(sce);
// <library_geometries>
- if (has_object_type(sce, OB_MESH)) {
+ if (bc_has_object_type(export_set, OB_MESH)) {
GeometryExporter ge(&sw, this->export_settings);
ge.exportGeom(sce);
}
@@ -262,10 +266,8 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
// <library_controllers>
ArmatureExporter arm_exporter(&sw, this->export_settings);
- if (this->export_settings->include_armatures) {
- if (has_object_type(sce, OB_ARMATURE)) {
- arm_exporter.export_controllers(sce);
- }
+ if (bc_has_object_type(export_set, OB_ARMATURE)) {
+ arm_exporter.export_controllers(sce);
}
// <library_visual_scenes>
@@ -275,7 +277,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
// <scene>
std::string scene_name(translate_id(id_name(sce)));
COLLADASW::Scene scene(&sw, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING,
- scene_name));
+ scene_name));
scene.add();
// close <Collada>
@@ -283,14 +285,13 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
}
-void DocumentExporter::exportScenes(const char* filename)
+void DocumentExporter::exportScenes(const char *filename)
{
}
/*
-
-NOTES:
-
-* AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a user
-
+ * NOTES:
+ *
+ * AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a user
+ *
*/
diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h
index 314ba2868e5..05620087d76 100644
--- a/source/blender/collada/DocumentExporter.h
+++ b/source/blender/collada/DocumentExporter.h
@@ -29,6 +29,10 @@
#include "ExportSettings.h"
+extern "C" {
+#include "DNA_customdata_types.h"
+}
+
struct Scene;
class DocumentExporter
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 6dca7828cc2..6c9d277de54 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -49,6 +49,7 @@
#include "COLLADASaxFWLLoader.h"
#include "COLLADASaxFWLIExtraDataCallbackHandler.h"
+extern "C" {
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
@@ -75,6 +76,8 @@
#include "MEM_guardedalloc.h"
+}
+
#include "ExtraHandler.h"
#include "ErrorHandler.h"
#include "DocumentImporter.h"
@@ -85,8 +88,8 @@
/*
- COLLADA Importer limitations:
- - no multiple scene import, all objects are added to active scene
+ COLLADA Importer limitations:
+ - no multiple scene import, all objects are added to active scene
*/
// #define COLLADA_DEBUG
@@ -100,13 +103,14 @@ DocumentImporter::DocumentImporter(bContext *C, const char *filename) :
armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)),
mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)),
anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C))
-{}
+{
+}
DocumentImporter::~DocumentImporter()
{
TagsMap::iterator etit;
etit = uid_tags_map.begin();
- while (etit!=uid_tags_map.end()) {
+ while (etit != uid_tags_map.end()) {
delete etit->second;
etit++;
}
@@ -168,11 +172,11 @@ void DocumentImporter::start()
void DocumentImporter::finish()
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return;
/** TODO Break up and put into 2-pass parsing of DAE */
- std::vector<const COLLADAFW::VisualScene*>::iterator it;
+ std::vector<const COLLADAFW::VisualScene *>::iterator it;
for (it = vscenes.begin(); it != vscenes.end(); it++) {
PointerRNA sceneptr, unit_settings;
PropertyRNA *system, *scale;
@@ -211,7 +215,7 @@ void DocumentImporter::finish()
armature_importer.fix_animation();
#endif
- for (std::vector<const COLLADAFW::VisualScene*>::iterator it = vscenes.begin(); it != vscenes.end(); it++) {
+ for (std::vector<const COLLADAFW::VisualScene *>::iterator it = vscenes.begin(); it != vscenes.end(); it++) {
const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes();
for (unsigned int i = 0; i < roots.getCount(); i++)
@@ -223,7 +227,7 @@ void DocumentImporter::finish()
fprintf(stderr, "got %d library nodes to free\n", (int)libnode_ob.size());
// free all library_nodes
- std::vector<Object*>::iterator it;
+ std::vector<Object *>::iterator it;
for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
Object *ob = *it;
@@ -231,8 +235,8 @@ void DocumentImporter::finish()
if (base) {
BLI_remlink(&sce->base, base);
BKE_libblock_free_us(&G.main->object, base->object);
- if (sce->basact==base)
- sce->basact= NULL;
+ if (sce->basact == base)
+ sce->basact = NULL;
MEM_freeN(base);
}
}
@@ -262,18 +266,20 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
root_map[node->getUniqueId()] = root_map[par->getUniqueId()];
}
- /*COLLADAFW::Transformation::TransformationType types[] = {
+#if 0
+ COLLADAFW::Transformation::TransformationType types[] = {
COLLADAFW::Transformation::ROTATE,
COLLADAFW::Transformation::SCALE,
COLLADAFW::Transformation::TRANSLATE,
COLLADAFW::Transformation::MATRIX
};
- Object *ob;*/
+ Object *ob;
+#endif
unsigned int i;
//for (i = 0; i < 4; i++)
- //ob =
+ // ob =
anim_importer.translate_Animations(node, root_map, object_map, FW_object_map);
COLLADAFW::NodePointerArray &children = node->getChildNodes();
@@ -283,8 +289,8 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
}
/** When this method is called, the writer must write the global document asset.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* asset )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeGlobalAsset(const COLLADAFW::FileInfo *asset)
{
unit_converter.read_asset(asset);
@@ -292,13 +298,13 @@ bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* asset )
}
/** When this method is called, the writer must write the scene.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeScene ( const COLLADAFW::Scene* scene )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeScene(const COLLADAFW::Scene *scene)
{
// XXX could store the scene id, but do nothing for now
return true;
}
-Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
+Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
{
const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId();
if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {
@@ -308,7 +314,7 @@ Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
Object *ob = bc_add_object(sce, OB_CAMERA, NULL);
Camera *cam = uid_camera_map[cam_uid];
- Camera *old_cam = (Camera*)ob->data;
+ Camera *old_cam = (Camera *)ob->data;
ob->data = cam;
old_cam->id.us--;
if (old_cam->id.us == 0)
@@ -316,7 +322,7 @@ Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
return ob;
}
-Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce)
+Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce)
{
const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId();
if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) {
@@ -326,7 +332,7 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce
Object *ob = bc_add_object(sce, OB_LAMP, NULL);
Lamp *la = uid_lamp_map[lamp_uid];
- Lamp *old_lamp = (Lamp*)ob->data;
+ Lamp *old_lamp = (Lamp *)ob->data;
ob->data = la;
old_lamp->id.us--;
if (old_lamp->id.us == 0)
@@ -334,12 +340,12 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce
return ob;
}
-Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node)
+Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node)
{
fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL);
Object *obn = BKE_object_copy(source_ob);
- obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
BKE_scene_base_add(sce, obn);
if (instance_node) {
@@ -396,21 +402,21 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
return obn;
}
-void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node)
+void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node)
{
Object *ob = NULL;
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
bool read_transform = true;
- std::vector<Object*> * objects_done = new std::vector<Object *>();
+ std::vector<Object *> *objects_done = new std::vector<Object *>();
if (is_joint) {
- if ( par ) {
- Object * empty = par;
- par = bc_add_object(sce, OB_ARMATURE, NULL);
- bc_set_parent(par, empty->parent, mContext);
- //remove empty : todo
- object_map.insert(std::make_pair<COLLADAFW::UniqueId, Object *>(parent_node->getUniqueId(), par));
+ if (par) {
+ Object *empty = par;
+ par = bc_add_object(sce, OB_ARMATURE, NULL);
+ bc_set_parent(par, empty->parent, mContext);
+ //remove empty : todo
+ object_map.insert(std::make_pair<COLLADAFW::UniqueId, Object *>(parent_node->getUniqueId(), par));
}
armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par, sce);
}
@@ -431,7 +437,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
// <instance_geometry>
while (geom_done < geom.getCount()) {
ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map,
- material_texture_mapping_map);
+ material_texture_mapping_map);
objects_done->push_back(ob);
++geom_done;
}
@@ -446,7 +452,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
++lamp_done;
}
while (controller_done < controller.getCount()) {
- COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[controller_done];
+ COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry *)controller[controller_done];
ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map);
objects_done->push_back(ob);
++controller_done;
@@ -484,7 +490,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
ob = *it;
std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
- rename_id(&ob->id, (char*)nodename.c_str());
+ rename_id(&ob->id, (char *)nodename.c_str());
object_map.insert(std::make_pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), ob));
node_map[node->getUniqueId()] = node;
@@ -495,10 +501,10 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
}
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
- ob =*it;
+ ob = *it;
if (read_transform)
- anim_importer.read_node_transform(node, ob); // overwrites location set earlier
+ anim_importer.read_node_transform(node, ob); // overwrites location set earlier
if (!is_joint) {
// if par was given make this object child of the previous
@@ -514,10 +520,10 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
}
/** When this method is called, the writer must write the entire visual scene.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualScene )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
// this method called on post process after writeGeometry, writeMaterial, etc.
@@ -536,11 +542,11 @@ bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualSc
}
/** When this method is called, the writer must handle all nodes contained in the
- library nodes.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* libraryNodes )
+* library nodes.
+* \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
Scene *sce = CTX_data_scene(mContext);
@@ -555,24 +561,24 @@ bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* librar
}
/** When this method is called, the writer must write the geometry.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geom )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
return mesh_importer.write_geometry(geom);
}
/** When this method is called, the writer must write the material.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
- Material *ma = BKE_material_add((char*)str_mat_id.c_str());
+ Material *ma = BKE_material_add((char *)str_mat_id.c_str());
this->uid_effect_map[cmat->getInstantiatedEffect()] = ma;
this->uid_material_map[cmat->getUniqueId()] = ma;
@@ -581,8 +587,8 @@ bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat )
}
// create mtex, create texture, set texture image
-MTex* DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma,
- int i, TexIndexTextureArrayMap &texindex_texarray_map)
+MTex *DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma,
+ int i, TexIndexTextureArrayMap &texindex_texarray_map)
{
COLLADAFW::SamplerPointerArray& samp_array = ef->getSamplerPointerArray();
COLLADAFW::Sampler *sampler = samp_array[ctex.getSamplerId()];
@@ -732,32 +738,34 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
mtex->tex->imaflag |= TEX_USEALPHA;
i++;
ma->spectra = ma->alpha = 0;
- ma->mode |= MA_ZTRANSP|MA_TRANSP;
+ ma->mode |= MA_ZTRANSP | MA_TRANSP;
}
}
// TRANSPARENT
// color
-// if (ef->getOpacity().isColor()) {
-// // XXX don't know what to do here
-// }
-// // texture
-// else if (ef->getOpacity().isTexture()) {
-// ctex = ef->getOpacity().getTexture();
-// if (mtex != NULL) mtex->mapto &= MAP_ALPHA;
-// else {
-// mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
-// if (mtex != NULL) mtex->mapto = MAP_ALPHA;
-// }
-// }
+#if 0
+ if (ef->getOpacity().isColor()) {
+ // XXX don't know what to do here
+ }
+ // texture
+ else if (ef->getOpacity().isTexture()) {
+ ctex = ef->getOpacity().getTexture();
+ if (mtex != NULL) mtex->mapto &= MAP_ALPHA;
+ else {
+ mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
+ if (mtex != NULL) mtex->mapto = MAP_ALPHA;
+ }
+ }
+#endif
material_texture_mapping_map[ma] = texindex_texarray_map;
}
/** When this method is called, the writer must write the effect.
- \return The writer should return true, if writing succeeded, false otherwise.*/
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
+bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
const COLLADAFW::UniqueId& uid = effect->getUniqueId();
@@ -768,9 +776,9 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
}
Material *ma = uid_effect_map[uid];
- std::map<COLLADAFW::UniqueId, Material*>::iterator iter;
- for (iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ ) {
- if ( iter->second == ma ) {
+ std::map<COLLADAFW::UniqueId, Material *>::iterator iter;
+ for (iter = uid_material_map.begin(); iter != uid_material_map.end(); iter++) {
+ if (iter->second == ma) {
this->FW_object_map[iter->first] = effect;
break;
}
@@ -791,10 +799,10 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
/** When this method is called, the writer must write the camera.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
Camera *cam = NULL;
@@ -802,8 +810,8 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
cam_id = camera->getOriginalId();
cam_name = camera->getName();
- if (cam_name.size()) cam = (Camera *)BKE_camera_add((char*)cam_name.c_str());
- else cam = (Camera *)BKE_camera_add((char*)cam_id.c_str());
+ if (cam_name.size()) cam = (Camera *)BKE_camera_add((char *)cam_name.c_str());
+ else cam = (Camera *)BKE_camera_add((char *)cam_id.c_str());
if (!cam) {
fprintf(stderr, "Cannot create camera.\n");
@@ -814,17 +822,17 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
COLLADAFW::Camera::CameraType type = camera->getCameraType();
switch (type) {
- case COLLADAFW::Camera::ORTHOGRAPHIC:
+ case COLLADAFW::Camera::ORTHOGRAPHIC:
{
cam->type = CAM_ORTHO;
}
break;
- case COLLADAFW::Camera::PERSPECTIVE:
+ case COLLADAFW::Camera::PERSPECTIVE:
{
cam->type = CAM_PERSP;
}
break;
- case COLLADAFW::Camera::UNDEFINED_CAMERATYPE:
+ case COLLADAFW::Camera::UNDEFINED_CAMERATYPE:
{
fprintf(stderr, "Current camera type is not supported.\n");
cam->type = CAM_PERSP;
@@ -833,35 +841,35 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
}
switch (camera->getDescriptionType()) {
- case COLLADAFW::Camera::ASPECTRATIO_AND_Y:
+ case COLLADAFW::Camera::ASPECTRATIO_AND_Y:
{
switch (cam->type) {
case CAM_ORTHO:
- {
- double ymag = camera->getYMag().getValue();
- double aspect = camera->getAspectRatio().getValue();
- double xmag = aspect*ymag;
- cam->ortho_scale = (float)xmag;
- }
- break;
+ {
+ double ymag = camera->getYMag().getValue();
+ double aspect = camera->getAspectRatio().getValue();
+ double xmag = aspect * ymag;
+ cam->ortho_scale = (float)xmag;
+ }
+ break;
case CAM_PERSP:
default:
- {
- double yfov = camera->getYFov().getValue();
- double aspect = camera->getAspectRatio().getValue();
- double xfov = aspect*yfov;
- // xfov is in degrees, cam->lens is in millimiters
- cam->lens = fov_to_focallength(DEG2RADF(xfov), cam->sensor_x);
- }
- break;
+ {
+ double yfov = camera->getYFov().getValue();
+ double aspect = camera->getAspectRatio().getValue();
+ double xfov = aspect * yfov;
+ // xfov is in degrees, cam->lens is in millimiters
+ cam->lens = fov_to_focallength(DEG2RADF(xfov), cam->sensor_x);
+ }
+ break;
}
}
break;
- /* XXX correct way to do following four is probably to get also render
- size and determine proper settings from that somehow */
- case COLLADAFW::Camera::ASPECTRATIO_AND_X:
- case COLLADAFW::Camera::SINGLE_X:
- case COLLADAFW::Camera::X_AND_Y:
+ /* XXX correct way to do following four is probably to get also render
+ size and determine proper settings from that somehow */
+ case COLLADAFW::Camera::ASPECTRATIO_AND_X:
+ case COLLADAFW::Camera::SINGLE_X:
+ case COLLADAFW::Camera::X_AND_Y:
{
switch (cam->type) {
case CAM_ORTHO:
@@ -869,16 +877,16 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
break;
case CAM_PERSP:
default:
- {
- double x = camera->getXFov().getValue();
- // x is in degrees, cam->lens is in millimiters
- cam->lens = fov_to_focallength(DEG2RADF(x), cam->sensor_x);
- }
- break;
+ {
+ double x = camera->getXFov().getValue();
+ // x is in degrees, cam->lens is in millimiters
+ cam->lens = fov_to_focallength(DEG2RADF(x), cam->sensor_x);
+ }
+ break;
}
}
break;
- case COLLADAFW::Camera::SINGLE_Y:
+ case COLLADAFW::Camera::SINGLE_Y:
{
switch (cam->type) {
case CAM_ORTHO:
@@ -886,18 +894,18 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
break;
case CAM_PERSP:
default:
- {
+ {
double yfov = camera->getYFov().getValue();
// yfov is in degrees, cam->lens is in millimiters
cam->lens = fov_to_focallength(DEG2RADF(yfov), cam->sensor_x);
- }
- break;
+ }
+ break;
}
}
break;
- case COLLADAFW::Camera::UNDEFINED:
- // read nothing, use blender defaults.
- break;
+ case COLLADAFW::Camera::UNDEFINED:
+ // read nothing, use blender defaults.
+ break;
}
this->uid_camera_map[camera->getUniqueId()] = cam;
@@ -907,15 +915,15 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
}
/** When this method is called, the writer must write the image.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
// XXX maybe it is necessary to check if the path is absolute or relative
const std::string& filepath = image->getImageURI().toNativePath();
- const char *filename = (const char*)mFilename.c_str();
+ const char *filename = (const char *)mFilename.c_str();
char dir[FILE_MAX];
char full_path[FILE_MAX];
@@ -932,10 +940,10 @@ bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
}
/** When this method is called, the writer must write the light.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
Lamp *lamp = NULL;
@@ -949,8 +957,8 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
la_id = light->getOriginalId();
la_name = light->getName();
- if (la_name.size()) lamp = (Lamp*)BKE_lamp_add((char*)la_name.c_str());
- else lamp = (Lamp*)BKE_lamp_add((char*)la_id.c_str());
+ if (la_name.size()) lamp = (Lamp *)BKE_lamp_add((char *)la_name.c_str());
+ else lamp = (Lamp *)BKE_lamp_add((char *)la_id.c_str());
if (!lamp) {
fprintf(stderr, "Cannot create lamp.\n");
@@ -1033,12 +1041,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
if (IS_EQ(linatt, 0.0f) && quadatt > 0.0f) {
att2 = quadatt;
- d = sqrt(1.0f/quadatt);
+ d = sqrt(1.0f / quadatt);
}
// linear light
else if (IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
att1 = linatt;
- d = (1.0f/linatt);
+ d = (1.0f / linatt);
}
else if (IS_EQ(constatt, 1.0f)) {
att1 = 1.0f;
@@ -1048,7 +1056,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
att1 = 1.0f;
}
- d *= ( 1.0f / unit_converter.getLinearMeter());
+ d *= (1.0f / unit_converter.getLinearMeter());
lamp->energy = e;
lamp->dist = d;
@@ -1056,47 +1064,47 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
COLLADAFW::Light::LightType type = light->getLightType();
switch (type) {
case COLLADAFW::Light::AMBIENT_LIGHT:
- {
- lamp->type = LA_HEMI;
- }
- break;
+ {
+ lamp->type = LA_HEMI;
+ }
+ break;
case COLLADAFW::Light::SPOT_LIGHT:
- {
- lamp->type = LA_SPOT;
- lamp->att1 = att1;
- lamp->att2 = att2;
- if (IS_EQ(att1, 0.0f) && att2 > 0)
- lamp->falloff_type = LA_FALLOFF_INVSQUARE;
- if (IS_EQ(att2, 0.0f) && att1 > 0)
- lamp->falloff_type = LA_FALLOFF_INVLINEAR;
- lamp->spotsize = light->getFallOffAngle().getValue();
- lamp->spotblend = light->getFallOffExponent().getValue();
- }
- break;
+ {
+ lamp->type = LA_SPOT;
+ lamp->att1 = att1;
+ lamp->att2 = att2;
+ if (IS_EQ(att1, 0.0f) && att2 > 0)
+ lamp->falloff_type = LA_FALLOFF_INVSQUARE;
+ if (IS_EQ(att2, 0.0f) && att1 > 0)
+ lamp->falloff_type = LA_FALLOFF_INVLINEAR;
+ lamp->spotsize = light->getFallOffAngle().getValue();
+ lamp->spotblend = light->getFallOffExponent().getValue();
+ }
+ break;
case COLLADAFW::Light::DIRECTIONAL_LIGHT:
- {
- /* our sun is very strong, so pick a smaller energy level */
- lamp->type = LA_SUN;
- lamp->mode |= LA_NO_SPEC;
- }
- break;
+ {
+ /* our sun is very strong, so pick a smaller energy level */
+ lamp->type = LA_SUN;
+ lamp->mode |= LA_NO_SPEC;
+ }
+ break;
case COLLADAFW::Light::POINT_LIGHT:
- {
- lamp->type = LA_LOCAL;
- lamp->att1 = att1;
- lamp->att2 = att2;
- if (IS_EQ(att1, 0.0f) && att2 > 0)
- lamp->falloff_type = LA_FALLOFF_INVSQUARE;
- if (IS_EQ(att2, 0.0f) && att1 > 0)
- lamp->falloff_type = LA_FALLOFF_INVLINEAR;
- }
- break;
+ {
+ lamp->type = LA_LOCAL;
+ lamp->att1 = att1;
+ lamp->att2 = att2;
+ if (IS_EQ(att1, 0.0f) && att2 > 0)
+ lamp->falloff_type = LA_FALLOFF_INVSQUARE;
+ if (IS_EQ(att2, 0.0f) && att1 > 0)
+ lamp->falloff_type = LA_FALLOFF_INVLINEAR;
+ }
+ break;
case COLLADAFW::Light::UNDEFINED:
- {
- fprintf(stderr, "Current lamp type is not supported.\n");
- lamp->type = LA_LOCAL;
- }
- break;
+ {
+ fprintf(stderr, "Current lamp type is not supported.\n");
+ lamp->type = LA_LOCAL;
+ }
+ break;
}
}
@@ -1106,9 +1114,9 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
}
// this function is called only for animations that pass COLLADAFW::validate
-bool DocumentImporter::writeAnimation( const COLLADAFW::Animation* anim )
+bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
// return true;
@@ -1116,9 +1124,9 @@ bool DocumentImporter::writeAnimation( const COLLADAFW::Animation* anim )
}
// called on post-process stage after writeVisualScenes
-bool DocumentImporter::writeAnimationList( const COLLADAFW::AnimationList* animationList )
+bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
// return true;
@@ -1126,40 +1134,40 @@ bool DocumentImporter::writeAnimationList( const COLLADAFW::AnimationList* anima
}
/** When this method is called, the writer must write the skin controller data.
- \return The writer should return true, if writing succeeded, false otherwise.*/
-bool DocumentImporter::writeSkinControllerData( const COLLADAFW::SkinControllerData* skin )
+ * \return The writer should return true, if writing succeeded, false otherwise.*/
+bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerData *skin)
{
return armature_importer.write_skin_controller_data(skin);
}
// this is called on postprocess, before writeVisualScenes
-bool DocumentImporter::writeController( const COLLADAFW::Controller* controller )
+bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
{
- if (mImportStage!=General)
+ if (mImportStage != General)
return true;
return armature_importer.write_controller(controller);
}
-bool DocumentImporter::writeFormulas( const COLLADAFW::Formulas* formulas )
+bool DocumentImporter::writeFormulas(const COLLADAFW::Formulas *formulas)
{
return true;
}
-bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* kinematicsScene )
+bool DocumentImporter::writeKinematicsScene(const COLLADAFW::KinematicsScene *kinematicsScene)
{
return true;
}
-ExtraTags* DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid)
+ExtraTags *DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid)
{
- if (uid_tags_map.find(uid.toAscii())==uid_tags_map.end()) {
+ if (uid_tags_map.find(uid.toAscii()) == uid_tags_map.end()) {
return NULL;
}
return uid_tags_map[uid.toAscii()];
}
-bool DocumentImporter::addExtraTags( const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags)
+bool DocumentImporter::addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags)
{
uid_tags_map[uid.toAscii()] = extra_tags;
return true;
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index 36ed6867525..3ed689628f7 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -31,6 +31,7 @@
#include "COLLADASWEffectProfile.h"
#include "EffectExporter.h"
+#include "DocumentExporter.h"
#include "MaterialExporter.h"
#include "DNA_mesh_types.h"
@@ -45,7 +46,7 @@
// OB_MESH is assumed
static std::string getActiveUVLayerName(Object *ob)
{
- Mesh *me = (Mesh*)ob->data;
+ Mesh *me = (Mesh *)ob->data;
int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
if (num_layers)
@@ -54,24 +55,25 @@ static std::string getActiveUVLayerName(Object *ob)
return "";
}
-EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryEffects(sw), export_settings(export_settings) {}
+EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryEffects(sw), export_settings(export_settings) {
+}
bool EffectsExporter::hasEffects(Scene *sce)
{
Base *base = (Base *)sce->base.first;
while (base) {
- Object *ob= base->object;
+ Object *ob = base->object;
int a;
for (a = 0; a < ob->totcol; a++) {
- Material *ma = give_current_material(ob, a+1);
+ Material *ma = give_current_material(ob, a + 1);
// no material, but check all of the slots
if (!ma) continue;
return true;
}
- base= base->next;
+ base = base->next;
}
return false;
}
@@ -82,7 +84,7 @@ void EffectsExporter::exportEffects(Scene *sce)
this->scene = sce;
openLibrary();
MaterialFunctor mf;
- mf.forEachMaterialInScene<EffectsExporter>(sce, *this, this->export_settings->selected);
+ mf.forEachMaterialInExportSet<EffectsExporter>(sce, *this, this->export_settings->export_set);
closeLibrary();
}
@@ -96,7 +98,7 @@ void EffectsExporter::writeBlinn(COLLADASW::EffectProfile &ep, Material *ma)
ep.setShininess(ma->har, false, "shininess");
// specular
cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
- ep.setSpecular(cot, false, "specular" );
+ ep.setSpecular(cot, false, "specular");
}
void EffectsExporter::writeLambert(COLLADASW::EffectProfile &ep, Material *ma)
@@ -110,10 +112,10 @@ void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma)
COLLADASW::ColorOrTexture cot;
ep.setShaderType(COLLADASW::EffectProfile::PHONG);
// shininess
- ep.setShininess(ma->har, false, "shininess" );
+ ep.setShininess(ma->har, false, "shininess");
// specular
cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
- ep.setSpecular(cot, false, "specular" );
+ ep.setSpecular(cot, false, "specular");
}
void EffectsExporter::operator()(Material *ma, Object *ob)
@@ -128,7 +130,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
ep.setProfileType(COLLADASW::EffectProfile::COMMON);
ep.openProfile();
// set shader type - one of three blinn, phong or lambert
- if (ma->spec>0.0f) {
+ if (ma->spec > 0.0f) {
if (ma->spec_shader == MA_SPEC_BLINN) {
writeBlinn(ep, ma);
}
@@ -143,8 +145,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
writeLambert(ep, ma);
}
else {
- // \todo figure out handling of all spec+diff shader combos blender has, for now write phong
- writePhong(ep, ma);
+ // \todo figure out handling of all spec+diff shader combos blender has, for now write phong
+ writePhong(ep, ma);
}
}
@@ -167,7 +169,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
}
// emission
- cot=getcol(ma->emit, ma->emit, ma->emit, 1.0f);
+ cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f);
ep.setEmission(cot, false, "emission");
// diffuse multiplied by diffuse intensity
@@ -177,7 +179,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// ambient
/* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */
if (this->scene->world)
- cot = getcol(this->scene->world->ambr*ma->amb, this->scene->world->ambg*ma->amb, this->scene->world->ambb*ma->amb, 1.0f);
+ cot = getcol(this->scene->world->ambr * ma->amb, this->scene->world->ambg * ma->amb, this->scene->world->ambb * ma->amb, 1.0f);
else
cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f);
@@ -190,9 +192,9 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
ep.setReflectivity(ma->ray_mirror);
}
// else {
- // cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
- // ep.setReflective(cot);
- // ep.setReflectivity(ma->spec);
+ // cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
+ // ep.setReflective(cot);
+ // ep.setReflectivity(ma->spec);
// }
// specular
@@ -228,7 +230,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
if (im_samp_map.find(key) == im_samp_map.end()) {
// //<newparam> <surface> <init_from>
// COLLADASW::Surface surface(COLLADASW::Surface::SURFACE_TYPE_2D,
- // key + COLLADASW::Surface::SURFACE_SID_SUFFIX);
+ // key + COLLADASW::Surface::SURFACE_SID_SUFFIX);
// COLLADASW::SurfaceInitOption sio(COLLADASW::SurfaceInitOption::INIT_FROM);
// sio.setImageReference(key);
// surface.setInitOption(sio);
@@ -238,8 +240,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
//<newparam> <sampler> <source>
COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
- key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
- key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
+ key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
+ key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
sampler.setImageId(key);
// copy values to arrays since they will live longer
samplers[a] = sampler;
@@ -272,7 +274,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
std::string key(id_name(ima));
key = translate_id(key);
int i = im_samp_map[key];
- COLLADASW::Sampler *sampler = (COLLADASW::Sampler*)samp_surf[i][0];
+ COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0];
//COLLADASW::Surface *surface = (COLLADASW::Surface*)samp_surf[i][1];
std::string uvname = strlen(t->uvname) ? t->uvname : active_uv;
@@ -319,7 +321,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
ep.addProfileElements();
bool twoSided = false;
if (ob->type == OB_MESH && ob->data) {
- Mesh *me = (Mesh*)ob->data;
+ Mesh *me = (Mesh *)ob->data;
if (me->flag & ME_TWOSIDED)
twoSided = true;
}
@@ -334,9 +336,9 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
}
COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
- std::string& uv_layer_name,
- COLLADASW::Sampler *sampler
- /*COLLADASW::Surface *surface*/)
+ std::string& uv_layer_name,
+ COLLADASW::Sampler *sampler
+ /*COLLADASW::Surface *surface*/)
{
COLLADASW::Texture texture(translate_id(id_name(ima)));
diff --git a/source/blender/collada/ErrorHandler.cpp b/source/blender/collada/ErrorHandler.cpp
index 530158ed418..7ac138ac807 100644
--- a/source/blender/collada/ErrorHandler.cpp
+++ b/source/blender/collada/ErrorHandler.cpp
@@ -45,36 +45,36 @@ ErrorHandler::~ErrorHandler()
}
//--------------------------------------------------------------------
-bool ErrorHandler::handleError( const COLLADASaxFWL::IError* error )
+bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
{
mError = true;
- if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER ) {
- COLLADASaxFWL::SaxParserError* saxParserError = (COLLADASaxFWL::SaxParserError*) error;
+ if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER) {
+ COLLADASaxFWL::SaxParserError *saxParserError = (COLLADASaxFWL::SaxParserError *) error;
const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();
// Workaround to avoid wrong error
- if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
- if ( strcmp(parserError.getElement(), "effect") == 0 ) {
+ if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
+ if (strcmp(parserError.getElement(), "effect") == 0) {
mError = false;
}
}
- if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
- if ( !((strcmp(parserError.getElement(), "extra") == 0) &&
- (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
+ if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
+ if (!((strcmp(parserError.getElement(), "extra") == 0) &&
+ (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
{
mError = false;
}
}
- if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) {
+ if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) {
std::cout << "Couldn't open file" << std::endl;
}
std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl;
}
- else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL ) {
- COLLADASaxFWL::SaxFWLError* saxFWLError = (COLLADASaxFWL::SaxFWLError*) error;
+ else if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL) {
+ COLLADASaxFWL::SaxFWLError *saxFWLError = (COLLADASaxFWL::SaxFWLError *) error;
std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
}
else {
diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h
index a6ae29bf2b2..e856eefab99 100644
--- a/source/blender/collada/ExportSettings.h
+++ b/source/blender/collada/ExportSettings.h
@@ -24,6 +24,10 @@
* \ingroup collada
*/
+extern "C" {
+#include "BLI_linklist.h"
+}
+
#ifndef __EXPORTSETTINGS_H__
#define __EXPORTSETTINGS_H__
@@ -33,10 +37,12 @@ struct ExportSettings
bool selected;
bool apply_modifiers;
bool include_armatures;
- bool include_bone_children;
+ bool include_children;
bool use_object_instantiation;
+ bool sort_by_name;
bool second_life;
char *filepath;
+ LinkNode *export_set;
};
#endif
diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp
index 6606fe1a27b..df49b4fe8b4 100644
--- a/source/blender/collada/ExtraHandler.cpp
+++ b/source/blender/collada/ExtraHandler.cpp
@@ -35,9 +35,10 @@ ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp) : cu
this->aimp = aimp;
}
-ExtraHandler::~ExtraHandler() {}
+ExtraHandler::~ExtraHandler() {
+}
-bool ExtraHandler::elementBegin( const char* elementName, const char** attributes)
+bool ExtraHandler::elementBegin(const char *elementName, const char **attributes)
{
// \todo attribute handling for profile tags
currentElement = std::string(elementName);
@@ -45,37 +46,38 @@ bool ExtraHandler::elementBegin( const char* elementName, const char** attribute
return true;
}
-bool ExtraHandler::elementEnd(const char* elementName )
+bool ExtraHandler::elementEnd(const char *elementName)
{
return true;
}
-bool ExtraHandler::textData(const char* text, size_t textLength)
+bool ExtraHandler::textData(const char *text, size_t textLength)
{
char buf[1024];
if (currentElement.length() == 0 || currentExtraTags == 0) return false;
- BLI_snprintf(buf, textLength+1, "%s", text);
+ BLI_snprintf(buf, textLength + 1, "%s", text);
currentExtraTags->addTag(currentElement, std::string(buf));
return true;
}
-bool ExtraHandler::parseElement (
- const char* profileName,
- const unsigned long& elementHash,
- const COLLADAFW::UniqueId& uniqueId ) {
- if (BLI_strcaseeq(profileName, "blender")) {
- //printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
- currentUid = uniqueId;
- ExtraTags *et = dimp->getExtraTags(uniqueId);
- if (!et) {
- et = new ExtraTags(std::string(profileName));
- dimp->addExtraTags(uniqueId, et);
- }
- currentExtraTags = et;
- return true;
+bool ExtraHandler::parseElement(
+ const char *profileName,
+ const unsigned long& elementHash,
+ const COLLADAFW::UniqueId& uniqueId)
+{
+ if (BLI_strcaseeq(profileName, "blender")) {
+ //printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
+ currentUid = uniqueId;
+ ExtraTags *et = dimp->getExtraTags(uniqueId);
+ if (!et) {
+ et = new ExtraTags(std::string(profileName));
+ dimp->addExtraTags(uniqueId, et);
}
- //printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
- return false;
+ currentExtraTags = et;
+ return true;
+ }
+ //printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
+ return false;
}
diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp
index c5a126894cb..6af61432fda 100644
--- a/source/blender/collada/ExtraTags.cpp
+++ b/source/blender/collada/ExtraTags.cpp
@@ -32,7 +32,7 @@
#include "ExtraTags.h"
-ExtraTags::ExtraTags( std::string profile)
+ExtraTags::ExtraTags(std::string profile)
{
this->profile = profile;
this->tags = std::map<std::string, std::string>();
@@ -42,19 +42,19 @@ ExtraTags::~ExtraTags()
{
}
-bool ExtraTags::isProfile( std::string profile)
+bool ExtraTags::isProfile(std::string profile)
{
return this->profile == profile;
}
-bool ExtraTags::addTag( std::string tag, std::string data)
+bool ExtraTags::addTag(std::string tag, std::string data)
{
tags[tag] = data;
return true;
}
-int ExtraTags::asInt( std::string tag, bool *ok)
+int ExtraTags::asInt(std::string tag, bool *ok)
{
if (tags.find(tag) == tags.end()) {
*ok = false;
@@ -64,7 +64,7 @@ int ExtraTags::asInt( std::string tag, bool *ok)
return atoi(tags[tag].c_str());
}
-float ExtraTags::asFloat( std::string tag, bool *ok)
+float ExtraTags::asFloat(std::string tag, bool *ok)
{
if (tags.find(tag) == tags.end()) {
*ok = false;
@@ -74,7 +74,7 @@ float ExtraTags::asFloat( std::string tag, bool *ok)
return (float)atof(tags[tag].c_str());
}
-std::string ExtraTags::asString( std::string tag, bool *ok)
+std::string ExtraTags::asString(std::string tag, bool *ok)
{
if (tags.find(tag) == tags.end()) {
*ok = false;
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 53d7f1e6449..94b977ca01c 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -38,7 +38,7 @@
#include "DNA_meshdata_types.h"
extern "C" {
- #include "BKE_DerivedMesh.h"
+ #include "BKE_DerivedMesh.h"
#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_library.h"
@@ -52,7 +52,8 @@ extern "C" {
#include "collada_utils.h"
// TODO: optimize UV sets by making indexed list with duplicates removed
-GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) {}
+GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) {
+}
void GeometryExporter::exportGeom(Scene *sce)
@@ -61,7 +62,7 @@ void GeometryExporter::exportGeom(Scene *sce)
mScene = sce;
GeometryFunctor gf;
- gf.forEachMeshObjectInScene<GeometryExporter>(sce, *this, this->export_settings->selected);
+ gf.forEachMeshObjectInExportSet<GeometryExporter>(sce, *this, this->export_settings->export_set);
closeLibrary();
}
@@ -76,11 +77,11 @@ void GeometryExporter::operator()(Object *ob)
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
- if ( this->export_settings->apply_modifiers ) {
+ if (this->export_settings->apply_modifiers) {
me = bc_to_mesh_apply_modifiers(mScene, ob);
}
else {
- me = (Mesh*)ob->data;
+ me = (Mesh *)ob->data;
}
BKE_mesh_tessface_ensure(me);
@@ -90,8 +91,10 @@ void GeometryExporter::operator()(Object *ob)
// Skip if linked geometry was already exported from another reference
if (use_instantiation &&
- exportedGeometry.find(geom_id) != exportedGeometry.end())
+ exportedGeometry.find(geom_id) != exportedGeometry.end())
+ {
return;
+ }
std::string geom_name = (use_instantiation) ? id_name(ob->data) : id_name(ob);
@@ -132,7 +135,7 @@ void GeometryExporter::operator()(Object *ob)
// XXX slow
if (ob->totcol) {
- for (int a = 0; a < ob->totcol; a++) {
+ for (int a = 0; a < ob->totcol; a++) {
createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind);
}
}
@@ -161,9 +164,9 @@ void GeometryExporter::operator()(Object *ob)
void GeometryExporter::createLooseEdgeList(Object *ob,
- Mesh *me,
- std::string& geom_id,
- std::vector<Face>& norind)
+ Mesh *me,
+ std::string& geom_id,
+ std::vector<Face>& norind)
{
MEdge *medges = me->medge;
@@ -204,8 +207,8 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
for (index = 0; index < edges_in_linelist; index++)
{
- lines.appendValues(edge_list[2*index+1]);
- lines.appendValues(edge_list[2*index]);
+ lines.appendValues(edge_list[2 * index + 1]);
+ lines.appendValues(edge_list[2 * index]);
}
lines.finish();
}
@@ -214,12 +217,12 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
// powerful because it handles both cases when there is material and when there's not
void GeometryExporter::createPolylist(short material_index,
- bool has_uvs,
- bool has_color,
- Object *ob,
- Mesh *me,
- std::string& geom_id,
- std::vector<Face>& norind)
+ bool has_uvs,
+ bool has_color,
+ Object *ob,
+ Mesh *me,
+ std::string& geom_id,
+ std::vector<Face>& norind)
{
MFace *mfaces = me->mface;
int totfaces = me->totface;
@@ -280,10 +283,10 @@ void GeometryExporter::createPolylist(short material_index,
for (i = 0; i < num_layers; i++) {
// char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
- makeUrl(makeTexcoordSourceId(geom_id, i)),
- 2, // offset always 2, this is only until we have optimized UV sets
- i // set number equals UV map index
- );
+ makeUrl(makeTexcoordSourceId(geom_id, i)),
+ 2, // offset always 2, this is only until we have optimized UV sets
+ i // set number equals UV map index
+ );
til.push_back(input3);
}
@@ -342,7 +345,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
COLLADASW::FloatSourceF source(mSW);
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION) +
- ARRAY_ID_SUFFIX);
+ ARRAY_ID_SUFFIX);
source.setAccessorCount(totverts);
source.setAccessorStride(3);
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
@@ -350,7 +353,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
param.push_back("Y");
param.push_back("Z");
/*main function, it creates <source id = "">, <float_array id = ""
- count = ""> */
+ count = ""> */
source.prepareToAppendValues();
//appends data to <float_array>
int i = 0;
@@ -388,7 +391,7 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
int index = CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
- MCol *mcol = (MCol*)me->fdata.layers[index].data;
+ MCol *mcol = (MCol *)me->fdata.layers[index].data;
MCol *c = mcol;
for (i = 0, f = me->mface; i < me->totface; i++, c += 4, f++)
@@ -422,10 +425,10 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
for (i = 0; i < totfaces; i++) {
MFace *f = &mfaces[i];
if (f->v4 == 0) {
- totuv+=3;
+ totuv += 3;
}
else {
- totuv+=4;
+ totuv += 4;
}
}
@@ -434,7 +437,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
// write <source> for each layer
// each <source> will get id like meshName + "map-channel-1"
for (int a = 0; a < num_layers; a++) {
- MTFace *tface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a);
+ MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a);
// char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, a);
COLLADASW::FloatSourceF source(mSW);
@@ -455,7 +458,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
for (int j = 0; j < (f->v4 == 0 ? 3 : 4); j++) {
source.appendValues(tface[i].uv[j][0],
- tface[i].uv[j][1]);
+ tface[i].uv[j][1]);
}
}
@@ -475,7 +478,7 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v
COLLADASW::FloatSourceF source(mSW);
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL) +
- ARRAY_ID_SUFFIX);
+ ARRAY_ID_SUFFIX);
source.setAccessorCount((unsigned long)nor.size());
source.setAccessorStride(3);
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
@@ -563,8 +566,9 @@ COLLADASW::URI GeometryExporter::makeUrl(std::string id)
return COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, id);
}
-
-/* int GeometryExporter::getTriCount(MFace *faces, int totface) {
+#if 0
+int GeometryExporter::getTriCount(MFace *faces, int totface)
+{
int i;
int tris = 0;
for (i = 0; i < totface; i++) {
@@ -576,4 +580,5 @@ COLLADASW::URI GeometryExporter::makeUrl(std::string id)
}
return tris;
- }*/
+}
+#endif
diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h
index 23cdcc0a5ba..f14775b9f44 100644
--- a/source/blender/collada/GeometryExporter.h
+++ b/source/blender/collada/GeometryExporter.h
@@ -42,6 +42,8 @@
#include "ExportSettings.h"
+extern Object *bc_get_highest_selected_ancestor_or_self(Object *ob);
+
// TODO: optimize UV sets by making indexed list with duplicates removed
class GeometryExporter : COLLADASW::LibraryGeometries
{
@@ -112,21 +114,15 @@ struct GeometryFunctor {
// f should have
// void operator()(Object* ob)
template<class Functor>
- void forEachMeshObjectInScene(Scene *sce, Functor &f, bool export_selected)
+ void forEachMeshObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
-
- Base *base= (Base*) sce->base.first;
- while (base) {
- Object *ob = base->object;
-
- if (ob->type == OB_MESH && ob->data &&
- !(export_selected && !(ob->flag & SELECT)) &&
- ((sce->lay & ob->lay)!=0))
+ LinkNode *node;
+ for (node=export_set; node; node = node->next) {
+ Object *ob = (Object *)node->link;
+ if (ob->type == OB_MESH)
{
f(ob);
}
- base= base->next;
-
}
}
};
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index 4d7c56ab419..c777a7d1fab 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -42,17 +42,18 @@
#include "BLI_string.h"
ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryImages(sw), export_settings(export_settings)
-{}
+{
+}
bool ImagesExporter::hasImages(Scene *sce)
{
- Base *base = (Base *)sce->base.first;
+ LinkNode *node;
- while (base) {
- Object *ob= base->object;
+ for (node=this->export_settings->export_set; node; node=node->next) {
+ Object *ob = (Object *)node->link;
int a;
for (a = 0; a < ob->totcol; a++) {
- Material *ma = give_current_material(ob, a+1);
+ Material *ma = give_current_material(ob, a + 1);
// no material, but check all of the slots
if (!ma) continue;
@@ -63,7 +64,6 @@ bool ImagesExporter::hasImages(Scene *sce)
}
}
- base= base->next;
}
return false;
}
@@ -73,7 +73,7 @@ void ImagesExporter::exportImages(Scene *sce)
if (hasImages(sce)) {
openLibrary();
MaterialFunctor mf;
- mf.forEachMaterialInScene<ImagesExporter>(sce, *this, this->export_settings->selected);
+ mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set);
closeLibrary();
}
diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp
index f83289ff5f5..788bd2a98b7 100644
--- a/source/blender/collada/InstanceWriter.cpp
+++ b/source/blender/collada/InstanceWriter.cpp
@@ -43,8 +43,8 @@
void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob)
{
- for (int a = 0; a < ob->totcol; a++) {
- Material *ma = give_current_material(ob, a+1);
+ for (int a = 0; a < ob->totcol; a++) {
+ Material *ma = give_current_material(ob, a + 1);
COLLADASW::InstanceMaterialList& iml = bind_material.getInstanceMaterialList();
@@ -56,7 +56,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia
COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid));
// create <bind_vertex_input> for each uv map
- Mesh *me = (Mesh*)ob->data;
+ Mesh *me = (Mesh *)ob->data;
int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
for (int b = 0; b < totlayer; b++) {
diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
index 6d276cd782f..af13d61a368 100644
--- a/source/blender/collada/LightExporter.cpp
+++ b/source/blender/collada/LightExporter.cpp
@@ -36,33 +36,33 @@
#include "collada_internal.h"
template<class Functor>
-void forEachLampObjectInScene(Scene *sce, Functor &f, bool export_selected)
+void forEachLampObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
- Base *base= (Base*) sce->base.first;
- while (base) {
- Object *ob = base->object;
+ LinkNode *node;
+ for (node = export_set; node; node = node->next) {
+ Object *ob = (Object *)node->link;
- if (ob->type == OB_LAMP && ob->data && !(export_selected && !(ob->flag & SELECT))) {
+ if (ob->type == OB_LAMP && ob->data) {
f(ob);
}
- base= base->next;
}
}
-LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryLights(sw), export_settings(export_settings) {}
+LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryLights(sw), export_settings(export_settings) {
+}
void LightsExporter::exportLights(Scene *sce)
{
openLibrary();
- forEachLampObjectInScene(sce, *this, this->export_settings->selected);
+ forEachLampObjectInExportSet(sce, *this, this->export_settings->export_set);
closeLibrary();
}
void LightsExporter::operator()(Object *ob)
{
- Lamp *la = (Lamp*)ob->data;
+ Lamp *la = (Lamp *)ob->data;
std::string la_id(get_light_id(ob));
std::string la_name(id_name(la));
COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy);
@@ -72,7 +72,7 @@ void LightsExporter::operator()(Object *ob)
constatt = 1.0f;
- if (la->falloff_type==LA_FALLOFF_INVLINEAR) {
+ if (la->falloff_type == LA_FALLOFF_INVLINEAR) {
linatt = 1.0f / d;
quadatt = 0.0f;
}
diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp
index 48fa5b690be..ef22a76d28e 100644
--- a/source/blender/collada/MaterialExporter.cpp
+++ b/source/blender/collada/MaterialExporter.cpp
@@ -31,7 +31,8 @@
#include "COLLADABUUtils.h"
#include "collada_internal.h"
-MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryMaterials(sw), export_settings(export_settings) {}
+MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryMaterials(sw), export_settings(export_settings) {
+}
void MaterialsExporter::exportMaterials(Scene *sce)
{
@@ -39,29 +40,26 @@ void MaterialsExporter::exportMaterials(Scene *sce)
openLibrary();
MaterialFunctor mf;
- mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, this->export_settings->selected);
+ mf.forEachMaterialInExportSet<MaterialsExporter>(sce, *this, this->export_settings->export_set);
closeLibrary();
}
}
-
bool MaterialsExporter::hasMaterials(Scene *sce)
{
- Base *base = (Base *)sce->base.first;
-
- while (base) {
- Object *ob= base->object;
+ LinkNode *node;
+ for(node=this->export_settings->export_set; node; node = node->next) {
+ Object *ob = (Object *)node->link;
int a;
for (a = 0; a < ob->totcol; a++) {
- Material *ma = give_current_material(ob, a+1);
+ Material *ma = give_current_material(ob, a + 1);
// no material, but check all of the slots
if (!ma) continue;
return true;
}
- base= base->next;
}
return false;
}
diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h
index 4a5422184d4..f65c8849c84 100644
--- a/source/blender/collada/MaterialExporter.h
+++ b/source/blender/collada/MaterialExporter.h
@@ -89,11 +89,11 @@ struct MaterialFunctor {
// f should have
// void operator()(Material* ma)
template<class Functor>
- void forEachMaterialInScene(Scene *sce, Functor &f, bool export_selected)
+ void forEachMaterialInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
ForEachMaterialFunctor<Functor> matfunc(&f);
GeometryFunctor gf;
- gf.forEachMeshObjectInScene<ForEachMaterialFunctor<Functor> >(sce, matfunc, export_selected);
+ gf.forEachMeshObjectInExportSet<ForEachMaterialFunctor<Functor> >(sce, matfunc, export_set);
}
};
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index bcfec7a8056..59927e961bf 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -72,24 +72,24 @@ static const char *bc_get_dae_name(T *node)
static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type)
{
switch (type) {
- case COLLADAFW::MeshPrimitive::LINES:
- return "LINES";
- case COLLADAFW::MeshPrimitive::LINE_STRIPS:
- return "LINESTRIPS";
- case COLLADAFW::MeshPrimitive::POLYGONS:
- return "POLYGONS";
- case COLLADAFW::MeshPrimitive::POLYLIST:
- return "POLYLIST";
- case COLLADAFW::MeshPrimitive::TRIANGLES:
- return "TRIANGLES";
- case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
- return "TRIANGLE_FANS";
- case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
- return "TRIANGLE_FANS";
- case COLLADAFW::MeshPrimitive::POINTS:
- return "POINTS";
- case COLLADAFW::MeshPrimitive::UNDEFINED_PRIMITIVE_TYPE:
- return "UNDEFINED_PRIMITIVE_TYPE";
+ case COLLADAFW::MeshPrimitive::LINES:
+ return "LINES";
+ case COLLADAFW::MeshPrimitive::LINE_STRIPS:
+ return "LINESTRIPS";
+ case COLLADAFW::MeshPrimitive::POLYGONS:
+ return "POLYGONS";
+ case COLLADAFW::MeshPrimitive::POLYLIST:
+ return "POLYLIST";
+ case COLLADAFW::MeshPrimitive::TRIANGLES:
+ return "TRIANGLES";
+ case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
+ return "TRIANGLE_FANS";
+ case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
+ return "TRIANGLE_FANS";
+ case COLLADAFW::MeshPrimitive::POINTS:
+ return "POINTS";
+ case COLLADAFW::MeshPrimitive::UNDEFINED_PRIMITIVE_TYPE:
+ return "UNDEFINED_PRIMITIVE_TYPE";
}
return "UNKNOWN";
}
@@ -97,43 +97,44 @@ static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type
static const char *bc_geomTypeToStr(COLLADAFW::Geometry::GeometryType type)
{
switch (type) {
- case COLLADAFW::Geometry::GEO_TYPE_MESH:
- return "MESH";
- case COLLADAFW::Geometry::GEO_TYPE_SPLINE:
- return "SPLINE";
- case COLLADAFW::Geometry::GEO_TYPE_CONVEX_MESH:
- return "CONVEX_MESH";
- case COLLADAFW::Geometry::GEO_TYPE_UNKNOWN:
- default:
- return "UNKNOWN";
+ case COLLADAFW::Geometry::GEO_TYPE_MESH:
+ return "MESH";
+ case COLLADAFW::Geometry::GEO_TYPE_SPLINE:
+ return "SPLINE";
+ case COLLADAFW::Geometry::GEO_TYPE_CONVEX_MESH:
+ return "CONVEX_MESH";
+ case COLLADAFW::Geometry::GEO_TYPE_UNKNOWN:
+ default:
+ return "UNKNOWN";
}
}
UVDataWrapper::UVDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata)
-{}
+{
+}
#ifdef COLLADA_DEBUG
void WVDataWrapper::print()
{
fprintf(stderr, "UVs:\n");
switch (mVData->getType()) {
- case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
- COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
+ COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
if (values->getCount()) {
for (int i = 0; i < values->getCount(); i += 2) {
- fprintf(stderr, "%.1f, %.1f\n", (*values)[i], (*values)[i+1]);
+ fprintf(stderr, "%.1f, %.1f\n", (*values)[i], (*values)[i + 1]);
}
}
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
- COLLADAFW::ArrayPrimitiveType<double>* values = mVData->getDoubleValues();
+ COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->getCount()) {
for (int i = 0; i < values->getCount(); i += 2) {
- fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i+1]);
+ fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i + 1]);
}
}
}
@@ -146,30 +147,30 @@ void WVDataWrapper::print()
void UVDataWrapper::getUV(int uv_index, float *uv)
{
int stride = mVData->getStride(0);
- if (stride==0) stride = 2;
+ if (stride == 0) stride = 2;
switch (mVData->getType()) {
- case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
- COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
+ COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
if (values->empty()) return;
- uv[0] = (*values)[uv_index*stride];
- uv[1] = (*values)[uv_index*stride + 1];
+ uv[0] = (*values)[uv_index * stride];
+ uv[1] = (*values)[uv_index * stride + 1];
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
- COLLADAFW::ArrayPrimitiveType<double>* values = mVData->getDoubleValues();
+ COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->empty()) return;
- uv[0] = (float)(*values)[uv_index*stride];
- uv[1] = (float)(*values)[uv_index*stride + 1];
+ uv[0] = (float)(*values)[uv_index * stride];
+ uv[1] = (float)(*values)[uv_index * stride + 1];
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
- default:
- fprintf(stderr, "MeshImporter.getUV(): unknown data type\n");
+ case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
+ default:
+ fprintf(stderr, "MeshImporter.getUV(): unknown data type\n");
}
}
@@ -198,7 +199,7 @@ void MeshImporter::rotate_face_indices(MFace *mface)
#endif
void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
- COLLADAFW::IndexList& index_list, unsigned int *tris_indices)
+ COLLADAFW::IndexList& index_list, unsigned int *tris_indices)
{
// per face vertex indices, this means for quad we have 4 indices, not 8
COLLADAFW::UIntValuesArray& indices = index_list.getIndices();
@@ -209,7 +210,7 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
}
void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
- COLLADAFW::IndexList& index_list, int index, bool quad)
+ COLLADAFW::IndexList& index_list, int index, bool quad)
{
// per face vertex indices, this means for quad we have 4 indices, not 8
COLLADAFW::UIntValuesArray& indices = index_list.getIndices();
@@ -223,31 +224,31 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
#ifdef COLLADA_DEBUG
if (quad) {
fprintf(stderr, "face uv:\n"
- "((%d, %d, %d, %d))\n"
- "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
-
- indices[index + 0],
- indices[index + 1],
- indices[index + 2],
- indices[index + 3],
-
- mtface->uv[0][0], mtface->uv[0][1],
- mtface->uv[1][0], mtface->uv[1][1],
- mtface->uv[2][0], mtface->uv[2][1],
- mtface->uv[3][0], mtface->uv[3][1]);
+ "((%d, %d, %d, %d))\n"
+ "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
+
+ indices[index + 0],
+ indices[index + 1],
+ indices[index + 2],
+ indices[index + 3],
+
+ mtface->uv[0][0], mtface->uv[0][1],
+ mtface->uv[1][0], mtface->uv[1][1],
+ mtface->uv[2][0], mtface->uv[2][1],
+ mtface->uv[3][0], mtface->uv[3][1]);
}
else {
fprintf(stderr, "face uv:\n"
- "((%d, %d, %d))\n"
- "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
+ "((%d, %d, %d))\n"
+ "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
- indices[index + 0],
- indices[index + 1],
- indices[index + 2],
+ indices[index + 0],
+ indices[index + 1],
+ indices[index + 2],
- mtface->uv[0][0], mtface->uv[0][1],
- mtface->uv[1][0], mtface->uv[1][1],
- mtface->uv[2][0], mtface->uv[2][1]);
+ mtface->uv[0][0], mtface->uv[0][1],
+ mtface->uv[1][0], mtface->uv[1][1],
+ mtface->uv[2][0], mtface->uv[2][1]);
}
#endif
}
@@ -263,7 +264,7 @@ void MeshImporter::print_index_list(COLLADAFW::IndexList& index_list)
}
#endif
-bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
+bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
{
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
@@ -279,26 +280,26 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has sup
// OpenCollada passes POLYGONS type for <polylist>
if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
- COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
+ COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vca = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < vca.getCount(); j++) {
int count = vca[j];
if (count < 3) {
fprintf(stderr, "Primitive %s in %s has at least one face with vertex count < 3\n",
- type_str, name);
+ type_str, name);
return false;
}
}
}
- else if ( type == COLLADAFW::MeshPrimitive::LINES )
+ else if (type == COLLADAFW::MeshPrimitive::LINES)
{
// TODO: Add Checker for line syntax here
}
- else if (type != COLLADAFW::MeshPrimitive::TRIANGLES && type!= COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
+ else if (type != COLLADAFW::MeshPrimitive::TRIANGLES && type != COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
fprintf(stderr, "Primitive type %s is not supported.\n", type_str);
return false;
}
@@ -317,10 +318,10 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
// vertices
COLLADAFW::MeshVertexData& pos = mesh->getPositions();
int stride = pos.getStride(0);
- if (stride==0) stride = 3;
+ if (stride == 0) stride = 3;
me->totvert = mesh->getPositions().getFloatValues()->getCount() / stride;
- me->mvert = (MVert*)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
+ me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
MVert *mvert;
int i;
@@ -339,12 +340,12 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve
dispbase.first = dispbase.last = NULL;
- dl = (DispList*)MEM_callocN(sizeof(DispList), "poly disp");
+ dl = (DispList *)MEM_callocN(sizeof(DispList), "poly disp");
dl->nr = totvert;
dl->type = DL_POLY;
dl->parts = 1;
- dl->verts = vert = (float*)MEM_callocN(totvert * 3 * sizeof(float), "poly verts");
- dl->index = (int*)MEM_callocN(sizeof(int) * 3 * totvert, "dl index");
+ dl->verts = vert = (float *)MEM_callocN(totvert * 3 * sizeof(float), "poly verts");
+ dl->index = (int *)MEM_callocN(sizeof(int) * 3 * totvert, "dl index");
BLI_addtail(&dispbase, dl);
@@ -356,14 +357,14 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve
BKE_displist_fill(&dispbase, &dispbase, 0);
int tottri = 0;
- dl= (DispList*)dispbase.first;
+ dl = (DispList *)dispbase.first;
if (dl->type == DL_INDEX3) {
tottri = dl->parts;
int *index = dl->index;
- for (i= 0; i < tottri; i++) {
- int t[3]= {*index, *(index + 1), *(index + 2)};
+ for (i = 0; i < tottri; i++) {
+ int t[3] = {*index, *(index + 1), *(index + 2)};
std::sort(t, t + 3);
@@ -394,9 +395,9 @@ int MeshImporter::count_new_tris(COLLADAFW::Mesh *mesh, Mesh *me)
unsigned int *indices = mp->getPositionIndices().getData();
if (type == COLLADAFW::MeshPrimitive::POLYLIST ||
- type == COLLADAFW::MeshPrimitive::POLYGONS) {
-
- COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
+ type == COLLADAFW::MeshPrimitive::POLYGONS)
+ {
+ COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vcounta = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < prim_totface; j++) {
@@ -433,8 +434,8 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) {
has_useable_normals = true;
else {
fprintf(stderr,
- "Warning: Number of normals %d is different from the number of vertices %d, skipping normals\n",
- normals_count, index_count );
+ "Warning: Number of normals %d is different from the number of vertices %d, skipping normals\n",
+ normals_count, index_count);
}
}
@@ -496,7 +497,7 @@ void MeshImporter::allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_t
// allocate space for faces
if (total_facecount > 0) {
me->totface = total_facecount + new_tris;
- me->mface = (MFace*)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
+ me->mface = (MFace *)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
}
}
@@ -566,7 +567,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
{
unsigned int loose_edge_count = get_loose_edge_count(mesh);
- if(loose_edge_count > 0) {
+ if (loose_edge_count > 0) {
unsigned int face_edge_count = me->totedge;
unsigned int total_edge_count = loose_edge_count + face_edge_count;
@@ -587,11 +588,11 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
unsigned int *indices = mp->getPositionIndices().getData();
for (int i = 0; i < edge_count; i++, med++) {
- med->bweight= 0;
- med->crease = 0;
- med->flag = 0;
- med->v1 = indices[ 2*i ];
- med->v2 = indices[ 2*i + 1];
+ med->bweight = 0;
+ med->crease = 0;
+ med->flag = 0;
+ med->v1 = indices[2 * i];
+ med->v2 = indices[2 * i + 1];
}
}
}
@@ -630,7 +631,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
// activate the first uv map
- if (totuvset) me->mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, 0);
+ if (totuvset) me->mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, 0);
UVDataWrapper uvs(mesh->getUVCoords());
@@ -669,11 +670,11 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
#ifdef COLLADA_DEBUG
/*
- fprintf(stderr, "Primitive %d:\n", i);
- for (unsigned int j = 0; j < totuvset; j++) {
- print_index_list(*index_list_array[j]);
- }
- */
+ fprintf(stderr, "Primitive %d:\n", i);
+ for (unsigned int j = 0; j < totuvset; j++) {
+ print_index_list(*index_list_array[j]);
+ }
+ */
#endif
if (type == COLLADAFW::MeshPrimitive::TRIANGLES) {
@@ -686,14 +687,14 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, k, *index_list_array[k], index, false);
}
}
#else
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, false);
}
#endif
@@ -725,24 +726,24 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) {
// For each triangle store indeces of its 3 vertices
- unsigned int triangle_vertex_indices[3]={first_vertex, indices[1], indices[2]};
+ unsigned int triangle_vertex_indices[3] = {first_vertex, indices[1], indices[2]};
set_face_indices(mface, triangle_vertex_indices, false);
test_index_face(mface, &me->fdata, face_index, 3);
if (mp_has_normals) { // vertex normals, same inplementation as for the triangles
// the same for vertces normals
- unsigned int vertex_normal_indices[3]={first_normal, nind[1], nind[2]};
+ unsigned int vertex_normal_indices[3] = {first_normal, nind[1], nind[2]};
if (!flat_face(vertex_normal_indices, nor, 3))
mface->flag |= ME_SMOOTH;
- nind++;
- }
-
- mface++; // same inplementation as for the triangles
- indices++;
- face_index++;
- prim.totface++;
+ nind++;
}
+ mface++; // same inplementation as for the triangles
+ indices++;
+ face_index++;
+ prim.totface++;
+ }
+
// Moving cursor to the next triangle fan.
if (mp_has_normals)
nind += 2;
@@ -751,7 +752,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
}
else if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
- COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
+ COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vcounta = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < prim_totface; j++) {
@@ -769,14 +770,14 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, k, *index_list_array[k], index, mface->v4 != 0);
}
}
#else
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, vcount == 4);
}
#endif
@@ -819,7 +820,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int l = 0; l < totuvset; l++) {
if (!index_list_array.empty() && index_list_array[l]) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, l);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, l);
set_face_uv(&mtface[face_index], uvs, l, *index_list_array[l], uv_indices);
}
}
@@ -828,7 +829,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
int uvset_index = index_list_array[l]->getSetIndex();
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, uvset_index);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, uvset_index);
set_face_uv(&mtface[face_index], uvs, *index_list_array[l], uv_indices);
}
#endif
@@ -873,9 +874,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
i *= stride;
switch (arr.getType()) {
- case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
- COLLADAFW::ArrayPrimitiveType<float>* values = arr.getFloatValues();
+ COLLADAFW::ArrayPrimitiveType<float> *values = arr.getFloatValues();
if (values->empty()) return;
v[0] = (*values)[i++];
@@ -884,9 +885,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
- COLLADAFW::ArrayPrimitiveType<double>* values = arr.getDoubleValues();
+ COLLADAFW::ArrayPrimitiveType<double> *values = arr.getDoubleValues();
if (values->empty()) return;
v[0] = (float)(*values)[i++];
@@ -894,8 +895,8 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
v[2] = (float)(*values)[i];
}
break;
- default:
- break;
+ default:
+ break;
}
}
@@ -921,12 +922,13 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor,
return true;
}
-MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {}
+MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {
+}
void MeshImporter::bmeshConversion()
{
- for (std::map<COLLADAFW::UniqueId, Mesh*>::iterator m = uid_mesh_map.begin();
- m != uid_mesh_map.end(); ++m)
+ for (std::map<COLLADAFW::UniqueId, Mesh *>::iterator m = uid_mesh_map.begin();
+ m != uid_mesh_map.end(); ++m)
{
if ((*m).second) {
Mesh *me = (*m).second;
@@ -947,21 +949,21 @@ Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid
}
MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture,
- Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map,
- MTex *color_texture)
+ Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map,
+ MTex *color_texture)
{
const COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId();
size_t setindex = ctexture.getSetIndex();
std::string uvname = ctexture.getSemantic();
- if (setindex==-1) return NULL;
+ if (setindex == -1) return NULL;
const CustomData *data = &me->fdata;
int layer_index = CustomData_get_layer_index(data, CD_MTFACE);
if (layer_index == -1) return NULL;
- CustomDataLayer *cdl = &data->layers[layer_index+setindex];
+ CustomDataLayer *cdl = &data->layers[layer_index + setindex];
/* set uvname to bind_vertex_input semantic */
BLI_strncpy(cdl->name, uvname.c_str(), sizeof(cdl->name));
@@ -972,9 +974,9 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
return color_texture;
}
- std::vector<MTex*> textures = texindex_texarray_map[texture_index];
+ std::vector<MTex *> textures = texindex_texarray_map[texture_index];
- std::vector<MTex*>::iterator it;
+ std::vector<MTex *>::iterator it;
for (it = textures.begin(); it != textures.end(); it++) {
@@ -989,12 +991,12 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
}
MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmaterial,
- std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
- Object *ob, const COLLADAFW::UniqueId *geom_uid,
- MTex **color_texture, char *layername, MTFace *texture_face,
- std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
+ std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
+ Object *ob, const COLLADAFW::UniqueId *geom_uid,
+ MTex **color_texture, char *layername, MTFace *texture_face,
+ std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
{
- Mesh *me = (Mesh*)ob->data;
+ Mesh *me = (Mesh *)ob->data;
const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial();
// do we know this material?
@@ -1008,9 +1010,9 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
// again. Make sure we don't overwrite them on the next occurrences, so keep list of
// what we already have handled.
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>::iterator it;
- it=materials_mapped_to_geom.find(*geom_uid);
- while (it!=materials_mapped_to_geom.end()) {
- if (it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found
+ it = materials_mapped_to_geom.find(*geom_uid);
+ while (it != materials_mapped_to_geom.end()) {
+ if (it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found
it++;
}
// first time we get geom_uid, ma_uid pair. Save for later check.
@@ -1020,22 +1022,22 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
assign_material(ob, ma, ob->totcol + 1);
COLLADAFW::TextureCoordinateBindingArray& tex_array =
- cmaterial.getTextureCoordinateBindingArray();
+ cmaterial.getTextureCoordinateBindingArray();
TexIndexTextureArrayMap texindex_texarray_map = material_texture_mapping_map[ma];
unsigned int i;
// loop through <bind_vertex_inputs>
for (i = 0; i < tex_array.getCount(); i++) {
*color_texture = assign_textures_to_uvlayer(tex_array[i], me, texindex_texarray_map,
- *color_texture);
+ *color_texture);
}
// set texture face
if (*color_texture &&
- strlen((*color_texture)->uvname) &&
- strcmp(layername, (*color_texture)->uvname) != 0) {
- texture_face = (MTFace*)CustomData_get_layer_named(&me->fdata, CD_MTFACE,
- (*color_texture)->uvname);
+ strlen((*color_texture)->uvname) &&
+ strcmp(layername, (*color_texture)->uvname) != 0) {
+ texture_face = (MTFace *)CustomData_get_layer_named(&me->fdata, CD_MTFACE,
+ (*color_texture)->uvname);
strcpy(layername, (*color_texture)->uvname);
}
@@ -1057,7 +1059,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
mface->mat_nr = mat_index;
// bind texture images to faces
if (texture_face && (*color_texture)) {
- texture_face->tpage = (Image*)(*color_texture)->tex->ima;
+ texture_face->tpage = (Image *)(*color_texture)->tex->ima;
texture_face++;
}
}
@@ -1068,9 +1070,9 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
}
Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
- bool isController,
- std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
- std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map)
+ bool isController,
+ std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
+ std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map)
{
const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
@@ -1097,7 +1099,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
// name Object
const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId();
- const char *name = (id.length())? id.c_str(): NULL;
+ const char *name = (id.length()) ? id.c_str() : NULL;
// add object
Object *ob = bc_add_object(scene, OB_MESH, name);
@@ -1106,7 +1108,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
uid_object_map[*geom_uid] = ob;
// replace ob->data freeing the old one
- Mesh *old_mesh = (Mesh*)ob->data;
+ Mesh *old_mesh = (Mesh *)ob->data;
set_mesh(ob, uid_mesh_map[*geom_uid]);
@@ -1118,15 +1120,15 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
MTex *color_texture = NULL;
COLLADAFW::MaterialBindingArray& mat_array =
- geom->getMaterialBindings();
+ geom->getMaterialBindings();
// loop through geom's materials
- for (unsigned int i = 0; i < mat_array.getCount(); i++) {
+ for (unsigned int i = 0; i < mat_array.getCount(); i++) {
if (mat_array[i].getReferencedMaterial().isValid()) {
texture_face = assign_material_to_geom(mat_array[i], uid_material_map, ob, geom_uid,
- &color_texture, layername, texture_face,
- material_texture_mapping_map, i);
+ &color_texture, layername, texture_face,
+ material_texture_mapping_map, i);
}
else {
fprintf(stderr, "invalid referenced material for %s\n", mat_array[i].getName().c_str());
@@ -1137,7 +1139,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
}
// create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
-bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
+bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
{
// TODO: import also uvs, normals
// XXX what to do with normal indices?
@@ -1150,7 +1152,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
return true;
}
- COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh*)geom;
+ COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom;
if (!is_nice_mesh(mesh)) {
fprintf(stderr, "Ignoring mesh %s\n", bc_get_dae_name(mesh));
@@ -1158,7 +1160,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
}
const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId();
- Mesh *me = BKE_mesh_add((char*)str_geom_id.c_str());
+ Mesh *me = BKE_mesh_add((char *)str_geom_id.c_str());
me->id.us--; // is already 1 here, but will be set later in set_mesh
// store the Mesh pointer to link it later with an Object
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 510107272cd..bd746e241ca 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -26,10 +26,12 @@
#include "SceneExporter.h"
#include "collada_utils.h"
+#include "BKE_object.h"
SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings)
: COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm), export_settings(export_settings)
-{}
+{
+}
void SceneExporter::exportScene(Scene *sce)
{
@@ -41,120 +43,101 @@ void SceneExporter::exportScene(Scene *sce)
closeLibrary();
}
-// Returns true if the parent chain does not contain any selected object
-// Otherwise return false (ob has selected predecessor)
-bool is_exported_base_node(Object *ob, bool selection_only) {
-
- if (selection_only && ob->flag & SELECT) {
- // Move up towards root object,
- // stop at first selected predecessor's child,
- // or at root, if no parent was selected
- while (ob->parent && (ob->parent->type==OB_ARMATURE || !(ob->parent->flag & SELECT)))
+void SceneExporter::exportHierarchy(Scene *sce)
+{
+ LinkNode *node;
+ std::vector<Object *> base_objects;
+
+ // Ensure all objects in the export_set are marked
+ for (node = this->export_settings->export_set; node; node = node->next) {
+ Object *ob = (Object *) node->link;
+ ob->id.flag |= LIB_DOIT;
+ }
+
+ // Now find all exportable base ojects (highest in export hierarchy)
+ for (node = this->export_settings->export_set; node; node = node->next) {
+ Object *ob = (Object *) node->link;
+ if (bc_is_base_node(this->export_settings->export_set, ob))
{
- ob = ob->parent;
+ switch (ob->type) {
+ case OB_MESH:
+ case OB_CAMERA:
+ case OB_LAMP:
+ case OB_EMPTY:
+ case OB_ARMATURE:
+ base_objects.push_back(ob);
+ break;
+ }
}
}
- return !ob->parent;
-}
-
-void SceneExporter::exportHierarchy(Scene *sce)
-{
- Base *base= (Base*) sce->base.first;
- while (base) {
- Object *ob = base->object;
-
- bool is_export_base_node = is_exported_base_node(ob, this->export_settings->selected);
- if (is_export_base_node) {
- if (sce->lay & ob->lay) {
- switch (ob->type) {
- case OB_MESH:
- case OB_CAMERA:
- case OB_LAMP:
- case OB_EMPTY:
- if (this->export_settings->selected && !(ob->flag & SELECT)) {
- break;
- }
- // write nodes....
- writeNodes(ob, sce);
- break;
- }
- }
+ // And now export the base objects:
+ for (int index = 0; index < base_objects.size(); index++) {
+ Object *ob = base_objects[index];
+ if (bc_is_marked(ob)) {
+ bc_remove_mark(ob);
+ writeNodes(ob, sce);
}
-
- base= base->next;
}
}
void SceneExporter::writeNodes(Object *ob, Scene *sce)
{
-
// Add associated armature first if available
- if (this->export_settings->include_armatures) {
- Object *ob_arm = bc_get_assigned_armature(ob);
- if(ob_arm != NULL)
+ bool armature_exported = false;
+ Object *ob_arm = bc_get_assigned_armature(ob);
+ if (ob_arm != NULL)
+ {
+ armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm);
+ if (armature_exported && bc_is_marked(ob_arm)) {
+ bc_remove_mark(ob_arm);
writeNodes(ob_arm, sce);
+ armature_exported = true;
+ }
}
- COLLADASW::Node node(mSW);
- node.setNodeId(translate_id(id_name(ob)));
- node.setNodeName(translate_id(id_name(ob)));
- node.setType(COLLADASW::Node::NODE);
-
- node.start();
-
- bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob);
- std::list<Object*> child_objects;
-
- // XXX Not sure about this.
- // For me this looks more like a very special case for a very special purpose.
- // Wouldn't it be better to have only one option here ?
- //
- // - include children
- //
- // Instead of "include_bone_children" ?
- // then we could just ask:
- // if (this->export_settings->include_children)
- // ...
- if (this->export_settings->include_armatures
- && this->export_settings->include_bone_children) {
-
- // list child objects
- Base *b = (Base*) sce->base.first;
- while (b) {
- // cob - child object
- Object *cob = b->object;
-
- if (cob->parent == ob) {
- switch (cob->type) {
- case OB_MESH:
- case OB_CAMERA:
- case OB_LAMP:
- case OB_EMPTY:
- case OB_ARMATURE:
+ COLLADASW::Node colladaNode(mSW);
+ colladaNode.setNodeId(translate_id(id_name(ob)));
+ colladaNode.setNodeName(translate_id(id_name(ob)));
+ colladaNode.setType(COLLADASW::Node::NODE);
+
+ colladaNode.start();
+
+ std::list<Object *> child_objects;
+
+ // list child objects
+ LinkNode *node;
+ for (node=this->export_settings->export_set; node; node=node->next) {
+ // cob - child object
+ Object *cob = (Object *)node->link;
+
+ if (cob->parent == ob) {
+ switch (cob->type) {
+ case OB_MESH:
+ case OB_CAMERA:
+ case OB_LAMP:
+ case OB_EMPTY:
+ case OB_ARMATURE:
+ if (bc_is_marked(cob))
child_objects.push_back(cob);
- break;
- }
+ break;
}
-
- b = b->next;
}
}
-
- if (ob->type == OB_MESH && this->export_settings->include_armatures && is_skinned_mesh)
+ if (ob->type == OB_MESH && armature_exported)
// for skinned mesh we write obmat in <bind_shape_matrix>
- TransformWriter::add_node_transform_identity(node);
+ TransformWriter::add_node_transform_identity(colladaNode);
else
- TransformWriter::add_node_transform_ob(node, ob);
+ TransformWriter::add_node_transform_ob(colladaNode, ob);
// <instance_geometry>
if (ob->type == OB_MESH) {
bool instance_controller_created = false;
- if (this->export_settings->include_armatures && is_skinned_mesh) {
+ if (armature_exported) {
instance_controller_created = arm_exporter->add_instance_controller(ob);
}
- if (!instance_controller_created){
+ if (!instance_controller_created) {
COLLADASW::InstanceGeometry instGeom(mSW);
instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation)));
@@ -167,9 +150,6 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
// <instance_controller>
else if (ob->type == OB_ARMATURE) {
arm_exporter->add_armature_bones(ob, sce, this, child_objects);
-
- // XXX this looks unstable...
- node.end();
}
// <instance_camera>
@@ -190,18 +170,25 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
GroupObject *go = NULL;
Group *gr = ob->dup_group;
/* printf("group detected '%s'\n", gr->id.name+2); */
- for (go = (GroupObject*)(gr->gobject.first); go; go=go->next) {
+ for (go = (GroupObject *)(gr->gobject.first); go; go = go->next) {
printf("\t%s\n", go->ob->id.name);
}
}
}
- for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) {
- writeNodes(*i, sce);
+ if (ob->type == OB_ARMATURE) {
+ colladaNode.end();
}
+ for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
+ if (bc_is_marked(*i)) {
+ bc_remove_mark(*i);
+ writeNodes(*i, sce);
+ }
+ }
- if (ob->type != OB_ARMATURE)
- node.end();
+ if (ob->type != OB_ARMATURE) {
+ colladaNode.end();
+ }
}
diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp
index edc8981deab..0116f89361b 100644
--- a/source/blender/collada/SkinInfo.cpp
+++ b/source/blender/collada/SkinInfo.cpp
@@ -57,14 +57,15 @@ static const char *bc_get_joint_name(T *node)
// This is used to store data passed in write_controller_data.
// Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
// so that arrays don't get freed until we free them explicitly.
-SkinInfo::SkinInfo() {}
+SkinInfo::SkinInfo() {
+}
SkinInfo::SkinInfo(const SkinInfo& skin) : weights(skin.weights),
- joint_data(skin.joint_data),
- unit_converter(skin.unit_converter),
- ob_arm(skin.ob_arm),
- controller_uid(skin.controller_uid),
- parent(skin.parent)
+ joint_data(skin.joint_data),
+ unit_converter(skin.unit_converter),
+ ob_arm(skin.ob_arm),
+ controller_uid(skin.controller_uid),
+ parent(skin.parent)
{
copy_m4_m4(bind_shape_matrix, (float (*)[4])skin.bind_shape_matrix);
@@ -73,7 +74,8 @@ SkinInfo::SkinInfo(const SkinInfo& skin) : weights(skin.weights),
transfer_int_array_data_const(skin.joint_indices, joint_indices);
}
-SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), parent(NULL) {}
+SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), parent(NULL) {
+}
// nobody owns the data after this, so it should be freed manually with releaseMemory
template <class T>
@@ -87,21 +89,21 @@ void SkinInfo::transfer_array_data(T& src, T& dest)
// when src is const we cannot src.yieldOwnerShip, this is used by copy constructor
void SkinInfo::transfer_int_array_data_const(const COLLADAFW::IntValuesArray& src, COLLADAFW::IntValuesArray& dest)
{
- dest.setData((int*)src.getData(), src.getCount());
+ dest.setData((int *)src.getData(), src.getCount());
dest.yieldOwnerShip();
}
void SkinInfo::transfer_uint_array_data_const(const COLLADAFW::UIntValuesArray& src, COLLADAFW::UIntValuesArray& dest)
{
- dest.setData((unsigned int*)src.getData(), src.getCount());
+ dest.setData((unsigned int *)src.getData(), src.getCount());
dest.yieldOwnerShip();
}
-void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData* skin)
+void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *skin)
{
- transfer_array_data((COLLADAFW::UIntValuesArray&)skin->getJointsPerVertex(), joints_per_vertex);
- transfer_array_data((COLLADAFW::UIntValuesArray&)skin->getWeightIndices(), weight_indices);
- transfer_array_data((COLLADAFW::IntValuesArray&)skin->getJointIndices(), joint_indices);
+ transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getJointsPerVertex(), joints_per_vertex);
+ transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getWeightIndices(), weight_indices);
+ transfer_array_data((COLLADAFW::IntValuesArray &)skin->getJointIndices(), joint_indices);
// transfer_array_data(skin->getWeights(), weights);
// cannot transfer data for FloatOrDoubleArray, copy values manually
@@ -130,7 +132,7 @@ void SkinInfo::add_joint(const COLLADABU::Math::Matrix4& matrix)
joint_data.push_back(jd);
}
-void SkinInfo::set_controller(const COLLADAFW::SkinController* co)
+void SkinInfo::set_controller(const COLLADAFW::SkinController *co)
{
controller_uid = co->getUniqueId();
@@ -155,7 +157,7 @@ Object *SkinInfo::create_armature(Scene *scene)
return ob_arm;
}
-Object* SkinInfo::set_armature(Object *ob_arm)
+Object *SkinInfo::set_armature(Object *ob_arm)
{
if (this->ob_arm)
return this->ob_arm;
@@ -211,8 +213,8 @@ bool SkinInfo::uses_joint_or_descendant(COLLADAFW::Node *node)
return false;
}
-void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& joint_by_uid,
- TransformReader *tm)
+void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& joint_by_uid,
+ TransformReader *tm)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -233,11 +235,11 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
BKE_object_workob_calc_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA;
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_TRANSFORM, NULL);
#endif
amd->deformflag = ARM_DEF_VGROUP;
@@ -257,7 +259,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
name = bc_get_joint_name(joint_by_uid[(*it).joint_uid]);
}
- ED_vgroup_add_name(ob, (char*)name);
+ ED_vgroup_add_name(ob, (char *)name);
}
// <vcount> - number of joints per vertex - joints_per_vertex
@@ -274,12 +276,12 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
for (unsigned int vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
unsigned int limit = weight + joints_per_vertex[vertex];
- for ( ; weight < limit; weight++) {
+ for (; weight < limit; weight++) {
int joint = joint_indices[weight], joint_weight = weight_indices[weight];
// -1 means "weight towards the bind shape", we just don't assign it to any group
if (joint != -1) {
- bDeformGroup *def = (bDeformGroup*)BLI_findlink(&ob->defbase, joint);
+ bDeformGroup *def = (bDeformGroup *)BLI_findlink(&ob->defbase, joint);
ED_vgroup_vert_add(ob, def, vertex, weights[joint_weight], WEIGHT_REPLACE);
}
@@ -297,16 +299,16 @@ void SkinInfo::set_parent(Object *_parent)
parent = _parent;
}
-Object* SkinInfo::get_parent()
+Object *SkinInfo::get_parent()
{
return parent;
}
-void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node*> &root_joints,
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& joint_by_uid,
- std::vector<COLLADAFW::Node*>& result)
+void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node *> &root_joints,
+ std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& joint_by_uid,
+ std::vector<COLLADAFW::Node *>& result)
{
- std::vector<COLLADAFW::Node*>::const_iterator it;
+ std::vector<COLLADAFW::Node *>::const_iterator it;
// for each root_joint
for (it = root_joints.begin(); it != root_joints.end(); it++) {
COLLADAFW::Node *root = *it;
diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp
index 4c7fde8ef17..be615f83787 100644
--- a/source/blender/collada/TransformReader.cpp
+++ b/source/blender/collada/TransformReader.cpp
@@ -29,7 +29,8 @@
#include "TransformReader.h"
-TransformReader::TransformReader(UnitConverter* conv) : unit_converter(conv) {}
+TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv) {
+}
void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob)
{
@@ -43,7 +44,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
COLLADAFW::Transformation *tm = node->getTransformations()[i];
COLLADAFW::Transformation::TransformationType type = tm->getTransformationType();
- switch (type) {
+ switch (type) {
case COLLADAFW::Transformation::TRANSLATE:
dae_translate_to_mat4(tm, cur);
break;
@@ -60,7 +61,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
case COLLADAFW::Transformation::SKEW:
fprintf(stderr, "LOOKAT and SKEW transformations are not supported yet.\n");
break;
- }
+ }
copy_m4_m4(copy, mat);
mult_m4_m4m4(mat, copy, cur);
@@ -78,7 +79,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
- COLLADAFW::Rotate *ro = (COLLADAFW::Rotate*)tm;
+ COLLADAFW::Rotate *ro = (COLLADAFW::Rotate *)tm;
COLLADABU::Math::Vector3& axis = ro->getRotationAxis();
const float angle = (float)DEG2RAD(ro->getRotationAngle());
const float ax[] = {axis[0], axis[1], axis[2]};
@@ -90,7 +91,7 @@ void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[
void TransformReader::dae_translate_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
- COLLADAFW::Translate *tra = (COLLADAFW::Translate*)tm;
+ COLLADAFW::Translate *tra = (COLLADAFW::Translate *)tm;
COLLADABU::Math::Vector3& t = tra->getTranslation();
unit_m4(m);
@@ -102,24 +103,24 @@ void TransformReader::dae_translate_to_mat4(COLLADAFW::Transformation *tm, float
void TransformReader::dae_scale_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
- COLLADABU::Math::Vector3& s = ((COLLADAFW::Scale*)tm)->getScale();
+ COLLADABU::Math::Vector3& s = ((COLLADAFW::Scale *)tm)->getScale();
float size[3] = {(float)s[0], (float)s[1], (float)s[2]};
size_to_mat4(m, size);
}
void TransformReader::dae_matrix_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
- unit_converter->dae_matrix_to_mat4_(m, ((COLLADAFW::Matrix*)tm)->getMatrix());
+ unit_converter->dae_matrix_to_mat4_(m, ((COLLADAFW::Matrix *)tm)->getMatrix());
}
void TransformReader::dae_translate_to_v3(COLLADAFW::Transformation *tm, float v[3])
{
- dae_vector3_to_v3(((COLLADAFW::Translate*)tm)->getTranslation(), v);
+ dae_vector3_to_v3(((COLLADAFW::Translate *)tm)->getTranslation(), v);
}
void TransformReader::dae_scale_to_v3(COLLADAFW::Transformation *tm, float v[3])
{
- dae_vector3_to_v3(((COLLADAFW::Scale*)tm)->getScale(), v);
+ dae_vector3_to_v3(((COLLADAFW::Scale *)tm)->getScale(), v);
}
void TransformReader::dae_vector3_to_v3(const COLLADABU::Math::Vector3 &v3, float v[3])
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index fbd36cd6613..0d6e3831637 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -47,11 +47,11 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4],
}
double dmat[4][4];
- UnitConverter* converter = new UnitConverter();
+ UnitConverter *converter = new UnitConverter();
converter->mat4_to_dae_double(dmat, local);
TransformBase::decompose(local, loc, rot, NULL, scale);
- if ( node.getType() == COLLADASW::Node::JOINT)
+ if (node.getType() == COLLADASW::Node::JOINT)
node.addMatrix("transform", dmat);
else
add_transform(node, loc, rot, scale);
@@ -59,7 +59,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4],
void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
{
- /*
+#if 0
float rot[3], loc[3], scale[3];
if (ob->parent) {
@@ -92,7 +92,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
}
add_transform(node, loc, rot, scale);
- */
+#endif
/* Using parentinv should allow use of existing curves */
if (ob->parent) {
@@ -124,9 +124,11 @@ void TransformWriter::add_node_transform_identity(COLLADASW::Node& node)
void TransformWriter::add_transform(COLLADASW::Node& node, float loc[3], float rot[3], float scale[3])
{
node.addTranslate("location", loc[0], loc[1], loc[2]);
- /*node.addRotateZ("rotationZ", COLLADABU::Math::Utils::radToDegF(rot[2]));
+#if 0
+ node.addRotateZ("rotationZ", COLLADABU::Math::Utils::radToDegF(rot[2]));
node.addRotateY("rotationY", COLLADABU::Math::Utils::radToDegF(rot[1]));
- node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0]));*/
+ node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0]));
+#endif
node.addRotateZ("rotationZ", RAD2DEGF(rot[2]));
node.addRotateY("rotationY", RAD2DEGF(rot[1]));
node.addRotateX("rotationX", RAD2DEGF(rot[0]));
diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp
index e880082c9ec..9a4fd44b9e9 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -41,48 +41,65 @@ extern "C"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
- int collada_import(bContext *C, const char *filepath)
- {
- DocumentImporter imp (C, filepath);
- if (imp.import()) return 1;
+int collada_import(bContext *C, const char *filepath)
+{
+ DocumentImporter imp(C, filepath);
+ if (imp.import()) return 1;
- return 0;
- }
+ return 0;
+}
- int collada_export(
- Scene *sce,
- const char *filepath,
- int selected,
- int apply_modifiers,
-
- int include_armatures,
- int include_bone_children,
-
- int use_object_instantiation,
- int second_life )
- {
- ExportSettings export_settings;
-
- export_settings.selected = selected != 0;
- export_settings.apply_modifiers = apply_modifiers != 0;
- export_settings.include_armatures = include_armatures != 0;
- export_settings.include_bone_children = include_bone_children != 0;
- export_settings.second_life = second_life != 0;
- export_settings.use_object_instantiation = use_object_instantiation != 0;
- export_settings.filepath = (char *)filepath;
-
- /* annoying, collada crashes if file cant be created! [#27162] */
- if (!BLI_exists(filepath)) {
- BLI_make_existing_file(filepath); /* makes the dir if its not there */
- if (BLI_file_touch(filepath) == 0) {
- return 0;
- }
- }
- /* end! */
+int collada_export(
+ Scene *sce,
+ const char *filepath,
+ int selected,
+ int apply_modifiers,
- DocumentExporter exporter(&export_settings);
- exporter.exportCurrentScene(sce);
+ int include_armatures,
+ int include_children,
- return 1;
+ int use_object_instantiation,
+ int sort_by_name,
+ int second_life)
+{
+ ExportSettings export_settings;
+
+ /* annoying, collada crashes if file cant be created! [#27162] */
+ if (!BLI_exists(filepath)) {
+ BLI_make_existing_file(filepath); /* makes the dir if its not there */
+ if (BLI_file_touch(filepath) == 0) {
+ return 0;
+ }
}
+ /* end! */
+
+
+ export_settings.selected = selected != 0;
+ export_settings.apply_modifiers = apply_modifiers != 0;
+ export_settings.include_armatures = include_armatures != 0;
+ export_settings.include_children = include_children != 0;
+ export_settings.second_life = second_life != 0;
+ export_settings.use_object_instantiation = use_object_instantiation != 0;
+ export_settings.sort_by_name = sort_by_name != 0;
+ export_settings.filepath = (char *)filepath;
+
+ int includeFilter = OB_REL_NONE;
+ if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
+ if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
+
+ eObjectSet objectSet = (export_settings.selected) ? OB_SET_SELECTED : OB_SET_ALL;
+ export_settings.export_set = BKE_object_relational_superset(sce, objectSet, (eObRelationTypes)includeFilter);
+
+ if (export_settings.sort_by_name)
+ bc_bubble_sort_by_Object_name(export_settings.export_set);
+
+ DocumentExporter exporter(&export_settings);
+ exporter.exportCurrentScene(sce);
+
+ BLI_linklist_free(export_settings.export_set, NULL);
+
+ return 1;
+}
+
+/* end extern C */
}
diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h
index 646c8469e6b..8daf2b65fe2 100644
--- a/source/blender/collada/collada.h
+++ b/source/blender/collada/collada.h
@@ -44,11 +44,14 @@ extern "C" {
int apply_modifiers,
int include_armatures,
- int include_bone_children,
+ int include_children,
int use_object_instantiation,
+ int sort_by_name,
int second_life);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp
index 81e5f88a3f8..0ee8419eda7 100644
--- a/source/blender/collada/collada_internal.cpp
+++ b/source/blender/collada/collada_internal.cpp
@@ -27,12 +27,14 @@
/* COLLADABU_ASSERT, may be able to remove later */
#include "COLLADABUPlatform.h"
-
#include "collada_internal.h"
-UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) {}
+#include "BLI_linklist.h"
+
+UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) {
+}
-void UnitConverter::read_asset(const COLLADAFW::FileInfo* asset)
+void UnitConverter::read_asset(const COLLADAFW::FileInfo *asset)
{
unit = asset->getUnit();
up_axis = asset->getUpAxisType();
@@ -120,72 +122,74 @@ void TransformBase::decompose(float mat[][4], float *loc, float eul[3], float qu
* must obviously be removed too, otherwise they would be heavily misinterpreted.
*/
const unsigned char translate_start_name_map[256] = {
-95, 95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-65, 66, 67, 68, 69, 70, 71, 72,
-73, 74, 75, 76, 77, 78, 79, 80,
-81, 82, 83, 84, 85, 86, 87, 88,
-89, 90, 95, 95, 95, 95, 95, 95,
-97, 98, 99, 100, 101, 102, 103, 104,
-105, 106, 107, 108, 109, 110, 111, 112,
-113, 114, 115, 116, 117, 118, 119, 120,
-121, 122, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 192,
-193, 194, 195, 196, 197, 198, 199, 200,
-201, 202, 203, 204, 205, 206, 207, 208,
-209, 210, 211, 212, 213, 214, 95, 216,
-217, 218, 219, 220, 221, 222, 223, 224,
-225, 226, 227, 228, 229, 230, 231, 232,
-233, 234, 235, 236, 237, 238, 239, 240,
-241, 242, 243, 244, 245, 246, 95, 248,
-249, 250, 251, 252, 253, 254, 255};
+ 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88,
+ 89, 90, 95, 95, 95, 95, 95, 95,
+ 97, 98, 99, 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120,
+ 121, 122, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 192,
+ 193, 194, 195, 196, 197, 198, 199, 200,
+ 201, 202, 203, 204, 205, 206, 207, 208,
+ 209, 210, 211, 212, 213, 214, 95, 216,
+ 217, 218, 219, 220, 221, 222, 223, 224,
+ 225, 226, 227, 228, 229, 230, 231, 232,
+ 233, 234, 235, 236, 237, 238, 239, 240,
+ 241, 242, 243, 244, 245, 246, 95, 248,
+ 249, 250, 251, 252, 253, 254, 255
+};
const unsigned char translate_name_map[256] = {
-95, 95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 45, 95, 95, 48,
-49, 50, 51, 52, 53, 54, 55, 56,
-57, 95, 95, 95, 95, 95, 95, 95,
-65, 66, 67, 68, 69, 70, 71, 72,
-73, 74, 75, 76, 77, 78, 79, 80,
-81, 82, 83, 84, 85, 86, 87, 88,
-89, 90, 95, 95, 95, 95, 95, 95,
-97, 98, 99, 100, 101, 102, 103, 104,
-105, 106, 107, 108, 109, 110, 111, 112,
-113, 114, 115, 116, 117, 118, 119, 120,
-121, 122, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 183, 95,
-95, 95, 95, 95, 95, 95, 95, 192,
-193, 194, 195, 196, 197, 198, 199, 200,
-201, 202, 203, 204, 205, 206, 207, 208,
-209, 210, 211, 212, 213, 214, 95, 216,
-217, 218, 219, 220, 221, 222, 223, 224,
-225, 226, 227, 228, 229, 230, 231, 232,
-233, 234, 235, 236, 237, 238, 239, 240,
-241, 242, 243, 244, 245, 246, 95, 248,
-249, 250, 251, 252, 253, 254, 255};
+ 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 45, 95, 95, 48,
+ 49, 50, 51, 52, 53, 54, 55, 56,
+ 57, 95, 95, 95, 95, 95, 95, 95,
+ 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88,
+ 89, 90, 95, 95, 95, 95, 95, 95,
+ 97, 98, 99, 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120,
+ 121, 122, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 183, 95,
+ 95, 95, 95, 95, 95, 95, 95, 192,
+ 193, 194, 195, 196, 197, 198, 199, 200,
+ 201, 202, 203, 204, 205, 206, 207, 208,
+ 209, 210, 211, 212, 213, 214, 95, 216,
+ 217, 218, 219, 220, 221, 222, 223, 224,
+ 225, 226, 227, 228, 229, 230, 231, 232,
+ 233, 234, 235, 236, 237, 238, 239, 240,
+ 241, 242, 243, 244, 245, 246, 95, 248,
+ 249, 250, 251, 252, 253, 254, 255
+};
typedef std::map< std::string, std::vector<std::string> > map_string_list;
map_string_list global_id_map;
@@ -204,7 +208,7 @@ std::string translate_id(const std::string &id)
std::string id_translated = id;
id_translated[0] = translate_start_name_map[(unsigned int)id_translated[0]];
- for (unsigned int i=1; i < id_translated.size(); i++) {
+ for (unsigned int i = 1; i < id_translated.size(); i++) {
id_translated[i] = translate_name_map[(unsigned int)id_translated[i]];
}
// It's so much workload now, the if () should speed up things.
@@ -214,7 +218,7 @@ std::string translate_id(const std::string &id)
if (iter != global_id_map.end()) {
unsigned int i = 0;
bool found = false;
- for (i=0; i < iter->second.size(); i++) {
+ for (i = 0; i < iter->second.size(); i++) {
if (id == iter->second[i]) {
found = true;
break;
@@ -222,9 +226,9 @@ std::string translate_id(const std::string &id)
}
bool convert = false;
if (found) {
- if (i > 0) {
- convert = true;
- }
+ if (i > 0) {
+ convert = true;
+ }
}
else {
convert = true;
@@ -243,7 +247,7 @@ std::string translate_id(const std::string &id)
std::string id_name(void *id)
{
- return ((ID*)id)->name + 2;
+ return ((ID *)id)->name + 2;
}
std::string get_geometry_id(Object *ob)
@@ -277,17 +281,3 @@ std::string get_material_id(Material *mat)
{
return translate_id(id_name(mat)) + "-material";
}
-
-bool has_object_type(Scene *sce, short obtype)
-{
- Base *base= (Base*) sce->base.first;
- while (base) {
- Object *ob = base->object;
-
- if (ob->type == obtype && ob->data) {
- return true;
- }
- base= base->next;
- }
- return false;
-}
diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h
index d00af791a1f..b64c75e7960 100644
--- a/source/blender/collada/collada_internal.h
+++ b/source/blender/collada/collada_internal.h
@@ -39,6 +39,8 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
+#include "BLI_math.h"
+#include "BLI_linklist.h"
class UnitConverter
{
@@ -96,6 +98,4 @@ extern std::string get_camera_id(Object *ob);
extern std::string get_material_id(Material *mat);
-extern bool has_object_type(Scene* sce, short obtype);
-
#endif /* __COLLADA_INTERNAL_H__ */
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 8693441d7c8..aa6f0b3c515 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -32,6 +32,8 @@
#include "COLLADAFWMeshPrimitive.h"
#include "COLLADAFWMeshVertexData.h"
+#include "collada_utils.h"
+
#include "DNA_modifier_types.h"
#include "DNA_customdata_types.h"
#include "DNA_object_types.h"
@@ -49,6 +51,7 @@
extern "C" {
#include "BKE_DerivedMesh.h"
+#include "BLI_linklist.h"
}
#include "WM_api.h" // XXX hrm, see if we can do without this
@@ -114,7 +117,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
DAG_scene_sort(bmain, sce);
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return true;
}
@@ -123,9 +126,9 @@ Object *bc_add_object(Scene *scene, int type, const char *name)
{
Object *ob = BKE_object_add_only_object(type, name);
- ob->data= BKE_object_obdata_add_from_type(type);
- ob->lay= scene->lay;
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->data = BKE_object_obdata_add_from_type(type);
+ ob->lay = scene->lay;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
BKE_scene_base_select(scene, BKE_scene_base_add(scene, ob));
@@ -151,16 +154,102 @@ Object *bc_get_assigned_armature(Object *ob)
ob_arm = ob->parent;
}
else {
- ModifierData *mod = (ModifierData*)ob->modifiers.first;
- while (mod) {
+ ModifierData *mod;
+ for (mod = (ModifierData *)ob->modifiers.first; mod; mod = mod->next) {
if (mod->type == eModifierType_Armature) {
- ob_arm = ((ArmatureModifierData*)mod)->object;
+ ob_arm = ((ArmatureModifierData *)mod)->object;
}
-
- mod = mod->next;
}
}
return ob_arm;
}
+// Returns the highest selected ancestor
+// returns NULL if no ancestor is selected
+// IMPORTANT: This function expects that
+// all exported objects have set:
+// ob->id.flag & LIB_DOIT
+Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob)
+{
+ Object *ancestor = ob;
+ while (ob->parent && bc_is_marked(ob->parent))
+ {
+ ob = ob->parent;
+ ancestor = ob;
+ }
+ return ancestor;
+}
+
+bool bc_is_base_node(LinkNode *export_set, Object *ob)
+{
+ Object *root = bc_get_highest_selected_ancestor_or_self(export_set, ob);
+ return (root == ob);
+}
+
+bool bc_is_in_Export_set(LinkNode *export_set, Object *ob)
+{
+ LinkNode *node = export_set;
+
+ while (node) {
+ Object *element = (Object *)node->link;
+
+ if (element == ob)
+ return true;
+
+ node= node->next;
+ }
+ return false;
+}
+
+bool bc_has_object_type(LinkNode *export_set, short obtype)
+{
+ LinkNode *node = export_set;
+
+ while (node) {
+ Object *ob = (Object *)node->link;
+
+ if (ob->type == obtype && ob->data) {
+ return true;
+ }
+ node= node->next;
+ }
+ return false;
+}
+
+int bc_is_marked(Object *ob)
+{
+ return ob && (ob->id.flag & LIB_DOIT);
+}
+
+void bc_remove_mark(Object *ob)
+{
+ ob->id.flag &= ~LIB_DOIT;
+}
+
+// Use bubble sort algorithm for sorting the export set
+void bc_bubble_sort_by_Object_name(LinkNode *export_set)
+{
+ bool sorted = false;
+ LinkNode *node;
+ for(node=export_set; node->next && !sorted; node=node->next) {
+
+ sorted = true;
+
+ LinkNode *current;
+ for (current=export_set; current->next; current = current->next) {
+ Object *a = (Object *)current->link;
+ Object *b = (Object *)current->next->link;
+
+ std::string str_a (a->id.name);
+ std::string str_b (b->id.name);
+
+ if (str_a.compare(str_b) > 0) {
+ current->link = b;
+ current->next->link = a;
+ sorted = false;
+ }
+
+ }
+ }
+}
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 9882b44d94c..139a2cb93bd 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -40,18 +40,37 @@
#include "DNA_customdata_types.h"
#include "DNA_texture_types.h"
#include "BKE_context.h"
+#include "BKE_object.h"
+
#include "DNA_scene_types.h"
+extern "C" {
+#include "BKE_DerivedMesh.h"
+#include "BLI_linklist.h"
+}
+
+#include "ExportSettings.h"
+
typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex*> > TexIndexTextureArrayMap;
extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index);
-
extern int bc_test_parent_loop(Object *par, Object *ob);
extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space=true);
-extern char *bc_CustomData_get_layer_name(const CustomData *data, int type, int n);
-extern char *bc_CustomData_get_active_layer_name(const CustomData *data, int type);
extern Object *bc_add_object(Scene *scene, int type, const char *name);
extern Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob);
+
extern Object *bc_get_assigned_armature(Object *ob);
+extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob);
+extern bool bc_is_base_node(LinkNode *export_set, Object *ob);
+extern bool bc_is_in_Export_set(LinkNode *export_set, Object *ob);
+extern bool bc_has_object_type(LinkNode *export_set, short obtype);
+
+extern int bc_is_marked(Object *ob);
+extern void bc_remove_mark(Object *ob);
+
+extern char *bc_CustomData_get_layer_name(const CustomData *data, int type, int n);
+extern char *bc_CustomData_get_active_layer_name(const CustomData *data, int type);
+
+extern void bc_bubble_sort_by_Object_name(LinkNode *export_set);
#endif
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 22f72270734..fbe391a554d 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -97,6 +97,9 @@ set(SRC
intern/COM_CompositorContext.h
intern/COM_ChannelInfo.cpp
intern/COM_ChannelInfo.h
+ intern/COM_SingleThreadedNodeOperation.cpp
+ intern/COM_SingleThreadedNodeOperation.h
+
operations/COM_QualityStepHelper.h
operations/COM_QualityStepHelper.cpp
@@ -320,6 +323,24 @@ set(SRC
operations/COM_DoubleEdgeMaskOperation.cpp
operations/COM_DoubleEdgeMaskOperation.h
+
+
+ nodes/COM_KeyingScreenNode.cpp
+ nodes/COM_KeyingScreenNode.h
+ operations/COM_KeyingScreenOperation.cpp
+ operations/COM_KeyingScreenOperation.h
+
+ nodes/COM_KeyingNode.cpp
+ nodes/COM_KeyingNode.h
+ operations/COM_KeyingOperation.cpp
+ operations/COM_KeyingOperation.h
+ operations/COM_KeyingBlurOperation.cpp
+ operations/COM_KeyingBlurOperation.h
+ operations/COM_KeyingDespillOperation.cpp
+ operations/COM_KeyingDespillOperation.h
+ operations/COM_KeyingClipOperation.cpp
+ operations/COM_KeyingClipOperation.h
+
operations/COM_ColorSpillOperation.cpp
operations/COM_ColorSpillOperation.h
operations/COM_RenderLayersBaseProg.cpp
@@ -458,6 +479,8 @@ set(SRC
operations/COM_MixBaseOperation.cpp
operations/COM_MixBlendOperation.cpp
operations/COM_MixBlendOperation.h
+ operations/COM_MixGlareOperation.cpp
+ operations/COM_MixGlareOperation.h
operations/COM_MixAddOperation.h
operations/COM_MixAddOperation.cpp
operations/COM_MixMultiplyOperation.h
@@ -554,8 +577,6 @@ set(SRC
operations/COM_ConvolutionEdgeFilterOperation.cpp
operations/COM_DilateErodeOperation.cpp
operations/COM_DilateErodeOperation.h
- operations/COM_FogGlowImageOperation.cpp
- operations/COM_FogGlowImageOperation.h
operations/COM_GlareThresholdOperation.cpp
operations/COM_GlareThresholdOperation.h
operations/COM_GlareBaseOperation.cpp
@@ -566,6 +587,8 @@ set(SRC
operations/COM_GlareStreaksOperation.h
operations/COM_GlareGhostOperation.cpp
operations/COM_GlareGhostOperation.h
+ operations/COM_GlareFogGlowOperation.cpp
+ operations/COM_GlareFogGlowOperation.h
operations/COM_SetSamplerOperation.cpp
operations/COM_SetSamplerOperation.h
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index b33a48464e1..4789fed2efd 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -21,256 +21,256 @@
*/
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
#include "DNA_node_types.h"
/**
- * @defgroup Model The data model of the compositor
- * @defgroup Memory The memory management stuff
- * @defgroup Execution The execution logic
- * @defgroup Conversion Conversion logic
- * @defgroup Node All nodes of the compositor
- * @defgroup Operation All operations of the compositor
- *
- * @mainpage Introduction of the Blender Compositor
- *
- * @section bcomp Blender compositor
- * This project redesigns the interals of Blender's compositor. The project has been executed in 2011 by At Mind.
- * At Mind is a technology company located in Amsterdam, The Netherlands.
- * The project has been crowdfunded. This code has been released under GPL2 to be used in Blender.
- *
- * @section goals The goals of the project
- * the new compositor has 2 goals.
- * - Make a faster compositor (speed of calculation)
- * - Make the compositor work faster for you (workflow)
- *
- * @section speed Faster compositor
- * The speedup has been done by making better use of the hardware Blenders is working on. The previous compositor only
- * used a single threaded model to calculate a node. The only exception to this is the Defocus node.
- * Only when it is possible to calculate two full nodes in parallel a second thread was used.
- * Current workstations have 8-16 threads available, and most of the time these are idle.
- *
- * In the new compositor we want to use as much of threads as possible. Even new OpenCL capable GPU-hardware can be
- * used for calculation.
- *
- * @section workflow Work faster
- * The previous compositor only showed the final image. The compositor could wait a long time before seeing the result
- * of his work. The new compositor will work in a way that it will focus on getting information back to the user.
- * It will prioritise its work to get earlier user feedback.
- *
- * @page memory Memory model
- * The main issue is the type of memory model to use. Blender is used by consumers and professionals.
- * Ranging from low-end machines to very high-end machines.
- * The system should work on high-end machines and on low-end machines.
- *
- *
- * @page executing Executing
- * @section prepare Prepare execution
- *
- * during the preparation of the execution All ReadBufferOperation will receive an offset.
- * This offset is used during execution as an optimization trick
- * Next all operations will be initialized for execution @see NodeOperation.initExecution
- * Next all ExecutionGroup's will be initialized for execution @see ExecutionGroup.initExecution
- * this all is controlled from @see ExecutionSystem.execute
- *
- * @section priority Render priority
- * Render priority is an priority of an output node. A user has a different need of Render priorities of output nodes
- * than during editing.
- * for example. the Active ViewerNode has top priority during editing, but during rendering a CompositeNode has.
- * All NodeOperation has a setting for their renderpriority, but only for output NodeOperation these have effect.
- * In ExecutionSystem.execute all priorities are checked. For every priority the ExecutionGroup's are check if the
- * priority do match.
- * When match the ExecutionGroup will be executed (this happens in serial)
- *
- * @see ExecutionSystem.execute control of the Render priority
- * @see NodeOperation.getRenderPriority receive the render priority
- * @see ExecutionGroup.execute the main loop to execute a whole ExecutionGroup
- *
- * @section order Chunk order
- *
- * When a ExecutionGroup is executed, first the order of chunks are determined.
- * The settings are stored in the ViewerNode inside the ExecutionGroup. ExecutionGroups that have no viewernode,
- * will use a default one.
- * There are several possible chunk orders
- * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]: Start calculating from a configurable point and order by nearest chunk
- * - [@ref OrderOfChunks.COM_TO_RANDOM]: Randomize all chunks.
- * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]: Start calculation from the bottom to the top of the image
- * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]: Experimental order based on 9 hotspots in the image
- *
- * When the chunkorder is determined, the first few chunks will be checked if they can be scheduled.
- * Chunks can have three states:
- * - [@ref ChunkExecutionState.COM_ES_NOT_SCHEDULED]: Chunk is not yet scheduled, or dependacies are not met
- * - [@ref ChunkExecutionState.COM_ES_SCHEDULED]: All dependacies are met, chunk is scheduled, but not finished
- * - [@ref ChunkExecutionState.COM_ES_EXECUTED]: Chunk is finished
- *
- * @see ExecutionGroup.execute
- * @see ViewerBaseOperation.getChunkOrder
- * @see OrderOfChunks
- *
- * @section interest Area of interest
- * An ExecutionGroup can have dependancies to other ExecutionGroup's. Data passing from one ExecutionGroup to another
- * one are stored in 'chunks'.
- * If not all input chunks are available the chunk execution will not be scheduled.
- * <pre>
- * +-------------------------------------+ +--------------------------------------+
- * | ExecutionGroup A | | ExecutionGroup B |
- * | +----------------+ +-------------+ | | +------------+ +-----------------+ |
- * | | NodeOperation a| | WriteBuffer | | | | ReadBuffer | | ViewerOperation | |
- * | | *==* Operation | | | | Operation *===* | |
- * | | | | | | | | | | | |
- * | +----------------+ +-------------+ | | +------------+ +-----------------+ |
- * | | | | | |
- * +--------------------------------|----+ +---|----------------------------------+
- * | |
- * | |
- * +---------------------------+
- * | MemoryProxy |
- * | +----------+ +---------+ |
- * | | Chunk a | | Chunk b | |
- * | | | | | |
- * | +----------+ +---------+ |
- * | |
- * +---------------------------+
- * </pre>
- *
- * In the above example ExecutionGroup B has an outputoperation (ViewerOperation) and is being executed.
- * The first chunk is evaluated [@ref ExecutionGroup.scheduleChunkWhenPossible],
- * but not all input chunks are available. The relevant ExecutionGroup (that can calculate the missing chunks;
- * ExecutionGroup A) is asked to calculate the area ExecutionGroup B is missing.
- * [@ref ExecutionGroup.scheduleAreaWhenPossible]
- * ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks.
- * If all input data is available these chunks are scheduled [@ref ExecutionGroup.scheduleChunk]
- *
- * <pre>
- *
- * +-------------------------+ +----------------+ +----------------+
- * | ExecutionSystem.execute | | ExecutionGroup | | ExecutionGroup |
- * +-------------------------+ | (B) | | (A) |
- * O +----------------+ +----------------+
- * O | |
- * O ExecutionGroup.execute | |
- * O------------------------------->O |
- * . O |
- * . O-------\ |
- * . . | ExecutionGroup.scheduleChunkWhenPossible
- * . . O----/ (*) |
- * . . O |
- * . . O |
- * . . O ExecutionGroup.scheduleAreaWhenPossible|
- * . . O---------------------------------------->O
- * . . . O----------\ ExecutionGroup.scheduleChunkWhenPossible
- * . . . . | (*)
- * . . . . O-------/
- * . . . . O
- * . . . . O
- * . . . . O-------\ ExecutionGroup.scheduleChunk
- * . . . . . |
- * . . . . . O----/
- * . . . . O<=O
- * . . . O<=O
- * . . . O
- * . . O<========================================O
- * . . O |
- * . O<=O |
- * . O |
- * . O |
- * </pre>
- *
- * This happens until all chunks of (ExecutionGroup B) are finished executing or the user break's the process.
- *
- * NodeOperation like the ScaleOperation can influence the area of interest by reimplementing the
- * [@ref NodeOperation.determineAreaOfInterest] method
- *
- * <pre>
- *
- * +--------------------------+ +---------------------------------+
- * | ExecutionGroup A | | ExecutionGroup B |
- * | | | |
- * +--------------------------+ +---------------------------------+
- * Needed chunks from ExecutionGroup A | Chunk of ExecutionGroup B (to be evaluated)
- * +-------+ +-------+ | +--------+
- * |Chunk 1| |Chunk 2| +----------------+ |Chunk 1 |
- * | | | | | ScaleOperation | | |
- * +-------+ +-------+ +----------------+ +--------+
- *
- * +-------+ +-------+
- * |Chunk 3| |Chunk 4|
- * | | | |
- * +-------+ +-------+
- *
- * </pre>
- *
- * @see ExecutionGroup.execute Execute a complete ExecutionGroup. Halts until finished or breaked by user
- * @see ExecutionGroup.scheduleChunkWhenPossible Tries to schedule a single chunk,
- * checks if all input data is available. Can trigger dependant chunks to be calculated
- * @see ExecutionGroup.scheduleAreaWhenPossible Tries to schedule an area. This can be multiple chunks
- * (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible])
- * @see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler
- * @see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk.
- * @see WriteBufferOperation NodeOperation to write to a MemoryProxy/MemoryBuffer
- * @see ReadBufferOperation NodeOperation to read from a MemoryProxy/MemoryBuffer
- * @see MemoryProxy proxy for information about memory image (a image consist out of multiple chunks)
- * @see MemoryBuffer Allocated memory for a single chunk
- *
- * @section workscheduler WorkScheduler
- * the WorkScheduler is implemented as a static class. the responsibility of the WorkScheduler is to balance
- * WorkPackages to the available and free devices.
- * the workscheduler can work in 2 states. For witching these between the state you need to recompile blender
- *
- * @subsection multithread Multi threaded
- * Default the workscheduler will place all work as WorkPackage in a queue.
- * For every CPUcore a working thread is created. These working threads will ask the WorkScheduler if there is work
- * for a specific Device.
- * the workscheduler will find work for the device and the device will be asked to execute the WorkPackage
+ * @defgroup Model The data model of the compositor
+ * @defgroup Memory The memory management stuff
+ * @defgroup Execution The execution logic
+ * @defgroup Conversion Conversion logic
+ * @defgroup Node All nodes of the compositor
+ * @defgroup Operation All operations of the compositor
+ *
+ * @mainpage Introduction of the Blender Compositor
+ *
+ * @section bcomp Blender compositor
+ * This project redesigns the interals of Blender's compositor. The project has been executed in 2011 by At Mind.
+ * At Mind is a technology company located in Amsterdam, The Netherlands.
+ * The project has been crowdfunded. This code has been released under GPL2 to be used in Blender.
+ *
+ * @section goals The goals of the project
+ * the new compositor has 2 goals.
+ * - Make a faster compositor (speed of calculation)
+ * - Make the compositor work faster for you (workflow)
+ *
+ * @section speed Faster compositor
+ * The speedup has been done by making better use of the hardware Blenders is working on. The previous compositor only
+ * used a single threaded model to calculate a node. The only exception to this is the Defocus node.
+ * Only when it is possible to calculate two full nodes in parallel a second thread was used.
+ * Current workstations have 8-16 threads available, and most of the time these are idle.
+ *
+ * In the new compositor we want to use as much of threads as possible. Even new OpenCL capable GPU-hardware can be
+ * used for calculation.
+ *
+ * @section workflow Work faster
+ * The previous compositor only showed the final image. The compositor could wait a long time before seeing the result
+ * of his work. The new compositor will work in a way that it will focus on getting information back to the user.
+ * It will prioritise its work to get earlier user feedback.
+ *
+ * @page memory Memory model
+ * The main issue is the type of memory model to use. Blender is used by consumers and professionals.
+ * Ranging from low-end machines to very high-end machines.
+ * The system should work on high-end machines and on low-end machines.
+ *
+ *
+ * @page executing Executing
+ * @section prepare Prepare execution
+ *
+ * during the preparation of the execution All ReadBufferOperation will receive an offset.
+ * This offset is used during execution as an optimization trick
+ * Next all operations will be initialized for execution @see NodeOperation.initExecution
+ * Next all ExecutionGroup's will be initialized for execution @see ExecutionGroup.initExecution
+ * this all is controlled from @see ExecutionSystem.execute
+ *
+ * @section priority Render priority
+ * Render priority is an priority of an output node. A user has a different need of Render priorities of output nodes
+ * than during editing.
+ * for example. the Active ViewerNode has top priority during editing, but during rendering a CompositeNode has.
+ * All NodeOperation has a setting for their renderpriority, but only for output NodeOperation these have effect.
+ * In ExecutionSystem.execute all priorities are checked. For every priority the ExecutionGroup's are check if the
+ * priority do match.
+ * When match the ExecutionGroup will be executed (this happens in serial)
+ *
+ * @see ExecutionSystem.execute control of the Render priority
+ * @see NodeOperation.getRenderPriority receive the render priority
+ * @see ExecutionGroup.execute the main loop to execute a whole ExecutionGroup
+ *
+ * @section order Chunk order
+ *
+ * When a ExecutionGroup is executed, first the order of chunks are determined.
+ * The settings are stored in the ViewerNode inside the ExecutionGroup. ExecutionGroups that have no viewernode,
+ * will use a default one.
+ * There are several possible chunk orders
+ * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]: Start calculating from a configurable point and order by nearest chunk
+ * - [@ref OrderOfChunks.COM_TO_RANDOM]: Randomize all chunks.
+ * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]: Start calculation from the bottom to the top of the image
+ * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]: Experimental order based on 9 hotspots in the image
+ *
+ * When the chunkorder is determined, the first few chunks will be checked if they can be scheduled.
+ * Chunks can have three states:
+ * - [@ref ChunkExecutionState.COM_ES_NOT_SCHEDULED]: Chunk is not yet scheduled, or dependacies are not met
+ * - [@ref ChunkExecutionState.COM_ES_SCHEDULED]: All dependacies are met, chunk is scheduled, but not finished
+ * - [@ref ChunkExecutionState.COM_ES_EXECUTED]: Chunk is finished
+ *
+ * @see ExecutionGroup.execute
+ * @see ViewerBaseOperation.getChunkOrder
+ * @see OrderOfChunks
+ *
+ * @section interest Area of interest
+ * An ExecutionGroup can have dependancies to other ExecutionGroup's. Data passing from one ExecutionGroup to another
+ * one are stored in 'chunks'.
+ * If not all input chunks are available the chunk execution will not be scheduled.
+ * <pre>
+ * +-------------------------------------+ +--------------------------------------+
+ * | ExecutionGroup A | | ExecutionGroup B |
+ * | +----------------+ +-------------+ | | +------------+ +-----------------+ |
+ * | | NodeOperation a| | WriteBuffer | | | | ReadBuffer | | ViewerOperation | |
+ * | | *==* Operation | | | | Operation *===* | |
+ * | | | | | | | | | | | |
+ * | +----------------+ +-------------+ | | +------------+ +-----------------+ |
+ * | | | | | |
+ * +--------------------------------|----+ +---|----------------------------------+
+ * | |
+ * | |
+ * +---------------------------+
+ * | MemoryProxy |
+ * | +----------+ +---------+ |
+ * | | Chunk a | | Chunk b | |
+ * | | | | | |
+ * | +----------+ +---------+ |
+ * | |
+ * +---------------------------+
+ * </pre>
+ *
+ * In the above example ExecutionGroup B has an outputoperation (ViewerOperation) and is being executed.
+ * The first chunk is evaluated [@ref ExecutionGroup.scheduleChunkWhenPossible],
+ * but not all input chunks are available. The relevant ExecutionGroup (that can calculate the missing chunks;
+ * ExecutionGroup A) is asked to calculate the area ExecutionGroup B is missing.
+ * [@ref ExecutionGroup.scheduleAreaWhenPossible]
+ * ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks.
+ * If all input data is available these chunks are scheduled [@ref ExecutionGroup.scheduleChunk]
+ *
+ * <pre>
+ *
+ * +-------------------------+ +----------------+ +----------------+
+ * | ExecutionSystem.execute | | ExecutionGroup | | ExecutionGroup |
+ * +-------------------------+ | (B) | | (A) |
+ * O +----------------+ +----------------+
+ * O | |
+ * O ExecutionGroup.execute | |
+ * O------------------------------->O |
+ * . O |
+ * . O-------\ |
+ * . . | ExecutionGroup.scheduleChunkWhenPossible
+ * . . O----/ (*) |
+ * . . O |
+ * . . O |
+ * . . O ExecutionGroup.scheduleAreaWhenPossible|
+ * . . O---------------------------------------->O
+ * . . . O----------\ ExecutionGroup.scheduleChunkWhenPossible
+ * . . . . | (*)
+ * . . . . O-------/
+ * . . . . O
+ * . . . . O
+ * . . . . O-------\ ExecutionGroup.scheduleChunk
+ * . . . . . |
+ * . . . . . O----/
+ * . . . . O<=O
+ * . . . O<=O
+ * . . . O
+ * . . O<========================================O
+ * . . O |
+ * . O<=O |
+ * . O |
+ * . O |
+ * </pre>
+ *
+ * This happens until all chunks of (ExecutionGroup B) are finished executing or the user break's the process.
+ *
+ * NodeOperation like the ScaleOperation can influence the area of interest by reimplementing the
+ * [@ref NodeOperation.determineAreaOfInterest] method
+ *
+ * <pre>
+ *
+ * +--------------------------+ +---------------------------------+
+ * | ExecutionGroup A | | ExecutionGroup B |
+ * | | | |
+ * +--------------------------+ +---------------------------------+
+ * Needed chunks from ExecutionGroup A | Chunk of ExecutionGroup B (to be evaluated)
+ * +-------+ +-------+ | +--------+
+ * |Chunk 1| |Chunk 2| +----------------+ |Chunk 1 |
+ * | | | | | ScaleOperation | | |
+ * +-------+ +-------+ +----------------+ +--------+
+ *
+ * +-------+ +-------+
+ * |Chunk 3| |Chunk 4|
+ * | | | |
+ * +-------+ +-------+
+ *
+ * </pre>
+ *
+ * @see ExecutionGroup.execute Execute a complete ExecutionGroup. Halts until finished or breaked by user
+ * @see ExecutionGroup.scheduleChunkWhenPossible Tries to schedule a single chunk,
+ * checks if all input data is available. Can trigger dependant chunks to be calculated
+ * @see ExecutionGroup.scheduleAreaWhenPossible Tries to schedule an area. This can be multiple chunks
+ * (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible])
+ * @see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler
+ * @see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk.
+ * @see WriteBufferOperation NodeOperation to write to a MemoryProxy/MemoryBuffer
+ * @see ReadBufferOperation NodeOperation to read from a MemoryProxy/MemoryBuffer
+ * @see MemoryProxy proxy for information about memory image (a image consist out of multiple chunks)
+ * @see MemoryBuffer Allocated memory for a single chunk
+ *
+ * @section workscheduler WorkScheduler
+ * the WorkScheduler is implemented as a static class. the responsibility of the WorkScheduler is to balance
+ * WorkPackages to the available and free devices.
+ * the workscheduler can work in 2 states. For witching these between the state you need to recompile blender
+ *
+ * @subsection multithread Multi threaded
+ * Default the workscheduler will place all work as WorkPackage in a queue.
+ * For every CPUcore a working thread is created. These working threads will ask the WorkScheduler if there is work
+ * for a specific Device.
+ * the workscheduler will find work for the device and the device will be asked to execute the WorkPackage
- * @subsection singlethread Single threaded
- * For debugging reasons the multi-threading can be disabled. This is done by changing the COM_CURRENT_THREADING_MODEL
- * to COM_TM_NOTHREAD. When compiling the workscheduler
- * will be changes to support no threading and run everything on the CPU.
- *
- * @section devices Devices
- * A Device within the compositor context is a Hardware component that can used to calculate chunks.
- * This chunk is encapseled in a WorkPackage.
- * the WorkScheduler controls the devices and selects the device where a WorkPackage will be calculated.
- *
- * @subsection WS_Devices Workscheduler
- * The WorkScheduler controls all Devices. When initializing the compositor the WorkScheduler selects
- * all devices that will be used during compositor.
- * There are two types of Devices, CPUDevice and OpenCLDevice.
- * When an ExecutionGroup schedules a Chunk the schedule method of the WorkScheduler
- * The Workscheduler determines if the chunk can be run on an OpenCLDevice
- * (and that there are available OpenCLDevice). If this is the case the chunk will be added to the worklist for
- * OpenCLDevice's
- * otherwise the chunk will be added to the worklist of CPUDevices.
- *
- * A thread will read the work-list and sends a workpackage to its device.
- *
- * @see WorkScheduler.schedule method that is called to schedule a chunk
- * @see Device.execute method called to execute a chunk
- *
- * @subsection CPUDevice CPUDevice
- * When a CPUDevice gets a WorkPackage the Device will get the inputbuffer that is needed to calculate the chunk.
- * Allocation is already done by the ExecutionGroup.
- * The outputbuffer of the chunk is being created.
- * The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer.
- *
- * @see ExecutionGroup
- * @see NodeOperation.executeRegion executes a single chunk of a NodeOperation
- * @see CPUDevice.execute
- *
- * @subsection GPUDevice OpenCLDevice
- *
- * To be completed!
- * @see NodeOperation.executeOpenCLRegion
- * @see OpenCLDevice.execute
- *
- * @section executePixel executing a pixel
- * Finally the last step, the node functionality :)
+ * @subsection singlethread Single threaded
+ * For debugging reasons the multi-threading can be disabled. This is done by changing the COM_CURRENT_THREADING_MODEL
+ * to COM_TM_NOTHREAD. When compiling the workscheduler
+ * will be changes to support no threading and run everything on the CPU.
+ *
+ * @section devices Devices
+ * A Device within the compositor context is a Hardware component that can used to calculate chunks.
+ * This chunk is encapseled in a WorkPackage.
+ * the WorkScheduler controls the devices and selects the device where a WorkPackage will be calculated.
+ *
+ * @subsection WS_Devices Workscheduler
+ * The WorkScheduler controls all Devices. When initializing the compositor the WorkScheduler selects
+ * all devices that will be used during compositor.
+ * There are two types of Devices, CPUDevice and OpenCLDevice.
+ * When an ExecutionGroup schedules a Chunk the schedule method of the WorkScheduler
+ * The Workscheduler determines if the chunk can be run on an OpenCLDevice
+ * (and that there are available OpenCLDevice). If this is the case the chunk will be added to the worklist for
+ * OpenCLDevice's
+ * otherwise the chunk will be added to the worklist of CPUDevices.
+ *
+ * A thread will read the work-list and sends a workpackage to its device.
+ *
+ * @see WorkScheduler.schedule method that is called to schedule a chunk
+ * @see Device.execute method called to execute a chunk
+ *
+ * @subsection CPUDevice CPUDevice
+ * When a CPUDevice gets a WorkPackage the Device will get the inputbuffer that is needed to calculate the chunk.
+ * Allocation is already done by the ExecutionGroup.
+ * The outputbuffer of the chunk is being created.
+ * The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer.
+ *
+ * @see ExecutionGroup
+ * @see NodeOperation.executeRegion executes a single chunk of a NodeOperation
+ * @see CPUDevice.execute
+ *
+ * @subsection GPUDevice OpenCLDevice
+ *
+ * To be completed!
+ * @see NodeOperation.executeOpenCLRegion
+ * @see OpenCLDevice.execute
+ *
+ * @section executePixel executing a pixel
+ * Finally the last step, the node functionality :)
- * @page newnode Creating new nodes
- */
+ * @page newnode Creating new nodes
+ */
/**
* @brief The main method that is used to execute the compositor tree.
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index f87265c50f5..57b73c836df 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -24,12 +24,10 @@
#define _COM_defines_h_
/**
- * @brief possible data types for SocketConnection
- * @ingroup Model
- */
+ * @brief possible data types for SocketConnection
+ * @ingroup Model
+ */
typedef enum DataType {
- /** @brief Unknown data type (or not yet known) */
- COM_DT_UNKNOWN = 0,
/** @brief Value data type */
COM_DT_VALUE = 1,
/** @brief Vector data type */
@@ -39,13 +37,13 @@ typedef enum DataType {
} DataType;
/**
- * @brief Possible quality settings
- * @see CompositorContext.quality
- * @ingroup Execution
- */
+ * @brief Possible quality settings
+ * @see CompositorContext.quality
+ * @ingroup Execution
+ */
typedef enum CompositorQuality {
/** @brief High quality setting */
- COM_QUALITY_HIGH = 0 ,
+ COM_QUALITY_HIGH = 0,
/** @brief Medium quality setting */
COM_QUALITY_MEDIUM = 1,
/** @brief Low quality setting */
@@ -53,12 +51,12 @@ typedef enum CompositorQuality {
} CompositorQuality;
/**
- * @brief Possible priority settings
- * @ingroup Execution
- */
+ * @brief Possible priority settings
+ * @ingroup Execution
+ */
typedef enum CompositorPriority {
/** @brief High quality setting */
- COM_PRIORITY_HIGH = 2 ,
+ COM_PRIORITY_HIGH = 2,
/** @brief Medium quality setting */
COM_PRIORITY_MEDIUM = 1,
/** @brief Low quality setting */
@@ -70,27 +68,28 @@ typedef enum CompositorPriority {
// chunk size determination
#define COM_PREVIEW_SIZE 140.0f
//#define COM_OPENCL_ENABLED
+//#define COM_DEBUG
// workscheduler threading models
/**
- * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern. This is the default option.
- */
+ * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern. This is the default option.
+ */
#define COM_TM_QUEUE 1
/**
- * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread. easy for debugging
- */
+ * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread. easy for debugging
+ */
#define COM_TM_NOTHREAD 0
/**
- * COM_CURRENT_THREADING_MODEL can be one of the above, COM_TM_QUEUE is currently default.
- */
+ * COM_CURRENT_THREADING_MODEL can be one of the above, COM_TM_QUEUE is currently default.
+ */
#define COM_CURRENT_THREADING_MODEL COM_TM_QUEUE
// chunk order
/**
- * @brief The order of chunks to be scheduled
- * @ingroup Execution
- */
+ * @brief The order of chunks to be scheduled
+ * @ingroup Execution
+ */
typedef enum OrderOfChunks {
/** @brief order from a distance to centerX/centerY */
COM_TO_CENTER_OUT = 0,
@@ -102,11 +101,10 @@ typedef enum OrderOfChunks {
COM_TO_RULE_OF_THIRDS = 3
} OrderOfChunks;
+#define COM_ORDER_OF_CHUNKS_DEFAULT COM_TO_CENTER_OUT
+
#define COM_RULE_OF_THIRDS_DIVIDER 100.0f
#define COM_NUMBER_OF_CHANNELS 4
-#define COM_DEFAULT_RESOLUTION_WIDTH 640
-#define COM_DEFAULT_RESOLUTION_HEIGHT 480
-
#endif
diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
index f151afd75be..95462b3c384 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.cpp
+++ b/source/blender/compositor/intern/COM_CPUDevice.cpp
@@ -25,11 +25,11 @@
void CPUDevice::execute(WorkPackage *work)
{
const unsigned int chunkNumber = work->getChunkNumber();
- ExecutionGroup * executionGroup = work->getExecutionGroup();
+ ExecutionGroup *executionGroup = work->getExecutionGroup();
rcti rect;
executionGroup->determineChunkRect(&rect, chunkNumber);
- MemoryBuffer ** inputBuffers = executionGroup->getInputBuffersCPU();
+ MemoryBuffer **inputBuffers = executionGroup->getInputBuffersCPU();
executionGroup->getOutputNodeOperation()->executeRegion(&rect, chunkNumber, inputBuffers);
diff --git a/source/blender/compositor/intern/COM_CPUDevice.h b/source/blender/compositor/intern/COM_CPUDevice.h
index f577e2b8926..3dc8fff66a3 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.h
+++ b/source/blender/compositor/intern/COM_CPUDevice.h
@@ -26,15 +26,15 @@
#include "COM_Device.h"
/**
- * @brief class representing a CPU device.
- * @note for every hardware thread in the system a CPUDevice instance will exist in the workscheduler
- */
-class CPUDevice: public Device {
+ * @brief class representing a CPU device.
+ * @note for every hardware thread in the system a CPUDevice instance will exist in the workscheduler
+ */
+class CPUDevice : public Device {
public:
/**
- * @brief execute a WorkPackage
- * @param work the WorkPackage to execute
- */
+ * @brief execute a WorkPackage
+ * @param work the WorkPackage to execute
+ */
void execute(WorkPackage *work);
};
diff --git a/source/blender/compositor/intern/COM_ChannelInfo.cpp b/source/blender/compositor/intern/COM_ChannelInfo.cpp
index 7dafee5f955..f2fa62006d5 100644
--- a/source/blender/compositor/intern/COM_ChannelInfo.cpp
+++ b/source/blender/compositor/intern/COM_ChannelInfo.cpp
@@ -25,8 +25,8 @@
#include <stdio.h>
/**
- * @brief create new ChannelInfo instance and sets the defaults.
- */
+ * @brief create new ChannelInfo instance and sets the defaults.
+ */
ChannelInfo::ChannelInfo()
{
this->number = 0;
diff --git a/source/blender/compositor/intern/COM_ChannelInfo.h b/source/blender/compositor/intern/COM_ChannelInfo.h
index 40933bce6f5..399fdc62fa2 100644
--- a/source/blender/compositor/intern/COM_ChannelInfo.h
+++ b/source/blender/compositor/intern/COM_ChannelInfo.h
@@ -32,9 +32,9 @@
using namespace std;
/**
- * @brief List of possible channel types
- * @ingroup Model
- */
+ * @brief List of possible channel types
+ * @ingroup Model
+ */
typedef enum ChannelType {
COM_CT_ColorComponent /** @brief this channel is contains color information. Specific used is determined by channelnumber, and in the future color space */,
COM_CT_Alpha /** @brief this channel is contains transparency value */,
@@ -47,31 +47,31 @@ typedef enum ChannelType {
} ChannelType;
/**
- * @brief ChannelInfo holds information about a channel.
- *
- * Channels are transported from node to node via a SocketConnection.
- * ChannelInfo holds specific setting of these channels in order that the to-node of the connection
- * Can handle specific logic per channel setting.
- *
- * @note currently this is not used, but a future place to implement color spacing and other things.
- * @ingroup Model
- */
+ * @brief ChannelInfo holds information about a channel.
+ *
+ * Channels are transported from node to node via a SocketConnection.
+ * ChannelInfo holds specific setting of these channels in order that the to-node of the connection
+ * Can handle specific logic per channel setting.
+ *
+ * @note currently this is not used, but a future place to implement color spacing and other things.
+ * @ingroup Model
+ */
class ChannelInfo {
private:
/**
- * @brief the channel number, in the connection. [0-3]
- */
+ * @brief the channel number, in the connection. [0-3]
+ */
int number;
/**
- * @brief type of channel
- */
+ * @brief type of channel
+ */
ChannelType type;
/**
- * @brieg Is this value in this channel premultiplied with its alpha
- * @note only valid if type = ColorComponent;
- */
+ * @brieg Is this value in this channel premultiplied with its alpha
+ * @note only valid if type = ColorComponent;
+ */
bool premultiplied;
// /**
@@ -82,39 +82,39 @@ private:
public:
/**
- * @brief creates a new ChannelInfo and set default values
- */
+ * @brief creates a new ChannelInfo and set default values
+ */
ChannelInfo();
/**
- * @brief set the index of this channel in the SocketConnection
- */
+ * @brief set the index of this channel in the SocketConnection
+ */
void setNumber(const int number) { this->number = number; }
/**
- * @brief get the index of this channel in the SocketConnection
- */
- const int getNumber() const {return this->number; }
+ * @brief get the index of this channel in the SocketConnection
+ */
+ const int getNumber() const { return this->number; }
/**
- * @brief set the type of channel
- */
+ * @brief set the type of channel
+ */
void setType(const ChannelType type) { this->type = type; }
/**
- * @brief get the type of channel
- */
- const ChannelType getType() const {return this->type; }
+ * @brief get the type of channel
+ */
+ const ChannelType getType() const { return this->type; }
/**
- * @brief set the premultiplicatioin of this channel
- */
+ * @brief set the premultiplicatioin of this channel
+ */
void setPremultiplied(const bool premultiplied) { this->premultiplied = premultiplied; }
/**
- * @brief is this channel premultiplied
- */
- const bool isPremultiplied() const {return this->premultiplied;}
+ * @brief is this channel premultiplied
+ */
+ const bool isPremultiplied() const { return this->premultiplied; }
};
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp
index 387e4a6ba70..02c28a1997a 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp
@@ -35,7 +35,7 @@ void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int nu
{
unsigned int index;
double distance = MAXFLOAT;
- for (index = 0 ; index < numberOfHotspots ; index ++) {
+ for (index = 0; index < numberOfHotspots; index++) {
ChunkOrderHotspot *hotspot = hotspots[index];
double ndistance = hotspot->determineDistance(this->x, this->y);
if (ndistance < distance) {
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h
index 3dbb4ae8080..f096ebeebfe 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.h
+++ b/source/blender/compositor/intern/COM_ChunkOrder.h
@@ -35,11 +35,11 @@ public:
void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots);
friend bool operator<(const ChunkOrder& a, const ChunkOrder& b);
- void setChunkNumber(unsigned int chunknumber) {this->number = chunknumber;}
- void setX(int x) {this->x = x;}
- void setY(int y) {this->y = y;}
- unsigned int getChunkNumber() {return this->number;}
- double getDistance() {return this->distance;}
+ void setChunkNumber(unsigned int chunknumber) { this->number = chunknumber; }
+ void setX(int x) { this->x = x; }
+ void setY(int y) { this->y = y; }
+ unsigned int getChunkNumber() { return this->number; }
+ double getDistance() { return this->distance; }
};
#endif
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
index 0ab08ec5810..96568092b72 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
@@ -32,9 +32,9 @@ ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition)
double ChunkOrderHotspot::determineDistance(int x, int y)
{
- int dx = x-this->x;
- int dy = y-this->y;
- double result = sqrt((double)(dx*dx+dy*dy));
+ int dx = x - this->x;
+ int dy = y - this->y;
+ double result = sqrt((double)(dx * dx + dy * dy));
result += (double)this->addition;
return result;
}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index 911de822f80..bb8e7d9606d 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -29,6 +29,7 @@ CompositorContext::CompositorContext()
this->scene = NULL;
this->quality = COM_QUALITY_HIGH;
this->hasActiveOpenCLDevices = false;
+ this->activegNode = NULL;
}
const int CompositorContext::getFramenumber() const
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 2889f43290e..93872f4839f 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -32,113 +32,128 @@
#include "COM_defines.h"
/**
- * @brief Overall context of the compositor
- */
+ * @brief Overall context of the compositor
+ */
class CompositorContext {
private:
/**
- * @brief The rendering field describes if we are rendering (F12) or if we are editing (Node editor)
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * @see ExecutionSystem
- */
+ * @brief The rendering field describes if we are rendering (F12) or if we are editing (Node editor)
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
bool rendering;
/**
- * @brief The quality of the composite.
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * @see ExecutionSystem
- */
+ * @brief The quality of the composite.
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
CompositorQuality quality;
/**
- * @brief Reference to the scene that is being composited.
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * @see ExecutionSystem
- */
+ * @brief Reference to the scene that is being composited.
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
Scene *scene;
/**
- * @brief reference to the bNodeTree
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * @see ExecutionSystem
- */
+ * @brief reference to the bNodeTree
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
bNodeTree *bnodetree;
+
+ /**
+ * @brief activegNode the group node that is currently being edited.
+ */
+ bNode *activegNode;
/**
- * @brief does this system have active opencl devices?
- */
+ * @brief does this system have active opencl devices?
+ */
bool hasActiveOpenCLDevices;
public:
/**
- * @brief constructor initializes the context with default values.
- */
+ * @brief constructor initializes the context with default values.
+ */
CompositorContext();
/**
- * @brief set the rendering field of the context
- */
+ * @brief set the rendering field of the context
+ */
void setRendering(bool rendering) { this->rendering = rendering; }
/**
- * @brief get the rendering field of the context
- */
- bool isRendering() const {return this->rendering;}
+ * @brief get the rendering field of the context
+ */
+ bool isRendering() const { return this->rendering; }
+
+ /**
+ * @brief set the scene of the context
+ */
+ void setScene(Scene *scene) { this->scene = scene; }
+
+ /**
+ * @brief set the bnodetree of the context
+ */
+ void setbNodeTree(bNodeTree *bnodetree) { this->bnodetree = bnodetree; }
/**
- * @brief set the scene of the context
- */
- void setScene(Scene *scene) {this->scene = scene;}
+ * @brief get the bnodetree of the context
+ */
+ const bNodeTree *getbNodeTree() const { return this->bnodetree; }
/**
- * @brief set the bnodetree of the context
- */
- void setbNodeTree(bNodeTree *bnodetree) {this->bnodetree = bnodetree;}
+ * @brief set the active groupnode of the context
+ */
+ void setActivegNode(bNode *gnode) { this->activegNode = gnode; }
/**
- * @brief get the bnodetree of the context
- */
- const bNodeTree * getbNodeTree() const {return this->bnodetree;}
+ * @brief get the active groupnode of the context
+ */
+ const bNode *getActivegNode() const { return this->activegNode; }
/**
- * @brief get the scene of the context
- */
- const Scene *getScene() const {return this->scene;}
+ * @brief get the scene of the context
+ */
+ const Scene *getScene() const { return this->scene; }
/**
- * @brief set the quality
- */
+ * @brief set the quality
+ */
void setQuality(CompositorQuality quality) {
this->quality = quality;
}
/**
- * @brief get the quality
- */
+ * @brief get the quality
+ */
const CompositorQuality getQuality() const {
return quality;
}
/**
- * @brief get the current framenumber of the scene in this context
- */
+ * @brief get the current framenumber of the scene in this context
+ */
const int getFramenumber() const;
/**
- * @brief has this system active openclDevices?
- */
+ * @brief has this system active openclDevices?
+ */
const bool getHasActiveOpenCLDevices() const {
return this->hasActiveOpenCLDevices;
}
/**
- * @brief set has this system active openclDevices?
- */
+ * @brief set has this system active openclDevices?
+ */
void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) {
this->hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
}
- int getChunksize() {return this->getbNodeTree()->chunksize;}
+ int getChunksize() { return this->getbNodeTree()->chunksize; }
const int isColorManaged() const;
};
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index dc6409e7b86..fa30d965938 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -112,10 +112,12 @@
#include "COM_DoubleEdgeMaskNode.h"
#include "COM_CropNode.h"
#include "COM_MaskNode.h"
+#include "COM_KeyingScreenNode.h"
+#include "COM_KeyingNode.h"
Node *Converter::convert(bNode *bNode)
{
- Node * node;
+ Node *node;
if (bNode->flag & NODE_MUTED) {
node = new MuteNode(bNode);
@@ -123,238 +125,244 @@ Node *Converter::convert(bNode *bNode)
}
switch (bNode->type) {
- case CMP_NODE_COMPOSITE:
- node = new CompositorNode(bNode);
- break;
- case CMP_NODE_R_LAYERS:
- node = new RenderLayersNode(bNode);
- break;
- case CMP_NODE_TEXTURE:
- node = new TextureNode(bNode);
- break;
- case CMP_NODE_RGBTOBW:
- node = new ColourToBWNode(bNode);
- break;
- case CMP_NODE_MIX_RGB:
- node = new MixNode(bNode);
- break;
- case CMP_NODE_TRANSLATE:
- node = new TranslateNode(bNode);
- break;
- case CMP_NODE_SCALE:
- node = new ScaleNode(bNode);
- break;
- case CMP_NODE_ROTATE:
- node = new RotateNode(bNode);
- break;
- case CMP_NODE_FLIP:
- node = new FlipNode(bNode);
- break;
- case CMP_NODE_FILTER:
- node = new FilterNode(bNode);
- break;
- case CMP_NODE_ID_MASK:
- node = new IDMaskNode(bNode);
- break;
- case CMP_NODE_BRIGHTCONTRAST:
- node = new BrightnessNode(bNode);
- break;
- case CMP_NODE_SEPRGBA:
- node = new SeparateRGBANode(bNode);
- break;
- case CMP_NODE_COMBRGBA:
- node = new CombineRGBANode(bNode);
- break;
- case CMP_NODE_SEPHSVA:
- node = new SeparateHSVANode(bNode);
- break;
- case CMP_NODE_COMBHSVA:
- node = new CombineHSVANode(bNode);
- break;
- case CMP_NODE_SEPYUVA:
- node = new SeparateYUVANode(bNode);
- break;
- case CMP_NODE_COMBYUVA:
- node = new CombineYUVANode(bNode);
- break;
- case CMP_NODE_SEPYCCA:
- node = new SeparateYCCANode(bNode);
- break;
- case CMP_NODE_COMBYCCA:
- node = new CombineYCCANode(bNode);
- break;
- case CMP_NODE_ALPHAOVER:
- node = new AlphaOverNode(bNode);
- break;
- case CMP_NODE_COLORBALANCE:
- node = new ColorBalanceNode(bNode);
- break;
- case CMP_NODE_VIEWER:
- node = new ViewerNode(bNode);
- break;
- case CMP_NODE_SPLITVIEWER:
- node = new SplitViewerNode(bNode);
- break;
- case CMP_NODE_INVERT:
- node = new InvertNode(bNode);
- break;
- case NODE_GROUP:
- node = new GroupNode(bNode);
- break;
- case CMP_NODE_NORMAL:
- node = new NormalNode(bNode);
- break;
- case CMP_NODE_NORMALIZE:
- node = new NormalizeNode(bNode);
- break;
- case CMP_NODE_IMAGE:
- node = new ImageNode(bNode);
- break;
- case CMP_NODE_SETALPHA:
- node = new SetAlphaNode(bNode);
- break;
- case CMP_NODE_PREMULKEY:
- node = new ConvertAlphaNode(bNode);
- break;
- case CMP_NODE_MATH:
- node = new MathNode(bNode);
- break;
- case CMP_NODE_HUE_SAT:
- node = new HueSaturationValueNode(bNode);
- break;
- case CMP_NODE_COLORCORRECTION:
- node = new ColorCorrectionNode(bNode);
- break;
- case CMP_NODE_MASK_BOX:
- node = new BoxMaskNode(bNode);
- break;
- case CMP_NODE_MASK_ELLIPSE:
- node = new EllipseMaskNode(bNode);
- break;
- case CMP_NODE_GAMMA:
- node = new GammaNode(bNode);
- break;
- case CMP_NODE_CURVE_RGB:
- node = new ColorCurveNode(bNode);
- break;
- case CMP_NODE_CURVE_VEC:
- node = new VectorCurveNode(bNode);
- break;
- case CMP_NODE_HUECORRECT:
- node = new HueSaturationValueCorrectNode(bNode);
- break;
- case CMP_NODE_MAP_UV:
- node = new MapUVNode(bNode);
- break;
- case CMP_NODE_DISPLACE:
- node = new DisplaceNode(bNode);
- break;
- case CMP_NODE_VALTORGB:
- node = new ColorRampNode(bNode);
- break;
- case CMP_NODE_DIFF_MATTE:
- node = new DifferenceMatteNode(bNode);
- break;
- case CMP_NODE_LUMA_MATTE:
- node = new LuminanceMatteNode(bNode);
- break;
- case CMP_NODE_DIST_MATTE:
- node = new DistanceMatteNode(bNode);
- break;
- case CMP_NODE_CHROMA_MATTE:
- node = new ChromaMatteNode(bNode);
- break;
- case CMP_NODE_COLOR_MATTE:
- node = new ColorMatteNode(bNode);
- break;
- case CMP_NODE_CHANNEL_MATTE:
- node = new ChannelMatteNode(bNode);
- break;
- case CMP_NODE_BLUR:
- node = new BlurNode(bNode);
- break;
- case CMP_NODE_BOKEHIMAGE:
- node = new BokehImageNode(bNode);
- break;
- case CMP_NODE_BOKEHBLUR:
- node = new BokehBlurNode(bNode);
- break;
- case CMP_NODE_DILATEERODE:
- node = new DilateErodeNode(bNode);
- break;
- case CMP_NODE_LENSDIST:
- node = new LensDistortionNode(bNode);
- break;
- case CMP_NODE_RGB:
- node = new ColorNode(bNode);
- break;
- case CMP_NODE_VALUE:
- node = new ValueNode(bNode);
- break;
- case CMP_NODE_TIME:
- node = new TimeNode(bNode);
- break;
- case CMP_NODE_DBLUR:
- node = new DirectionalBlurNode(bNode);
- break;
- case CMP_NODE_ZCOMBINE:
- node = new ZCombineNode(bNode);
- break;
- case CMP_NODE_TONEMAP:
- node = new TonemapNode(bNode);
- break;
- case CMP_NODE_SWITCH:
- node = new SwitchNode(bNode);
- break;
- case CMP_NODE_GLARE:
- node = new GlareNode(bNode);
- break;
- case CMP_NODE_MOVIECLIP:
- node = new MovieClipNode(bNode);
- break;
- case CMP_NODE_COLOR_SPILL:
- node = new ColorSpillNode(bNode);
- break;
-case CMP_NODE_OUTPUT_FILE:
- node = new OutputFileNode(bNode);
- break;
- case CMP_NODE_MAP_VALUE:
- node = new MapValueNode(bNode);
- break;
- case CMP_NODE_TRANSFORM:
- node = new TransformNode(bNode);
- break;
- case CMP_NODE_STABILIZE2D:
- node = new Stabilize2dNode(bNode);
- break;
- case CMP_NODE_BILATERALBLUR:
- node = new BilateralBlurNode(bNode);
- break;
- case CMP_NODE_VECBLUR:
- node = new VectorBlurNode(bNode);
- break;
- case CMP_NODE_MOVIEDISTORTION:
- node = new MovieDistortionNode(bNode);
- break;
- case CMP_NODE_VIEW_LEVELS:
- node = new ViewLevelsNode(bNode);
- break;
- case CMP_NODE_DEFOCUS:
- node = new DefocusNode(bNode);
- break;
- case CMP_NODE_DOUBLEEDGEMASK:
- node = new DoubleEdgeMaskNode(bNode);
- break;
- case CMP_NODE_CROP:
- node = new CropNode(bNode);
- break;
- case CMP_NODE_MASK:
- node = new MaskNode(bNode);
- break;
- /* not inplemented yet */
- default:
- node = new MuteNode(bNode);
- break;
+ case CMP_NODE_COMPOSITE:
+ node = new CompositorNode(bNode);
+ break;
+ case CMP_NODE_R_LAYERS:
+ node = new RenderLayersNode(bNode);
+ break;
+ case CMP_NODE_TEXTURE:
+ node = new TextureNode(bNode);
+ break;
+ case CMP_NODE_RGBTOBW:
+ node = new ColourToBWNode(bNode);
+ break;
+ case CMP_NODE_MIX_RGB:
+ node = new MixNode(bNode);
+ break;
+ case CMP_NODE_TRANSLATE:
+ node = new TranslateNode(bNode);
+ break;
+ case CMP_NODE_SCALE:
+ node = new ScaleNode(bNode);
+ break;
+ case CMP_NODE_ROTATE:
+ node = new RotateNode(bNode);
+ break;
+ case CMP_NODE_FLIP:
+ node = new FlipNode(bNode);
+ break;
+ case CMP_NODE_FILTER:
+ node = new FilterNode(bNode);
+ break;
+ case CMP_NODE_ID_MASK:
+ node = new IDMaskNode(bNode);
+ break;
+ case CMP_NODE_BRIGHTCONTRAST:
+ node = new BrightnessNode(bNode);
+ break;
+ case CMP_NODE_SEPRGBA:
+ node = new SeparateRGBANode(bNode);
+ break;
+ case CMP_NODE_COMBRGBA:
+ node = new CombineRGBANode(bNode);
+ break;
+ case CMP_NODE_SEPHSVA:
+ node = new SeparateHSVANode(bNode);
+ break;
+ case CMP_NODE_COMBHSVA:
+ node = new CombineHSVANode(bNode);
+ break;
+ case CMP_NODE_SEPYUVA:
+ node = new SeparateYUVANode(bNode);
+ break;
+ case CMP_NODE_COMBYUVA:
+ node = new CombineYUVANode(bNode);
+ break;
+ case CMP_NODE_SEPYCCA:
+ node = new SeparateYCCANode(bNode);
+ break;
+ case CMP_NODE_COMBYCCA:
+ node = new CombineYCCANode(bNode);
+ break;
+ case CMP_NODE_ALPHAOVER:
+ node = new AlphaOverNode(bNode);
+ break;
+ case CMP_NODE_COLORBALANCE:
+ node = new ColorBalanceNode(bNode);
+ break;
+ case CMP_NODE_VIEWER:
+ node = new ViewerNode(bNode);
+ break;
+ case CMP_NODE_SPLITVIEWER:
+ node = new SplitViewerNode(bNode);
+ break;
+ case CMP_NODE_INVERT:
+ node = new InvertNode(bNode);
+ break;
+ case NODE_GROUP:
+ node = new GroupNode(bNode);
+ break;
+ case CMP_NODE_NORMAL:
+ node = new NormalNode(bNode);
+ break;
+ case CMP_NODE_NORMALIZE:
+ node = new NormalizeNode(bNode);
+ break;
+ case CMP_NODE_IMAGE:
+ node = new ImageNode(bNode);
+ break;
+ case CMP_NODE_SETALPHA:
+ node = new SetAlphaNode(bNode);
+ break;
+ case CMP_NODE_PREMULKEY:
+ node = new ConvertAlphaNode(bNode);
+ break;
+ case CMP_NODE_MATH:
+ node = new MathNode(bNode);
+ break;
+ case CMP_NODE_HUE_SAT:
+ node = new HueSaturationValueNode(bNode);
+ break;
+ case CMP_NODE_COLORCORRECTION:
+ node = new ColorCorrectionNode(bNode);
+ break;
+ case CMP_NODE_MASK_BOX:
+ node = new BoxMaskNode(bNode);
+ break;
+ case CMP_NODE_MASK_ELLIPSE:
+ node = new EllipseMaskNode(bNode);
+ break;
+ case CMP_NODE_GAMMA:
+ node = new GammaNode(bNode);
+ break;
+ case CMP_NODE_CURVE_RGB:
+ node = new ColorCurveNode(bNode);
+ break;
+ case CMP_NODE_CURVE_VEC:
+ node = new VectorCurveNode(bNode);
+ break;
+ case CMP_NODE_HUECORRECT:
+ node = new HueSaturationValueCorrectNode(bNode);
+ break;
+ case CMP_NODE_MAP_UV:
+ node = new MapUVNode(bNode);
+ break;
+ case CMP_NODE_DISPLACE:
+ node = new DisplaceNode(bNode);
+ break;
+ case CMP_NODE_VALTORGB:
+ node = new ColorRampNode(bNode);
+ break;
+ case CMP_NODE_DIFF_MATTE:
+ node = new DifferenceMatteNode(bNode);
+ break;
+ case CMP_NODE_LUMA_MATTE:
+ node = new LuminanceMatteNode(bNode);
+ break;
+ case CMP_NODE_DIST_MATTE:
+ node = new DistanceMatteNode(bNode);
+ break;
+ case CMP_NODE_CHROMA_MATTE:
+ node = new ChromaMatteNode(bNode);
+ break;
+ case CMP_NODE_COLOR_MATTE:
+ node = new ColorMatteNode(bNode);
+ break;
+ case CMP_NODE_CHANNEL_MATTE:
+ node = new ChannelMatteNode(bNode);
+ break;
+ case CMP_NODE_BLUR:
+ node = new BlurNode(bNode);
+ break;
+ case CMP_NODE_BOKEHIMAGE:
+ node = new BokehImageNode(bNode);
+ break;
+ case CMP_NODE_BOKEHBLUR:
+ node = new BokehBlurNode(bNode);
+ break;
+ case CMP_NODE_DILATEERODE:
+ node = new DilateErodeNode(bNode);
+ break;
+ case CMP_NODE_LENSDIST:
+ node = new LensDistortionNode(bNode);
+ break;
+ case CMP_NODE_RGB:
+ node = new ColorNode(bNode);
+ break;
+ case CMP_NODE_VALUE:
+ node = new ValueNode(bNode);
+ break;
+ case CMP_NODE_TIME:
+ node = new TimeNode(bNode);
+ break;
+ case CMP_NODE_DBLUR:
+ node = new DirectionalBlurNode(bNode);
+ break;
+ case CMP_NODE_ZCOMBINE:
+ node = new ZCombineNode(bNode);
+ break;
+ case CMP_NODE_TONEMAP:
+ node = new TonemapNode(bNode);
+ break;
+ case CMP_NODE_SWITCH:
+ node = new SwitchNode(bNode);
+ break;
+ case CMP_NODE_GLARE:
+ node = new GlareNode(bNode);
+ break;
+ case CMP_NODE_MOVIECLIP:
+ node = new MovieClipNode(bNode);
+ break;
+ case CMP_NODE_COLOR_SPILL:
+ node = new ColorSpillNode(bNode);
+ break;
+ case CMP_NODE_OUTPUT_FILE:
+ node = new OutputFileNode(bNode);
+ break;
+ case CMP_NODE_MAP_VALUE:
+ node = new MapValueNode(bNode);
+ break;
+ case CMP_NODE_TRANSFORM:
+ node = new TransformNode(bNode);
+ break;
+ case CMP_NODE_STABILIZE2D:
+ node = new Stabilize2dNode(bNode);
+ break;
+ case CMP_NODE_BILATERALBLUR:
+ node = new BilateralBlurNode(bNode);
+ break;
+ case CMP_NODE_VECBLUR:
+ node = new VectorBlurNode(bNode);
+ break;
+ case CMP_NODE_MOVIEDISTORTION:
+ node = new MovieDistortionNode(bNode);
+ break;
+ case CMP_NODE_VIEW_LEVELS:
+ node = new ViewLevelsNode(bNode);
+ break;
+ case CMP_NODE_DEFOCUS:
+ node = new DefocusNode(bNode);
+ break;
+ case CMP_NODE_DOUBLEEDGEMASK:
+ node = new DoubleEdgeMaskNode(bNode);
+ break;
+ case CMP_NODE_CROP:
+ node = new CropNode(bNode);
+ break;
+ case CMP_NODE_MASK:
+ node = new MaskNode(bNode);
+ break;
+ case CMP_NODE_KEYINGSCREEN:
+ node = new KeyingScreenNode(bNode);
+ break;
+ case CMP_NODE_KEYING:
+ node = new KeyingNode(bNode);
+ break;
+ /* not inplemented yet */
+ default:
+ node = new MuteNode(bNode);
+ break;
}
return node;
}
@@ -362,9 +370,9 @@ void Converter::convertDataType(SocketConnection *connection, ExecutionSystem *s
{
OutputSocket *outputSocket = connection->getFromSocket();
InputSocket *inputSocket = connection->getToSocket();
- DataType fromDatatype = outputSocket->getActualDataType();
- DataType toDatatype = inputSocket->getActualDataType();
- NodeOperation * converter = NULL;
+ DataType fromDatatype = outputSocket->getDataType();
+ DataType toDatatype = inputSocket->getDataType();
+ NodeOperation *converter = NULL;
if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
converter = new ConvertValueToColourProg();
}
@@ -394,68 +402,68 @@ void Converter::convertResolution(SocketConnection *connection, ExecutionSystem
{
InputSocketResizeMode mode = connection->getToSocket()->getResizeMode();
- NodeOperation * toOperation = (NodeOperation*)connection->getToNode();
+ NodeOperation *toOperation = (NodeOperation *)connection->getToNode();
const float toWidth = toOperation->getWidth();
const float toHeight = toOperation->getHeight();
- NodeOperation * fromOperation = (NodeOperation*)connection->getFromNode();
+ NodeOperation *fromOperation = (NodeOperation *)connection->getFromNode();
const float fromWidth = fromOperation->getWidth();
const float fromHeight = fromOperation->getHeight();
bool doCenter = false;
bool doScale = false;
- float addX= (toWidth-fromWidth)/2.0f;
- float addY = (toHeight-fromHeight)/2.0f;
- float scaleX=0;
- float scaleY=0;
+ float addX = (toWidth - fromWidth) / 2.0f;
+ float addY = (toHeight - fromHeight) / 2.0f;
+ float scaleX = 0;
+ float scaleY = 0;
switch (mode) {
- case COM_SC_NO_RESIZE:
- break;
- case COM_SC_CENTER:
- doCenter = true;
- break;
- case COM_SC_FIT_WIDTH:
- doCenter = true;
- doScale = true;
- scaleX = scaleY = toWidth/fromWidth;
- break;
- case COM_SC_FIT_HEIGHT:
- doCenter = true;
- doScale = true;
- scaleX = scaleY = toHeight/fromHeight;
- break;
- case COM_SC_FIT:
- doCenter = true;
- doScale = true;
- scaleX = toWidth/fromWidth;
- scaleY = toHeight/fromHeight;
- if (scaleX < scaleY) {
- scaleX = scaleY;
- }
- else {
- scaleY = scaleX;
- }
- break;
- case COM_SC_STRETCH:
- doCenter = true;
- doScale = true;
- scaleX = toWidth/fromWidth;
- scaleY = toHeight/fromHeight;
- break;
+ case COM_SC_NO_RESIZE:
+ break;
+ case COM_SC_CENTER:
+ doCenter = true;
+ break;
+ case COM_SC_FIT_WIDTH:
+ doCenter = true;
+ doScale = true;
+ scaleX = scaleY = toWidth / fromWidth;
+ break;
+ case COM_SC_FIT_HEIGHT:
+ doCenter = true;
+ doScale = true;
+ scaleX = scaleY = toHeight / fromHeight;
+ break;
+ case COM_SC_FIT:
+ doCenter = true;
+ doScale = true;
+ scaleX = toWidth / fromWidth;
+ scaleY = toHeight / fromHeight;
+ if (scaleX < scaleY) {
+ scaleX = scaleY;
+ }
+ else {
+ scaleY = scaleX;
+ }
+ break;
+ case COM_SC_STRETCH:
+ doCenter = true;
+ doScale = true;
+ scaleX = toWidth / fromWidth;
+ scaleY = toHeight / fromHeight;
+ break;
}
if (doCenter) {
NodeOperation *first = NULL;
SocketConnection *c;
- ScaleOperation * scaleOperation = NULL;
+ ScaleOperation *scaleOperation = NULL;
if (doScale) {
scaleOperation = new ScaleOperation();
first = scaleOperation;
- SetValueOperation * sxop = new SetValueOperation();
+ SetValueOperation *sxop = new SetValueOperation();
sxop->setValue(scaleX);
c = ExecutionSystemHelper::addLink(system->getConnections(), sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
c->setIgnoreResizeCheck(true);
- SetValueOperation * syop = new SetValueOperation();
+ SetValueOperation *syop = new SetValueOperation();
syop->setValue(scaleY);
c = ExecutionSystemHelper::addLink(system->getConnections(), syop->getOutputSocket(), scaleOperation->getInputSocket(2));
c->setIgnoreResizeCheck(true);
@@ -471,13 +479,13 @@ void Converter::convertResolution(SocketConnection *connection, ExecutionSystem
c->setIgnoreResizeCheck(true);
}
- TranslateOperation * translateOperation = new TranslateOperation();
+ TranslateOperation *translateOperation = new TranslateOperation();
if (!first) first = translateOperation;
- SetValueOperation * xop = new SetValueOperation();
+ SetValueOperation *xop = new SetValueOperation();
xop->setValue(addX);
c = ExecutionSystemHelper::addLink(system->getConnections(), xop->getOutputSocket(), translateOperation->getInputSocket(1));
c->setIgnoreResizeCheck(true);
- SetValueOperation * yop = new SetValueOperation();
+ SetValueOperation *yop = new SetValueOperation();
yop->setValue(addY);
c = ExecutionSystemHelper::addLink(system->getConnections(), yop->getOutputSocket(), translateOperation->getInputSocket(2));
c->setIgnoreResizeCheck(true);
@@ -495,7 +503,7 @@ void Converter::convertResolution(SocketConnection *connection, ExecutionSystem
c->setIgnoreResizeCheck(true);
}
- InputSocket * inputSocket = connection->getToSocket();
+ InputSocket *inputSocket = connection->getToSocket();
inputSocket->relinkConnections(first->getInputSocket(0));
c = ExecutionSystemHelper::addLink(system->getConnections(), translateOperation->getOutputSocket(), inputSocket);
c->setIgnoreResizeCheck(true);
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index fa12be4e79a..d01556cc79c 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -32,39 +32,39 @@
class Converter {
public:
/**
- * @brief Convert/wraps a bNode in its Node instance.
- *
- * For all nodetypes a wrapper class is created.
- * Muted nodes are wrapped with MuteNode.
- *
- * @note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
- *
- * @see Node
- * @see MuteNode
- */
+ * @brief Convert/wraps a bNode in its Node instance.
+ *
+ * For all nodetypes a wrapper class is created.
+ * Muted nodes are wrapped with MuteNode.
+ *
+ * @note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
+ *
+ * @see Node
+ * @see MuteNode
+ */
static Node *convert(bNode *bNode);
/**
- * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
- *
- * @note this method is called when conversion is needed.
- *
- * @param connection the SocketConnection what needs conversion
- * @param system the ExecutionSystem to add the conversion to.
- * @see SocketConnection - a link between two sockets
- */
+ * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
+ *
+ * @note this method is called when conversion is needed.
+ *
+ * @param connection the SocketConnection what needs conversion
+ * @param system the ExecutionSystem to add the conversion to.
+ * @see SocketConnection - a link between two sockets
+ */
static void convertDataType(SocketConnection *connection, ExecutionSystem *system);
/**
- * @brief This method will add a resolution rule based on the settings of the InputSocket.
- *
- * @note Conversion logic is implemented in this method
- * @see InputSocketResizeMode for the possible conversions.
-
- * @param connection the SocketConnection what needs conversion
- * @param system the ExecutionSystem to add the conversion to.
- * @see SocketConnection - a link between two sockets
- */
+ * @brief This method will add a resolution rule based on the settings of the InputSocket.
+ *
+ * @note Conversion logic is implemented in this method
+ * @see InputSocketResizeMode for the possible conversions.
+
+ * @param connection the SocketConnection what needs conversion
+ * @param system the ExecutionSystem to add the conversion to.
+ * @see SocketConnection - a link between two sockets
+ */
static void convertResolution(SocketConnection *connection, ExecutionSystem *system);
};
#endif
diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h
index 74a9400f8f3..08fdb5bb578 100644
--- a/source/blender/compositor/intern/COM_Device.h
+++ b/source/blender/compositor/intern/COM_Device.h
@@ -30,26 +30,26 @@
#include "COM_MemoryBuffer.h"
/**
- * @brief Abstract class for device implementations to be used by the Compositor.
- * devices are queried, initialized and used by the WorkScheduler.
- * work are packaged as a WorkPackage instance.
- */
+ * @brief Abstract class for device implementations to be used by the Compositor.
+ * devices are queried, initialized and used by the WorkScheduler.
+ * work are packaged as a WorkPackage instance.
+ */
class Device {
public:
/**
- * @brief initialize the device
- */
- virtual bool initialize() {return true;}
+ * @brief initialize the device
+ */
+ virtual bool initialize() { return true; }
/**
- * @brief deinitialize the device
- */
+ * @brief deinitialize the device
+ */
virtual void deinitialize() {}
/**
- * @brief execute a WorkPackage
- * @param work the WorkPackage to execute
- */
+ * @brief execute a WorkPackage
+ * @param work the WorkPackage to execute
+ */
virtual void execute(WorkPackage *work) = 0;
};
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index 481b83c81a3..2a790da0354 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -54,6 +54,7 @@ ExecutionGroup::ExecutionGroup()
this->numberOfChunks = 0;
this->initialized = false;
this->openCL = false;
+ this->singleThreaded = false;
this->chunksFinished = 0;
}
@@ -64,7 +65,7 @@ CompositorPriority ExecutionGroup::getRenderPriotrity()
bool ExecutionGroup::containsOperation(NodeOperation *operation)
{
- for (vector<NodeOperation*>::const_iterator iterator = this->operations.begin() ; iterator != this->operations.end() ; ++iterator) {
+ for (vector<NodeOperation *>::const_iterator iterator = this->operations.begin(); iterator != this->operations.end(); ++iterator) {
NodeOperation *inListOperation = *iterator;
if (inListOperation == operation) {
return true;
@@ -80,10 +81,10 @@ const bool ExecutionGroup::isComplex() const
bool ExecutionGroup::canContainOperation(NodeOperation *operation)
{
- if (!this->initialized) {return true;}
- if (operation->isReadBufferOperation()) {return true;}
- if (operation->isWriteBufferOperation()) {return false;}
- if (operation->isSetOperation()) {return true;}
+ if (!this->initialized) { return true; }
+ if (operation->isReadBufferOperation()) { return true; }
+ if (operation->isWriteBufferOperation()) { return false; }
+ if (operation->isSetOperation()) { return true; }
if (!this->isComplex()) {
return (!operation->isComplex());
@@ -100,20 +101,21 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat
if (!operation->isBufferOperation()) {
this->complex = operation->isComplex();
this->openCL = operation->isOpenCL();
+ this->singleThreaded = operation->isSingleThreaded();
this->initialized = true;
}
this->operations.push_back(operation);
if (operation->isReadBufferOperation()) {
- ReadBufferOperation *readOperation = (ReadBufferOperation*)operation;
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
WriteBufferOperation *writeOperation = readOperation->getMemoryProxy()->getWriteBufferOperation();
this->addOperation(system, writeOperation);
}
else {
unsigned int index;
- for (index = 0 ; index < operation->getNumberOfInputSockets(); index ++) {
- InputSocket * inputSocket = operation->getInputSocket(index);
+ for (index = 0; index < operation->getNumberOfInputSockets(); index++) {
+ InputSocket *inputSocket = operation->getInputSocket(index);
if (inputSocket->isConnected()) {
- NodeOperation *node = (NodeOperation*)inputSocket->getConnection()->getFromNode();
+ NodeOperation *node = (NodeOperation *)inputSocket->getConnection()->getFromNode();
this->addOperation(system, node);
}
}
@@ -121,7 +123,7 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat
}
else {
if (operation->isWriteBufferOperation()) {
- WriteBufferOperation * writeoperation = (WriteBufferOperation*)operation;
+ WriteBufferOperation *writeoperation = (WriteBufferOperation *)operation;
if (writeoperation->getMemoryProxy()->getExecutor() == NULL) {
ExecutionGroup *newGroup = new ExecutionGroup();
writeoperation->getMemoryProxy()->setExecutor(newGroup);
@@ -148,7 +150,7 @@ void ExecutionGroup::initExecution()
this->chunkExecutionStates = NULL;
if (this->numberOfChunks != 0) {
this->chunkExecutionStates = new ChunkExecutionState[numberOfChunks];
- for (index = 0 ; index < numberOfChunks ; index ++) {
+ for (index = 0; index < numberOfChunks; index++) {
this->chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED;
}
}
@@ -156,10 +158,10 @@ void ExecutionGroup::initExecution()
unsigned int maxNumber = 0;
- for (index = 0 ; index < this->operations.size(); index ++) {
+ for (index = 0; index < this->operations.size(); index++) {
NodeOperation *operation = this->operations[index];
if (operation->isReadBufferOperation()) {
- ReadBufferOperation *readOperation = (ReadBufferOperation*)operation;
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
this->cachedReadOperations.push_back(readOperation);
maxNumber = max(maxNumber, readOperation->getOffset());
}
@@ -184,32 +186,36 @@ void ExecutionGroup::deinitExecution()
void ExecutionGroup::determineResolution(unsigned int resolution[])
{
NodeOperation *operation = this->getOutputNodeOperation();
- unsigned int preferredResolution[2];
- preferredResolution[0] = 0;
- preferredResolution[1] = 0;
- operation->determineResolution(resolution, preferredResolution);
- operation->setResolution(resolution);
+ resolution[0] = operation->getWidth();
+ resolution[1] = operation->getHeight();
this->setResolution(resolution);
}
void ExecutionGroup::determineNumberOfChunks()
{
- const float chunkSizef = this->chunkSize;
- this->numberOfXChunks = ceil(this->width / chunkSizef);
- this->numberOfYChunks = ceil(this->height / chunkSizef);
- this->numberOfChunks = this->numberOfXChunks * this->numberOfYChunks;
+ if (singleThreaded) {
+ this->numberOfXChunks = 1;
+ this->numberOfYChunks = 1;
+ this->numberOfChunks = 1;
+ }
+ else {
+ const float chunkSizef = this->chunkSize;
+ this->numberOfXChunks = ceil(this->width / chunkSizef);
+ this->numberOfYChunks = ceil(this->height / chunkSizef);
+ this->numberOfChunks = this->numberOfXChunks * this->numberOfYChunks;
+ }
}
/**
- * this method is called for the top execution groups. containing the compositor node or the preview node or the viewer node)
- */
+ * this method is called for the top execution groups. containing the compositor node or the preview node or the viewer node)
+ */
void ExecutionGroup::execute(ExecutionSystem *graph)
{
CompositorContext& context = graph->getContext();
const bNodeTree *bTree = context.getbNodeTree();
- if (this->width == 0 || this->height == 0) {return;} /// @note: break out... no pixels to calculate.
- if (bTree->test_break && bTree->test_break(bTree->tbh)) {return;} /// @note: early break out for blur and preview nodes
- if (this->numberOfChunks == 0) {return;} /// @note: early break out
+ if (this->width == 0 || this->height == 0) {return; } /// @note: break out... no pixels to calculate.
+ if (bTree->test_break && bTree->test_break(bTree->tbh)) {return; } /// @note: early break out for blur and preview nodes
+ if (this->numberOfChunks == 0) {return; } /// @note: early break out
unsigned int chunkNumber;
this->chunksFinished = 0;
@@ -217,38 +223,38 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
unsigned int index;
unsigned int *chunkOrder = new unsigned int[this->numberOfChunks];
- for (chunkNumber = 0 ; chunkNumber<this->numberOfChunks ; chunkNumber++) {
+ for (chunkNumber = 0; chunkNumber < this->numberOfChunks; chunkNumber++) {
chunkOrder[chunkNumber] = chunkNumber;
}
NodeOperation *operation = this->getOutputNodeOperation();
float centerX = 0.5;
float centerY = 0.5;
- int chunkorder = COM_TO_CENTER_OUT;
+ OrderOfChunks chunkorder = COM_ORDER_OF_CHUNKS_DEFAULT;
if (operation->isViewerOperation()) {
- ViewerBaseOperation *viewer = (ViewerBaseOperation*)operation;
+ ViewerBaseOperation *viewer = (ViewerBaseOperation *)operation;
centerX = viewer->getCenterX();
centerY = viewer->getCenterY();
chunkorder = viewer->getChunkOrder();
}
switch (chunkorder) {
- case COM_TO_RANDOM:
- for (index = 0 ; index < 2 * numberOfChunks ; index ++) {
- int index1 = rand()%numberOfChunks;
- int index2 = rand()%numberOfChunks;
- int s = chunkOrder[index1];
- chunkOrder[index1] = chunkOrder[index2];
- chunkOrder[index2] = s;
- }
- break;
- case COM_TO_CENTER_OUT:
+ case COM_TO_RANDOM:
+ for (index = 0; index < 2 * numberOfChunks; index++) {
+ int index1 = rand() % numberOfChunks;
+ int index2 = rand() % numberOfChunks;
+ int s = chunkOrder[index1];
+ chunkOrder[index1] = chunkOrder[index2];
+ chunkOrder[index2] = s;
+ }
+ break;
+ case COM_TO_CENTER_OUT:
{
- ChunkOrderHotspot **hotspots = new ChunkOrderHotspot*[1];
- hotspots[0] = new ChunkOrderHotspot(this->width*centerX, this->height*centerY, 0.0f);
+ ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[1];
+ hotspots[0] = new ChunkOrderHotspot(this->width * centerX, this->height * centerY, 0.0f);
rcti rect;
ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks];
- for (index = 0 ; index < this->numberOfChunks; index ++) {
+ for (index = 0; index < this->numberOfChunks; index++) {
determineChunkRect(&rect, index);
chunkOrders[index].setChunkNumber(index);
chunkOrders[index].setX(rect.xmin);
@@ -256,8 +262,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
chunkOrders[index].determineDistance(hotspots, 1);
}
- sort(&chunkOrders[0], &chunkOrders[numberOfChunks-1]);
- for (index = 0 ; index < numberOfChunks; index ++) {
+ sort(&chunkOrders[0], &chunkOrders[numberOfChunks - 1]);
+ for (index = 0; index < numberOfChunks; index++) {
chunkOrder[index] = chunkOrders[index].getChunkNumber();
}
@@ -266,29 +272,29 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
delete[] chunkOrders;
}
break;
- case COM_TO_RULE_OF_THIRDS:
+ case COM_TO_RULE_OF_THIRDS:
{
- ChunkOrderHotspot **hotspots = new ChunkOrderHotspot*[9];
- unsigned int tx = this->width/6;
- unsigned int ty = this->height/6;
- unsigned int mx = this->width/2;
- unsigned int my = this->height/2;
- unsigned int bx = mx+2*tx;
- unsigned int by = my+2*ty;
-
- float addition = numberOfChunks/COM_RULE_OF_THIRDS_DIVIDER;
- hotspots[0] = new ChunkOrderHotspot(mx, my, addition*0);
- hotspots[1] = new ChunkOrderHotspot(tx, my, addition*1);
- hotspots[2] = new ChunkOrderHotspot(bx, my, addition*2);
- hotspots[3] = new ChunkOrderHotspot(bx, by, addition*3);
- hotspots[4] = new ChunkOrderHotspot(tx, ty, addition*4);
- hotspots[5] = new ChunkOrderHotspot(bx, ty, addition*5);
- hotspots[6] = new ChunkOrderHotspot(tx, by, addition*6);
- hotspots[7] = new ChunkOrderHotspot(mx, ty, addition*7);
- hotspots[8] = new ChunkOrderHotspot(mx, by, addition*8);
+ ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[9];
+ unsigned int tx = this->width / 6;
+ unsigned int ty = this->height / 6;
+ unsigned int mx = this->width / 2;
+ unsigned int my = this->height / 2;
+ unsigned int bx = mx + 2 * tx;
+ unsigned int by = my + 2 * ty;
+
+ float addition = numberOfChunks / COM_RULE_OF_THIRDS_DIVIDER;
+ hotspots[0] = new ChunkOrderHotspot(mx, my, addition * 0);
+ hotspots[1] = new ChunkOrderHotspot(tx, my, addition * 1);
+ hotspots[2] = new ChunkOrderHotspot(bx, my, addition * 2);
+ hotspots[3] = new ChunkOrderHotspot(bx, by, addition * 3);
+ hotspots[4] = new ChunkOrderHotspot(tx, ty, addition * 4);
+ hotspots[5] = new ChunkOrderHotspot(bx, ty, addition * 5);
+ hotspots[6] = new ChunkOrderHotspot(tx, by, addition * 6);
+ hotspots[7] = new ChunkOrderHotspot(mx, ty, addition * 7);
+ hotspots[8] = new ChunkOrderHotspot(mx, by, addition * 8);
rcti rect;
ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks];
- for (index = 0 ; index < this->numberOfChunks; index ++) {
+ for (index = 0; index < this->numberOfChunks; index++) {
determineChunkRect(&rect, index);
chunkOrders[index].setChunkNumber(index);
chunkOrders[index].setX(rect.xmin);
@@ -298,7 +304,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
sort(&chunkOrders[0], &chunkOrders[numberOfChunks]);
- for (index = 0 ; index < numberOfChunks; index ++) {
+ for (index = 0; index < numberOfChunks; index++) {
chunkOrder[index] = chunkOrders[index].getChunkNumber();
}
@@ -315,40 +321,40 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
delete[] chunkOrders;
}
break;
- case COM_TO_TOP_DOWN:
- default:
- break;
+ case COM_TO_TOP_DOWN:
+ default:
+ break;
}
bool breaked = false;
bool finished = false;
unsigned int startIndex = 0;
- const int maxNumberEvaluated = BLI_system_thread_count()*2;
+ const int maxNumberEvaluated = BLI_system_thread_count() * 2;
while (!finished && !breaked) {
- unsigned int index;
+ unsigned int index;
bool startEvaluated = false;
finished = true;
int numberEvaluated = 0;
- for (index = startIndex ; index < numberOfChunks && numberEvaluated < maxNumberEvaluated; index ++) {
+ for (index = startIndex; index < numberOfChunks && numberEvaluated < maxNumberEvaluated; index++) {
int chunkNumber = chunkOrder[index];
- int yChunk = chunkNumber/this->numberOfXChunks;
- int xChunk = chunkNumber - (yChunk*this->numberOfXChunks);
+ int yChunk = chunkNumber / this->numberOfXChunks;
+ int xChunk = chunkNumber - (yChunk * this->numberOfXChunks);
const ChunkExecutionState state = this->chunkExecutionStates[chunkNumber];
if (state == COM_ES_NOT_SCHEDULED) {
scheduleChunkWhenPossible(graph, xChunk, yChunk);
- finished=false;
+ finished = false;
startEvaluated = true;
numberEvaluated++;
}
else if (state == COM_ES_SCHEDULED) {
- finished=false;
+ finished = false;
startEvaluated = true;
numberEvaluated++;
}
else if (state == COM_ES_EXECUTED && !startEvaluated) {
- startIndex = index+1;
+ startIndex = index + 1;
}
}
@@ -362,39 +368,39 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
delete[] chunkOrder;
}
-MemoryBuffer** ExecutionGroup::getInputBuffersCPU()
+MemoryBuffer **ExecutionGroup::getInputBuffersCPU()
{
- vector<MemoryProxy*> memoryproxies;
+ vector<MemoryProxy *> memoryproxies;
unsigned int index;
this->determineDependingMemoryProxies(&memoryproxies);
- MemoryBuffer **memoryBuffers = new MemoryBuffer*[this->cachedMaxReadBufferOffset];
- for (index = 0 ; index < this->cachedMaxReadBufferOffset ; index ++) {
+ MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->cachedMaxReadBufferOffset];
+ for (index = 0; index < this->cachedMaxReadBufferOffset; index++) {
memoryBuffers[index] = NULL;
}
- for (index = 0 ; index < this->cachedReadOperations.size(); index ++) {
- ReadBufferOperation *readOperation = (ReadBufferOperation*)this->cachedReadOperations[index];
+ for (index = 0; index < this->cachedReadOperations.size(); index++) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)this->cachedReadOperations[index];
memoryBuffers[readOperation->getOffset()] = readOperation->getMemoryProxy()->getBuffer();
}
return memoryBuffers;
}
-MemoryBuffer** ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
+MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
{
rcti rect;
- vector<MemoryProxy*> memoryproxies;
+ vector<MemoryProxy *> memoryproxies;
unsigned int index;
determineChunkRect(&rect, chunkNumber);
this->determineDependingMemoryProxies(&memoryproxies);
- MemoryBuffer **memoryBuffers = new MemoryBuffer*[this->cachedMaxReadBufferOffset];
- for (index = 0 ; index < this->cachedMaxReadBufferOffset ; index ++) {
+ MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->cachedMaxReadBufferOffset];
+ for (index = 0; index < this->cachedMaxReadBufferOffset; index++) {
memoryBuffers[index] = NULL;
}
rcti output;
- for (index = 0 ; index < this->cachedReadOperations.size(); index ++) {
- ReadBufferOperation *readOperation = (ReadBufferOperation*)this->cachedReadOperations[index];
- MemoryProxy * memoryProxy = readOperation->getMemoryProxy();
+ for (index = 0; index < this->cachedReadOperations.size(); index++) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)this->cachedReadOperations[index];
+ MemoryProxy *memoryProxy = readOperation->getMemoryProxy();
this->determineDependingAreaOfInterest(&rect, readOperation, &output);
MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(memoryProxy, &output);
memoryBuffers[readOperation->getOffset()] = memoryBuffer;
@@ -404,21 +410,21 @@ MemoryBuffer** ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
{
- MemoryBuffer* imageBuffer = memoryProxy->getBuffer();
- MemoryBuffer* result = new MemoryBuffer(memoryProxy, rect);
+ MemoryBuffer *imageBuffer = memoryProxy->getBuffer();
+ MemoryBuffer *result = new MemoryBuffer(memoryProxy, rect);
result->copyContentFrom(imageBuffer);
return result;
}
-void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer** memoryBuffers)
+void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
{
if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
this->chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
this->chunksFinished++;
if (memoryBuffers) {
- for (unsigned int index = 0 ; index < this->cachedMaxReadBufferOffset; index ++) {
- MemoryBuffer * buffer = memoryBuffers[index];
+ for (unsigned int index = 0; index < this->cachedMaxReadBufferOffset; index++) {
+ MemoryBuffer *buffer = memoryBuffers[index];
if (buffer) {
if (buffer->isTemporarily()) {
memoryBuffers[index] = NULL;
@@ -431,16 +437,21 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer** memo
if (bTree) {
// status report is only performed for top level Execution Groups.
float progress = chunksFinished;
- progress/=numberOfChunks;
+ progress /= numberOfChunks;
bTree->progress(bTree->prh, progress);
}
}
-inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk ) const
+inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const
{
- const unsigned int minx = xChunk * chunkSize;
- const unsigned int miny = yChunk * chunkSize;
- BLI_init_rcti(rect, minx, min(minx + this->chunkSize, this->width), miny, min(miny + this->chunkSize, this->height));
+ if (singleThreaded) {
+ BLI_init_rcti(rect, 0, this->width, 0, this->height);
+ }
+ else {
+ const unsigned int minx = xChunk * chunkSize;
+ const unsigned int miny = yChunk * chunkSize;
+ BLI_init_rcti(rect, minx, min(minx + this->chunkSize, this->width), miny, min(miny + this->chunkSize, this->height));
+ }
}
void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumber) const
@@ -453,9 +464,9 @@ void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumb
MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti *rect)
{
// we asume that this method is only called from complex execution groups.
- NodeOperation * operation = this->getOutputNodeOperation();
+ NodeOperation *operation = this->getOutputNodeOperation();
if (operation->isWriteBufferOperation()) {
- WriteBufferOperation *writeOperation = (WriteBufferOperation*)operation;
+ WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation;
MemoryBuffer *buffer = new MemoryBuffer(writeOperation->getMemoryProxy(), rect);
return buffer;
}
@@ -463,22 +474,25 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti *rect)
}
-bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem * graph, rcti *area)
+bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
{
+ if (singleThreaded) {
+ return scheduleChunkWhenPossible(graph, 0, 0);
+ }
// find all chunks inside the rect
// determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
float chunkSizef = this->chunkSize;
int indexx, indexy;
- const int minxchunk = floor(area->xmin/chunkSizef);
- const int maxxchunk = ceil((area->xmax-1)/chunkSizef);
- const int minychunk = floor(area->ymin/chunkSizef);
- const int maxychunk = ceil((area->ymax-1)/chunkSizef);
+ const int minxchunk = floor(area->xmin / chunkSizef);
+ const int maxxchunk = ceil((area->xmax - 1) / chunkSizef);
+ const int minychunk = floor(area->ymin / chunkSizef);
+ const int maxychunk = ceil((area->ymax - 1) / chunkSizef);
bool result = true;
- for (indexx = max(minxchunk, 0); indexx<maxxchunk ; indexx++) {
- for (indexy = max(minychunk, 0); indexy<maxychunk ; indexy++) {
+ for (indexx = max(minxchunk, 0); indexx < maxxchunk; indexx++) {
+ for (indexy = max(minychunk, 0); indexy < maxychunk; indexy++) {
if (!scheduleChunkWhenPossible(graph, indexx, indexy)) {
result = false;
}
@@ -498,7 +512,7 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
return false;
}
-bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChunk, int yChunk)
+bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk)
{
if (xChunk < 0 || xChunk >= (int)this->numberOfXChunks) {
return true;
@@ -506,7 +520,7 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChu
if (yChunk < 0 || yChunk >= (int)this->numberOfYChunks) {
return true;
}
- int chunkNumber = yChunk*this->numberOfXChunks + xChunk;
+ int chunkNumber = yChunk * this->numberOfXChunks + xChunk;
// chunk is already executed
if (this->chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) {
return true;
@@ -518,7 +532,7 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChu
}
// chunk is nor executed nor scheduled.
- vector<MemoryProxy*> memoryProxies;
+ vector<MemoryProxy *> memoryProxies;
this->determineDependingMemoryProxies(&memoryProxies);
rcti rect;
@@ -527,10 +541,10 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChu
bool canBeExecuted = true;
rcti area;
- for (index = 0 ; index < cachedReadOperations.size() ; index ++) {
- ReadBufferOperation * readOperation = (ReadBufferOperation*)cachedReadOperations[index];
+ for (index = 0; index < cachedReadOperations.size(); index++) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)cachedReadOperations[index];
BLI_init_rcti(&area, 0, 0, 0, 0);
- MemoryProxy * memoryProxy = memoryProxies[index];
+ MemoryProxy *memoryProxy = memoryProxies[index];
determineDependingAreaOfInterest(&rect, readOperation, &area);
ExecutionGroup *group = memoryProxy->getExecutor();
@@ -551,16 +565,16 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChu
return false;
}
-void ExecutionGroup::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output)
+void ExecutionGroup::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
this->getOutputNodeOperation()->determineDependingAreaOfInterest(input, readOperation, output);
}
-void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy*> *memoryProxies)
+void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies)
{
unsigned int index;
- for (index = 0 ; index < this->cachedReadOperations.size() ; index ++) {
- ReadBufferOperation * readOperation = (ReadBufferOperation*) this->cachedReadOperations[index];
+ for (index = 0; index < this->cachedReadOperations.size(); index++) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation *) this->cachedReadOperations[index];
memoryProxies->push_back(readOperation->getMemoryProxy());
}
}
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index 416a78eb8b8..541b3e4866d 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -33,21 +33,21 @@
/**
- * @brief the execution state of a chunk in an ExecutionGroup
- * @ingroup Execution
- */
+ * @brief the execution state of a chunk in an ExecutionGroup
+ * @ingroup Execution
+ */
typedef enum ChunkExecutionState {
/**
- * @brief chunk is not yet scheduled
- */
+ * @brief chunk is not yet scheduled
+ */
COM_ES_NOT_SCHEDULED = 0,
/**
- * @brief chunk is scheduled, but not yet executed
- */
+ * @brief chunk is scheduled, but not yet executed
+ */
COM_ES_SCHEDULED = 1,
/**
- * @brief chunk is executed.
- */
+ * @brief chunk is executed.
+ */
COM_ES_EXECUTED = 2
} ChunkExecutionState;
@@ -56,353 +56,343 @@ class ReadBufferOperation;
class Device;
/**
- * @brief Class ExecutionGroup is a group of NodeOperations that are executed as one.
- * This grouping is used to combine Operations that can be executed as one whole when multi-processing.
- * @ingroup Execution
- */
+ * @brief Class ExecutionGroup is a group of NodeOperations that are executed as one.
+ * This grouping is used to combine Operations that can be executed as one whole when multi-processing.
+ * @ingroup Execution
+ */
class ExecutionGroup {
private:
// fields
- /**
- * @brief unique identifier of this node.
- */
- string id;
/**
- * @brief list of operations in this ExecutionGroup
- */
- vector<NodeOperation*> operations;
+ * @brief list of operations in this ExecutionGroup
+ */
+ vector<NodeOperation *> operations;
/**
- * @brief is this ExecutionGroup an input ExecutionGroup
- * an input execution group is a group that is at the end of the calculation (the output is important for the user)
- */
+ * @brief is this ExecutionGroup an input ExecutionGroup
+ * an input execution group is a group that is at the end of the calculation (the output is important for the user)
+ */
int isOutput;
/**
- * @brief Width of the output
- */
+ * @brief Width of the output
+ */
unsigned int width;
/**
- * @brief Height of the output
- */
+ * @brief Height of the output
+ */
unsigned int height;
/**
- * @brief size of a single chunk, being Width or of height
- * a chunk is always a square, except at the edges of the MemoryBuffer
- */
+ * @brief size of a single chunk, being Width or of height
+ * a chunk is always a square, except at the edges of the MemoryBuffer
+ */
unsigned int chunkSize;
/**
- * @brief number of chunks in the x-axis
- */
+ * @brief number of chunks in the x-axis
+ */
unsigned int numberOfXChunks;
/**
- * @brief number of chunks in the y-axis
- */
+ * @brief number of chunks in the y-axis
+ */
unsigned int numberOfYChunks;
/**
- * @brief total number of chunks
- */
+ * @brief total number of chunks
+ */
unsigned int numberOfChunks;
/**
- * @brief contains this ExecutionGroup a complex NodeOperation.
- */
+ * @brief contains this ExecutionGroup a complex NodeOperation.
+ */
bool complex;
/**
- * @brief can this ExecutionGroup be scheduled on an OpenCLDevice
- */
+ * @brief can this ExecutionGroup be scheduled on an OpenCLDevice
+ */
bool openCL;
/**
- * @brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
- * @note this is used to construct the MemoryBuffers that will be passed during execution.
- */
+ * @brief Is this Execution group SingleThreaded
+ */
+ bool singleThreaded;
+
+ /**
+ * @brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
+ * @note this is used to construct the MemoryBuffers that will be passed during execution.
+ */
unsigned int cachedMaxReadBufferOffset;
/**
- * @brief a cached vector of all read operations in the execution group.
- */
- vector<NodeOperation*> cachedReadOperations;
+ * @brief a cached vector of all read operations in the execution group.
+ */
+ vector<NodeOperation *> cachedReadOperations;
/**
- * @brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
- * @note can only be used to call the callbacks for progress, status and break
- */
- const bNodeTree * bTree;
+ * @brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
+ * @note can only be used to call the callbacks for progress, status and break
+ */
+ const bNodeTree *bTree;
/**
- * @brief total number of chunks that have been calculated for this ExecutionGroup
- */
+ * @brief total number of chunks that have been calculated for this ExecutionGroup
+ */
unsigned int chunksFinished;
/**
- * @brief the chunkExecutionStates holds per chunk the execution state. this state can be
- * - COM_ES_NOT_SCHEDULED: not scheduled
- * - COM_ES_SCHEDULED: scheduled
- * - COM_ES_EXECUTED: executed
- */
+ * @brief the chunkExecutionStates holds per chunk the execution state. this state can be
+ * - COM_ES_NOT_SCHEDULED: not scheduled
+ * - COM_ES_SCHEDULED: scheduled
+ * - COM_ES_EXECUTED: executed
+ */
ChunkExecutionState *chunkExecutionStates;
/**
- * @brief indicator when this ExecutionGroup has valid NodeOperations in its vector for Execution
- * @note When building the ExecutionGroup NodeOperations are added via recursion. First a WriteBufferOperations is added, then the
- * @note Operation containing the settings that is important for the ExecutiongGroup is added,
- * @note When this occurs, these settings are copied over from the node to the ExecutionGroup
- * @note and the Initialized flag is set to true.
+ * @brief indicator when this ExecutionGroup has valid NodeOperations in its vector for Execution
+ * @note When building the ExecutionGroup NodeOperations are added via recursion. First a WriteBufferOperations is added, then the
+ * @note Operation containing the settings that is important for the ExecutiongGroup is added,
+ * @note When this occurs, these settings are copied over from the node to the ExecutionGroup
+ * @note and the Initialized flag is set to true.
* @see complex
- * @see openCL
- */
+ * @see openCL
+ */
bool initialized;
// methods
/**
- * @brief check whether parameter operation can be added to the execution group
- * @param operation the operation to be added
- */
+ * @brief check whether parameter operation can be added to the execution group
+ * @param operation the operation to be added
+ */
bool canContainOperation(NodeOperation *operation);
/**
- * @brief calculate the actual chunk size of this execution group.
- * @note A chunk size is an unsigned int that is both the height and width of a chunk.
- * @note The chunk size will not be stored in the chunkSize field. This needs to be done
- * @note by the calling method.
- */
+ * @brief calculate the actual chunk size of this execution group.
+ * @note A chunk size is an unsigned int that is both the height and width of a chunk.
+ * @note The chunk size will not be stored in the chunkSize field. This needs to be done
+ * @note by the calling method.
+ */
unsigned int determineChunkSize();
/**
- * @brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
- * @note Only gives usefull results ater the determination of the chunksize
- * @see determineChunkSize()
- */
+ * @brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
+ * @note Only gives usefull results ater the determination of the chunksize
+ * @see determineChunkSize()
+ */
void determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const;
/**
- * @brief determine the number of chunks, based on the chunkSize, width and height.
- * @note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks
- */
+ * @brief determine the number of chunks, based on the chunkSize, width and height.
+ * @note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks
+ */
void determineNumberOfChunks();
/**
- * @brief try to schedule a specific chunk.
- * @note scheduling succeeds when all input requirements are met and the chunks hasen't been scheduled yet.
- * @param graph
- * @param xChunk
- * @param yChunk
- * @return [true:false]
- * true: package(s) are scheduled
- * false: scheduling is deferred (depending workpackages are scheduled)
- */
- bool scheduleChunkWhenPossible(ExecutionSystem * graph, int xChunk, int yChunk);
-
- /**
- * @brief try to schedule a specific area.
- * @note Check if a certain area is available, when not available this are will be checked.
- * @note This method is called from other ExecutionGroup's.
- * @param graph
- * @param rect
- * @return [true:false]
- * true: package(s) are scheduled
- * false: scheduling is deferred (depending workpackages are scheduled)
- */
- bool scheduleAreaWhenPossible(ExecutionSystem * graph, rcti * rect);
-
- /**
- * @brief add a chunk to the WorkScheduler.
- * @param chunknumber
- */
+ * @brief try to schedule a specific chunk.
+ * @note scheduling succeeds when all input requirements are met and the chunks hasen't been scheduled yet.
+ * @param graph
+ * @param xChunk
+ * @param yChunk
+ * @return [true:false]
+ * true: package(s) are scheduled
+ * false: scheduling is deferred (depending workpackages are scheduled)
+ */
+ bool scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk);
+
+ /**
+ * @brief try to schedule a specific area.
+ * @note Check if a certain area is available, when not available this are will be checked.
+ * @note This method is called from other ExecutionGroup's.
+ * @param graph
+ * @param rect
+ * @return [true:false]
+ * true: package(s) are scheduled
+ * false: scheduling is deferred (depending workpackages are scheduled)
+ */
+ bool scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *rect);
+
+ /**
+ * @brief add a chunk to the WorkScheduler.
+ * @param chunknumber
+ */
bool scheduleChunk(unsigned int chunkNumber);
/**
- * @brief determine the area of interest of a certain input area
- * @note This method only evaluates a single ReadBufferOperation
- * @param input the input area
- * @param readOperation The ReadBufferOperation where the area needs to be evaluated
- * @param output the area needed of the ReadBufferOperation. Result
- */
- void determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output);
+ * @brief determine the area of interest of a certain input area
+ * @note This method only evaluates a single ReadBufferOperation
+ * @param input the input area
+ * @param readOperation The ReadBufferOperation where the area needs to be evaluated
+ * @param output the area needed of the ReadBufferOperation. Result
+ */
+ void determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
public:
// constructors
ExecutionGroup();
-
- /**
- * @brief set the id of this ExecutionGroup
- * @param id
- */
- void setId(string id) {this->id = id;}
-
- /**
- * @brief return the id of this ExecutionGroup
- */
- const string getId() const {return this->id;}
-
+
// methods
/**
- * @brief check to see if a NodeOperation is already inside this execution group
- * @param operation the NodeOperation to check
- * @return [true,false]
- */
+ * @brief check to see if a NodeOperation is already inside this execution group
+ * @param operation the NodeOperation to check
+ * @return [true,false]
+ */
bool containsOperation(NodeOperation *operation);
/**
- * @brief add an operation to this ExecutionGroup
- * @note this method will add input of the operations recursivly
- * @note this method can create multiple ExecutionGroup's
- * @param system
- * @param operation
- */
+ * @brief add an operation to this ExecutionGroup
+ * @note this method will add input of the operations recursivly
+ * @note this method can create multiple ExecutionGroup's
+ * @param system
+ * @param operation
+ */
void addOperation(ExecutionSystem *system, NodeOperation *operation);
/**
- * @brief is this ExecutionGroup an output ExecutionGroup
- * @note An OutputExecution group are groups containing a
- * @note ViewerOperation, CompositeOperation, PreviewOperation.
- * @see NodeOperation.isOutputOperation
- */
- const int isOutputExecutionGroup() const {return this->isOutput;}
-
+ * @brief is this ExecutionGroup an output ExecutionGroup
+ * @note An OutputExecution group are groups containing a
+ * @note ViewerOperation, CompositeOperation, PreviewOperation.
+ * @see NodeOperation.isOutputOperation
+ */
+ const int isOutputExecutionGroup() const { return this->isOutput; }
+
/**
- * @brief set whether this ExecutionGroup is an output
- * @param isOutput
- */
- void setOutputExecutionGroup(int isOutput) {this->isOutput = isOutput;}
-
+ * @brief set whether this ExecutionGroup is an output
+ * @param isOutput
+ */
+ void setOutputExecutionGroup(int isOutput) { this->isOutput = isOutput; }
+
/**
- * @brief determine the resolution of this ExecutionGroup
- * @param resolution
- */
+ * @brief determine the resolution of this ExecutionGroup
+ * @param resolution
+ */
void determineResolution(unsigned int resolution[]);
/**
- * @brief set the resolution of this executiongroup
- * @param resolution
- */
- void setResolution(unsigned int resolution[]) {this->width = resolution[0];this->height = resolution[1];}
+ * @brief set the resolution of this executiongroup
+ * @param resolution
+ */
+ void setResolution(unsigned int resolution[]) { this->width = resolution[0]; this->height = resolution[1]; }
/**
- * @brief get the width of this execution group
- */
- const unsigned int getWidth() {return this->width;}
+ * @brief get the width of this execution group
+ */
+ const unsigned int getWidth() { return this->width; }
/**
- * @brief get the height of this execution group
- */
- const unsigned int getHeight() {return this->height;}
+ * @brief get the height of this execution group
+ */
+ const unsigned int getHeight() { return this->height; }
/**
- * @brief does this ExecutionGroup contains a complex NodeOperation
- */
+ * @brief does this ExecutionGroup contains a complex NodeOperation
+ */
const bool isComplex() const;
/**
- * @brief get the output operation of this ExecutionGroup
- * @return NodeOperation *output operation
- */
- NodeOperation *getOutputNodeOperation() const;
+ * @brief get the output operation of this ExecutionGroup
+ * @return NodeOperation *output operation
+ */
+ NodeOperation *getOutputNodeOperation() const;
/**
- * @brief compose multiple chunks into a single chunk
- * @return Memorybuffer *consolidated chunk
- */
+ * @brief compose multiple chunks into a single chunk
+ * @return Memorybuffer *consolidated chunk
+ */
MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *output);
/**
- * @brief initExecution is called just before the execution of the whole graph will be done.
- * @note The implementation will calculate the chunkSize of this execution group.
- */
+ * @brief initExecution is called just before the execution of the whole graph will be done.
+ * @note The implementation will calculate the chunkSize of this execution group.
+ */
void initExecution();
/**
- * @brief get all inputbuffers needed to calculate an chunk
- * @note all inputbuffers must be executed
- * @param chunkNumber the chunk to be calculated
- * @return MemoryBuffer** the inputbuffers
- */
- MemoryBuffer** getInputBuffersCPU();
+ * @brief get all inputbuffers needed to calculate an chunk
+ * @note all inputbuffers must be executed
+ * @param chunkNumber the chunk to be calculated
+ * @return MemoryBuffer** the inputbuffers
+ */
+ MemoryBuffer **getInputBuffersCPU();
/**
- * @brief get all inputbuffers needed to calculate an chunk
- * @note all inputbuffers must be executed
- * @param chunkNumber the chunk to be calculated
- * @return MemoryBuffer** the inputbuffers
- */
- MemoryBuffer** getInputBuffersOpenCL(int chunkNumber);
+ * @brief get all inputbuffers needed to calculate an chunk
+ * @note all inputbuffers must be executed
+ * @param chunkNumber the chunk to be calculated
+ * @return MemoryBuffer** the inputbuffers
+ */
+ MemoryBuffer **getInputBuffersOpenCL(int chunkNumber);
/**
- * @brief allocate the outputbuffer of a chunk
- * @param chunkNumber the number of the chunk in the ExecutionGroup
- * @param rect the rect of that chunk
- * @see determineChunkRect
- */
+ * @brief allocate the outputbuffer of a chunk
+ * @param chunkNumber the number of the chunk in the ExecutionGroup
+ * @param rect the rect of that chunk
+ * @see determineChunkRect
+ */
MemoryBuffer *allocateOutputBuffer(int chunkNumber, rcti *rect);
/**
- * @brief after a chunk is executed the needed resources can be freed or unlocked.
- * @param chunknumber
- * @param memorybuffers
- */
- void finalizeChunkExecution(int chunkNumber, MemoryBuffer** memoryBuffers);
+ * @brief after a chunk is executed the needed resources can be freed or unlocked.
+ * @param chunknumber
+ * @param memorybuffers
+ */
+ void finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers);
/**
- * @brief deinitExecution is called just after execution the whole graph.
- * @note It will release all needed resources
- */
+ * @brief deinitExecution is called just after execution the whole graph.
+ * @note It will release all needed resources
+ */
void deinitExecution();
/**
- * @brief schedule an ExecutionGroup
- * @note this method will return when all chunks have been calculated, or the execution has breaked (by user)
- *
- * first the order of the chunks will be determined. This is determined by finding the ViewerOperation and get the relevant information from it.
- * - ChunkOrdering
- * - CenterX
- * - CenterY
- *
- * After determining the order of the chunks the chunks will be scheduled
- *
- * @see ViewerOperation
- * @param system
- */
+ * @brief schedule an ExecutionGroup
+ * @note this method will return when all chunks have been calculated, or the execution has breaked (by user)
+ *
+ * first the order of the chunks will be determined. This is determined by finding the ViewerOperation and get the relevant information from it.
+ * - ChunkOrdering
+ * - CenterX
+ * - CenterY
+ *
+ * After determining the order of the chunks the chunks will be scheduled
+ *
+ * @see ViewerOperation
+ * @param system
+ */
void execute(ExecutionSystem *system);
/**
- * @brief this method determines the MemoryProxy's where this execution group depends on.
- * @note After this method determineDependingAreaOfInterest can be called to determine
- * @note the area of the MemoryProxy.creator thas has to be executed.
- * @param memoryProxies result
- */
- void determineDependingMemoryProxies(vector<MemoryProxy*> *memoryProxies);
+ * @brief this method determines the MemoryProxy's where this execution group depends on.
+ * @note After this method determineDependingAreaOfInterest can be called to determine
+ * @note the area of the MemoryProxy.creator thas has to be executed.
+ * @param memoryProxies result
+ */
+ void determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies);
/**
- * @brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
- * @note Only gives usefull results ater the determination of the chunksize
- * @see determineChunkSize()
- */
+ * @brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
+ * @note Only gives usefull results ater the determination of the chunksize
+ * @see determineChunkSize()
+ */
void determineChunkRect(rcti *rect, const unsigned int chunkNumber) const;
/**
- * @brief can this ExecutionGroup be scheduled on an OpenCLDevice
- * @see WorkScheduler.schedule
- */
+ * @brief can this ExecutionGroup be scheduled on an OpenCLDevice
+ * @see WorkScheduler.schedule
+ */
bool isOpenCL();
- void setChunksize(int chunksize) {this->chunkSize = chunksize;}
+ void setChunksize(int chunksize) { this->chunkSize = chunksize; }
/**
- * @brief get the Render priority of this ExecutionGroup
- * @see ExecutionSystem.execute
- */
+ * @brief get the Render priority of this ExecutionGroup
+ * @see ExecutionSystem.execute
+ */
CompositorPriority getRenderPriotrity();
};
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index 8c0b37a0685..7250a851f7b 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -41,7 +41,14 @@
ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering)
{
- this->context.setbNodeTree(editingtree);
+ context.setbNodeTree(editingtree);
+ bNode *gnode;
+ for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) {
+ if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) {
+ context.setActivegNode(gnode);
+ break;
+ }
+ }
/* initialize the CompositorContext */
if (rendering) {
@@ -53,27 +60,27 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering)
context.setRendering(rendering);
context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL));
- Node *mainOutputNode=NULL;
+ Node *mainOutputNode = NULL;
- mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree);
+ mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL);
if (mainOutputNode) {
- context.setScene((Scene*)mainOutputNode->getbNode()->id);
+ context.setScene((Scene *)mainOutputNode->getbNode()->id);
this->convertToOperations();
this->groupOperations(); /* group operations in ExecutionGroups */
- vector<ExecutionGroup*> executionGroups;
- this->findOutputExecutionGroup(&executionGroups);
unsigned int index;
unsigned int resolution[2];
- for (index = 0 ; index < executionGroups.size(); index ++) {
- resolution[0]=0;
- resolution[1]=0;
- ExecutionGroup *executionGroup = executionGroups[index];
+ for (index = 0; index < this->groups.size(); index++) {
+ resolution[0] = 0;
+ resolution[1] = 0;
+ ExecutionGroup *executionGroup = groups[index];
executionGroup->determineResolution(resolution);
}
}
- if (G.f & G_DEBUG) ExecutionSystemHelper::debugDump(this);
+#ifdef COM_DEBUG
+ ExecutionSystemHelper::debugDump(this);
+#endif
}
ExecutionSystem::~ExecutionSystem()
@@ -104,23 +111,24 @@ ExecutionSystem::~ExecutionSystem()
void ExecutionSystem::execute()
{
unsigned int order = 0;
- for (vector<NodeOperation*>::iterator iter = this->operations.begin(); iter != operations.end(); ++iter) {
+ for (vector<NodeOperation *>::iterator iter = this->operations.begin(); iter != operations.end(); ++iter) {
NodeBase *node = *iter;
- NodeOperation *operation = (NodeOperation*) node;
+ NodeOperation *operation = (NodeOperation *) node;
if (operation->isReadBufferOperation()) {
- ReadBufferOperation * readOperation = (ReadBufferOperation*)operation;
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
readOperation->setOffset(order);
- order ++;
+ order++;
}
}
unsigned int index;
- for (index = 0 ; index < this->operations.size() ; index ++) {
- NodeOperation * operation = this->operations[index];
+ for (index = 0; index < this->operations.size(); index++) {
+ NodeOperation *operation = this->operations[index];
+ operation->setbNodeTree(this->context.getbNodeTree());
operation->initExecution();
}
- for (index = 0 ; index < this->groups.size() ; index ++) {
- ExecutionGroup * executionGroup = this->groups[index];
+ for (index = 0; index < this->groups.size(); index++) {
+ ExecutionGroup *executionGroup = this->groups[index];
executionGroup->setChunksize(context.getChunksize());
executionGroup->initExecution();
}
@@ -134,23 +142,23 @@ void ExecutionSystem::execute()
WorkScheduler::finish();
WorkScheduler::stop();
- for (index = 0 ; index < this->operations.size() ; index ++) {
- NodeOperation * operation = this->operations[index];
+ for (index = 0; index < this->operations.size(); index++) {
+ NodeOperation *operation = this->operations[index];
operation->deinitExecution();
}
- for (index = 0 ; index < this->groups.size() ; index ++) {
- ExecutionGroup * executionGroup = this->groups[index];
+ for (index = 0; index < this->groups.size(); index++) {
+ ExecutionGroup *executionGroup = this->groups[index];
executionGroup->deinitExecution();
}
}
void ExecutionSystem::executeGroups(CompositorPriority priority)
{
- int index;
- vector<ExecutionGroup*> executionGroups;
+ unsigned int index;
+ vector<ExecutionGroup *> executionGroups;
this->findOutputExecutionGroup(&executionGroups, priority);
- for (index = 0 ; index < executionGroups.size(); index ++) {
+ for (index = 0; index < executionGroups.size(); index++) {
ExecutionGroup *group = executionGroups[index];
group->execute(this);
}
@@ -159,6 +167,7 @@ void ExecutionSystem::executeGroups(CompositorPriority priority)
void ExecutionSystem::addOperation(NodeOperation *operation)
{
ExecutionSystemHelper::addOperation(this->operations, operation);
+// operation->setBTree
}
void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation)
@@ -166,87 +175,96 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation)
// for every input add write and read operation if input is not a read operation
// only add read operation to other links when they are attached to buffered operations.
unsigned int index;
- for (index = 0 ; index < operation->getNumberOfInputSockets();index++) {
+ for (index = 0; index < operation->getNumberOfInputSockets(); index++) {
InputSocket *inputsocket = operation->getInputSocket(index);
if (inputsocket->isConnected()) {
SocketConnection *connection = inputsocket->getConnection();
- NodeOperation *otherEnd = (NodeOperation*)connection->getFromNode();
+ NodeOperation *otherEnd = (NodeOperation *)connection->getFromNode();
if (!otherEnd->isReadBufferOperation()) {
// check of other end already has write operation
OutputSocket *fromsocket = connection->getFromSocket();
- WriteBufferOperation * writeoperation = fromsocket->findAttachedWriteBufferOperation();
+ WriteBufferOperation *writeoperation = fromsocket->findAttachedWriteBufferOperation();
if (writeoperation == NULL) {
writeoperation = new WriteBufferOperation();
writeoperation->setbNodeTree(this->getContext().getbNodeTree());
this->addOperation(writeoperation);
ExecutionSystemHelper::addLink(this->getConnections(), fromsocket, writeoperation->getInputSocket(0));
+ writeoperation->readResolutionFromInputSocket();
}
ReadBufferOperation *readoperation = new ReadBufferOperation();
readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
connection->setFromSocket(readoperation->getOutputSocket());
readoperation->getOutputSocket()->addConnection(connection);
+ readoperation->readResolutionFromWriteBuffer();
this->addOperation(readoperation);
}
}
}
/*
- link the outputsocket to a write operation
- link the writeoperation to a read operation
- link the read operation to the next node.
- */
- OutputSocket * outputsocket = operation->getOutputSocket();
+ * link the outputsocket to a write operation
+ * link the writeoperation to a read operation
+ * link the read operation to the next node.
+ */
+ OutputSocket *outputsocket = operation->getOutputSocket();
if (outputsocket->isConnected()) {
int index;
WriteBufferOperation *writeOperation;
writeOperation = new WriteBufferOperation();
writeOperation->setbNodeTree(this->getContext().getbNodeTree());
this->addOperation(writeOperation);
- for (index = 0 ; index < outputsocket->getNumberOfConnections();index ++) {
- SocketConnection * connection = outputsocket->getConnection(index);
+ ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0));
+ writeOperation->readResolutionFromInputSocket();
+ for (index = 0; index < outputsocket->getNumberOfConnections() - 1; index++) {
+ SocketConnection *connection = outputsocket->getConnection(index);
ReadBufferOperation *readoperation = new ReadBufferOperation();
readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
connection->setFromSocket(readoperation->getOutputSocket());
readoperation->getOutputSocket()->addConnection(connection);
+ readoperation->readResolutionFromWriteBuffer();
this->addOperation(readoperation);
}
- ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0));
}
}
void ExecutionSystem::convertToOperations()
{
unsigned int index;
- // first determine data types of the nodes, this can be used by the node to convert to a different operation system
- this->determineActualSocketDataTypes((vector<NodeBase*>&)this->nodes);
for (index = 0; index < this->nodes.size(); index++) {
- Node *node = (Node*)this->nodes[index];
+ Node *node = (Node *)this->nodes[index];
node->convertToOperations(this, &this->context);
}
- // update the socket types of the operations. this will be used to add conversion operations in the system
- this->determineActualSocketDataTypes((vector<NodeBase*>&)this->operations);
- for (index = 0 ; index < this->connections.size(); index ++) {
+ for (index = 0; index < this->connections.size(); index++) {
SocketConnection *connection = this->connections[index];
if (connection->isValid()) {
- if (connection->getFromSocket()->getActualDataType() != connection->getToSocket()->getActualDataType()) {
+ if (connection->getFromSocket()->getDataType() != connection->getToSocket()->getDataType()) {
Converter::convertDataType(connection, this);
}
}
}
// determine all resolutions of the operations (Width/Height)
- for (index = 0 ; index < this->operations.size(); index ++) {
+ for (index = 0; index < this->operations.size(); index++) {
+ NodeOperation *operation = this->operations[index];
+ if (operation->isOutputOperation(context.isRendering()) && !operation->isPreviewOperation()) {
+ unsigned int resolution[2] = {0, 0};
+ unsigned int preferredResolution[2] = {0, 0};
+ operation->determineResolution(resolution, preferredResolution);
+ operation->setResolution(resolution);
+ }
+ }
+ for (index = 0; index < this->operations.size(); index++) {
NodeOperation *operation = this->operations[index];
- if (operation->isOutputOperation(context.isRendering())) {
- unsigned int resolution[2] = {0,0};
- unsigned int preferredResolution[2] = {0,0};
+ if (operation->isOutputOperation(context.isRendering()) && operation->isPreviewOperation()) {
+ unsigned int resolution[2] = {0, 0};
+ unsigned int preferredResolution[2] = {0, 0};
operation->determineResolution(resolution, preferredResolution);
operation->setResolution(resolution);
}
}
// add convert resolution operations when needed.
- for (index = 0 ; index < this->connections.size(); index ++) {
+ for (index = 0; index < this->connections.size(); index++) {
SocketConnection *connection = this->connections[index];
if (connection->isValid()) {
if (connection->needsResolutionConversion()) {
@@ -254,13 +272,12 @@ void ExecutionSystem::convertToOperations()
}
}
}
-
}
void ExecutionSystem::groupOperations()
{
- vector<NodeOperation*> outputOperations;
- NodeOperation * operation;
+ vector<NodeOperation *> outputOperations;
+ NodeOperation *operation;
unsigned int index;
// surround complex operations with ReadBufferOperation and WriteBufferOperation
for (index = 0; index < this->operations.size(); index++) {
@@ -270,7 +287,7 @@ void ExecutionSystem::groupOperations()
}
}
ExecutionSystemHelper::findOutputNodeOperations(&outputOperations, this->getOperations(), this->context.isRendering());
- for (vector<NodeOperation*>::iterator iter = outputOperations.begin(); iter != outputOperations.end(); ++iter) {
+ for (vector<NodeOperation *>::iterator iter = outputOperations.begin(); iter != outputOperations.end(); ++iter) {
operation = *iter;
ExecutionGroup *group = new ExecutionGroup();
group->addOperation(this, operation);
@@ -285,30 +302,10 @@ void ExecutionSystem::addSocketConnection(SocketConnection *connection)
}
-void ExecutionSystem::determineActualSocketDataTypes(vector<NodeBase*> &nodes)
-{
- unsigned int index;
- /* first do all input nodes */
- for (index = 0; index < nodes.size(); index++) {
- NodeBase *node = nodes[index];
- if (node->isInputNode()) {
- node->determineActualSocketDataTypes();
- }
- }
-
- /* then all other nodes */
- for (index = 0; index < nodes.size(); index++) {
- NodeBase *node = nodes[index];
- if (!node->isInputNode()) {
- node->determineActualSocketDataTypes();
- }
- }
-}
-
-void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup*> *result, CompositorPriority priority) const
+void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const
{
unsigned int index;
- for (index = 0 ; index < this->groups.size() ; index ++) {
+ for (index = 0; index < this->groups.size(); index++) {
ExecutionGroup *group = this->groups[index];
if (group->isOutputExecutionGroup() && group->getRenderPriotrity() == priority) {
result->push_back(group);
@@ -316,10 +313,10 @@ void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup*> *result,
}
}
-void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup*> *result) const
+void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result) const
{
unsigned int index;
- for (index = 0 ; index < this->groups.size() ; index ++) {
+ for (index = 0; index < this->groups.size(); index++) {
ExecutionGroup *group = this->groups[index];
if (group->isOutputExecutionGroup()) {
result->push_back(group);
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 510e58ba1bb..70fd94ca57f 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -36,69 +36,69 @@ class ExecutionGroup;
using namespace std;
/**
- * @page execution Execution model
- * In order to get to an efficient model for execution, serveral steps are being done. these steps are explained below.
- *
- * @section EM_Step1 Step 1: translating blender node system to the new compsitor system
- * Blenders node structure is based on C structs (DNA). These structs are not efficient in the new architecture. We want to use classes in order to simplify the system.
- * during this step the blender node_tree is evaluated and converted to a CPP node system.
- *
- * @see ExecutionSystem
- * @see Converter.convert
- * @see Node
- *
- * @section EM_Step2 Step2: translating nodes to operations
- * Ungrouping the GroupNodes. Group nodes are node_tree's in node_tree's. The new system only supports a single level of node_tree. We will 'flatten' the system in a single level.
- * @see GroupNode
- * @see ExecutionSystemHelper.ungroup
- *
- * Every node has the ability to convert itself to operations. The node itself is responsible to create a correct NodeOperation setup based on its internal settings.
- * Most Node only need to convert it to its NodeOperation. Like a ColorToBWNode doesn't check anything, but replaces itself with a ConvertColorToBWOperation.
- * More complex nodes can use different NodeOperation based on settings; like MixNode. based on the selected Mixtype a different operation will be used.
- * for more information see the page about creating new Nodes. [@subpage newnode]
- *
- * @see ExecutionSystem.convertToOperations
- * @see Node.convertToOperations
- * @see NodeOperation base class for all operations in the system
- *
- * @section EM_Step3 Step3: add additional conversions to the operation system
- * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR. The user can connect a Value socket to a color socket. As values are ordered differently than colors a conversion happens.
- *
- * - Image size conversions: the system can automatically convert when resolutions do not match. An InputSocket has a resize mode. This can be any of the folowing settings.
- * - [@ref InputSocketResizeMode.COM_SC_CENTER]: The center of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]: The width of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]: the height of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT]: The width, or the height of both images are aligned to make sure that it fits.
- * - [@ref InputSocketResizeMode.COM_SC_STRETCH]: The width and the height of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_NO_RESIZE]: bottom left of the images are aligned.
- *
- * @see Converter.convertDataType Datatype conversions
- * @see Converter.convertResolution Image size conversions
- *
- * @section EM_Step4 Step4: group operations in executions groups
- * ExecutionGroup are groups of operations that are calculated as being one bigger operation. All operations will be part of an ExecutionGroup.
- * Complex nodes will be added to separate groups. Between ExecutionGroup's the data will be stored in MemoryBuffers. ReadBufferOperations and WriteBufferOperations are added where needed.
- *
- * <pre>
- *
- * +------------------------------+ +----------------+
- * | ExecutionGroup A | |ExecutionGroup B| ExecutionGroup
- * | +----------+ +----------+| |+----------+ |
- * /----->| Operation|---->| Operation|-\ /--->| Operation|-\ | NodeOperation
- * | | | A | | B ||| | || C | | |
- * | | | cFFA | /->| cFFA ||| | || cFFA | | |
- * | | +----------+ | +----------+|| | |+----------+ | |
- * | +---------------|--------------+v | +-------------v--+
- * +-*----+ +---*--+ +--*-*--+ +--*----+
- * |inputA| |inputB| |outputA| |outputB| MemoryBuffer
- * |cFAA | |cFAA | |cFAA | |cFAA |
- * +------+ +------+ +-------+ +-------+
- * </pre>
- * @see ExecutionSystem.groupOperations method doing this step
- * @see ExecutionSystem.addReadWriteBufferOperations
- * @see NodeOperation.isComplex
- * @see ExecutionGroup class representing the ExecutionGroup
- */
+ * @page execution Execution model
+ * In order to get to an efficient model for execution, serveral steps are being done. these steps are explained below.
+ *
+ * @section EM_Step1 Step 1: translating blender node system to the new compsitor system
+ * Blenders node structure is based on C structs (DNA). These structs are not efficient in the new architecture. We want to use classes in order to simplify the system.
+ * during this step the blender node_tree is evaluated and converted to a CPP node system.
+ *
+ * @see ExecutionSystem
+ * @see Converter.convert
+ * @see Node
+ *
+ * @section EM_Step2 Step2: translating nodes to operations
+ * Ungrouping the GroupNodes. Group nodes are node_tree's in node_tree's. The new system only supports a single level of node_tree. We will 'flatten' the system in a single level.
+ * @see GroupNode
+ * @see ExecutionSystemHelper.ungroup
+ *
+ * Every node has the ability to convert itself to operations. The node itself is responsible to create a correct NodeOperation setup based on its internal settings.
+ * Most Node only need to convert it to its NodeOperation. Like a ColorToBWNode doesn't check anything, but replaces itself with a ConvertColorToBWOperation.
+ * More complex nodes can use different NodeOperation based on settings; like MixNode. based on the selected Mixtype a different operation will be used.
+ * for more information see the page about creating new Nodes. [@subpage newnode]
+ *
+ * @see ExecutionSystem.convertToOperations
+ * @see Node.convertToOperations
+ * @see NodeOperation base class for all operations in the system
+ *
+ * @section EM_Step3 Step3: add additional conversions to the operation system
+ * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR. The user can connect a Value socket to a color socket. As values are ordered differently than colors a conversion happens.
+ *
+ * - Image size conversions: the system can automatically convert when resolutions do not match. An InputSocket has a resize mode. This can be any of the folowing settings.
+ * - [@ref InputSocketResizeMode.COM_SC_CENTER]: The center of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]: The width of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]: the height of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT]: The width, or the height of both images are aligned to make sure that it fits.
+ * - [@ref InputSocketResizeMode.COM_SC_STRETCH]: The width and the height of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_NO_RESIZE]: bottom left of the images are aligned.
+ *
+ * @see Converter.convertDataType Datatype conversions
+ * @see Converter.convertResolution Image size conversions
+ *
+ * @section EM_Step4 Step4: group operations in executions groups
+ * ExecutionGroup are groups of operations that are calculated as being one bigger operation. All operations will be part of an ExecutionGroup.
+ * Complex nodes will be added to separate groups. Between ExecutionGroup's the data will be stored in MemoryBuffers. ReadBufferOperations and WriteBufferOperations are added where needed.
+ *
+ * <pre>
+ *
+ * +------------------------------+ +----------------+
+ * | ExecutionGroup A | |ExecutionGroup B| ExecutionGroup
+ * | +----------+ +----------+| |+----------+ |
+ * /----->| Operation|---->| Operation|-\ /--->| Operation|-\ | NodeOperation
+ * | | | A | | B ||| | || C | | |
+ * | | | cFFA | /->| cFFA ||| | || cFFA | | |
+ * | | +----------+ | +----------+|| | |+----------+ | |
+ * | +---------------|--------------+v | +-------------v--+
+ * +-*----+ +---*--+ +--*-*--+ +--*----+
+ * |inputA| |inputB| |outputA| |outputB| MemoryBuffer
+ * |cFAA | |cFAA | |cFAA | |cFAA |
+ * +------+ +------+ +-------+ +-------+
+ * </pre>
+ * @see ExecutionSystem.groupOperations method doing this step
+ * @see ExecutionSystem.addReadWriteBufferOperations
+ * @see NodeOperation.isComplex
+ * @see ExecutionGroup class representing the ExecutionGroup
+ */
/**
* @brief the ExecutionSystem contains the whole compositor tree.
@@ -106,129 +106,129 @@ using namespace std;
class ExecutionSystem {
private:
/**
- * @brief the context used during execution
- */
+ * @brief the context used during execution
+ */
CompositorContext context;
/**
- * @brief vector of nodes
- */
- vector<Node*> nodes;
+ * @brief vector of nodes
+ */
+ vector<Node *> nodes;
/**
- * @brief vector of operations
- */
- vector<NodeOperation*> operations;
+ * @brief vector of operations
+ */
+ vector<NodeOperation *> operations;
/**
- * @brief vector of groups
- */
- vector<ExecutionGroup*> groups
+ * @brief vector of groups
+ */
+ vector<ExecutionGroup *> groups
/**
- * @brief vector of connections
- */;
- vector<SocketConnection*> connections;
+ * @brief vector of connections
+ */;
+ vector<SocketConnection *> connections;
private: //methods
/**
- * @brief add ReadBufferOperation and WriteBufferOperation around an operation
- * @param operation the operation to add the bufferoperations around.
- */
+ * @brief add ReadBufferOperation and WriteBufferOperation around an operation
+ * @param operation the operation to add the bufferoperations around.
+ */
void addReadWriteBufferOperations(NodeOperation *operation);
/**
- * find all execution group with output nodes
- */
- void findOutputExecutionGroup(vector<ExecutionGroup*> *result, CompositorPriority priority) const;
+ * find all execution group with output nodes
+ */
+ void findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const;
/**
- * find all execution group with output nodes
- */
- void findOutputExecutionGroup(vector<ExecutionGroup*> *result) const;
+ * find all execution group with output nodes
+ */
+ void findOutputExecutionGroup(vector<ExecutionGroup *> *result) const;
public:
/**
- * @brief Create a new ExecutionSystem and initialize it with the
- * editingtree.
- *
- * @param editingtree [bNodeTree*]
- * @param rendering [true false]
- */
+ * @brief Create a new ExecutionSystem and initialize it with the
+ * editingtree.
+ *
+ * @param editingtree [bNodeTree*]
+ * @param rendering [true false]
+ */
ExecutionSystem(bNodeTree *editingtree, bool rendering);
/**
- * Destructor
- */
+ * Destructor
+ */
~ExecutionSystem();
/**
- * @brief execute this system
- * - initialize the NodeOperation's and ExecutionGroup's
- * - schedule the output ExecutionGroup's based on their priority
- * - deinitialize the ExecutionGroup's and NodeOperation's
- */
+ * @brief execute this system
+ * - initialize the NodeOperation's and ExecutionGroup's
+ * - schedule the output ExecutionGroup's based on their priority
+ * - deinitialize the ExecutionGroup's and NodeOperation's
+ */
void execute();
/**
- * @brief Add an operation to the operation list
- *
- * @param operation the operation to add
- */
+ * @brief Add an operation to the operation list
+ *
+ * @param operation the operation to add
+ */
void addOperation(NodeOperation *operation);
/**
- * Add an editor link to the system. convert it to an socketconnection (CPP-representative)
- * this converted socket is returned.
- */
+ * Add an editor link to the system. convert it to an socketconnection (CPP-representative)
+ * this converted socket is returned.
+ */
SocketConnection *addNodeLink(bNodeLink *bNodeLink);
void addSocketConnection(SocketConnection *connection);
/**
- * @brief Convert all nodes to operations
- */
+ * @brief Convert all nodes to operations
+ */
void convertToOperations();
/**
- * @brief group operations in ExecutionGroup's
- * @see ExecutionGroup
- */
+ * @brief group operations in ExecutionGroup's
+ * @see ExecutionGroup
+ */
void groupOperations();
/**
- * @brief get the reference to the compositor context
- */
- CompositorContext& getContext() {return this->context;}
+ * @brief get the reference to the compositor context
+ */
+ CompositorContext& getContext() { return this->context; }
/**
- * @brief get the reference to the compositor nodes
- */
- vector<Node*>& getNodes() {return this->nodes;}
+ * @brief get the reference to the compositor nodes
+ */
+ vector<Node *>& getNodes() { return this->nodes; }
/**
- * @brief get the reference to the compositor connections
- */
- vector<SocketConnection*>& getConnections() {return this->connections;}
+ * @brief get the reference to the compositor connections
+ */
+ vector<SocketConnection *>& getConnections() { return this->connections; }
/**
- * @brief get the reference to the list of execution groups
- */
- vector<ExecutionGroup*>& getExecutionGroups() {return this->groups;}
+ * @brief get the reference to the list of execution groups
+ */
+ vector<ExecutionGroup *>& getExecutionGroups() { return this->groups; }
/**
- * @brief get the reference to the list of operations
- */
- vector<NodeOperation*>& getOperations() {return this->operations;}
+ * @brief get the reference to the list of operations
+ */
+ vector<NodeOperation *>& getOperations() { return this->operations; }
private:
/**
- * @brief determine the actual data types of all sockets
- * @param nodes list of nodes or operations to do the data type determination
- */
- void determineActualSocketDataTypes(vector<NodeBase*> &nodes);
+ * @brief determine the actual data types of all sockets
+ * @param nodes list of nodes or operations to do the data type determination
+ */
+ void determineActualSocketDataTypes(vector<NodeBase *> &nodes);
void executeGroups(CompositorPriority priority);
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
index 67554cd464b..bcb606316ab 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
@@ -35,36 +35,40 @@
#include "COM_GroupNode.h"
#include "COM_WriteBufferOperation.h"
#include "COM_ReadBufferOperation.h"
+#include "COM_ViewerBaseOperation.h"
-Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree)
+Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode)
{
- vector<Node*>& nodes = system.getNodes();
- vector<SocketConnection*>& links = system.getConnections();
+ vector<Node *>& nodes = system.getNodes();
+ vector<SocketConnection *>& links = system.getConnections();
Node *mainnode = NULL;
+ const bNode *activeGroupNode = system.getContext().getActivegNode();
+ bool isActiveGroup = activeGroupNode == groupnode;
+
/* add all nodes of the tree to the node list */
- bNode *node = (bNode*)tree->nodes.first;
+ bNode *node = (bNode *)tree->nodes.first;
while (node != NULL) {
- Node *execnode = addNode(nodes, node);
+ Node *execnode = addNode(nodes, node, isActiveGroup);
if (node->type == CMP_NODE_COMPOSITE) {
mainnode = execnode;
}
- node = (bNode*)node->next;
+ node = (bNode *)node->next;
}
- NodeRange node_range(nodes.begin()+nodes_start, nodes.end());
+ NodeRange node_range(nodes.begin() + nodes_start, nodes.end());
/* add all nodelinks of the tree to the link list */
- bNodeLink *nodelink = (bNodeLink*)tree->links.first;
+ bNodeLink *nodelink = (bNodeLink *)tree->links.first;
while (nodelink != NULL) {
addNodeLink(node_range, links, nodelink);
- nodelink = (bNodeLink*)nodelink->next;
+ nodelink = (bNodeLink *)nodelink->next;
}
/* Expand group nodes */
- for (int i=nodes_start; i < nodes.size(); ++i) {
+ for (unsigned int i = nodes_start; i < nodes.size(); ++i) {
Node *execnode = nodes[i];
if (execnode->isGroupNode()) {
- GroupNode * groupNode = (GroupNode*)execnode;
+ GroupNode *groupNode = (GroupNode *)execnode;
groupNode->ungroup(system);
}
}
@@ -72,37 +76,38 @@ Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_sta
return mainnode;
}
-void ExecutionSystemHelper::addNode(vector<Node*>& nodes, Node *node)
+void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node)
{
nodes.push_back(node);
}
-Node *ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode)
+Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *bNode, bool inActiveGroup)
{
Converter converter;
- Node * node;
+ Node *node;
node = converter.convert(bNode);
+ node->setIsInActiveGroup(inActiveGroup);
if (node != NULL) {
addNode(nodes, node);
return node;
}
return NULL;
}
-void ExecutionSystemHelper::addOperation(vector<NodeOperation*>& operations, NodeOperation *operation)
+void ExecutionSystemHelper::addOperation(vector<NodeOperation *>& operations, NodeOperation *operation)
{
operations.push_back(operation);
}
-void ExecutionSystemHelper::addExecutionGroup(vector<ExecutionGroup*>& executionGroups, ExecutionGroup *executionGroup)
+void ExecutionSystemHelper::addExecutionGroup(vector<ExecutionGroup *>& executionGroups, ExecutionGroup *executionGroup)
{
executionGroups.push_back(executionGroup);
}
-void ExecutionSystemHelper::findOutputNodeOperations(vector<NodeOperation*>* result, vector<NodeOperation*>& operations, bool rendering)
+void ExecutionSystemHelper::findOutputNodeOperations(vector<NodeOperation *> *result, vector<NodeOperation *>& operations, bool rendering)
{
unsigned int index;
- for (index = 0 ; index < operations.size() ; index ++) {
+ for (index = 0; index < operations.size(); index++) {
NodeOperation *operation = operations[index];
if (operation->isOutputOperation(rendering)) {
result->push_back(operation);
@@ -113,18 +118,18 @@ void ExecutionSystemHelper::findOutputNodeOperations(vector<NodeOperation*>* res
static InputSocket *find_input(NodeRange &node_range, bNode *bnode, bNodeSocket *bsocket)
{
if (bnode != NULL) {
- for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ for (NodeIterator it = node_range.first; it != node_range.second; ++it) {
Node *node = *it;
if (node->getbNode() == bnode)
return node->findInputSocketBybNodeSocket(bsocket);
}
}
else {
- for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ for (NodeIterator it = node_range.first; it != node_range.second; ++it) {
Node *node = *it;
if (node->isProxyNode()) {
InputSocket *proxySocket = node->getInputSocket(0);
- if (proxySocket->getbNodeSocket()==bsocket)
+ if (proxySocket->getbNodeSocket() == bsocket)
return proxySocket;
}
}
@@ -134,29 +139,29 @@ static InputSocket *find_input(NodeRange &node_range, bNode *bnode, bNodeSocket
static OutputSocket *find_output(NodeRange &node_range, bNode *bnode, bNodeSocket *bsocket)
{
if (bnode != NULL) {
- for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ for (NodeIterator it = node_range.first; it != node_range.second; ++it) {
Node *node = *it;
if (node->getbNode() == bnode)
return node->findOutputSocketBybNodeSocket(bsocket);
}
}
else {
- for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ for (NodeIterator it = node_range.first; it != node_range.second; ++it) {
Node *node = *it;
if (node->isProxyNode()) {
OutputSocket *proxySocket = node->getOutputSocket(0);
- if (proxySocket->getbNodeSocket()==bsocket)
+ if (proxySocket->getbNodeSocket() == bsocket)
return proxySocket;
}
}
}
return NULL;
}
-SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink)
+SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *bNodeLink)
{
/// @note: cyclic lines will be ignored. This has been copied from node.c
if (bNodeLink->tonode != 0 && bNodeLink->fromnode != 0) {
- if (!(bNodeLink->fromnode->level >= bNodeLink->tonode->level && bNodeLink->tonode->level!=0xFFF)) { // only add non cyclic lines! so execution will procede
+ if (!(bNodeLink->fromnode->level >= bNodeLink->tonode->level && bNodeLink->tonode->level != 0xFFF)) { // only add non cyclic lines! so execution will procede
return NULL;
}
}
@@ -173,9 +178,9 @@ SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vect
return connection;
}
-SocketConnection *ExecutionSystemHelper::addLink(vector<SocketConnection*>& links, OutputSocket *fromSocket, InputSocket *toSocket)
+SocketConnection *ExecutionSystemHelper::addLink(vector<SocketConnection *>& links, OutputSocket *fromSocket, InputSocket *toSocket)
{
- SocketConnection * newconnection = new SocketConnection();
+ SocketConnection *newconnection = new SocketConnection();
newconnection->setFromSocket(fromSocket);
newconnection->setToSocket(toSocket);
fromSocket->addConnection(newconnection);
@@ -194,12 +199,12 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
printf("-- BEGIN COMPOSITOR DUMP --\r\n");
printf("digraph compositorexecution {\r\n");
tot = system->getNodes().size();
- for (int i = 0 ; i < tot ; i ++) {
+ for (int i = 0; i < tot; i++) {
node = system->getNodes()[i];
printf("// NODE: %s\r\n", node->getbNode()->typeinfo->name);
}
tot = system->getOperations().size();
- for (int i = 0 ; i < tot ; i ++) {
+ for (int i = 0; i < tot; i++) {
operation = system->getOperations()[i];
printf("// OPERATION: %p\r\n", operation);
printf("\t\"O_%p\"", operation);
@@ -207,32 +212,35 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
tot2 = operation->getNumberOfInputSockets();
if (tot2 != 0) {
printf("{");
- for (int j = 0 ; j < tot2 ; j ++) {
+ for (int j = 0; j < tot2; j++) {
InputSocket *socket = operation->getInputSocket(j);
if (j != 0) {
printf("|");
}
printf("<IN_%p>", socket);
- switch (socket->getActualDataType()) {
- case COM_DT_VALUE:
- printf("Value");
- break;
- case COM_DT_VECTOR:
- printf("Vector");
- break;
- case COM_DT_COLOR:
- printf("Color");
- break;
- case COM_DT_UNKNOWN:
- printf("Unknown");
- break;
+ switch (socket->getDataType()) {
+ case COM_DT_VALUE:
+ printf("Value");
+ break;
+ case COM_DT_VECTOR:
+ printf("Vector");
+ break;
+ case COM_DT_COLOR:
+ printf("Color");
+ break;
}
}
printf("}");
printf("|");
}
if (operation->isViewerOperation()) {
- printf("Viewer");
+ ViewerBaseOperation *viewer = (ViewerBaseOperation *)operation;
+ if (viewer->isActiveViewerOutput()) {
+ printf("Active viewer");
+ }
+ else {
+ printf("Viewer");
+ }
}
else if (operation->isOutputOperation(system->getContext().isRendering())) {
printf("Output");
@@ -249,29 +257,27 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
else {
printf("O_%p", operation);
}
+ printf(" (%d,%d)", operation->getWidth(), operation->getHeight());
tot2 = operation->getNumberOfOutputSockets();
if (tot2 != 0) {
printf("|");
printf("{");
- for (int j = 0 ; j < tot2 ; j ++) {
+ for (int j = 0; j < tot2; j++) {
OutputSocket *socket = operation->getOutputSocket(j);
if (j != 0) {
printf("|");
}
printf("<OUT_%p>", socket);
- switch (socket->getActualDataType()) {
- case COM_DT_VALUE:
- printf("Value");
- break;
- case COM_DT_VECTOR:
- printf("Vector");
- break;
- case COM_DT_COLOR:
- printf("Color");
- break;
- case COM_DT_UNKNOWN:
- printf("Unknown");
- break;
+ switch (socket->getDataType()) {
+ case COM_DT_VALUE:
+ printf("Value");
+ break;
+ case COM_DT_VECTOR:
+ printf("Vector");
+ break;
+ case COM_DT_COLOR:
+ printf("Color");
+ break;
}
}
printf("}");
@@ -280,7 +286,7 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
printf("\r\n");
}
tot = system->getExecutionGroups().size();
- for (int i = 0 ; i < tot ; i ++) {
+ for (int i = 0; i < tot; i++) {
group = system->getExecutionGroups()[i];
printf("// GROUP: %d\r\n", i);
printf("subgraph {\r\n");
@@ -289,16 +295,16 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
printf("}\r\n");
}
tot = system->getOperations().size();
- for (int i = 0 ; i < tot ; i ++) {
+ for (int i = 0; i < tot; i++) {
operation = system->getOperations()[i];
if (operation->isReadBufferOperation()) {
- ReadBufferOperation * read = (ReadBufferOperation*)operation;
- WriteBufferOperation * write = read->getMemoryProxy()->getWriteBufferOperation();
+ ReadBufferOperation *read = (ReadBufferOperation *)operation;
+ WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation();
printf("\t\"O_%p\" -> \"O_%p\" [style=dotted]\r\n", write, read);
}
}
tot = system->getConnections().size();
- for (int i = 0 ; i < tot ; i ++) {
+ for (int i = 0; i < tot; i++) {
connection = system->getConnections()[i];
printf("// CONNECTION: %p.%p -> %p.%p\r\n", connection->getFromNode(), connection->getFromSocket(), connection->getToNode(), connection->getToSocket());
printf("\t\"O_%p\":\"OUT_%p\" -> \"O_%p\":\"IN_%p\"", connection->getFromNode(), connection->getFromSocket(), connection->getToNode(), connection->getToSocket());
@@ -306,19 +312,16 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
printf(" [color=red]");
}
else {
- switch (connection->getFromSocket()->getActualDataType()) {
- case COM_DT_VALUE:
- printf(" [color=grey]");
- break;
- case COM_DT_VECTOR:
- printf(" [color=blue]");
- break;
- case COM_DT_COLOR:
- printf(" [color=orange]");
- break;
- case COM_DT_UNKNOWN:
- printf(" [color=black]");
- break;
+ switch (connection->getFromSocket()->getDataType()) {
+ case COM_DT_VALUE:
+ printf(" [color=grey]");
+ break;
+ case COM_DT_VECTOR:
+ printf(" [color=blue]");
+ break;
+ case COM_DT_COLOR:
+ printf(" [color=orange]");
+ break;
}
}
printf("\r\n");
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
index a72e269115e..99a05472075 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
@@ -42,86 +42,86 @@ class ExecutionSystemHelper {
public:
/**
- * @brief add an bNodeTree to the nodes list and connections
- * @param system Execution system
- * @param nodes_start Starting index in the system's nodes list for nodes in this tree.
- * @param tree bNodeTree to add
- * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added
- */
- static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree);
-
+ * @brief add an bNodeTree to the nodes list and connections
+ * @param system Execution system
+ * @param nodes_start Starting index in the system's nodes list for nodes in this tree.
+ * @param tree bNodeTree to add
+ * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added
+ */
+ static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode);
+
/**
- * @brief add an editor node to the system.
- * this node is converted to a Node instance.
- * and the converted node is returned
- *
- * @param bNode node to add
- * @return Node that represents the bNode or null when not able to convert.
- */
- static Node *addNode(vector<Node*>& nodes, bNode *bNode);
-
+ * @brief add an editor node to the system.
+ * this node is converted to a Node instance.
+ * and the converted node is returned
+ *
+ * @param bNode node to add
+ * @return Node that represents the bNode or null when not able to convert.
+ */
+ static Node *addNode(vector<Node *>& nodes, bNode *bNode, bool isInActiveGroup);
+
/**
- * @brief Add a Node to a list
- *
- * @param nodes the list where the node needs to be added to
- * @param node the node to be added
- */
- static void addNode(vector<Node*>& nodes, Node *node);
-
+ * @brief Add a Node to a list
+ *
+ * @param nodes the list where the node needs to be added to
+ * @param node the node to be added
+ */
+ static void addNode(vector<Node *>& nodes, Node *node);
+
/**
- * @brief Add an operation to the operation list
- *
- * The id of the operation is updated.
- *
- * @param operations the list where the operation need to be added to
- * @param operation the operation to add
- */
- static void addOperation(vector<NodeOperation*> &operations, NodeOperation *operation);
-
+ * @brief Add an operation to the operation list
+ *
+ * The id of the operation is updated.
+ *
+ * @param operations the list where the operation need to be added to
+ * @param operation the operation to add
+ */
+ static void addOperation(vector<NodeOperation *> &operations, NodeOperation *operation);
+
/**
- * @brief Add an ExecutionGroup to a list
- *
- * The id of the ExecutionGroup is updated.
- *
- * @param executionGroups the list where the executionGroup need to be added to
- * @param executionGroup the ExecutionGroup to add
- */
- static void addExecutionGroup(vector<ExecutionGroup*>& executionGroups, ExecutionGroup *executionGroup);
-
+ * @brief Add an ExecutionGroup to a list
+ *
+ * The id of the ExecutionGroup is updated.
+ *
+ * @param executionGroups the list where the executionGroup need to be added to
+ * @param executionGroup the ExecutionGroup to add
+ */
+ static void addExecutionGroup(vector<ExecutionGroup *>& executionGroups, ExecutionGroup *executionGroup);
+
/**
- * Find all Node Operations that needs to be executed.
- * @param rendering
- * the rendering parameter will tell what type of execution we are doing
- * FALSE is editing, TRUE is rendering
- */
- static void findOutputNodeOperations(vector<NodeOperation*>* result, vector<NodeOperation*>& operations , bool rendering);
-
+ * Find all Node Operations that needs to be executed.
+ * @param rendering
+ * the rendering parameter will tell what type of execution we are doing
+ * FALSE is editing, TRUE is rendering
+ */
+ static void findOutputNodeOperations(vector<NodeOperation *> *result, vector<NodeOperation *>& operations, bool rendering);
+
/**
- * @brief add a bNodeLink to the list of links
- * the bNodeLink will be wrapped in a SocketConnection
- *
- * @note Cyclic links will be ignored
- *
- * @param node_range list of possible nodes for lookup.
- * @param links list of links to add the bNodeLink to
- * @param bNodeLink the link to be added
- * @return the created SocketConnection or NULL
- */
- static SocketConnection *addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink);
-
+ * @brief add a bNodeLink to the list of links
+ * the bNodeLink will be wrapped in a SocketConnection
+ *
+ * @note Cyclic links will be ignored
+ *
+ * @param node_range list of possible nodes for lookup.
+ * @param links list of links to add the bNodeLink to
+ * @param bNodeLink the link to be added
+ * @return the created SocketConnection or NULL
+ */
+ static SocketConnection *addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *bNodeLink);
+
/**
- * @brief create a new SocketConnection and add to a vector of links
- * @param links the vector of links
- * @param fromSocket the startpoint of the connection
- * @param toSocket the endpoint of the connection
- * @return the new created SocketConnection
- */
- static SocketConnection *addLink(vector<SocketConnection*>& links, OutputSocket *fromSocket, InputSocket *toSocket);
-
+ * @brief create a new SocketConnection and add to a vector of links
+ * @param links the vector of links
+ * @param fromSocket the startpoint of the connection
+ * @param toSocket the endpoint of the connection
+ * @return the new created SocketConnection
+ */
+ static SocketConnection *addLink(vector<SocketConnection *>& links, OutputSocket *fromSocket, InputSocket *toSocket);
+
/**
- * @brief dumps the content of the execution system to standard out
- * @param system the execution system to dump
- */
+ * @brief dumps the content of the execution system to standard out
+ * @param system the execution system to dump
+ */
static void debugDump(ExecutionSystem *system);
};
#endif
diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp
index 4d96d077901..3ca74f157b4 100644
--- a/source/blender/compositor/intern/COM_InputSocket.cpp
+++ b/source/blender/compositor/intern/COM_InputSocket.cpp
@@ -25,18 +25,18 @@
#include "COM_SocketConnection.h"
#include "COM_ExecutionSystem.h"
-InputSocket::InputSocket(DataType datatype) :Socket(datatype)
+InputSocket::InputSocket(DataType datatype) : Socket(datatype)
{
this->connection = NULL;
this->resizeMode = COM_SC_CENTER;
}
-InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) :Socket(datatype)
+InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) : Socket(datatype)
{
this->connection = NULL;
this->resizeMode = resizeMode;
}
-InputSocket::InputSocket(InputSocket *from) :Socket(from->getDataType())
+InputSocket::InputSocket(InputSocket *from) : Socket(from->getDataType())
{
this->connection = NULL;
this->resizeMode = from->getResizeMode();
@@ -54,7 +54,7 @@ SocketConnection *InputSocket::getConnection()
return this->connection;
}
-void InputSocket::determineResolution(unsigned int resolution[],unsigned int preferredResolution[])
+void InputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
if (this->isConnected()) {
this->connection->getFromSocket()->determineResolution(resolution, preferredResolution);
@@ -64,68 +64,6 @@ void InputSocket::determineResolution(unsigned int resolution[],unsigned int pre
}
}
-DataType InputSocket::convertToSupportedDataType(DataType datatype)
-{
- int supportedDataTypes = getDataType();
- if (supportedDataTypes&datatype) {
- return datatype;
- }
- bool candoValue = supportedDataTypes&COM_DT_VALUE;
- bool candoVector = supportedDataTypes&COM_DT_VECTOR;
- bool candoColor = supportedDataTypes&COM_DT_COLOR;
-
- if (datatype == COM_DT_VALUE) {
- if (candoColor) {
- return COM_DT_COLOR;
- }
- else if (candoVector) {
- return COM_DT_VECTOR;
- }
- }
- else if (datatype == COM_DT_VECTOR) {
- if (candoColor) {
- return COM_DT_COLOR;
- }
- else if (candoValue) {
- return COM_DT_VALUE;
- }
- }
- else if (datatype == COM_DT_COLOR) {
- if (candoVector) {
- return COM_DT_VECTOR;
- }
- else if (candoValue) {
- return COM_DT_VALUE;
- }
- }
- return this->getDataType();
-}
-
-void InputSocket::determineActualDataType()
-{
- /// @note: this method is only called for inputsocket that are not connected.
- /// @note: passes COM_DT_COLOR, the convertToSupportedDataType converts this to a capable DataType
- this->setActualDataType(this->convertToSupportedDataType(COM_DT_COLOR));
- #if 0 // XXX TODO check for proxy node and use output data type?
- if (this->getGroupOutputSocket()) {
- if (!this->isInsideOfGroupNode()) {
- this->getGroupOutputSocket()->determineActualDataType();
- }
- }
- #endif
-}
-
-void InputSocket::notifyActualInputType(DataType datatype)
-{
- DataType supportedDataType = convertToSupportedDataType(datatype);
- this->setActualDataType(supportedDataType);
- this->fireActualDataTypeSet();
-}
-
-void InputSocket::fireActualDataTypeSet()
-{
- this->getNode()->notifyActualDataTypeSet(this, this->getActualDataType());
-}
void InputSocket::relinkConnections(InputSocket *relinkToSocket)
{
if (!isConnected()) {
@@ -140,23 +78,22 @@ void InputSocket::relinkConnections(InputSocket *relinkToSocket)
void InputSocket::relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *graph)
{
if (!this->isConnected()) {
- Node *node = (Node*)this->getNode();
- switch (this->getActualDataType()) {
- case COM_DT_UNKNOWN:
- case COM_DT_COLOR:
- node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VECTOR:
- node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VALUE:
- node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
+ Node *node = (Node *)this->getNode();
+ switch (this->getDataType()) {
+ case COM_DT_COLOR:
+ node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VECTOR:
+ node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VALUE:
+ node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
}
return;
}
- SocketConnection * newConnection = new SocketConnection();
- OutputSocket * fromSocket = this->getConnection()->getFromSocket();
+ SocketConnection *newConnection = new SocketConnection();
+ OutputSocket *fromSocket = this->getConnection()->getFromSocket();
newConnection->setToSocket(relinkToSocket);
newConnection->setFromSocket(fromSocket);
relinkToSocket->setConnection(newConnection);
@@ -170,32 +107,21 @@ void InputSocket::relinkConnections(InputSocket *relinkToSocket, int editorNode
relinkConnections(relinkToSocket);
}
else {
- Node *node = (Node*)this->getNode();
- switch (this->getActualDataType()) {
- case COM_DT_UNKNOWN:
- case COM_DT_COLOR:
- node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VECTOR:
- node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VALUE:
- node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
+ Node *node = (Node *)this->getNode();
+ switch (this->getDataType()) {
+ case COM_DT_COLOR:
+ node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VECTOR:
+ node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VALUE:
+ node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
}
}
}
-const ChannelInfo *InputSocket::getChannelInfo(const int channelnumber)
-{
- if (this->isConnected() && this->connection->getFromSocket()) {
- return this->connection->getFromSocket()->getChannelInfo(channelnumber);
- }
- else {
- return NULL;
- }
-}
-
bool InputSocket::isStatic()
{
if (isConnected()) {
@@ -214,7 +140,7 @@ SocketReader *InputSocket::getReader()
NodeOperation *InputSocket::getOperation() const
{
if (isConnected()) {
- return (NodeOperation*)this->connection->getFromSocket()->getNode();
+ return (NodeOperation *)this->connection->getFromSocket()->getNode();
}
else {
return NULL;
@@ -230,14 +156,14 @@ float *InputSocket::getStaticValues()
static float default_null = 0.0f;
switch (this->getDataType()) {
- case COM_DT_VALUE:
- return &((bNodeSocketValueFloat*)b_socket->default_value)->value;
- case COM_DT_COLOR:
- return ((bNodeSocketValueRGBA*)b_socket->default_value)->value;
- case COM_DT_VECTOR:
- return ((bNodeSocketValueVector*)b_socket->default_value)->value;
- default:
- /* XXX this should never happen, just added to please the compiler */
- return &default_null;
+ case COM_DT_VALUE:
+ return &((bNodeSocketValueFloat *)b_socket->default_value)->value;
+ case COM_DT_COLOR:
+ return ((bNodeSocketValueRGBA *)b_socket->default_value)->value;
+ case COM_DT_VECTOR:
+ return ((bNodeSocketValueVector *)b_socket->default_value)->value;
+ default:
+ /* XXX this should never happen, just added to please the compiler */
+ return &default_null;
}
}
diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h
index b1c75e34844..c066b5d8303 100644
--- a/source/blender/compositor/intern/COM_InputSocket.h
+++ b/source/blender/compositor/intern/COM_InputSocket.h
@@ -36,10 +36,10 @@ class ChannelInfo;
class NodeOperation;
/**
- * @brief Resize modes of inputsockets
- * How are the input and working resolutions matched
- * @ingroup Model
- */
+ * @brief Resize modes of inputsockets
+ * How are the input and working resolutions matched
+ * @ingroup Model
+ */
typedef enum InputSocketResizeMode {
/** @brief Center the input image to the center of the working area of the node, no resizing occurs */
COM_SC_CENTER = NS_CR_CENTER,
@@ -56,36 +56,23 @@ typedef enum InputSocketResizeMode {
} InputSocketResizeMode;
/**
- * @brief InputSocket are sockets that can receive data/input
- * @ingroup Model
- */
+ * @brief InputSocket are sockets that can receive data/input
+ * @ingroup Model
+ */
class InputSocket : public Socket {
private:
/**
- * @brief connection connected to this InputSocket.
- * An input socket can only have a single connection
- */
+ * @brief connection connected to this InputSocket.
+ * An input socket can only have a single connection
+ */
SocketConnection *connection;
/**
- * @brief resize mode of this socket
- */
+ * @brief resize mode of this socket
+ */
InputSocketResizeMode resizeMode;
- /**
- * @brief convert a data type to a by the socket supported data type.
- *
- * @param datatype the datatype that needs to be checked
- * @section data-conversion
- */
- DataType convertToSupportedDataType(DataType datatype);
-
- /**
- * @brief called when the ActualDataType is set. notifies other parties
- */
- void fireActualDataTypeSet();
-
public:
InputSocket(DataType datatype);
InputSocket(DataType datatype, InputSocketResizeMode resizeMode);
@@ -98,55 +85,57 @@ public:
int isInputSocket() const;
/**
- * @brief determine the resolution of this data going through this socket
- * @param resolution the result of this operation
- * @param preferredResolution the preferrable resolution as no resolution could be determined
- */
- void determineResolution(unsigned int resolution[],unsigned int preferredResolution[]);
-
- void determineActualDataType();
+ * @brief determine the resolution of this data going through this socket
+ * @param resolution the result of this operation
+ * @param preferredResolution the preferrable resolution as no resolution could be determined
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
/**
- * @brief Notifies the Input of the data type (via a SocketConnection)
- * @param datatype the datatype to evaluate
- */
+ * @brief Notifies the Input of the data type (via a SocketConnection)
+ * @param datatype the datatype to evaluate
+ */
void notifyActualInputType(DataType datatype);
/**
- * @brief move all connections of this input socket to another socket
- * only use this method when already checked the availability of a SocketConnection
- * @param relinkToSocket the socket to move to connections to
- */
+ * @brief move all connections of this input socket to another socket
+ * only use this method when already checked the availability of a SocketConnection
+ * @param relinkToSocket the socket to move to connections to
+ */
void relinkConnections(InputSocket *relinkToSocket);
/**
- * @brief move all connections of this input socket to another socket
- * @param relinkToSocket the socket to move to connections to
- * @param autoconnect will a set operation be added when no connections exist
- * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
- * @param system ExecutionSystem to update to
- */
+ * @brief move all connections of this input socket to another socket
+ * @param relinkToSocket the socket to move to connections to
+ * @param autoconnect will a set operation be added when no connections exist
+ * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
+ * @param system ExecutionSystem to update to
+ */
void relinkConnections(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system);
/**
- * @brief move all connections of this input socket to another socket
- * @param relinkToSocket the socket to move to connections to
- * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
- * @param system ExecutionSystem to update to
- */
+ * @brief move all connections of this input socket to another socket
+ * @param relinkToSocket the socket to move to connections to
+ * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
+ * @param system ExecutionSystem to update to
+ */
void relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system);
/**
- * @brief set the resize mode
- * @param resizeMode the new resize mode.
- */
- void setResizeMode(InputSocketResizeMode resizeMode) {this->resizeMode = resizeMode;}
+ * @brief set the resize mode
+ * @param resizeMode the new resize mode.
+ */
+ void setResizeMode(InputSocketResizeMode resizeMode) {
+ this->resizeMode = resizeMode;
+ }
/**
- * @brief get the resize mode of this socket
- * @return InputSocketResizeMode
- */
- InputSocketResizeMode getResizeMode() const {return this->resizeMode;}
+ * @brief get the resize mode of this socket
+ * @return InputSocketResizeMode
+ */
+ InputSocketResizeMode getResizeMode() const {
+ return this->resizeMode;
+ }
const ChannelInfo *getChannelInfo(const int channelnumber);
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index 3ebf8398c02..ceed53c4c0d 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -32,30 +32,30 @@ unsigned int MemoryBuffer::determineBufferSize()
int MemoryBuffer::getWidth() const
{
- return this->rect.xmax-this->rect.xmin;
+ return this->rect.xmax - this->rect.xmin;
}
int MemoryBuffer::getHeight() const
{
- return this->rect.ymax-this->rect.ymin;
+ return this->rect.ymax - this->rect.ymin;
}
-MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, unsigned int chunkNumber, rcti *rect)
+MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect)
{
BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
this->memoryProxy = memoryProxy;
this->chunkNumber = chunkNumber;
- this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer");
+ this->buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer");
this->state = COM_MB_ALLOCATED;
this->datatype = COM_DT_COLOR;
this->chunkWidth = this->rect.xmax - this->rect.xmin;
}
-MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, rcti *rect)
+MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
{
BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
this->memoryProxy = memoryProxy;
this->chunkNumber = -1;
- this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer");
+ this->buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer");
this->state = COM_MB_TEMPORARILY;
this->datatype = COM_DT_COLOR;
this->chunkWidth = this->rect.xmax - this->rect.xmin;
@@ -63,12 +63,12 @@ MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, rcti *rect)
MemoryBuffer *MemoryBuffer::duplicate()
{
MemoryBuffer *result = new MemoryBuffer(this->memoryProxy, &this->rect);
- memcpy(result->buffer, this->buffer, this->determineBufferSize()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+ memcpy(result->buffer, this->buffer, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float));
return result;
}
void MemoryBuffer::clear()
{
- memset(this->buffer, 0, this->determineBufferSize()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+ memset(this->buffer, 0, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float));
}
float *MemoryBuffer::convertToValueBuffer()
@@ -81,7 +81,7 @@ float *MemoryBuffer::convertToValueBuffer()
const float *fp_src = this->buffer;
float *fp_dst = result;
- for (i = 0; i < size ; i++, fp_dst++, fp_src += COM_NUMBER_OF_CHANNELS) {
+ for (i = 0; i < size; i++, fp_dst++, fp_src += COM_NUMBER_OF_CHANNELS) {
*fp_dst = *fp_src;
}
@@ -110,17 +110,17 @@ void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer)
int otherOffset;
- for (otherY = minY ; otherY<maxY ; otherY ++) {
- otherOffset = ((otherY-otherBuffer->rect.ymin) * otherBuffer->chunkWidth + minX-otherBuffer->rect.xmin)*COM_NUMBER_OF_CHANNELS;
- offset = ((otherY - this->rect.ymin) * this->chunkWidth + minX-this->rect.xmin)*COM_NUMBER_OF_CHANNELS;
- memcpy(&this->buffer[offset], &otherBuffer->buffer[otherOffset], (maxX-minX) * COM_NUMBER_OF_CHANNELS*sizeof(float));
+ for (otherY = minY; otherY < maxY; otherY++) {
+ otherOffset = ((otherY - otherBuffer->rect.ymin) * otherBuffer->chunkWidth + minX - otherBuffer->rect.xmin) * COM_NUMBER_OF_CHANNELS;
+ offset = ((otherY - this->rect.ymin) * this->chunkWidth + minX - this->rect.xmin) * COM_NUMBER_OF_CHANNELS;
+ memcpy(&this->buffer[offset], &otherBuffer->buffer[otherOffset], (maxX - minX) * COM_NUMBER_OF_CHANNELS * sizeof(float));
}
}
void MemoryBuffer::read(float result[4], int x, int y)
{
- if (x>=this->rect.xmin && x < this->rect.xmax &&
- y>=this->rect.ymin && y < this->rect.ymax)
+ if (x >= this->rect.xmin && x < this->rect.xmax &&
+ y >= this->rect.ymin && y < this->rect.ymax)
{
const int dx = x - this->rect.xmin;
const int dy = y - this->rect.ymin;
@@ -141,6 +141,16 @@ void MemoryBuffer::writePixel(int x, int y, const float color[4])
}
}
+void MemoryBuffer::addPixel(int x, int y, const float color[4])
+{
+ if (x >= this->rect.xmin && x < this->rect.xmax &&
+ y >= this->rect.ymin && y < this->rect.ymax)
+ {
+ const int offset = (this->chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS;
+ add_v4_v4(&this->buffer[offset], color);
+ }
+}
+
void MemoryBuffer::readCubic(float result[4], float x, float y)
{
int x1 = floor(x);
@@ -163,84 +173,84 @@ void MemoryBuffer::readCubic(float result[4], float x, float y)
read(color3, x2, y1);
read(color4, x2, y2);
- color1[0] = color1[0]*mvaluey + color2[0]*valuey;
- color1[1] = color1[1]*mvaluey + color2[1]*valuey;
- color1[2] = color1[2]*mvaluey + color2[2]*valuey;
- color1[3] = color1[3]*mvaluey + color2[3]*valuey;
-
- color3[0] = color3[0]*mvaluey + color4[0]*valuey;
- color3[1] = color3[1]*mvaluey + color4[1]*valuey;
- color3[2] = color3[2]*mvaluey + color4[2]*valuey;
- color3[3] = color3[3]*mvaluey + color4[3]*valuey;
-
- result[0] = color1[0]*mvaluex + color3[0]*valuex;
- result[1] = color1[1]*mvaluex + color3[1]*valuex;
- result[2] = color1[2]*mvaluex + color3[2]*valuex;
- result[3] = color1[3]*mvaluex + color3[3]*valuex;
+ color1[0] = color1[0] * mvaluey + color2[0] * valuey;
+ color1[1] = color1[1] * mvaluey + color2[1] * valuey;
+ color1[2] = color1[2] * mvaluey + color2[2] * valuey;
+ color1[3] = color1[3] * mvaluey + color2[3] * valuey;
+
+ color3[0] = color3[0] * mvaluey + color4[0] * valuey;
+ color3[1] = color3[1] * mvaluey + color4[1] * valuey;
+ color3[2] = color3[2] * mvaluey + color4[2] * valuey;
+ color3[3] = color3[3] * mvaluey + color4[3] * valuey;
+
+ result[0] = color1[0] * mvaluex + color3[0] * valuex;
+ result[1] = color1[1] * mvaluex + color3[1] * valuex;
+ result[2] = color1[2] * mvaluex + color3[2] * valuex;
+ result[3] = color1[3] * mvaluex + color3[3] * valuex;
}
// table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
// used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible
#define EWA_MAXIDX 255
-static float EWA_WTS[EWA_MAXIDX + 1] =
-{ 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f,
- 0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f, 0.879734f, 0.871638f, 0.863605f,
- 0.855636f, 0.847728f, 0.839883f, 0.832098f, 0.824375f, 0.816712f, 0.809108f, 0.801564f,
- 0.794079f, 0.786653f, 0.779284f, 0.771974f, 0.76472f, 0.757523f, 0.750382f, 0.743297f,
- 0.736267f, 0.729292f, 0.722372f, 0.715505f, 0.708693f, 0.701933f, 0.695227f, 0.688572f,
- 0.68197f, 0.67542f, 0.66892f, 0.662471f, 0.656073f, 0.649725f, 0.643426f, 0.637176f,
- 0.630976f, 0.624824f, 0.618719f, 0.612663f, 0.606654f, 0.600691f, 0.594776f, 0.588906f,
- 0.583083f, 0.577305f, 0.571572f, 0.565883f, 0.56024f, 0.55464f, 0.549084f, 0.543572f,
- 0.538102f, 0.532676f, 0.527291f, 0.521949f, 0.516649f, 0.511389f, 0.506171f, 0.500994f,
- 0.495857f, 0.490761f, 0.485704f, 0.480687f, 0.475709f, 0.470769f, 0.465869f, 0.461006f,
- 0.456182f, 0.451395f, 0.446646f, 0.441934f, 0.437258f, 0.432619f, 0.428017f, 0.42345f,
- 0.418919f, 0.414424f, 0.409963f, 0.405538f, 0.401147f, 0.39679f, 0.392467f, 0.388178f,
- 0.383923f, 0.379701f, 0.375511f, 0.371355f, 0.367231f, 0.363139f, 0.359079f, 0.355051f,
- 0.351055f, 0.347089f, 0.343155f, 0.339251f, 0.335378f, 0.331535f, 0.327722f, 0.323939f,
- 0.320186f, 0.316461f, 0.312766f, 0.3091f, 0.305462f, 0.301853f, 0.298272f, 0.294719f,
- 0.291194f, 0.287696f, 0.284226f, 0.280782f, 0.277366f, 0.273976f, 0.270613f, 0.267276f,
- 0.263965f, 0.26068f, 0.257421f, 0.254187f, 0.250979f, 0.247795f, 0.244636f, 0.241502f,
- 0.238393f, 0.235308f, 0.232246f, 0.229209f, 0.226196f, 0.223206f, 0.220239f, 0.217296f,
- 0.214375f, 0.211478f, 0.208603f, 0.20575f, 0.20292f, 0.200112f, 0.197326f, 0.194562f,
- 0.191819f, 0.189097f, 0.186397f, 0.183718f, 0.18106f, 0.178423f, 0.175806f, 0.17321f,
- 0.170634f, 0.168078f, 0.165542f, 0.163026f, 0.16053f, 0.158053f, 0.155595f, 0.153157f,
- 0.150738f, 0.148337f, 0.145955f, 0.143592f, 0.141248f, 0.138921f, 0.136613f, 0.134323f,
- 0.132051f, 0.129797f, 0.12756f, 0.125341f, 0.123139f, 0.120954f, 0.118786f, 0.116635f,
- 0.114501f, 0.112384f, 0.110283f, 0.108199f, 0.106131f, 0.104079f, 0.102043f, 0.100023f,
- 0.0980186f, 0.09603f, 0.094057f, 0.0920994f, 0.0901571f, 0.08823f, 0.0863179f, 0.0844208f,
- 0.0825384f, 0.0806708f, 0.0788178f, 0.0769792f, 0.0751551f, 0.0733451f, 0.0715493f, 0.0697676f,
- 0.0679997f, 0.0662457f, 0.0645054f, 0.0627786f, 0.0610654f, 0.0593655f, 0.0576789f, 0.0560055f,
- 0.0543452f, 0.0526979f, 0.0510634f, 0.0494416f, 0.0478326f, 0.0462361f, 0.0446521f, 0.0430805f,
- 0.0415211f, 0.039974f, 0.0384389f, 0.0369158f, 0.0354046f, 0.0339052f, 0.0324175f, 0.0309415f,
- 0.029477f, 0.0280239f, 0.0265822f, 0.0251517f, 0.0237324f, 0.0223242f, 0.020927f, 0.0195408f,
- 0.0181653f, 0.0168006f, 0.0154466f, 0.0141031f, 0.0127701f, 0.0114476f, 0.0101354f, 0.00883339f,
- 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f
+static float EWA_WTS[EWA_MAXIDX + 1] = {
+ 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f,
+ 0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f, 0.879734f, 0.871638f, 0.863605f,
+ 0.855636f, 0.847728f, 0.839883f, 0.832098f, 0.824375f, 0.816712f, 0.809108f, 0.801564f,
+ 0.794079f, 0.786653f, 0.779284f, 0.771974f, 0.76472f, 0.757523f, 0.750382f, 0.743297f,
+ 0.736267f, 0.729292f, 0.722372f, 0.715505f, 0.708693f, 0.701933f, 0.695227f, 0.688572f,
+ 0.68197f, 0.67542f, 0.66892f, 0.662471f, 0.656073f, 0.649725f, 0.643426f, 0.637176f,
+ 0.630976f, 0.624824f, 0.618719f, 0.612663f, 0.606654f, 0.600691f, 0.594776f, 0.588906f,
+ 0.583083f, 0.577305f, 0.571572f, 0.565883f, 0.56024f, 0.55464f, 0.549084f, 0.543572f,
+ 0.538102f, 0.532676f, 0.527291f, 0.521949f, 0.516649f, 0.511389f, 0.506171f, 0.500994f,
+ 0.495857f, 0.490761f, 0.485704f, 0.480687f, 0.475709f, 0.470769f, 0.465869f, 0.461006f,
+ 0.456182f, 0.451395f, 0.446646f, 0.441934f, 0.437258f, 0.432619f, 0.428017f, 0.42345f,
+ 0.418919f, 0.414424f, 0.409963f, 0.405538f, 0.401147f, 0.39679f, 0.392467f, 0.388178f,
+ 0.383923f, 0.379701f, 0.375511f, 0.371355f, 0.367231f, 0.363139f, 0.359079f, 0.355051f,
+ 0.351055f, 0.347089f, 0.343155f, 0.339251f, 0.335378f, 0.331535f, 0.327722f, 0.323939f,
+ 0.320186f, 0.316461f, 0.312766f, 0.3091f, 0.305462f, 0.301853f, 0.298272f, 0.294719f,
+ 0.291194f, 0.287696f, 0.284226f, 0.280782f, 0.277366f, 0.273976f, 0.270613f, 0.267276f,
+ 0.263965f, 0.26068f, 0.257421f, 0.254187f, 0.250979f, 0.247795f, 0.244636f, 0.241502f,
+ 0.238393f, 0.235308f, 0.232246f, 0.229209f, 0.226196f, 0.223206f, 0.220239f, 0.217296f,
+ 0.214375f, 0.211478f, 0.208603f, 0.20575f, 0.20292f, 0.200112f, 0.197326f, 0.194562f,
+ 0.191819f, 0.189097f, 0.186397f, 0.183718f, 0.18106f, 0.178423f, 0.175806f, 0.17321f,
+ 0.170634f, 0.168078f, 0.165542f, 0.163026f, 0.16053f, 0.158053f, 0.155595f, 0.153157f,
+ 0.150738f, 0.148337f, 0.145955f, 0.143592f, 0.141248f, 0.138921f, 0.136613f, 0.134323f,
+ 0.132051f, 0.129797f, 0.12756f, 0.125341f, 0.123139f, 0.120954f, 0.118786f, 0.116635f,
+ 0.114501f, 0.112384f, 0.110283f, 0.108199f, 0.106131f, 0.104079f, 0.102043f, 0.100023f,
+ 0.0980186f, 0.09603f, 0.094057f, 0.0920994f, 0.0901571f, 0.08823f, 0.0863179f, 0.0844208f,
+ 0.0825384f, 0.0806708f, 0.0788178f, 0.0769792f, 0.0751551f, 0.0733451f, 0.0715493f, 0.0697676f,
+ 0.0679997f, 0.0662457f, 0.0645054f, 0.0627786f, 0.0610654f, 0.0593655f, 0.0576789f, 0.0560055f,
+ 0.0543452f, 0.0526979f, 0.0510634f, 0.0494416f, 0.0478326f, 0.0462361f, 0.0446521f, 0.0430805f,
+ 0.0415211f, 0.039974f, 0.0384389f, 0.0369158f, 0.0354046f, 0.0339052f, 0.0324175f, 0.0309415f,
+ 0.029477f, 0.0280239f, 0.0265822f, 0.0251517f, 0.0237324f, 0.0223242f, 0.020927f, 0.0195408f,
+ 0.0181653f, 0.0168006f, 0.0154466f, 0.0141031f, 0.0127701f, 0.0114476f, 0.0101354f, 0.00883339f,
+ 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f
};
static void radangle2imp(float a2, float b2, float th, float *A, float *B, float *C, float *F)
{
float ct2 = cosf(th);
- const float st2 = 1.f - ct2*ct2; // <- sin(th)^2
+ const float st2 = 1.f - ct2 * ct2; // <- sin(th)^2
ct2 *= ct2;
- *A = a2*st2 + b2*ct2;
- *B = (b2 - a2)*sinf(2.f*th);
- *C = a2*ct2 + b2*st2;
- *F = a2*b2;
+ *A = a2 * st2 + b2 * ct2;
+ *B = (b2 - a2) * sinf(2.f * th);
+ *C = a2 * ct2 + b2 * st2;
+ *F = a2 * b2;
}
// all tests here are done to make sure possible overflows are hopefully minimized
static void imp2radangle(float A, float B, float C, float F, float *a, float *b, float *th, float *ecc)
{
- if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity
+ if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity
*a = sqrtf(A > C ? A : C);
*b = 0.f;
*ecc = 1e10f;
- *th = 0.5f*(atan2f(B, A - C) + (float)M_PI);
+ *th = 0.5f * (atan2f(B, A - C) + (float)M_PI);
}
else {
- const float AmC = A - C, ApC = A + C, F2 = F*2.f;
- const float r = sqrtf(AmC*AmC + B*B);
+ const float AmC = A - C, ApC = A + C, F2 = F * 2.f;
+ const float r = sqrtf(AmC * AmC + B * B);
float d = ApC - r;
*a = (d <= 0.f) ? sqrtf(A > C ? A : C) : sqrtf(F2 / d);
d = ApC + r;
@@ -253,7 +263,7 @@ static void imp2radangle(float A, float B, float C, float F, float *a, float *b,
*ecc = *a / *b;
}
// incr theta by 0.5*pi (angle of major axis)
- *th = 0.5f*(atan2f(B, AmC) + (float)M_PI);
+ *th = 0.5f * (atan2f(B, AmC) + (float)M_PI);
}
}
@@ -270,11 +280,11 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
// scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values,
// scaling by aspect ratio alone does the opposite, so try something in between instead...
const float ff2 = width, ff = sqrtf(ff2), q = height / ff;
- const float Ux = dx*ff, Vx = dx*q, Uy = dy*ff, Vy = dy*q;
- float A = Vx*Vx + Vy*Vy;
- float B = -2.f*(Ux*Vx + Uy*Vy);
- float C = Ux*Ux + Uy*Uy;
- float F = A*C - B*B*0.25f;
+ const float Ux = dx * ff, Vx = dx * q, Uy = dy * ff, Vy = dy * q;
+ float A = Vx * Vx + Vy * Vy;
+ float B = -2.f * (Ux * Vx + Uy * Vy);
+ float C = Ux * Ux + Uy * Uy;
+ float F = A * C - B * B * 0.25f;
float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d;
int u, v, u1, u2, v1, v2;
// The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C,
@@ -284,13 +294,13 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
// Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off,
// and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on
// (minimum values: const float rmin = intpol ? 1.f : 0.5f;)
- const float rmin = 1.5625f/ff2;
+ const float rmin = 1.5625f / ff2;
imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
- if ((b2 = b*b) < rmin) {
- if ((a2 = a*a) < rmin) {
+ if ((b2 = b * b) < rmin) {
+ if ((a2 = a * a) < rmin) {
B = 0.f;
A = C = rmin;
- F = A*C;
+ F = A * C;
}
else {
b2 = rmin;
@@ -298,9 +308,9 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
}
}
- ue = ff*sqrtf(C);
- ve = ff*sqrtf(A);
- d = (float)(EWA_MAXIDX + 1) / (F*ff2);
+ ue = ff * sqrtf(C);
+ ve = ff * sqrtf(A);
+ d = (float)(EWA_MAXIDX + 1) / (F * ff2);
A *= d;
B *= d;
C *= d;
@@ -313,26 +323,24 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
v2 = (int)(ceilf(V0 + ve));
U0 -= 0.5f;
V0 -= 0.5f;
- DDQ = 2.f*A;
+ DDQ = 2.f * A;
U = u1 - U0;
- ac1 = A*(2.f*U + 1.f);
- ac2 = A*U*U;
- BU = B*U;
+ ac1 = A * (2.f * U + 1.f);
+ ac2 = A * U * U;
+ BU = B * U;
d = result[0] = result[1] = result[2] = result[3] = 0.f;
- for (v=v1; v<=v2; ++v) {
+ for (v = v1; v <= v2; ++v) {
const float V = v - V0;
- float DQ = ac1 + B*V;
- float Q = (C*V + BU)*V + ac2;
- for (u=u1; u<=u2; ++u) {
+ float DQ = ac1 + B * V;
+ float Q = (C * V + BU) * V + ac2;
+ for (u = u1; u <= u2; ++u) {
if (Q < (float)(EWA_MAXIDX + 1)) {
float tc[4];
const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q];
read(tc, clipuv(u, width), clipuv(v, height));
- result[0] += tc[0]*wt;
- result[1] += tc[1]*wt;
- result[2] += tc[2]*wt;
- result[3] += result[3] ? tc[3]*wt : 0.f;
+ madd_v3_v3fl(result, tc, wt);
+ result[3] += result[3] ? tc[3] * wt : 0.f;
d += wt;
}
Q += DQ;
@@ -341,10 +349,10 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
}
// d should hopefully never be zero anymore
- d = 1.f/d;
+ d = 1.f / d;
result[0] *= d;
result[1] *= d;
result[2] *= d;
// clipping can be ignored if alpha used, texr->ta already includes filtered edge
- result[3] = result[3] ? result[3] *d : 1.f;
+ result[3] = result[3] ? result[3] * d : 1.f;
}
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index fd90e5fcb5a..dd24a30e85e 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -34,9 +34,9 @@ extern "C" {
#include <vector>
/**
- * @brief state of a memory buffer
- * @ingroup Memory
- */
+ * @brief state of a memory buffer
+ * @ingroup Memory
+ */
typedef enum MemoryBufferState {
/** @brief memory has been allocated on creator device and CPU machine, but kernel has not been executed */
COM_MB_ALLOCATED = 1,
@@ -49,115 +49,116 @@ typedef enum MemoryBufferState {
class MemoryProxy;
/**
- * @brief a MemoryBuffer contains access to the data of a chunk
- */
+ * @brief a MemoryBuffer contains access to the data of a chunk
+ */
class MemoryBuffer {
private:
/**
- * @brief proxy of the memory (same for all chunks in the same buffer)
- */
- MemoryProxy * memoryProxy;
+ * @brief proxy of the memory (same for all chunks in the same buffer)
+ */
+ MemoryProxy *memoryProxy;
/**
- * @brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR
- */
+ * @brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR
+ */
DataType datatype;
/**
- * @brief region of this buffer inside reative to the MemoryProxy
- */
+ * @brief region of this buffer inside reative to the MemoryProxy
+ */
rcti rect;
/**
- * brief refers to the chunknumber within the executiongroup where related to the MemoryProxy
- * @see memoryProxy
- */
+ * brief refers to the chunknumber within the executiongroup where related to the MemoryProxy
+ * @see memoryProxy
+ */
unsigned int chunkNumber;
/**
- * @brief width of the chunk
- */
+ * @brief width of the chunk
+ */
unsigned int chunkWidth;
/**
- * @brief state of the buffer
- */
+ * @brief state of the buffer
+ */
MemoryBufferState state;
/**
- * @brief the actual float buffer/data
- */
+ * @brief the actual float buffer/data
+ */
float *buffer;
public:
/**
- * @brief construct new MemoryBuffer for a chunk
- */
+ * @brief construct new MemoryBuffer for a chunk
+ */
MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect);
/**
- * @brief construct new temporarily MemoryBuffer for an area
- */
+ * @brief construct new temporarily MemoryBuffer for an area
+ */
MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect);
/**
- * @brief destructor
- */
+ * @brief destructor
+ */
~MemoryBuffer();
/**
- * @brief read the ChunkNumber of this MemoryBuffer
- */
- unsigned int getChunkNumber() {return this->chunkNumber;}
+ * @brief read the ChunkNumber of this MemoryBuffer
+ */
+ unsigned int getChunkNumber() { return this->chunkNumber; }
/**
- * @brief get the data of this MemoryBuffer
- * @note buffer should already be available in memory
- */
- float *getBuffer() {return this->buffer;}
+ * @brief get the data of this MemoryBuffer
+ * @note buffer should already be available in memory
+ */
+ float *getBuffer() { return this->buffer; }
/**
- * @brief after execution the state will be set to available by calling this method
- */
+ * @brief after execution the state will be set to available by calling this method
+ */
void setCreatedState() {
this->state = COM_MB_AVAILABLE;
}
void read(float result[4], int x, int y);
void writePixel(int x, int y, const float color[4]);
+ void addPixel(int x, int y, const float color[4]);
void readCubic(float result[4], float x, float y);
void readEWA(float result[4], float fx, float fy, float dx, float dy);
/**
- * @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
- */
- inline const bool isTemporarily() const {return this->state == COM_MB_TEMPORARILY;}
+ * @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
+ */
+ inline const bool isTemporarily() const { return this->state == COM_MB_TEMPORARILY; }
/**
- * @brief add the content from otherBuffer to this MemoryBuffer
- * @param otherBuffer source buffer
- */
+ * @brief add the content from otherBuffer to this MemoryBuffer
+ * @param otherBuffer source buffer
+ */
void copyContentFrom(MemoryBuffer *otherBuffer);
/**
- * @brief get the rect of this MemoryBuffer
- */
- rcti *getRect() {return &this->rect;}
+ * @brief get the rect of this MemoryBuffer
+ */
+ rcti *getRect() { return &this->rect; }
/**
- * @brief get the width of this MemoryBuffer
- */
+ * @brief get the width of this MemoryBuffer
+ */
int getWidth() const;
/**
- * @brief get the height of this MemoryBuffer
- */
+ * @brief get the height of this MemoryBuffer
+ */
int getHeight() const;
/**
- * @brief clear the buffer. Make all pixels black transparant.
- */
+ * @brief clear the buffer. Make all pixels black transparant.
+ */
void clear();
MemoryBuffer *duplicate();
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h
index e0ac72de0d3..e7e7f1cf3a0 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.h
+++ b/source/blender/compositor/intern/COM_MemoryProxy.h
@@ -30,78 +30,78 @@ class MemoryProxy;
class ExecutionGroup;
/**
- * @brief A MemoryProxy is a unique identifier for a memory buffer.
- * A single MemoryProxy is used among all chunks of the same buffer,
- * the MemoryBuffer only stores the data of a single chunk.
- * @ingroup Memory
- */
+ * @brief A MemoryProxy is a unique identifier for a memory buffer.
+ * A single MemoryProxy is used among all chunks of the same buffer,
+ * the MemoryBuffer only stores the data of a single chunk.
+ * @ingroup Memory
+ */
class MemoryProxy {
private:
/**
- * @brief reference to the ouput operation of the executiongroup
- */
+ * @brief reference to the ouput operation of the executiongroup
+ */
WriteBufferOperation *writeBufferOperation;
/**
- * @brief reference to the executor. the Execution group that can fill a chunk
- */
+ * @brief reference to the executor. the Execution group that can fill a chunk
+ */
ExecutionGroup *executor;
/**
- * @brief datatype of this MemoryProxy
- */
+ * @brief datatype of this MemoryProxy
+ */
DataType datatype;
/**
- * @brief channel information of this buffer
- */
+ * @brief channel information of this buffer
+ */
ChannelInfo channelInfo[COM_NUMBER_OF_CHANNELS];
/**
- * @brief the allocated memory
- */
- MemoryBuffer* buffer;
+ * @brief the allocated memory
+ */
+ MemoryBuffer *buffer;
public:
MemoryProxy();
/**
- * @brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
- * @param group the ExecutionGroup to set
- */
- void setExecutor(ExecutionGroup *executor) {this->executor = executor;}
-
+ * @brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
+ * @param group the ExecutionGroup to set
+ */
+ void setExecutor(ExecutionGroup *executor) { this->executor = executor; }
+
/**
- * @brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
- */
- ExecutionGroup *getExecutor() {return this->executor;}
-
+ * @brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
+ */
+ ExecutionGroup *getExecutor() { return this->executor; }
+
/**
- * @brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
- * @param operation
- */
- void setWriteBufferOperation(WriteBufferOperation *operation) {this->writeBufferOperation = operation;}
-
+ * @brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
+ * @param operation
+ */
+ void setWriteBufferOperation(WriteBufferOperation *operation) { this->writeBufferOperation = operation; }
+
/**
- * @brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
- * @return WriteBufferOperation
- */
- WriteBufferOperation *getWriteBufferOperation() {return this->writeBufferOperation;}
+ * @brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
+ * @return WriteBufferOperation
+ */
+ WriteBufferOperation *getWriteBufferOperation() { return this->writeBufferOperation; }
/**
- * @brief allocate memory of size widht x height
- */
+ * @brief allocate memory of size widht x height
+ */
void allocate(unsigned int width, unsigned int height);
/**
- * @brief free the allocated memory
- */
+ * @brief free the allocated memory
+ */
void free();
/**
- * @brief get the allocated memory
- */
- inline MemoryBuffer* getBuffer() {return this->buffer;}
+ * @brief get the allocated memory
+ */
+ inline MemoryBuffer *getBuffer() { return this->buffer; }
};
#endif
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index 264725b4b2c..62e030b777c 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -43,23 +43,23 @@ Node::Node(bNode *editorNode, bool create_sockets)
this->editorNode = editorNode;
if (create_sockets) {
- bNodeSocket * input = (bNodeSocket*)editorNode->inputs.first;
+ bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
while (input != NULL) {
DataType dt = COM_DT_VALUE;
if (input->type == SOCK_RGBA) dt = COM_DT_COLOR;
if (input->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
this->addInputSocket(dt, (InputSocketResizeMode)input->resizemode, input);
- input = (bNodeSocket*)input->next;
+ input = (bNodeSocket *)input->next;
}
- bNodeSocket *output = (bNodeSocket*)editorNode->outputs.first;
+ bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
while (output != NULL) {
DataType dt = COM_DT_VALUE;
if (output->type == SOCK_RGBA) dt = COM_DT_COLOR;
if (output->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
this->addOutputSocket(dt, output);
- output = (bNodeSocket*)output->next;
+ output = (bNodeSocket *)output->next;
}
}
}
@@ -75,9 +75,9 @@ bNode *Node::getbNode()
void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ bNodeSocket *bSock = (bNodeSocket *)this->getEditorInputSocket(editorNodeInputSocketIndex);
SetValueOperation *operation = new SetValueOperation();
- bNodeSocketValueFloat *val = (bNodeSocketValueFloat*)bSock->default_value;
+ bNodeSocketValueFloat *val = (bNodeSocketValueFloat *)bSock->default_value;
operation->setValue(val->value);
this->addLink(graph, operation->getOutputSocket(), inputsocket);
graph->addOperation(operation);
@@ -85,16 +85,18 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket
void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket)
{
- PreviewOperation *operation = new PreviewOperation();
- system->addOperation(operation);
- operation->setbNode(this->getbNode());
- operation->setbNodeTree(system->getContext().getbNodeTree());
- this->addLink(system, outputSocket, operation->getInputSocket(0));
+ if (this->isInActiveGroup()) {
+ PreviewOperation *operation = new PreviewOperation();
+ system->addOperation(operation);
+ operation->setbNode(this->getbNode());
+ operation->setbNodeTree(system->getContext().getbNodeTree());
+ this->addLink(system, outputSocket, operation->getInputSocket(0));
+ }
}
void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket)
{
- if (inputSocket->isConnected()) {
+ if (inputSocket->isConnected() && this->isInActiveGroup()) {
OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket();
this->addPreviewOperation(system, outputsocket);
}
@@ -116,9 +118,9 @@ SocketConnection *Node::addLink(ExecutionSystem *graph, OutputSocket *outputSock
void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ bNodeSocket *bSock = (bNodeSocket *)this->getEditorInputSocket(editorNodeInputSocketIndex);
SetColorOperation *operation = new SetColorOperation();
- bNodeSocketValueRGBA *val = (bNodeSocketValueRGBA*)bSock->default_value;
+ bNodeSocketValueRGBA *val = (bNodeSocketValueRGBA *)bSock->default_value;
operation->setChannel1(val->value[0]);
operation->setChannel2(val->value[1]);
operation->setChannel3(val->value[2]);
@@ -129,8 +131,8 @@ void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket
void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
- bNodeSocketValueVector *val = (bNodeSocketValueVector*)bSock->default_value;
+ bNodeSocket *bSock = (bNodeSocket *)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ bNodeSocketValueVector *val = (bNodeSocketValueVector *)bSock->default_value;
SetVectorOperation *operation = new SetVectorOperation();
operation->setX(val->value[0]);
operation->setY(val->value[1]);
@@ -141,7 +143,7 @@ void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocke
bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket*)this->getbNode()->inputs.first;
+ bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first;
int index = 0;
while (bSock != NULL) {
if (index == editorNodeInputSocketIndex) {
@@ -154,7 +156,7 @@ bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
}
bNodeSocket *Node::getEditorOutputSocket(int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket*)this->getbNode()->outputs.first;
+ bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->outputs.first;
int index = 0;
while (bSock != NULL) {
if (index == editorNodeInputSocketIndex) {
@@ -168,9 +170,9 @@ bNodeSocket *Node::getEditorOutputSocket(int editorNodeInputSocketIndex)
InputSocket *Node::findInputSocketBybNodeSocket(bNodeSocket *socket)
{
- vector<InputSocket*> &inputsockets = this->getInputSockets();
+ vector<InputSocket *> &inputsockets = this->getInputSockets();
unsigned int index;
- for (index = 0 ; index < inputsockets.size(); index ++) {
+ for (index = 0; index < inputsockets.size(); index++) {
InputSocket *input = inputsockets[index];
if (input->getbNodeSocket() == socket) {
return input;
@@ -181,9 +183,9 @@ InputSocket *Node::findInputSocketBybNodeSocket(bNodeSocket *socket)
OutputSocket *Node::findOutputSocketBybNodeSocket(bNodeSocket *socket)
{
- vector<OutputSocket*> &outputsockets = this->getOutputSockets();
+ vector<OutputSocket *> &outputsockets = this->getOutputSockets();
unsigned int index;
- for (index = 0 ; index < outputsockets.size(); index ++) {
+ for (index = 0; index < outputsockets.size(); index++) {
OutputSocket *output = outputsockets[index];
if (output->getbNodeSocket() == socket) {
return output;
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 23744adf642..12baa26cd6e 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -38,83 +38,102 @@ class Node;
class NodeOperation;
class ExecutionSystem;
-typedef vector<Node*> NodeList;
+typedef vector<Node *> NodeList;
typedef NodeList::iterator NodeIterator;
typedef pair<NodeIterator, NodeIterator> NodeRange;
/**
- * My node documentation.
- */
-class Node:public NodeBase {
+ * My node documentation.
+ */
+class Node : public NodeBase {
private:
/**
- * @brief stores the reference to the SDNA bNode struct
- */
+ * @brief stores the reference to the SDNA bNode struct
+ */
bNode *editorNode;
+ /**
+ * @brief Is this node part of the active group
+ */
+ bool inActiveGroup;
+
public:
- Node(bNode *editorNode, bool create_sockets=true);
+ Node(bNode *editorNode, bool create_sockets = true);
/**
- * @brief get the reference to the SDNA bNode struct
- */
+ * @brief get the reference to the SDNA bNode struct
+ */
bNode *getbNode();
/**
- * @brief convert node to operation
- *
- * @todo this must be described furter
- *
- * @param system the ExecutionSystem where the operations need to be added
- * @param context reference to the CompositorContext
- */
- virtual void convertToOperations(ExecutionSystem *system, CompositorContext * context) =0;
+ * @brief Is this node in the active group (the group that is being edited)
+ * @param isInActiveGroup
+ */
+ void setIsInActiveGroup(bool isInActiveGroup) { this->inActiveGroup = isInActiveGroup; }
+
+ /**
+ * @brief Is this node part of the active group
+ * the active group is the group that is currently being edited. When no group is edited,
+ * the active group will be the main tree (all nodes that are not part of a group will be active)
+ * @return bool [false:true]
+ */
+ inline bool isInActiveGroup() { return this->inActiveGroup; }
+
+ /**
+ * @brief convert node to operation
+ *
+ * @todo this must be described furter
+ *
+ * @param system the ExecutionSystem where the operations need to be added
+ * @param context reference to the CompositorContext
+ */
+ virtual void convertToOperations(ExecutionSystem *system, CompositorContext *context) = 0;
/**
- * this method adds a SetValueOperation as input of the input socket.
- * This can only be used from the convertToOperation method. all other usages are not allowed
- */
+ * this method adds a SetValueOperation as input of the input socket.
+ * This can only be used from the convertToOperation method. all other usages are not allowed
+ */
void addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
/**
- * this method adds a SetColorOperation as input of the input socket.
- * This can only be used from the convertToOperation method. all other usages are not allowed
- */
+ * this method adds a SetColorOperation as input of the input socket.
+ * This can only be used from the convertToOperation method. all other usages are not allowed
+ */
void addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
/**
- * this method adds a SetVectorOperation as input of the input socket.
- * This can only be used from the convertToOperation method. all other usages are not allowed
- */
+ * this method adds a SetVectorOperation as input of the input socket.
+ * This can only be used from the convertToOperation method. all other usages are not allowed
+ */
void addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
/**
- * Creates a new link between an outputSocket and inputSocket and registrates the link to the graph
- * @return the new created link
- */
+ * Creates a new link between an outputSocket and inputSocket and registrates the link to the graph
+ * @return the new created link
+ */
SocketConnection *addLink(ExecutionSystem *graph, OutputSocket *outputSocket, InputSocket *inputsocket);
/**
- * is this node a group node.
- */
+ * is this node a group node.
+ */
virtual bool isGroupNode() const { return false; }
/**
- * is this node a proxy node.
- */
+ * is this node a proxy node.
+ */
virtual bool isProxyNode() const { return false; }
/**
- * @brief find the InputSocket by bNodeSocket
- *
- * @param socket
- */
+ * @brief find the InputSocket by bNodeSocket
+ *
+ * @param socket
+ */
InputSocket *findInputSocketBybNodeSocket(bNodeSocket *socket);
/**
- * @brief find the OutputSocket by bNodeSocket
- *
- * @param socket
- */
+ * @brief find the OutputSocket by bNodeSocket
+ *
+ * @param socket
+ */
OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket);
protected:
diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp
index 17a623c9c81..42946d7315e 100644
--- a/source/blender/compositor/intern/COM_NodeBase.cpp
+++ b/source/blender/compositor/intern/COM_NodeBase.cpp
@@ -31,6 +31,7 @@
NodeBase::NodeBase()
{
+ /* pass */
}
@@ -89,55 +90,3 @@ InputSocket *NodeBase::getInputSocket(int index)
{
return this->inputsockets[index];
}
-
-
-void NodeBase::determineActualSocketDataTypes()
-{
- unsigned int index;
- for (index = 0 ; index < this->outputsockets.size() ; index ++) {
- OutputSocket *socket = this->outputsockets[index];
- if (socket->getActualDataType() ==COM_DT_UNKNOWN && socket->isConnected()) {
- socket->determineActualDataType();
- }
- }
- for (index = 0 ; index < this->inputsockets.size() ; index ++) {
- InputSocket *socket = this->inputsockets[index];
- if (socket->getActualDataType() ==COM_DT_UNKNOWN) {
- socket->determineActualDataType();
- }
- }
-}
-
-DataType NodeBase::determineActualDataType(OutputSocket *outputsocket)
-{
- const int inputIndex = outputsocket->getInputSocketDataTypeDeterminatorIndex();
- if (inputIndex != -1) {
- return this->getInputSocket(inputIndex)->getActualDataType();
- }
- else {
- return outputsocket->getDataType();
- }
-}
-
-void NodeBase::notifyActualDataTypeSet(InputSocket *socket, DataType actualType)
-{
- unsigned int index;
- int socketIndex = -1;
- for (index = 0 ; index < this->inputsockets.size() ; index ++) {
- if (this->inputsockets[index] == socket) {
- socketIndex = (int)index;
- break;
- }
- }
- if (socketIndex == -1) return;
-
- for (index = 0 ; index < this->outputsockets.size() ; index ++) {
- OutputSocket *socket = this->outputsockets[index];
- if (socket->isActualDataTypeDeterminedByInputSocket() &&
- socket->getInputSocketDataTypeDeterminatorIndex() == socketIndex)
- {
- socket->setActualDataType(actualType);
- socket->fireActualDataType();
- }
- }
-}
diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h
index 123797c780a..5e3a4fa5531 100644
--- a/source/blender/compositor/intern/COM_NodeBase.h
+++ b/source/blender/compositor/intern/COM_NodeBase.h
@@ -37,136 +37,108 @@ class NodeOperation;
class ExecutionSystem;
/**
- * @brief The NodeBase class is the super-class of all node related objects like @see Node @see NodeOperation
- * the reason for the existence of this class is to support graph-nodes when using ExecutionSystem
- * the NodeBase also contains the reference to InputSocket and OutputSocket.
- * @ingroup Model
- */
+ * @brief The NodeBase class is the super-class of all node related objects like @see Node @see NodeOperation
+ * the reason for the existence of this class is to support graph-nodes when using ExecutionSystem
+ * the NodeBase also contains the reference to InputSocket and OutputSocket.
+ * @ingroup Model
+ */
class NodeBase {
private:
/**
- * @brief the list of actual inputsockets @see InputSocket
- */
- vector<InputSocket*> inputsockets;
+ * @brief the list of actual inputsockets @see InputSocket
+ */
+ vector<InputSocket *> inputsockets;
/**
- * @brief the list of actual outputsockets @see OutputSocket
- */
- vector<OutputSocket*> outputsockets;
+ * @brief the list of actual outputsockets @see OutputSocket
+ */
+ vector<OutputSocket *> outputsockets;
protected:
/**
- * @brief get access to the vector of input sockets
- */
- inline vector<InputSocket*>& getInputSockets() {return this->inputsockets;}
+ * @brief get access to the vector of input sockets
+ */
+ inline vector<InputSocket *>& getInputSockets() { return this->inputsockets; }
/**
- * @brief get access to the vector of input sockets
- */
- inline vector<OutputSocket*>& getOutputSockets() {return this->outputsockets;}
+ * @brief get access to the vector of input sockets
+ */
+ inline vector<OutputSocket *>& getOutputSockets() { return this->outputsockets; }
public:
/**
- * @brief destructor
- * clean up memory related to this NodeBase.
- */
+ * @brief destructor
+ * clean up memory related to this NodeBase.
+ */
virtual ~NodeBase();
/**
- * @brief determine the actual socket data types that will go through the system
- */
- virtual void determineActualSocketDataTypes();
-
- /**
- * @brief determine the actual socket data types of a specific outputsocket
- *
- * @param outputsocket
- * a reference to the actual outputsocket where the datatype must be determined from
- *
- * @return
- * COM_DT_VALUE if it is a value (1 float buffer)
- * COM_DT_COLOR if it is a value (4 float buffer)
- * COM_DT_VECTOR if it is a value (3 float buffer)
- */
- virtual DataType determineActualDataType(OutputSocket *outputsocket);
+ * @brief is this node an operation?
+ * This is true when the instance is of the subclass NodeOperation.
+ * @return [true:false]
+ * @see NodeOperation
+ */
+ virtual const int isOperation() const { return false; }
/**
- * @brief is this node an operation?
- * This is true when the instance is of the subclass NodeOperation.
- * @return [true:false]
- * @see NodeOperation
- */
- virtual const int isOperation() const {return false;}
-
- /**
- * @brief check if this is an input node
- * An input node is a node that only has output sockets and no input sockets
- * @return [false..true]
- */
+ * @brief check if this is an input node
+ * An input node is a node that only has output sockets and no input sockets
+ * @return [false..true]
+ */
const bool isInputNode() const;
/**
- * @brief Return the number of input sockets of this node.
- */
- const unsigned int getNumberOfInputSockets() const {return this->inputsockets.size();}
-
- /**
- * @brief Return the number of output sockets of this node.
- */
- const unsigned int getNumberOfOutputSockets() const {return this->outputsockets.size();}
-
+ * @brief Return the number of input sockets of this node.
+ */
+ const unsigned int getNumberOfInputSockets() const { return this->inputsockets.size(); }
+
/**
- * after the data has been determined of an outputsocket that has a connection with an inputsocket this method is called on the
- * node that contains the inputsocket.
- * @param socket
- * the reference of the inputsocket where connected data type is found
- * @param actualType [COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR]
- * the actual data type that is coming from the connected output socket
- */
- virtual void notifyActualDataTypeSet(InputSocket *socket, const DataType actualType);
-
+ * @brief Return the number of output sockets of this node.
+ */
+ const unsigned int getNumberOfOutputSockets() const { return this->outputsockets.size(); }
+
/**
- * get the reference to a certain outputsocket
- * @param index
- * the index of the needed outputsocket
- */
+ * get the reference to a certain outputsocket
+ * @param index
+ * the index of the needed outputsocket
+ */
OutputSocket *getOutputSocket(const int index);
/**
- * get the reference to the first outputsocket
- * @param index
- * the index of the needed outputsocket
- */
- inline OutputSocket *getOutputSocket() {return getOutputSocket(0);}
+ * get the reference to the first outputsocket
+ * @param index
+ * the index of the needed outputsocket
+ */
+ inline OutputSocket *getOutputSocket() { return getOutputSocket(0); }
/**
- * get the reference to a certain inputsocket
- * @param index
- * the index of the needed inputsocket
- */
+ * get the reference to a certain inputsocket
+ * @param index
+ * the index of the needed inputsocket
+ */
InputSocket *getInputSocket(const int index);
- virtual bool isStatic() const {return false;}
- void getStaticValues(float *result) const {}
+ virtual bool isStatic() const { return false; }
+ void getStaticValues(float *result) const { }
protected:
NodeBase();
/**
- * @brief add an InputSocket to the collection of inputsockets
- * @note may only be called in an constructor
- * @param socket the InputSocket to add
- */
+ * @brief add an InputSocket to the collection of inputsockets
+ * @note may only be called in an constructor
+ * @param socket the InputSocket to add
+ */
void addInputSocket(DataType datatype);
void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode);
void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket *socket);
/**
- * @brief add an OutputSocket to the collection of outputsockets
- * @note may only be called in an constructor
- * @param socket the OutputSocket to add
- */
+ * @brief add an OutputSocket to the collection of outputsockets
+ * @note may only be called in an constructor
+ * @param socket the OutputSocket to add
+ */
void addOutputSocket(DataType datatype);
void addOutputSocket(DataType datatype, bNodeSocket *socket);
};
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index 650e4af5ae0..114d9f44cef 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -34,15 +34,16 @@ NodeOperation::NodeOperation()
this->width = 0;
this->height = 0;
this->openCL = false;
+ this->btree = NULL;
}
void NodeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
unsigned int temp[2];
unsigned int temp2[2];
- vector<InputSocket*> &inputsockets = this->getInputSockets();
+ vector<InputSocket *> &inputsockets = this->getInputSockets();
- for (unsigned int index = 0 ; index < inputsockets.size();index++) {
+ for (unsigned int index = 0; index < inputsockets.size(); index++) {
InputSocket *inputSocket = inputsockets[index];
if (inputSocket->isConnected()) {
if (index == this->resolutionInputSocketIndex) {
@@ -53,7 +54,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int
}
}
}
- for (unsigned int index = 0 ; index < inputsockets.size();index++) {
+ for (unsigned int index = 0; index < inputsockets.size(); index++) {
InputSocket *inputSocket = inputsockets[index];
if (inputSocket->isConnected()) {
if (index != resolutionInputSocketIndex) {
@@ -68,18 +69,32 @@ void NodeOperation::setResolutionInputSocketIndex(unsigned int index)
}
void NodeOperation::initExecution()
{
+ /* pass */
}
void NodeOperation::initMutex()
{
BLI_mutex_init(&mutex);
}
+
+void NodeOperation::lockMutex()
+{
+ BLI_mutex_lock(&mutex);
+}
+
+void NodeOperation::unlockMutex()
+{
+ BLI_mutex_unlock(&mutex);
+}
+
void NodeOperation::deinitMutex()
{
BLI_mutex_end(&mutex);
}
+
void NodeOperation::deinitExecution()
{
+ /* pass */
}
SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex)
{
@@ -90,10 +105,10 @@ NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
return this->getInputSocket(inputSocketIndex)->getOperation();
}
-void NodeOperation::getConnectedInputSockets(vector<InputSocket*> *sockets)
+void NodeOperation::getConnectedInputSockets(vector<InputSocket *> *sockets)
{
- vector<InputSocket*> &inputsockets = this->getInputSockets();
- for (vector<InputSocket*>::iterator iterator = inputsockets.begin() ; iterator!= inputsockets.end() ; iterator++) {
+ vector<InputSocket *> &inputsockets = this->getInputSockets();
+ for (vector<InputSocket *>::iterator iterator = inputsockets.begin(); iterator != inputsockets.end(); iterator++) {
InputSocket *socket = *iterator;
if (socket->isConnected()) {
sockets->push_back(socket);
@@ -101,7 +116,7 @@ void NodeOperation::getConnectedInputSockets(vector<InputSocket*> *sockets)
}
}
-bool NodeOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output)
+bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
if (this->isInputNode()) {
BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax);
@@ -109,12 +124,12 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOpe
}
else {
unsigned int index;
- vector<InputSocket*> &inputsockets = this->getInputSockets();
+ vector<InputSocket *> &inputsockets = this->getInputSockets();
- for (index = 0 ; index < inputsockets.size() ; index++) {
+ for (index = 0; index < inputsockets.size(); index++) {
InputSocket *inputsocket = inputsockets[index];
if (inputsocket->isConnected()) {
- NodeOperation *inputoperation = (NodeOperation*)inputsocket->getConnection()->getFromNode();
+ NodeOperation *inputoperation = (NodeOperation *)inputsocket->getConnection()->getFromNode();
bool result = inputoperation->determineDependingAreaOfInterest(input, readOperation, output);
if (result) {
return true;
@@ -125,24 +140,24 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOpe
}
}
-cl_mem NodeOperation::COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader* reader)
+cl_mem NodeOperation::COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader)
{
cl_int error;
- MemoryBuffer* result = (MemoryBuffer*)reader->initializeTileData(NULL, inputMemoryBuffers);
+ MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers);
const cl_image_format imageFormat = {
CL_RGBA,
CL_FLOAT
};
- cl_mem clBuffer = clCreateImage2D(context, CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(),
+ cl_mem clBuffer = clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(),
result->getHeight(), 0, result->getBuffer(), &error);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
if (error == CL_SUCCESS) cleanup->push_back(clBuffer);
error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result);
return clBuffer;
@@ -152,11 +167,11 @@ void NodeOperation::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel ke
{
if (offsetIndex != -1) {
cl_int error;
- rcti* rect = memoryBuffer->getRect();
+ rcti *rect = memoryBuffer->getRect();
cl_int2 offset = {rect->xmin, rect->ymin};
error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
}
}
@@ -167,7 +182,7 @@ void NodeOperation::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offs
cl_int2 offset = {this->getWidth(), this->getHeight()};
error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
}
}
@@ -180,10 +195,10 @@ void NodeOperation::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel ke
void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) {
cl_int error;
- const size_t size[] = {outputMemoryBuffer->getWidth(),outputMemoryBuffer->getHeight()};
+ const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()};
error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
}
void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex) {
@@ -196,17 +211,20 @@ void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel,
size_t size[2];
cl_int2 offset;
- for (offsety = 0 ; offsety < height; offsety+=localSize) {
+ bool breaked = false;
+ for (offsety = 0; offsety < height && (!breaked); offsety += localSize) {
offset[1] = offsety;
- if (offsety+localSize < height) {
+ if (offsety + localSize < height) {
size[1] = localSize;
- } else {
+ }
+ else {
size[1] = height - offsety;
}
- for (offsetx = 0 ; offsetx < width ; offsetx+=localSize) {
- if (offsetx+localSize < width) {
+ for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) {
+ if (offsetx + localSize < width) {
size[0] = localSize;
- } else {
+ }
+ else {
size[0] = width - offsetx;
}
offset[0] = offsetx;
@@ -214,8 +232,11 @@ void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel,
error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
clFlush(queue);
+ if (isBreaked()) {
+ breaked = false;
+ }
}
}
}
@@ -223,9 +244,8 @@ void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel,
cl_kernel NodeOperation::COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp)
{
cl_int error;
- cl_kernel kernel = clCreateKernel(program, kernelname, &error) ;
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
- }
+ cl_kernel kernel = clCreateKernel(program, kernelname, &error);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
else {
if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel);
}
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 2219907b0c8..30731572712 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -35,222 +35,251 @@ class NodeOperation;
#include "list"
#include "BLI_threads.h"
+#include "BLI_math_color.h"
+#include "BLI_math_vector.h"
+
class ReadBufferOperation;
/**
- * @brief NodeOperation are contains calculation logic
- *
- * Subclasses needs to implement the execution method (defined in SocketReader) to implement logic.
- * @ingroup Model
- */
+ * @brief NodeOperation are contains calculation logic
+ *
+ * Subclasses needs to implement the execution method (defined in SocketReader) to implement logic.
+ * @ingroup Model
+ */
class NodeOperation : public NodeBase, public SocketReader {
private:
/**
- * @brief the index of the input socket that will be used to determine the resolution
- */
+ * @brief the index of the input socket that will be used to determine the resolution
+ */
unsigned int resolutionInputSocketIndex;
/**
- * @brief is this operation a complex one.
- *
- * Complex operations are typically doing many reads to calculate the output of a single pixel.
- * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
- */
+ * @brief is this operation a complex one.
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
bool complex;
/**
- * @brief can this operation be scheduled on an OpenCL device.
- * @note Only applicable if complex is True
- */
+ * @brief can this operation be scheduled on an OpenCL device.
+ * @note Only applicable if complex is True
+ */
bool openCL;
/**
- * @brief mutex reference for very special node initializations
- * @note only use when you really know what you are doing.
- * this mutex is used to share data among chunks in the same operation
- * @see TonemapOperation for an example of usage
- * @see NodeOperation.initMutex initializes this mutex
- * @see NodeOperation.deinitMutex deinitializes this mutex
- * @see NodeOperation.getMutex retrieve a pointer to this mutex.
- */
+ * @brief mutex reference for very special node initializations
+ * @note only use when you really know what you are doing.
+ * this mutex is used to share data among chunks in the same operation
+ * @see TonemapOperation for an example of usage
+ * @see NodeOperation.initMutex initializes this mutex
+ * @see NodeOperation.deinitMutex deinitializes this mutex
+ * @see NodeOperation.getMutex retrieve a pointer to this mutex.
+ */
ThreadMutex mutex;
+
+ /**
+ * @brief reference to the editing bNodeTree only used for break callback
+ */
+ const bNodeTree *btree;
public:
/**
- * @brief is this node an operation?
- * This is true when the instance is of the subclass NodeOperation.
- * @return [true:false]
- * @see NodeBase
- */
- const int isOperation() const {return true;}
+ * @brief is this node an operation?
+ * This is true when the instance is of the subclass NodeOperation.
+ * @return [true:false]
+ * @see NodeBase
+ */
+ const int isOperation() const { return true; }
/**
- * @brief determine the resolution of this node
- * @note this method will not set the resolution, this is the responsibility of the caller
- * @param resolution the result of this operation
- * @param preferredResolution the preferrable resolution as no resolution could be determined
- */
+ * @brief determine the resolution of this node
+ * @note this method will not set the resolution, this is the responsibility of the caller
+ * @param resolution the result of this operation
+ * @param preferredResolution the preferrable resolution as no resolution could be determined
+ */
virtual void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
/**
- * @brief isOutputOperation determines whether this operation is an output of the ExecutionSystem during rendering or editing.
- *
- * Default behaviour if not overriden, this operation will not be evaluated as being an output of the ExecutionSystem.
- *
- * @see ExecutionSystem
- * @group check
- * @param rendering [true false]
- * true: rendering
- * false: editing
- *
- * @return bool the result of this method
- */
- virtual bool isOutputOperation(bool rendering) const {return false;}
+ * @brief isOutputOperation determines whether this operation is an output of the ExecutionSystem during rendering or editing.
+ *
+ * Default behaviour if not overriden, this operation will not be evaluated as being an output of the ExecutionSystem.
+ *
+ * @see ExecutionSystem
+ * @group check
+ * @param rendering [true false]
+ * true: rendering
+ * false: editing
+ *
+ * @return bool the result of this method
+ */
+ virtual bool isOutputOperation(bool rendering) const { return false; }
/**
- * isBufferOperation returns if this is an operation that work directly on buffers.
- *
- * there are only 2 implementation where this is true:
- * @see ReadBufferOperation
- * @see WriteBufferOperation
- * for all other operations this will result in false.
- */
- virtual int isBufferOperation() {return false;}
+ * isBufferOperation returns if this is an operation that work directly on buffers.
+ *
+ * there are only 2 implementation where this is true:
+ * @see ReadBufferOperation
+ * @see WriteBufferOperation
+ * for all other operations this will result in false.
+ */
+ virtual int isBufferOperation() { return false; }
+ virtual int isSingleThreaded() { return false; }
+ void setbNodeTree(const bNodeTree *tree) { this->btree = tree; }
virtual void initExecution();
- void initMutex();
/**
- * @brief when a chunk is executed by a CPUDevice, this method is called
- * @ingroup execution
- * @param rect the rectangle of the chunk (location and size)
- * @param chunkNumber the chunkNumber to be calculated
- * @param memoryBuffers all input MemoryBuffer's needed
- */
- virtual void executeRegion(rcti *rect, unsigned int chunkNumber, MemoryBuffer** memoryBuffers) {}
+ * @brief when a chunk is executed by a CPUDevice, this method is called
+ * @ingroup execution
+ * @param rect the rectangle of the chunk (location and size)
+ * @param chunkNumber the chunkNumber to be calculated
+ * @param memoryBuffers all input MemoryBuffer's needed
+ */
+ virtual void executeRegion(rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers) {}
/**
- * @brief when a chunk is executed by an OpenCLDevice, this method is called
- * @ingroup execution
- * @note this method is only implemented in WriteBufferOperation
- * @param context the OpenCL context
- * @param program the OpenCL program containing all compositor kernels
- * @param queue the OpenCL command queue of the device the chunk is executed on
- * @param rect the rectangle of the chunk (location and size)
- * @param chunkNumber the chunkNumber to be calculated
- * @param memoryBuffers all input MemoryBuffer's needed
- * @param outputBuffer the outputbuffer to write to
- */
+ * @brief when a chunk is executed by an OpenCLDevice, this method is called
+ * @ingroup execution
+ * @note this method is only implemented in WriteBufferOperation
+ * @param context the OpenCL context
+ * @param program the OpenCL program containing all compositor kernels
+ * @param queue the OpenCL command queue of the device the chunk is executed on
+ * @param rect the rectangle of the chunk (location and size)
+ * @param chunkNumber the chunkNumber to be calculated
+ * @param memoryBuffers all input MemoryBuffer's needed
+ * @param outputBuffer the outputbuffer to write to
+ */
virtual void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect,
- unsigned int chunkNumber, MemoryBuffer** memoryBuffers, MemoryBuffer* outputBuffer) {}
+ unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer) {}
/**
- * @brief custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevice
- * @ingroup execution
- * @param context the OpenCL context
- * @param program the OpenCL program containing all compositor kernels
- * @param queue the OpenCL command queue of the device the chunk is executed on
- * @param outputMemoryBuffer the allocated memory buffer in main CPU memory
- * @param clOutputBuffer the allocated memory buffer in OpenCLDevice memory
- * @param inputMemoryBuffers all input MemoryBuffer's needed
- * @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution
- * @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution
- */
- virtual void executeOpenCL(cl_context context,cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer** inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {}
+ * @brief custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevice
+ * @ingroup execution
+ * @param context the OpenCL context
+ * @param program the OpenCL program containing all compositor kernels
+ * @param queue the OpenCL command queue of the device the chunk is executed on
+ * @param outputMemoryBuffer the allocated memory buffer in main CPU memory
+ * @param clOutputBuffer the allocated memory buffer in OpenCLDevice memory
+ * @param inputMemoryBuffers all input MemoryBuffer's needed
+ * @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution
+ * @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution
+ */
+ virtual void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {}
virtual void deinitExecution();
- void deinitMutex();
+
+ bool isResolutionSet() {
+ return this->width != 0 && height != 0;
+ }
/**
- * @brief set the resolution
- * @param resolution the resolution to set
- */
- void setResolution(unsigned int resolution[]) {this->width = resolution[0];this->height = resolution[1];}
- void getConnectedInputSockets(vector<InputSocket*> *sockets);
+ * @brief set the resolution
+ * @param resolution the resolution to set
+ */
+ void setResolution(unsigned int resolution[]) {
+ if (!isResolutionSet()) {
+ this->width = resolution[0];
+ this->height = resolution[1];
+ }
+ }
+
+
+ void getConnectedInputSockets(vector<InputSocket *> *sockets);
/**
- * @brief is this operation complex
- *
- * Complex operations are typically doing many reads to calculate the output of a single pixel.
- * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
- */
- const bool isComplex() const {return this->complex;}
- virtual const bool isSetOperation() const {return false;}
+ * @brief is this operation complex
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ const bool isComplex() const { return this->complex; }
+ virtual const bool isSetOperation() const { return false; }
/**
- * @brief is this operation of type ReadBufferOperation
- * @return [true:false]
- * @see ReadBufferOperation
- */
- virtual const bool isReadBufferOperation() const {return false;}
+ * @brief is this operation of type ReadBufferOperation
+ * @return [true:false]
+ * @see ReadBufferOperation
+ */
+ virtual const bool isReadBufferOperation() const { return false; }
/**
- * @brief is this operation of type WriteBufferOperation
- * @return [true:false]
- * @see WriteBufferOperation
- */
- virtual const bool isWriteBufferOperation() const {return false;}
+ * @brief is this operation of type WriteBufferOperation
+ * @return [true:false]
+ * @see WriteBufferOperation
+ */
+ virtual const bool isWriteBufferOperation() const { return false; }
/**
- * @brief is this operation the active viewer output
- * user can select an ViewerNode to be active (the result of this node will be drawn on the backdrop)
- * @return [true:false]
- * @see BaseViewerOperation
- */
- virtual const bool isActiveViewerOutput() const {return false;}
+ * @brief is this operation the active viewer output
+ * user can select an ViewerNode to be active (the result of this node will be drawn on the backdrop)
+ * @return [true:false]
+ * @see BaseViewerOperation
+ */
+ virtual const bool isActiveViewerOutput() const { return false; }
- virtual bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output);
+ virtual bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
/**
- * @brief set the index of the input socket that will determine the resolution of this operation
- * @param index the index to set
- */
+ * @brief set the index of the input socket that will determine the resolution of this operation
+ * @param index the index to set
+ */
void setResolutionInputSocketIndex(unsigned int index);
/**
- * @brief get the render priority of this node.
- * @note only applicable for output operations like ViewerOperation
- * @return CompositorPriority
- */
- virtual const CompositorPriority getRenderPriority() const {return COM_PRIORITY_LOW;}
+ * @brief get the render priority of this node.
+ * @note only applicable for output operations like ViewerOperation
+ * @return CompositorPriority
+ */
+ virtual const CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
/**
- * @brief can this NodeOperation be scheduled on an OpenCLDevice
- * @see WorkScheduler.schedule
- * @see ExecutionGroup.addOperation
- */
+ * @brief can this NodeOperation be scheduled on an OpenCLDevice
+ * @see WorkScheduler.schedule
+ * @see ExecutionGroup.addOperation
+ */
bool isOpenCL() { return this->openCL; }
- virtual bool isViewerOperation() {return false;}
+ virtual bool isViewerOperation() { return false; }
+ virtual bool isPreviewOperation() { return false; }
+
+ inline bool isBreaked() {
+ return btree->test_break(btree->tbh);
+ }
+
protected:
NodeOperation();
- void setWidth(unsigned int width) {this->width = width;}
- void setHeight(unsigned int height) {this->height = height;}
+ void setWidth(unsigned int width) { this->width = width; }
+ void setHeight(unsigned int height) { this->height = height; }
SocketReader *getInputSocketReader(unsigned int inputSocketindex);
NodeOperation *getInputOperation(unsigned int inputSocketindex);
- inline ThreadMutex *getMutex() {return &this->mutex;}
+ void deinitMutex();
+ void initMutex();
+ void lockMutex();
+ void unlockMutex();
+
/**
- * @brief set whether this operation is complex
- *
- * Complex operations are typically doing many reads to calculate the output of a single pixel.
- * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
- */
- void setComplex(bool complex) {this->complex = complex;}
+ * @brief set whether this operation is complex
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ void setComplex(bool complex) { this->complex = complex; }
/**
- * @brief set if this NodeOperation can be scheduled on a OpenCLDevice
- */
- void setOpenCL(bool openCL) {this->openCL = openCL;}
+ * @brief set if this NodeOperation can be scheduled on a OpenCLDevice
+ */
+ void setOpenCL(bool openCL) { this->openCL = openCL; }
- static cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader* reader);
+ static cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader);
static void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers);
static void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer);
void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex);
- static void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer* outputMemoryBuffer);
- static void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex);
- cl_kernel COM_clCreateKernel(cl_program program, const char* kernelname, list<cl_kernel> *clKernelsToCleanUp);
+ static void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer);
+ void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex);
+ cl_kernel COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp);
};
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index e6d3789b06d..9d005804098 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -49,12 +49,12 @@ void OpenCLDevice::deinitialize()
void OpenCLDevice::execute(WorkPackage *work)
{
const unsigned int chunkNumber = work->getChunkNumber();
- ExecutionGroup * executionGroup = work->getExecutionGroup();
+ ExecutionGroup *executionGroup = work->getExecutionGroup();
rcti rect;
executionGroup->determineChunkRect(&rect, chunkNumber);
- MemoryBuffer ** inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber);
- MemoryBuffer * outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
+ MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber);
+ MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this->context, this->program, this->queue, &rect,
chunkNumber, inputBuffers, outputBuffer);
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h
index f61c555558d..83ce8cec811 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.h
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.h
@@ -31,57 +31,57 @@ class OpenCLDevice;
/**
- * @brief device representing an GPU OpenCL device.
- * an instance of this class represents a single cl_device
- */
-class OpenCLDevice: public Device {
+ * @brief device representing an GPU OpenCL device.
+ * an instance of this class represents a single cl_device
+ */
+class OpenCLDevice : public Device {
private:
/**
- *@brief opencl context
- */
+ * @brief opencl context
+ */
cl_context context;
/**
- *@brief opencl device
- */
+ * @brief opencl device
+ */
cl_device_id device;
/**
- *@brief opencl program
- */
+ * @brief opencl program
+ */
cl_program program;
/**
- *@brief opencl command queue
- */
+ * @brief opencl command queue
+ */
cl_command_queue queue;
public:
/**
- *@brief constructor with opencl device
- *@param context
- *@param device
- */
+ * @brief constructor with opencl device
+ * @param context
+ * @param device
+ */
OpenCLDevice(cl_context context, cl_device_id device, cl_program program);
/**
- * @brief initialize the device
- * During initialization the OpenCL cl_command_queue is created
- * the command queue is stored in the field queue.
- * @see queue
- */
+ * @brief initialize the device
+ * During initialization the OpenCL cl_command_queue is created
+ * the command queue is stored in the field queue.
+ * @see queue
+ */
bool initialize();
/**
- * @brief deinitialize the device
- * During deintiialization the command queue is cleared
- */
+ * @brief deinitialize the device
+ * During deintiialization the command queue is cleared
+ */
void deinitialize();
/**
- * @brief execute a WorkPackage
- * @param work the WorkPackage to execute
- */
+ * @brief execute a WorkPackage
+ * @param work the WorkPackage to execute
+ */
void execute(WorkPackage *work);
};
diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp
index 00d3518cd15..484254fe6de 100644
--- a/source/blender/compositor/intern/COM_OutputSocket.cpp
+++ b/source/blender/compositor/intern/COM_OutputSocket.cpp
@@ -25,63 +25,28 @@
#include "COM_SocketConnection.h"
#include "COM_NodeOperation.h"
-OutputSocket::OutputSocket(DataType datatype) :Socket(datatype)
+OutputSocket::OutputSocket(DataType datatype) : Socket(datatype)
{
- this->inputSocketDataTypeDeterminatorIndex = -1;
-}
-OutputSocket::OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex) :Socket(datatype)
-{
- this->inputSocketDataTypeDeterminatorIndex = inputSocketDataTypeDeterminatorIndex;
-}
-
-OutputSocket::OutputSocket(OutputSocket *from): Socket(from->getDataType())
-{
- this->inputSocketDataTypeDeterminatorIndex = from->getInputSocketDataTypeDeterminatorIndex();
+ /* pass */
}
int OutputSocket::isOutputSocket() const { return true; }
-const int OutputSocket::isConnected() const { return this->connections.size()!=0; }
+const int OutputSocket::isConnected() const { return this->connections.size() != 0; }
void OutputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
NodeBase *node = this->getNode();
if (node->isOperation()) {
- NodeOperation *operation = (NodeOperation*)node;
- operation->determineResolution(resolution, preferredResolution);
- operation->setResolution(resolution);
- }
-}
-
-void OutputSocket::determineActualDataType()
-{
- DataType actualDatatype = this->getNode()->determineActualDataType(this);
-
- /** @todo: set the channel info needs to be moved after integration with OCIO */
- this->channelinfo[0].setNumber(0);
- this->channelinfo[1].setNumber(1);
- this->channelinfo[2].setNumber(2);
- this->channelinfo[3].setNumber(3);
- switch (actualDatatype) {
- case COM_DT_VALUE:
- this->channelinfo[0].setType(COM_CT_Value);
- break;
- case COM_DT_VECTOR:
- this->channelinfo[0].setType(COM_CT_X);
- this->channelinfo[1].setType(COM_CT_Y);
- this->channelinfo[2].setType(COM_CT_Z);
- break;
- case COM_DT_COLOR:
- this->channelinfo[0].setType(COM_CT_ColorComponent);
- this->channelinfo[1].setType(COM_CT_ColorComponent);
- this->channelinfo[2].setType(COM_CT_ColorComponent);
- this->channelinfo[3].setType(COM_CT_Alpha);
- break;
- default:
- break;
+ NodeOperation *operation = (NodeOperation *)node;
+ if (operation->isResolutionSet()) {
+ resolution[0] = operation->getWidth();
+ resolution[1] = operation->getHeight();
+ }
+ else {
+ operation->determineResolution(resolution, preferredResolution);
+ operation->setResolution(resolution);
+ }
}
-
- this->setActualDataType(actualDatatype);
- this->fireActualDataType();
}
void OutputSocket::addConnection(SocketConnection *connection)
@@ -89,14 +54,6 @@ void OutputSocket::addConnection(SocketConnection *connection)
this->connections.push_back(connection);
}
-void OutputSocket::fireActualDataType()
-{
- unsigned int index;
- for (index = 0 ; index < this->connections.size();index ++) {
- SocketConnection *connection = this->connections[index];
- connection->getToSocket()->notifyActualInputType(this->getActualDataType());
- }
-}
void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single)
{
if (isConnected()) {
@@ -104,17 +61,15 @@ void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single)
SocketConnection *connection = this->connections[0];
connection->setFromSocket(relinkToSocket);
relinkToSocket->addConnection(connection);
-// relinkToSocket->setActualDataType(this->getActualDataType());
this->connections.erase(this->connections.begin());
}
else {
unsigned int index;
- for (index = 0 ; index < this->connections.size();index ++) {
+ for (index = 0; index < this->connections.size(); index++) {
SocketConnection *connection = this->connections[index];
connection->setFromSocket(relinkToSocket);
relinkToSocket->addConnection(connection);
}
-// relinkToSocket->setActualDataType(this->getActualDataType());
this->connections.clear();
}
}
@@ -139,21 +94,16 @@ void OutputSocket::clearConnections()
WriteBufferOperation *OutputSocket::findAttachedWriteBufferOperation() const
{
unsigned int index;
- for (index = 0 ; index < this->connections.size();index++) {
+ for (index = 0; index < this->connections.size(); index++) {
SocketConnection *connection = this->connections[index];
NodeBase *node = connection->getToNode();
if (node->isOperation()) {
- NodeOperation *operation = (NodeOperation*)node;
+ NodeOperation *operation = (NodeOperation *)node;
if (operation->isWriteBufferOperation()) {
- return (WriteBufferOperation*)operation;
+ return (WriteBufferOperation *)operation;
}
}
}
return NULL;
}
-ChannelInfo *OutputSocket::getChannelInfo(const int channelnumber)
-{
- return &this->channelinfo[channelnumber];
-}
-
diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h
index 640588417b4..c073703c423 100644
--- a/source/blender/compositor/intern/COM_OutputSocket.h
+++ b/source/blender/compositor/intern/COM_OutputSocket.h
@@ -37,68 +37,46 @@ class WriteBufferOperation;
//#define COM_ST_OUTPUT 1
/**
- * @brief OutputSocket are sockets that can send data/input
- * @ingroup Model
- */
+ * @brief OutputSocket are sockets that can send data/input
+ * @ingroup Model
+ */
class OutputSocket : public Socket {
private:
- vector<SocketConnection*> connections;
-
- /**
- * @brief index of the inputsocket that determines the datatype of this outputsocket
- * -1 will not use any inputsocket to determine the datatype, but use the outputsocket
- * default datatype.
- */
- int inputSocketDataTypeDeterminatorIndex;
-
- ChannelInfo channelinfo[4];
+ vector<SocketConnection *> connections;
+
void removeFirstConnection();
public:
OutputSocket(DataType datatype);
OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex);
- OutputSocket(OutputSocket * from);
+ OutputSocket(OutputSocket *from);
void addConnection(SocketConnection *connection);
- SocketConnection *getConnection(unsigned int index) {return this->connections[index];}
+ SocketConnection *getConnection(unsigned int index) { return this->connections[index]; }
const int isConnected() const;
int isOutputSocket() const;
/**
- * @brief determine the resolution of this socket
- * @param resolution the result of this operation
- * @param preferredResolution the preferrable resolution as no resolution could be determined
- */
+ * @brief determine the resolution of this socket
+ * @param resolution the result of this operation
+ * @param preferredResolution the preferrable resolution as no resolution could be determined
+ */
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
/**
- * @brief determine the actual data type and channel info.
- */
- void determineActualDataType();
- void relinkConnections(OutputSocket *relinkToSocket) {this->relinkConnections(relinkToSocket, false);};
+ * @brief determine the actual data type and channel info.
+ */
+ void relinkConnections(OutputSocket *relinkToSocket) { this->relinkConnections(relinkToSocket, false); };
void relinkConnections(OutputSocket *relinkToSocket, bool single);
- bool isActualDataTypeDeterminedByInputSocket() {
- return this->inputSocketDataTypeDeterminatorIndex>-1;
- }
- const int getNumberOfConnections() {return connections.size();}
+ const int getNumberOfConnections() { return connections.size(); }
- /**
- * @brief get the index of the inputsocket that determines the datatype of this outputsocket
- */
- int getInputSocketDataTypeDeterminatorIndex() {return this->inputSocketDataTypeDeterminatorIndex;}
void clearConnections();
/**
- * @brief find a connected write buffer operation to this OutputSocket
- * @return WriteBufferOperation or NULL
- */
+ * @brief find a connected write buffer operation to this OutputSocket
+ * @return WriteBufferOperation or NULL
+ */
WriteBufferOperation *findAttachedWriteBufferOperation() const;
ChannelInfo *getChannelInfo(const int channelnumber);
- /**
- * @brief trigger determine actual data type to all connected sockets
- * @note will only be triggered just after the actual data type is set.
- */
- void fireActualDataType();
-
private:
};
diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp
new file mode 100644
index 00000000000..01043664412
--- /dev/null
+++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SingleThreadedNodeOperation.h"
+
+SingleThreadedNodeOperation::SingleThreadedNodeOperation() : NodeOperation()
+{
+ this->cachedInstance = NULL;
+ setComplex(true);
+}
+
+void SingleThreadedNodeOperation::initExecution()
+{
+ initMutex();
+}
+
+void SingleThreadedNodeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+ this->cachedInstance->read(color, x, y);
+}
+
+void SingleThreadedNodeOperation::deinitExecution()
+{
+ deinitMutex();
+ if (this->cachedInstance) {
+ delete cachedInstance;
+ this->cachedInstance = NULL;
+ }
+}
+void *SingleThreadedNodeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+ if (this->cachedInstance) return this->cachedInstance;
+
+ lockMutex();
+ if (this->cachedInstance == NULL) {
+ //
+ this->cachedInstance = createMemoryBuffer(rect, memoryBuffers);
+ }
+ unlockMutex();
+ return this->cachedInstance;
+}
diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h
new file mode 100644
index 00000000000..b1bf28c9c07
--- /dev/null
+++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SingleThreadedNodeOperation_h
+#define _COM_SingleThreadedNodeOperation_h
+#include "COM_NodeOperation.h"
+
+class SingleThreadedNodeOperation : public NodeOperation {
+private:
+ MemoryBuffer *cachedInstance;
+
+protected:
+ inline bool isCached() {
+ return cachedInstance != NULL;
+ }
+
+public:
+ SingleThreadedNodeOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ virtual MemoryBuffer *createMemoryBuffer(rcti *rect, MemoryBuffer **memoryBuffers) = 0;
+
+ int isSingleThreaded() { return true; }
+};
+#endif
diff --git a/source/blender/compositor/intern/COM_Socket.cpp b/source/blender/compositor/intern/COM_Socket.cpp
index a5336ac1202..11739a4e9c5 100644
--- a/source/blender/compositor/intern/COM_Socket.cpp
+++ b/source/blender/compositor/intern/COM_Socket.cpp
@@ -27,7 +27,6 @@
Socket::Socket(DataType datatype)
{
this->datatype = datatype;
- this->actualType = COM_DT_UNKNOWN;
this->editorSocket = NULL;
this->node = NULL;
}
@@ -39,12 +38,6 @@ DataType Socket::getDataType() const
int Socket::isInputSocket() const { return false; }
int Socket::isOutputSocket() const { return false; }
-const int Socket::isConnected() const {return false;}
-void Socket::setNode(NodeBase *node) {this->node = node;}
-NodeBase *Socket::getNode() const {return this->node;}
-
-DataType Socket::getActualDataType() const {return this->actualType;}
-void Socket::setActualDataType(DataType actualType)
-{
- this->actualType = actualType;
-}
+const int Socket::isConnected() const { return false; }
+void Socket::setNode(NodeBase *node) { this->node = node; }
+NodeBase *Socket::getNode() const { return this->node; }
diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h
index 8ad7a5c7fde..7c5c2198a16 100644
--- a/source/blender/compositor/intern/COM_Socket.h
+++ b/source/blender/compositor/intern/COM_Socket.h
@@ -34,35 +34,29 @@ class SocketConnection;
class NodeBase;
/**
- * @brief Base class for InputSocket and OutputSocket.
- *
- * A socket are the points on an node where the user can make a connection between.
- * Sockets are always part of a node or an operation.
- *
- * @see InputSocket
- * @see OutputSocket
- * @see SocketConnection - a connection between an InputSocket and an OutputSocket
- * @ingroup Model
- */
+ * @brief Base class for InputSocket and OutputSocket.
+ *
+ * A socket are the points on an node where the user can make a connection between.
+ * Sockets are always part of a node or an operation.
+ *
+ * @see InputSocket
+ * @see OutputSocket
+ * @see SocketConnection - a connection between an InputSocket and an OutputSocket
+ * @ingroup Model
+ */
class Socket {
private:
/**
- * Reference to the node where this Socket belongs to
- */
+ * Reference to the node where this Socket belongs to
+ */
NodeBase *node;
/**
- * the datatype of this socket. Is used for automatically data transformation.
- * @section data-conversion
- */
+ * the datatype of this socket. Is used for automatically data transformation.
+ * @section data-conversion
+ */
DataType datatype;
- /**
- * the actual data type during execution. This can be different than the field datatype, based on the conversion rules of the node
- * @section data-conversion
- */
- DataType actualType;
-
bNodeSocket *editorSocket;
public:
Socket(DataType datatype);
@@ -71,28 +65,14 @@ public:
void setNode(NodeBase *node);
NodeBase *getNode() const;
- /**
- * @brief get the actual data type
- *
- * @note The actual data type can differ from the data type this socket expects.
- * @return actual DataType
- */
- DataType getActualDataType() const;
-
- /**
- * @brief set the actual data type
- * @param actualType the new actual type
- */
- void setActualDataType(DataType actualType);
-
+
const virtual int isConnected() const;
int isInputSocket() const;
int isOutputSocket() const;
virtual void determineResolution(int resolution[], unsigned int preferredResolution[]) {}
- virtual void determineActualDataType() {}
-
- void setEditorSocket(bNodeSocket *editorSocket) {this->editorSocket = editorSocket;}
- bNodeSocket *getbNodeSocket() const {return this->editorSocket;}
+
+ void setEditorSocket(bNodeSocket *editorSocket) { this->editorSocket = editorSocket; }
+ bNodeSocket *getbNodeSocket() const { return this->editorSocket; }
};
diff --git a/source/blender/compositor/intern/COM_SocketConnection.cpp b/source/blender/compositor/intern/COM_SocketConnection.cpp
index 9f0c736392a..1edeb6158b9 100644
--- a/source/blender/compositor/intern/COM_SocketConnection.cpp
+++ b/source/blender/compositor/intern/COM_SocketConnection.cpp
@@ -38,7 +38,7 @@ void SocketConnection::setFromSocket(OutputSocket *fromsocket)
this->fromSocket = fromsocket;
}
-OutputSocket *SocketConnection::getFromSocket() const {return this->fromSocket;}
+OutputSocket *SocketConnection::getFromSocket() const { return this->fromSocket; }
void SocketConnection::setToSocket(InputSocket *tosocket)
{
if (tosocket == NULL) {
@@ -47,7 +47,7 @@ void SocketConnection::setToSocket(InputSocket *tosocket)
this->toSocket = tosocket;
}
-InputSocket *SocketConnection::getToSocket() const {return this->toSocket;}
+InputSocket *SocketConnection::getToSocket() const { return this->toSocket; }
NodeBase *SocketConnection::getFromNode() const
{
@@ -79,10 +79,10 @@ bool SocketConnection::isValid() const
bool SocketConnection::needsResolutionConversion() const
{
- if (this->ignoreResizeCheck) {return false;}
- NodeOperation *fromOperation = (NodeOperation*)this->getFromNode();
- NodeOperation *toOperation = (NodeOperation*)this->getToNode();
- if (this->toSocket->getResizeMode() == COM_SC_NO_RESIZE) {return false;}
+ if (this->ignoreResizeCheck) { return false; }
+ NodeOperation *fromOperation = (NodeOperation *)this->getFromNode();
+ NodeOperation *toOperation = (NodeOperation *)this->getToNode();
+ if (this->toSocket->getResizeMode() == COM_SC_NO_RESIZE) { return false; }
const unsigned int fromWidth = fromOperation->getWidth();
const unsigned int fromHeight = fromOperation->getHeight();
const unsigned int toWidth = toOperation->getWidth();
diff --git a/source/blender/compositor/intern/COM_SocketConnection.h b/source/blender/compositor/intern/COM_SocketConnection.h
index 1c4dcebfe07..5385c5be49b 100644
--- a/source/blender/compositor/intern/COM_SocketConnection.h
+++ b/source/blender/compositor/intern/COM_SocketConnection.h
@@ -29,94 +29,94 @@
#include "COM_ChannelInfo.h"
/**
- * @brief An SocketConnection is an connection between an InputSocket and an OutputSocket.
- *
- * <pre>
- * +----------+ To InputSocket +----------+
- * | From | SocketConnection \| To Node |
- * | Node *====================* |
- * | |\ | |
- * | | From OutputSocket +----------+
- * +----------+
- * </pre>
- * @ingroup Model
- * @see InputSocket
- * @see OutputSocket
- */
+ * @brief An SocketConnection is an connection between an InputSocket and an OutputSocket.
+ *
+ * <pre>
+ * +----------+ To InputSocket +----------+
+ * | From | SocketConnection \| To Node |
+ * | Node *====================* |
+ * | |\ | |
+ * | | From OutputSocket +----------+
+ * +----------+
+ * </pre>
+ * @ingroup Model
+ * @see InputSocket
+ * @see OutputSocket
+ */
class SocketConnection {
private:
/**
- * @brief Startpoint of the connection
- */
+ * @brief Startpoint of the connection
+ */
OutputSocket *fromSocket;
/**
- * @brief Endpoint of the connection
- */
+ * @brief Endpoint of the connection
+ */
InputSocket *toSocket;
/**
- * @brief has the resize already been done for this connection
- */
+ * @brief has the resize already been done for this connection
+ */
bool ignoreResizeCheck;
public:
SocketConnection();
/**
- * @brief set the startpoint of the connection
- * @param fromsocket
- */
+ * @brief set the startpoint of the connection
+ * @param fromsocket
+ */
void setFromSocket(OutputSocket *fromsocket);
/**
- * @brief get the startpoint of the connection
- * @return from OutputSocket
- */
+ * @brief get the startpoint of the connection
+ * @return from OutputSocket
+ */
OutputSocket *getFromSocket() const;
/**
- * @brief set the endpoint of the connection
- * @param tosocket
- */
+ * @brief set the endpoint of the connection
+ * @param tosocket
+ */
void setToSocket(InputSocket *tosocket);
/**
- * @brief get the endpoint of the connection
- * @return to InputSocket
- */
+ * @brief get the endpoint of the connection
+ * @return to InputSocket
+ */
InputSocket *getToSocket() const;
/**
- * @brief check if this connection is valid
- */
+ * @brief check if this connection is valid
+ */
bool isValid() const;
/**
- * @brief return the Node where this connection is connected from
- */
- NodeBase * getFromNode() const;
+ * @brief return the Node where this connection is connected from
+ */
+ NodeBase *getFromNode() const;
/**
- * @brief return the Node where this connection is connected to
- */
- NodeBase * getToNode() const;
+ * @brief return the Node where this connection is connected to
+ */
+ NodeBase *getToNode() const;
/**
- * @brief set, whether the resize has already been done for this SocketConnection
- */
- void setIgnoreResizeCheck(bool check) {this->ignoreResizeCheck = check;}
+ * @brief set, whether the resize has already been done for this SocketConnection
+ */
+ void setIgnoreResizeCheck(bool check) { this->ignoreResizeCheck = check; }
/**
- * @brief has the resize already been done for this SocketConnection
- */
- bool isIgnoreResizeCheck() const { return this->ignoreResizeCheck;}
+ * @brief has the resize already been done for this SocketConnection
+ */
+ bool isIgnoreResizeCheck() const { return this->ignoreResizeCheck; }
/**
- * @brief does this SocketConnection need resolution conversion
- * @note PreviewOperation's will be ignored
- * @note Already converted SocketConnection's will be ignored
- * @return needs conversion [true:false]
- */
+ * @brief does this SocketConnection need resolution conversion
+ * @note PreviewOperation's will be ignored
+ * @note Already converted SocketConnection's will be ignored
+ * @return needs conversion [true:false]
+ */
bool needsResolutionConversion() const;
};
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index 24322847517..3eb39e4bf02 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -33,43 +33,43 @@ typedef enum PixelSampler {
class MemoryBuffer;
/**
- * @brief Helper class for reading socket data.
- * Only use this class for dispatching (un-ary and n-ary) executions.
- * @ingroup Execution
- */
+ * @brief Helper class for reading socket data.
+ * Only use this class for dispatching (un-ary and n-ary) executions.
+ * @ingroup Execution
+ */
class SocketReader {
private:
protected:
/**
- * @brief Holds the width of the output of this operation.
- */
+ * @brief Holds the width of the output of this operation.
+ */
unsigned int width;
/**
- * @brief Holds the height of the output of this operation.
- */
+ * @brief Holds the height of the output of this operation.
+ */
unsigned int height;
/**
- * @brief calculate a single pixel
- * @note this method is called for non-complex
- * @param result is a float[4] array to store the result
- * @param x the x-coordinate of the pixel to calculate in image space
- * @param y the y-coordinate of the pixel to calculate in image space
- * @param inputBuffers chunks that can be read by their ReadBufferOperation.
- */
+ * @brief calculate a single pixel
+ * @note this method is called for non-complex
+ * @param result is a float[4] array to store the result
+ * @param x the x-coordinate of the pixel to calculate in image space
+ * @param y the y-coordinate of the pixel to calculate in image space
+ * @param inputBuffers chunks that can be read by their ReadBufferOperation.
+ */
virtual void executePixel(float *result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {}
/**
- * @brief calculate a single pixel
- * @note this method is called for complex
- * @param result is a float[4] array to store the result
- * @param x the x-coordinate of the pixel to calculate in image space
- * @param y the y-coordinate of the pixel to calculate in image space
- * @param inputBuffers chunks that can be read by their ReadBufferOperation.
- * @param chunkData chunk specific data a during execution time.
- */
+ * @brief calculate a single pixel
+ * @note this method is called for complex
+ * @param result is a float[4] array to store the result
+ * @param x the x-coordinate of the pixel to calculate in image space
+ * @param y the y-coordinate of the pixel to calculate in image space
+ * @param inputBuffers chunks that can be read by their ReadBufferOperation.
+ * @param chunkData chunk specific data a during execution time.
+ */
virtual void executePixel(float *result, int x, int y, MemoryBuffer *inputBuffers[], void *chunkData) {
executePixel(result, x, y, COM_PS_NEAREST, inputBuffers);
}
@@ -97,17 +97,15 @@ public:
executePixel(result, x, y, dx, dy, inputBuffers);
}
- virtual void *initializeTileData(rcti *rect, MemoryBuffer** memoryBuffers) {
- return 0;
- }
- virtual void deinitializeTileData(rcti *rect, MemoryBuffer** memoryBuffers, void *data) {
+ virtual void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { return 0; }
+ virtual void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) {
}
- virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return 0;}
+ virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; }
- inline const unsigned int getWidth() const {return this->width;}
- inline const unsigned int getHeight() const {return this->height;}
+ inline const unsigned int getWidth() const { return this->width; }
+ inline const unsigned int getHeight() const { return this->height; }
};
#endif
diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h
index 8bdf21499cf..18d83cc151c 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.h
+++ b/source/blender/compositor/intern/COM_WorkPackage.h
@@ -28,37 +28,37 @@ class WorkPackage;
#include "COM_ExecutionGroup.h"
/**
- * @brief contains data about work that can be scheduled
- * @see WorkScheduler
- */
+ * @brief contains data about work that can be scheduled
+ * @see WorkScheduler
+ */
class WorkPackage {
private:
/**
- * @brief executionGroup with the operations-setup to be evaluated
- */
+ * @brief executionGroup with the operations-setup to be evaluated
+ */
ExecutionGroup *executionGroup;
/**
- * @brief number of the chunk to be executed
- */
+ * @brief number of the chunk to be executed
+ */
unsigned int chunkNumber;
public:
/**
- * @constructor
- * @param group the ExecutionGroup
- * @param chunkNumber the number of the chunk
- */
+ * @constructor
+ * @param group the ExecutionGroup
+ * @param chunkNumber the number of the chunk
+ */
WorkPackage(ExecutionGroup *group, unsigned int chunkNumber);
/**
- * @brief get the ExecutionGroup
- */
- ExecutionGroup *getExecutionGroup() const {return this->executionGroup;}
+ * @brief get the ExecutionGroup
+ */
+ ExecutionGroup *getExecutionGroup() const { return this->executionGroup; }
/**
- * @brief get the number of the chunk
- */
- unsigned int getChunkNumber() const {return this->chunkNumber;}
+ * @brief get the number of the chunk
+ */
+ unsigned int getChunkNumber() const { return this->chunkNumber; }
};
#endif
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index ba8bfe55310..fb7a8f8a764 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -40,19 +40,19 @@
/// @brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created
-static vector<CPUDevice*> cpudevices;
+static vector<CPUDevice *> cpudevices;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
/// @brief list of all thread for every CPUDevice in cpudevices a thread exists
static ListBase cputhreads;
/// @brief all scheduled work for the cpu
-static ThreadQueue * cpuqueue;
-static ThreadQueue * gpuqueue;
+static ThreadQueue *cpuqueue;
+static ThreadQueue *gpuqueue;
#ifdef COM_OPENCL_ENABLED
static cl_context context;
static cl_program program;
/// @brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is created
-static vector<OpenCLDevice*> gpudevices;
+static vector<OpenCLDevice *> gpudevices;
/// @brief list of all thread for every GPUDevice in cpudevices a thread exists
static ListBase gputhreads;
/// @brief all scheduled work for the gpu
@@ -66,10 +66,10 @@ static bool openclActive = false;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
void *WorkScheduler::thread_execute_cpu(void *data)
{
- Device *device = (Device*)data;
+ Device *device = (Device *)data;
WorkPackage *work;
- while ((work = (WorkPackage*)BLI_thread_queue_pop(cpuqueue))) {
+ while ((work = (WorkPackage *)BLI_thread_queue_pop(cpuqueue))) {
device->execute(work);
delete work;
}
@@ -79,10 +79,10 @@ void *WorkScheduler::thread_execute_cpu(void *data)
void *WorkScheduler::thread_execute_gpu(void *data)
{
- Device *device = (Device*)data;
+ Device *device = (Device *)data;
WorkPackage *work;
- while ((work = (WorkPackage*)BLI_thread_queue_pop(gpuqueue))) {
+ while ((work = (WorkPackage *)BLI_thread_queue_pop(gpuqueue))) {
device->execute(work);
delete work;
}
@@ -120,7 +120,7 @@ void WorkScheduler::start(CompositorContext &context)
unsigned int index;
cpuqueue = BLI_thread_queue_init();
BLI_init_threads(&cputhreads, thread_execute_cpu, cpudevices.size());
- for (index = 0 ; index < cpudevices.size() ; index ++) {
+ for (index = 0; index < cpudevices.size(); index++) {
Device *device = cpudevices[index];
BLI_insert_thread(&cputhreads, device);
}
@@ -128,7 +128,7 @@ void WorkScheduler::start(CompositorContext &context)
if (context.getHasActiveOpenCLDevices()) {
gpuqueue = BLI_thread_queue_init();
BLI_init_threads(&gputhreads, thread_execute_gpu, gpudevices.size());
- for (index = 0 ; index < gpudevices.size() ; index ++) {
+ for (index = 0; index < gpudevices.size(); index++) {
Device *device = gpudevices[index];
BLI_insert_thread(&gputhreads, device);
}
@@ -178,7 +178,7 @@ bool WorkScheduler::hasGPUDevices()
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
#ifdef COM_OPENCL_ENABLED
- return gpudevices.size()>0;
+ return gpudevices.size() > 0;
#else
return 0;
#endif
@@ -197,7 +197,7 @@ void WorkScheduler::initialize()
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
int numberOfCPUThreads = BLI_system_thread_count();
- for (int index = 0 ; index < numberOfCPUThreads ; index ++) {
+ for (int index = 0; index < numberOfCPUThreads; index++) {
CPUDevice *device = new CPUDevice();
device->initialize();
cpudevices.push_back(device);
@@ -209,13 +209,13 @@ void WorkScheduler::initialize()
cl_uint numberOfPlatforms = 0;
cl_int error;
error = clGetPlatformIDs(0, 0, &numberOfPlatforms);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
if (G.f & G_DEBUG) printf("%d number of platforms\n", numberOfPlatforms);
cl_platform_id *platforms = new cl_platform_id[numberOfPlatforms];
error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
unsigned int indexPlatform;
cl_uint totalNumberOfDevices = 0;
- for (indexPlatform = 0 ; indexPlatform < numberOfPlatforms ; indexPlatform ++) {
+ for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) {
cl_platform_id platform = platforms[indexPlatform];
cl_uint numberOfDevices;
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
@@ -224,16 +224,16 @@ void WorkScheduler::initialize()
cl_device_id *cldevices = new cl_device_id[totalNumberOfDevices];
unsigned int numberOfDevicesReceived = 0;
- for (indexPlatform = 0 ; indexPlatform < numberOfPlatforms ; indexPlatform ++) {
+ for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) {
cl_platform_id platform = platforms[indexPlatform];
cl_uint numberOfDevices;
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
- clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices+numberOfDevicesReceived*sizeof (cl_device_id), 0);
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices + numberOfDevicesReceived * sizeof (cl_device_id), 0);
numberOfDevicesReceived += numberOfDevices;
}
if (totalNumberOfDevices > 0) {
context = clCreateContext(NULL, totalNumberOfDevices, cldevices, clContextError, NULL, &error);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
program = clCreateProgramWithSource(context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error);
error = clBuildProgram(program, totalNumberOfDevices, cldevices, 0, 0, 0);
if (error != CL_SUCCESS) {
@@ -241,10 +241,10 @@ void WorkScheduler::initialize()
size_t ret_val_size = 0;
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
- if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- char *build_log = new char[ret_val_size+1];
+ if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ char *build_log = new char[ret_val_size + 1];
error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
- if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
build_log[ret_val_size] = '\0';
printf("%s", build_log);
delete build_log;
@@ -252,11 +252,11 @@ void WorkScheduler::initialize()
}
else {
unsigned int indexDevices;
- for (indexDevices = 0 ; indexDevices < totalNumberOfDevices ; indexDevices ++) {
+ for (indexDevices = 0; indexDevices < totalNumberOfDevices; indexDevices++) {
cl_device_id device = cldevices[indexDevices];
OpenCLDevice *clDevice = new OpenCLDevice(context, device, program);
clDevice->initialize(),
- gpudevices.push_back(clDevice);
+ gpudevices.push_back(clDevice);
if (G.f & G_DEBUG) {
char resultString[32];
error = clGetDeviceInfo(device, CL_DEVICE_NAME, 32, resultString, 0);
@@ -267,8 +267,8 @@ void WorkScheduler::initialize()
}
}
}
- delete [] cldevices;
- delete [] platforms;
+ delete[] cldevices;
+ delete[] platforms;
}
#endif
#endif
@@ -278,14 +278,14 @@ void WorkScheduler::deinitialize()
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
Device *device;
- while (cpudevices.size()>0) {
+ while (cpudevices.size() > 0) {
device = cpudevices.back();
cpudevices.pop_back();
device->deinitialize();
delete device;
}
#ifdef COM_OPENCL_ENABLED
- while (gpudevices.size()>0) {
+ while (gpudevices.size() > 0) {
device = gpudevices.back();
gpudevices.pop_back();
device->deinitialize();
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
index b03b514d139..e52e0295607 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.h
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -32,83 +32,83 @@ extern "C" {
#include "COM_Device.h"
/** @brief the workscheduler
- * @ingroup execution
- */
+ * @ingroup execution
+ */
class WorkScheduler {
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
/**
- * @brief are we being stopped.
- */
+ * @brief are we being stopped.
+ */
static bool isStopping();
/**
- * @brief main thread loop for cpudevices
- * inside this loop new work is queried and being executed
- */
+ * @brief main thread loop for cpudevices
+ * inside this loop new work is queried and being executed
+ */
static void *thread_execute_cpu(void *data);
/**
- * @brief main thread loop for gpudevices
- * inside this loop new work is queried and being executed
- */
+ * @brief main thread loop for gpudevices
+ * inside this loop new work is queried and being executed
+ */
static void *thread_execute_gpu(void *data);
#endif
public:
/**
- * @brief schedule a chunk of a group to be calculated.
- * An execution group schedules a chunk in the WorkScheduler
- * when ExecutionGroup.isOpenCL is set the work will be handled by a OpenCLDevice
- * otherwide the work is scheduled for an CPUDevice
- * @see ExecutionGroup.execute
- * @param group the execution group
- * @param chunkNumber the number of the chunk in the group to be executed
- */
+ * @brief schedule a chunk of a group to be calculated.
+ * An execution group schedules a chunk in the WorkScheduler
+ * when ExecutionGroup.isOpenCL is set the work will be handled by a OpenCLDevice
+ * otherwide the work is scheduled for an CPUDevice
+ * @see ExecutionGroup.execute
+ * @param group the execution group
+ * @param chunkNumber the number of the chunk in the group to be executed
+ */
static void schedule(ExecutionGroup *group, int chunkNumber);
/**
- * @brief initialize the WorkScheduler
- *
- * during initialization the mutexes are initialized.
- * there are two mutexes (for every device type one)
- * After mutex initialization the system is queried in order to count the number of CPUDevices and GPUDevices to be created.
- * For every hardware thread a CPUDevice and for every OpenCL GPU device a OpenCLDevice is created.
- * these devices are stored in a separate list (cpudevices & gpudevices)
- */
+ * @brief initialize the WorkScheduler
+ *
+ * during initialization the mutexes are initialized.
+ * there are two mutexes (for every device type one)
+ * After mutex initialization the system is queried in order to count the number of CPUDevices and GPUDevices to be created.
+ * For every hardware thread a CPUDevice and for every OpenCL GPU device a OpenCLDevice is created.
+ * these devices are stored in a separate list (cpudevices & gpudevices)
+ */
static void initialize();
/**
- * @brief deinitialize the WorkScheduler
- * free all allocated resources
- */
+ * @brief deinitialize the WorkScheduler
+ * free all allocated resources
+ */
static void deinitialize();
/**
- * @brief Start the execution
- * this methods will start the WorkScheduler. Inside this method all threads are initialized.
- * for every device a thread is created.
- * @see initialize Initialization and query of the number of devices
- */
+ * @brief Start the execution
+ * this methods will start the WorkScheduler. Inside this method all threads are initialized.
+ * for every device a thread is created.
+ * @see initialize Initialization and query of the number of devices
+ */
static void start(CompositorContext &context);
/**
- * @brief stop the execution
- * All created thread by the start method are destroyed.
- * @see start
- */
+ * @brief stop the execution
+ * All created thread by the start method are destroyed.
+ * @see start
+ */
static void stop();
/**
- * @brief wait for all work to be completed.
- */
+ * @brief wait for all work to be completed.
+ */
static void finish();
/**
- * @brief Are there OpenCL capable GPU devices initialized?
- * the result of this method is stored in the CompositorContext
- * A node can generate a different operation tree when OpenCLDevices exists.
- * @see CompositorContext.getHasActiveOpenCLDevices
- */
+ * @brief Are there OpenCL capable GPU devices initialized?
+ * the result of this method is stored in the CompositorContext
+ * A node can generate a different operation tree when OpenCLDevices exists.
+ * @see CompositorContext.getHasActiveOpenCLDevices
+ */
static bool hasGPUDevices();
};
#endif
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
index e27bff4401e..2bbfd18e7c5 100644
--- a/source/blender/compositor/intern/COM_compositor.cpp
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -51,7 +51,6 @@ void COM_execute(bNodeTree *editingtree, int rendering)
/* set progress bar to 0% and status to init compositing*/
editingtree->progress(editingtree->prh, 0.0);
- editingtree->stats_draw(editingtree->sdh, (char*)"Compositing");
/* initialize execution system */
ExecutionSystem *system = new ExecutionSystem(editingtree, rendering);
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
index eb3cd821172..4f3ed36aadb 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
@@ -31,7 +31,7 @@
#include "COM_SetValueOperation.h"
#include "DNA_material_types.h" // the ramp types
-void AlphaOverNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void AlphaOverNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *valueSocket = this->getInputSocket(0);
InputSocket *color1Socket = this->getInputSocket(1);
@@ -40,8 +40,8 @@ void AlphaOverNode::convertToOperations(ExecutionSystem *graph, CompositorContex
bNode *editorNode = this->getbNode();
MixBaseOperation *convertProg;
- NodeTwoFloats *ntf = (NodeTwoFloats*)editorNode->storage;
- if (ntf->x!= 0.0f) {
+ NodeTwoFloats *ntf = (NodeTwoFloats *)editorNode->storage;
+ if (ntf->x != 0.0f) {
AlphaOverMixedOperation *mixOperation = new AlphaOverMixedOperation();
mixOperation->setX(ntf->x);
convertProg = mixOperation;
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h
index 64f78e76837..f7375d9a7c5 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.h
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief AlphaOverNode
- * @ingroup Node
- */
-class AlphaOverNode: public Node {
+ * @brief AlphaOverNode
+ * @ingroup Node
+ */
+class AlphaOverNode : public Node {
public:
- AlphaOverNode(bNode *editorNode) :Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ AlphaOverNode(bNode *editorNode) : Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
index fa654d35785..f96a92068f4 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
@@ -26,13 +26,14 @@
#include "COM_ExecutionSystem.h"
#include "COM_BilateralBlurOperation.h"
-BilateralBlurNode::BilateralBlurNode(bNode *editorNode): Node(editorNode)
+BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- NodeBilateralBlurData *data = (NodeBilateralBlurData*)this->getbNode()->storage;
+ NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage;
BilateralBlurOperation *operation = new BilateralBlurOperation();
operation->setQuality(context->getQuality());
operation->setData(data);
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.h b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
index a92de0eaa62..e6f9242fa32 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief BilateralBlurNode
- * @ingroup Node
- */
-class BilateralBlurNode: public Node {
+ * @brief BilateralBlurNode
+ * @ingroup Node
+ */
+class BilateralBlurNode : public Node {
public:
BilateralBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index d9cf2c2fef0..1b541d81c33 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -29,25 +29,23 @@
#include "COM_GaussianBokehBlurOperation.h"
#include "COM_FastGaussianBlurOperation.h"
-BlurNode::BlurNode(bNode *editorNode): Node(editorNode)
+BlurNode::BlurNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
bNode *editorNode = this->getbNode();
- NodeBlurData * data = (NodeBlurData*)editorNode->storage;
- InputSocket * inputSizeSocket = this->getInputSocket(1);
+ NodeBlurData *data = (NodeBlurData *)editorNode->storage;
+ InputSocket *inputSizeSocket = this->getInputSocket(1);
bool connectedSizeSocket = inputSizeSocket->isConnected();
const bNodeSocket *sock = this->getInputSocket(1)->getbNodeSocket();
- const float size = ((const bNodeSocketValueFloat*)sock->default_value)->value;
+ const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value;
CompositorQuality quality = context->getQuality();
- if (data->filtertype == R_FILTER_MITCH || data->filtertype == R_FILTER_CATROM) {
- quality = COM_QUALITY_HIGH;
- }
if (data->filtertype == R_FILTER_FAST_GAUSS) {
FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
operationfgb->setData(data);
diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h
index 04a680c32cf..e7daff1c414 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.h
+++ b/source/blender/compositor/nodes/COM_BlurNode.h
@@ -26,14 +26,14 @@
#include "COM_Node.h"
/**
- * @brief BlurNode
- * @ingroup Node
- */
+ * @brief BlurNode
+ * @ingroup Node
+ */
-class BlurNode: public Node {
+class BlurNode : public Node {
public:
BlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
index abae1b88890..296056b6c48 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
@@ -30,11 +30,12 @@
#include "COM_VariableSizeBokehBlurOperation.h"
#include "COM_ConvertDepthToRadiusOperation.h"
-BokehBlurNode::BokehBlurNode(bNode *editorNode): Node(editorNode)
+BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
Object *camob = context->getScene()->camera;
@@ -58,7 +59,7 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph);
- operation->setSize(((bNodeSocketValueFloat*)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
+ operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
operation->setQuality(context->getQuality());
graph->addOperation(operation);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h
index eb9fada5112..5ce75a7d42b 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h
@@ -26,14 +26,14 @@
#include "COM_Node.h"
/**
- * @brief BokehBlurNode
- * @ingroup Node
- */
+ * @brief BokehBlurNode
+ * @ingroup Node
+ */
-class BokehBlurNode: public Node {
+class BokehBlurNode : public Node {
public:
BokehBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
index f498fa11e30..75f5e07d552 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
@@ -25,15 +25,16 @@
#include "COM_BokehImageOperation.h"
#include "COM_ExecutionSystem.h"
-BokehImageNode::BokehImageNode(bNode *editorNode): Node(editorNode)
+BokehImageNode::BokehImageNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void BokehImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BokehImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
BokehImageOperation *operation = new BokehImageOperation();
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
graph->addOperation(operation);
- operation->setData((NodeBokehImage*)this->getbNode()->storage);
+ operation->setData((NodeBokehImage *)this->getbNode()->storage);
addPreviewOperation(graph, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.h b/source/blender/compositor/nodes/COM_BokehImageNode.h
index d4fabf0e516..a4bfe2bedc0 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.h
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief BokehImageNode
- * @ingroup Node
- */
-class BokehImageNode: public Node {
+ * @brief BokehImageNode
+ * @ingroup Node
+ */
+class BokehImageNode : public Node {
public:
BokehImageNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
index e99252663d0..789ff265a5c 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
@@ -25,15 +25,16 @@
#include "COM_BoxMaskOperation.h"
#include "COM_ExecutionSystem.h"
-BoxMaskNode::BoxMaskNode(bNode *editorNode): Node(editorNode)
+BoxMaskNode::BoxMaskNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void BoxMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BoxMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
BoxMaskOperation *operation;
operation = new BoxMaskOperation();
- operation->setData((NodeBoxMask*)this->getbNode()->storage);
+ operation->setData((NodeBoxMask *)this->getbNode()->storage);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.h b/source/blender/compositor/nodes/COM_BoxMaskNode.h
index c71c6a18388..9ebe2cc755a 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.h
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief BoxMaskNode
- * @ingroup Node
- */
-class BoxMaskNode: public Node {
+ * @brief BoxMaskNode
+ * @ingroup Node
+ */
+class BoxMaskNode : public Node {
public:
BoxMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cpp b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
index 9ccb58a45de..1e1fbdbc301 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.cpp
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
@@ -25,11 +25,12 @@
#include "COM_BrightnessOperation.h"
#include "COM_ExecutionSystem.h"
-BrightnessNode::BrightnessNode(bNode *editorNode): Node(editorNode)
+BrightnessNode::BrightnessNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void BrightnessNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BrightnessNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
BrightnessOperation *operation = new BrightnessOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.h b/source/blender/compositor/nodes/COM_BrightnessNode.h
index 4c3b6421322..a10372049f0 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.h
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief BrightnessNode
- * @ingroup Node
- */
-class BrightnessNode: public Node {
+ * @brief BrightnessNode
+ * @ingroup Node
+ */
+class BrightnessNode : public Node {
public:
BrightnessNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
index f1d5b8d39cc..69f39639660 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -27,8 +27,10 @@
#include "COM_ConvertRGBToYUVOperation.h"
#include "COM_SetAlphaOperation.h"
-ChannelMatteNode::ChannelMatteNode(bNode *editorNode): Node(editorNode)
-{}
+ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
@@ -36,30 +38,30 @@ void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCon
OutputSocket *outputSocketImage = this->getOutputSocket(0);
OutputSocket *outputSocketMatte = this->getOutputSocket(1);
- NodeOperation *convert=NULL;
+ NodeOperation *convert = NULL;
bNode *node = this->getbNode();
/* colorspace */
switch (node->custom1) {
- case CMP_NODE_CHANNEL_MATTE_CS_RGB:
- break;
- case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/
- convert = new ConvertRGBToHSVOperation();
- break;
- case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/
- convert = new ConvertRGBToYUVOperation();
- break;
- case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/
- convert = new ConvertRGBToYCCOperation();
- ((ConvertRGBToYCCOperation *)convert)->setMode(0); /* BLI_YCC_ITU_BT601 */
- break;
- default:
- break;
+ case CMP_NODE_CHANNEL_MATTE_CS_RGB:
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/
+ convert = new ConvertRGBToHSVOperation();
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/
+ convert = new ConvertRGBToYUVOperation();
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/
+ convert = new ConvertRGBToYCCOperation();
+ ((ConvertRGBToYCCOperation *)convert)->setMode(0); /* BLI_YCC_ITU_BT601 */
+ break;
+ default:
+ break;
}
ChannelMatteOperation *operation = new ChannelMatteOperation();
/* pass the ui properties to the operation */
- operation->setSettings((NodeChroma*)node->storage, node->custom2);
+ operation->setSettings((NodeChroma *)node->storage, node->custom2);
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
index cb67ac604b2..45d03e18a6a 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
@@ -25,9 +25,9 @@
#include "COM_Node.h"
/**
- * @brief ChannelMatteNode
- * @ingroup Node
- */
+ * @brief ChannelMatteNode
+ * @ingroup Node
+ */
class ChannelMatteNode : public Node
{
public:
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
index 82059ed8493..0fb09157351 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
@@ -25,8 +25,10 @@
#include "COM_ConvertRGBToYCCOperation.h"
#include "COM_SetAlphaOperation.h"
-ChromaMatteNode::ChromaMatteNode(bNode *editorNode): Node(editorNode)
-{}
+ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
@@ -42,7 +44,7 @@ void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCont
ChromaMatteOperation *operation = new ChromaMatteOperation();
bNode *editorsnode = getbNode();
- operation->setSettings((NodeChroma*)editorsnode->storage);
+ operation->setSettings((NodeChroma *)editorsnode->storage);
inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), 0, graph);
inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 0, graph);
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
index 6008137b4a7..ed8250b0329 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
@@ -25,9 +25,9 @@
#include "COM_Node.h"
/**
- * @brief ChromaMatteNode
- * @ingroup Node
- */
+ * @brief ChromaMatteNode
+ * @ingroup Node
+ */
class ChromaMatteNode : public Node
{
public:
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
index 7b852678191..d85b1ec1de1 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
@@ -27,10 +27,12 @@
#include "BKE_node.h"
#include "COM_MixBlendOperation.h"
-ColorBalanceNode::ColorBalanceNode(bNode *editorNode): Node(editorNode)
+ColorBalanceNode::ColorBalanceNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+
+void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
InputSocket *inputImageSocket = this->getInputSocket(1);
@@ -38,16 +40,16 @@ void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorCon
bNode *node = this->getbNode();
NodeColorBalance *n = (NodeColorBalance *)node->storage;
- NodeOperation*operation;
+ NodeOperation *operation;
if (node->custom1 == 0) {
ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation();
{
- int c;
+ int c;
- for (c = 0; c < 3; c++) {
- n->lift_lgg[c] = 2.0f - n->lift[c];
- n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f/n->gamma[c] : 1000000.0f;
- }
+ for (c = 0; c < 3; c++) {
+ n->lift_lgg[c] = 2.0f - n->lift[c];
+ n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
+ }
}
operationLGG->setGain(n->gain);
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
index 61a09d28c01..c2bdc306e20 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
@@ -26,9 +26,9 @@
#include "COM_Node.h"
/**
- * @brief ColorBalanceNode
- * @ingroup Node
- */
+ * @brief ColorBalanceNode
+ * @ingroup Node
+ */
class ColorBalanceNode : public Node
{
public:
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
index 4909f1b9895..41b3bebbd7b 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
@@ -25,20 +25,21 @@
#include "COM_ColorCorrectionOperation.h"
#include "COM_ExecutionSystem.h"
-ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode): Node(editorNode)
+ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ColorCorrectionNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ColorCorrectionNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
ColorCorrectionOperation *operation = new ColorCorrectionOperation();
bNode *editorNode = getbNode();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- operation->setData((NodeColorCorrection*)editorNode->storage);
- operation->setRedChannelEnabled((editorNode->custom1&1)>0);
- operation->setGreenChannelEnabled((editorNode->custom1&2)>0);
- operation->setBlueChannelEnabled((editorNode->custom1&4)>0);
+ operation->setData((NodeColorCorrection *)editorNode->storage);
+ operation->setRedChannelEnabled((editorNode->custom1 & 1) > 0);
+ operation->setGreenChannelEnabled((editorNode->custom1 & 2) > 0);
+ operation->setBlueChannelEnabled((editorNode->custom1 & 4) > 0);
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
index 46b7fe5e0bc..f1b0f69bec5 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief ColorCorrectionNode
- * @ingroup Node
- */
-class ColorCorrectionNode: public Node {
+ * @brief ColorCorrectionNode
+ * @ingroup Node
+ */
+class ColorCorrectionNode : public Node {
public:
ColorCorrectionNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
index 0d331ed9b05..9ae11c22b6a 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
@@ -25,11 +25,12 @@
#include "COM_ColorCurveOperation.h"
#include "COM_ExecutionSystem.h"
-ColorCurveNode::ColorCurveNode(bNode *editorNode): Node(editorNode)
+ColorCurveNode::ColorCurveNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ColorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ColorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
if (this->getInputSocket(2)->isConnected() || this->getInputSocket(3)->isConnected()) {
ColorCurveOperation *operation = new ColorCurveOperation();
@@ -41,21 +42,22 @@ void ColorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorConte
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- operation->setCurveMapping((CurveMapping*)this->getbNode()->storage);
+ operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
graph->addOperation(operation);
- } else {
+ }
+ else {
ConstantLevelColorCurveOperation *operation = new ConstantLevelColorCurveOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- bNodeSocketValueRGBA *val = (bNodeSocketValueRGBA*)this->getInputSocket(2)->getbNodeSocket()->default_value;
+ bNodeSocketValueRGBA *val = (bNodeSocketValueRGBA *)this->getInputSocket(2)->getbNodeSocket()->default_value;
operation->setBlackLevel(val->value);
- val = (bNodeSocketValueRGBA*)this->getInputSocket(3)->getbNodeSocket()->default_value;
+ val = (bNodeSocketValueRGBA *)this->getInputSocket(3)->getbNodeSocket()->default_value;
operation->setWhiteLevel(val->value);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- operation->setCurveMapping((CurveMapping*)this->getbNode()->storage);
+ operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.h b/source/blender/compositor/nodes/COM_ColorCurveNode.h
index 264e2691566..ecfae1f86f8 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief ColorCurveNode
- * @ingroup Node
- */
-class ColorCurveNode: public Node {
+ * @brief ColorCurveNode
+ * @ingroup Node
+ */
+class ColorCurveNode : public Node {
public:
ColorCurveNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
index ad117e1ca2c..38ab6ba8da2 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
@@ -25,8 +25,10 @@
#include "COM_ConvertRGBToHSVOperation.h"
#include "COM_SetAlphaOperation.h"
-ColorMatteNode::ColorMatteNode(bNode *editorNode): Node(editorNode)
-{}
+ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
void ColorMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
@@ -40,7 +42,7 @@ void ColorMatteNode::convertToOperations(ExecutionSystem *graph, CompositorConte
ColorMatteOperation *operation = new ColorMatteOperation();
bNode *editorsnode = getbNode();
- operation->setSettings((NodeChroma*)editorsnode->storage);
+ operation->setSettings((NodeChroma *)editorsnode->storage);
inputSocketImage->relinkConnections(operationRGBToHSV_Image->getInputSocket(0), 0, graph);
inputSocketKey->relinkConnections(operationRGBToHSV_Key->getInputSocket(0), 1, graph);
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h
index af64616d054..375c914a122 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h
@@ -25,9 +25,9 @@
#include "COM_Node.h"
/**
- * @brief ColorMatteNode
- * @ingroup Node
- */
+ * @brief ColorMatteNode
+ * @ingroup Node
+ */
class ColorMatteNode : public Node
{
public:
diff --git a/source/blender/compositor/nodes/COM_ColorNode.cpp b/source/blender/compositor/nodes/COM_ColorNode.cpp
index f5fcb0177f7..65480c7aeb2 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorNode.cpp
@@ -25,15 +25,16 @@
#include "COM_SetColorOperation.h"
#include "COM_ExecutionSystem.h"
-ColorNode::ColorNode(bNode *editorNode): Node(editorNode)
+ColorNode::ColorNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ColorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ColorNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
SetColorOperation *operation = new SetColorOperation();
bNodeSocket *socket = this->getEditorOutputSocket(0);
- bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)socket->default_value;
+ bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)socket->default_value;
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
operation->setChannels(dval->value);
graph->addOperation(operation);
diff --git a/source/blender/compositor/nodes/COM_ColorNode.h b/source/blender/compositor/nodes/COM_ColorNode.h
index 937979dd961..3e3df63e90a 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.h
+++ b/source/blender/compositor/nodes/COM_ColorNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief ColorNode
- * @ingroup Node
- */
-class ColorNode: public Node {
+ * @brief ColorNode
+ * @ingroup Node
+ */
+class ColorNode : public Node {
public:
ColorNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cpp b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
index c6090120467..a79c7885ae4 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
@@ -27,10 +27,12 @@
#include "COM_SeparateChannelOperation.h"
#include "DNA_texture_types.h"
-ColorRampNode::ColorRampNode(bNode *editorNode): Node(editorNode)
-{}
+ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
-void ColorRampNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ColorRampNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
OutputSocket *outputSocket = this->getOutputSocket(0);
@@ -46,7 +48,7 @@ void ColorRampNode::convertToOperations(ExecutionSystem *graph, CompositorContex
operation2->setChannel(3);
graph->addOperation(operation2);
}
- operation->setColorBand((ColorBand*)editorNode->storage);
+ operation->setColorBand((ColorBand *)editorNode->storage);
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h
index 53fff2b0d98..4d706e126e1 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.h
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.h
@@ -26,14 +26,14 @@
#include "COM_Node.h"
/**
- * @brief ColorRampNode
- * @ingroup Node
- */
+ * @brief ColorRampNode
+ * @ingroup Node
+ */
class ColorRampNode : public Node
{
public:
ColorRampNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif // COM_ColorRampNODE_H
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
index 503ca3c8bd3..0e586955ff8 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
@@ -24,8 +24,10 @@
#include "BKE_node.h"
#include "COM_ColorSpillOperation.h"
-ColorSpillNode::ColorSpillNode(bNode *editorNode): Node(editorNode)
-{}
+ColorSpillNode::ColorSpillNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
@@ -45,8 +47,8 @@ void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorConte
// Average color spill
operation = new ColorSpillAverageOperation();
}
- operation->setSettings((NodeColorspill*)editorsnode->storage);
- operation->setSpillChannel(editorsnode->custom1-1); // Channel for spilling
+ operation->setSettings((NodeColorspill *)editorsnode->storage);
+ operation->setSpillChannel(editorsnode->custom1 - 1); // Channel for spilling
inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph);
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h
index ed0e33b0742..d8ce6878fa0 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.h
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h
@@ -26,9 +26,9 @@
#include "COM_Node.h"
/**
- * @brief ColorSpillNode
- * @ingroup Node
- */
+ * @brief ColorSpillNode
+ * @ingroup Node
+ */
class ColorSpillNode : public Node
{
public:
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
index ed2869d35f2..430f317eae2 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
@@ -25,11 +25,12 @@
#include "COM_ConvertColorToBWOperation.h"
#include "COM_ExecutionSystem.h"
-ColourToBWNode::ColourToBWNode(bNode *editorNode): Node(editorNode)
+ColourToBWNode::ColourToBWNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ColourToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ColourToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *colourSocket = this->getInputSocket(0);
OutputSocket *valueSocket = this->getOutputSocket(0);
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h
index e2badd1b104..34a157c73d8 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.h
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief ColourToBWNode
- * @ingroup Node
- */
+ * @brief ColourToBWNode
+ * @ingroup Node
+ */
class ColourToBWNode : public Node {
public:
ColourToBWNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.cpp b/source/blender/compositor/nodes/COM_CombineHSVANode.cpp
index a0f46ad6b6c..beba41fade9 100644
--- a/source/blender/compositor/nodes/COM_CombineHSVANode.cpp
+++ b/source/blender/compositor/nodes/COM_CombineHSVANode.cpp
@@ -28,11 +28,12 @@
#include "COM_SetValueOperation.h"
#include "COM_ConvertHSVToRGBOperation.h"
-CombineHSVANode::CombineHSVANode(bNode *editorNode): CombineRGBANode(editorNode)
+CombineHSVANode::CombineHSVANode(bNode *editorNode) : CombineRGBANode(editorNode)
{
+ /* pass */
}
-void CombineHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void CombineHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
ConvertHSVToRGBOperation *operation = new ConvertHSVToRGBOperation();
OutputSocket *outputSocket = this->getOutputSocket(0);
diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.h b/source/blender/compositor/nodes/COM_CombineHSVANode.h
index fabd6f91f7e..d8aba71d456 100644
--- a/source/blender/compositor/nodes/COM_CombineHSVANode.h
+++ b/source/blender/compositor/nodes/COM_CombineHSVANode.h
@@ -27,12 +27,12 @@
#include "DNA_node_types.h"
#include "COM_CombineRGBANode.h"
/**
- * @brief CombineHSVANode
- * @ingroup Node
- */
+ * @brief CombineHSVANode
+ * @ingroup Node
+ */
class CombineHSVANode : public CombineRGBANode {
public:
CombineHSVANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.cpp b/source/blender/compositor/nodes/COM_CombineRGBANode.cpp
index e6fcc48ac5b..a8cdd8c2950 100644
--- a/source/blender/compositor/nodes/COM_CombineRGBANode.cpp
+++ b/source/blender/compositor/nodes/COM_CombineRGBANode.cpp
@@ -29,12 +29,12 @@
#include "DNA_material_types.h" // the ramp types
-CombineRGBANode::CombineRGBANode(bNode *editorNode): Node(editorNode)
+CombineRGBANode::CombineRGBANode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-
-void CombineRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void CombineRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputRSocket = this->getInputSocket(0);
InputSocket *inputGSocket = this->getInputSocket(1);
diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.h b/source/blender/compositor/nodes/COM_CombineRGBANode.h
index 182bfece6d3..1f25d8deed9 100644
--- a/source/blender/compositor/nodes/COM_CombineRGBANode.h
+++ b/source/blender/compositor/nodes/COM_CombineRGBANode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief CombineRGBANode
- * @ingroup Node
- */
+ * @brief CombineRGBANode
+ * @ingroup Node
+ */
class CombineRGBANode : public Node {
public:
CombineRGBANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.cpp b/source/blender/compositor/nodes/COM_CombineYCCANode.cpp
index ad6203ea85a..5319eb84184 100644
--- a/source/blender/compositor/nodes/COM_CombineYCCANode.cpp
+++ b/source/blender/compositor/nodes/COM_CombineYCCANode.cpp
@@ -22,8 +22,9 @@
#include "COM_CombineYCCANode.h"
#include "COM_ConvertYCCToRGBOperation.h"
-CombineYCCANode::CombineYCCANode(bNode *editorNode): CombineRGBANode(editorNode)
+CombineYCCANode::CombineYCCANode(bNode *editorNode) : CombineRGBANode(editorNode)
{
+ /* pass */
}
void CombineYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.h b/source/blender/compositor/nodes/COM_CombineYCCANode.h
index 86e2d50e950..3b143aabc7f 100644
--- a/source/blender/compositor/nodes/COM_CombineYCCANode.h
+++ b/source/blender/compositor/nodes/COM_CombineYCCANode.h
@@ -26,9 +26,9 @@
#include "DNA_node_types.h"
#include "COM_CombineRGBANode.h"
/**
- * @brief CombineYCCANode
- * @ingroup Node
- */
+ * @brief CombineYCCANode
+ * @ingroup Node
+ */
class CombineYCCANode : public CombineRGBANode {
public:
CombineYCCANode(bNode *editorNode);
diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.cpp b/source/blender/compositor/nodes/COM_CombineYUVANode.cpp
index ea92a40f803..48c2c6ca649 100644
--- a/source/blender/compositor/nodes/COM_CombineYUVANode.cpp
+++ b/source/blender/compositor/nodes/COM_CombineYUVANode.cpp
@@ -22,8 +22,9 @@
#include "COM_CombineYUVANode.h"
#include "COM_ConvertYUVToRGBOperation.h"
-CombineYUVANode::CombineYUVANode(bNode *editorNode): CombineRGBANode(editorNode)
+CombineYUVANode::CombineYUVANode(bNode *editorNode) : CombineRGBANode(editorNode)
{
+ /* pass */
}
void CombineYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.h b/source/blender/compositor/nodes/COM_CombineYUVANode.h
index 7d2f9cddf7e..1eae44c83a5 100644
--- a/source/blender/compositor/nodes/COM_CombineYUVANode.h
+++ b/source/blender/compositor/nodes/COM_CombineYUVANode.h
@@ -26,9 +26,9 @@
#include "DNA_node_types.h"
#include "COM_CombineRGBANode.h"
/**
- * @brief CombineYUVANode
- * @ingroup Node
- */
+ * @brief CombineYUVANode
+ * @ingroup Node
+ */
class CombineYUVANode : public CombineRGBANode {
public:
CombineYUVANode(bNode *editorNode);
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index e2cc34bb6ce..fccb92ddd8b 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -24,11 +24,12 @@
#include "COM_CompositorOperation.h"
#include "COM_ExecutionSystem.h"
-CompositorNode::CompositorNode(bNode *editorNode): Node(editorNode)
+CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *imageSocket = this->getInputSocket(0);
InputSocket *alphaSocket = this->getInputSocket(1);
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h
index e77d1d2f225..585dae7761e 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.h
+++ b/source/blender/compositor/nodes/COM_CompositorNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief CompositorNode
- * @ingroup Node
- */
+ * @brief CompositorNode
+ * @ingroup Node
+ */
class CompositorNode : public Node {
public:
CompositorNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
index 0b4326a17ca..70aeee8fc27 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
@@ -24,7 +24,7 @@
#include "COM_ConvertKeyToPremulOperation.h"
#include "COM_ExecutionSystem.h"
-void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
NodeOperation *operation = NULL;
bNode *node = this->getbNode();
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
index 2e3fe743f4e..d9077c23a02 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
@@ -25,13 +25,13 @@
#include "COM_Node.h"
/**
- * @brief ConvertAlphaNode
- * @ingroup Node
- */
-class ConvertAlphaNode: public Node {
+ * @brief ConvertAlphaNode
+ * @ingroup Node
+ */
+class ConvertAlphaNode : public Node {
public:
- ConvertAlphaNode(bNode *editorNode) :Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ ConvertAlphaNode(bNode *editorNode) : Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp
index c58fcc874cb..b80a3e088f2 100644
--- a/source/blender/compositor/nodes/COM_CropNode.cpp
+++ b/source/blender/compositor/nodes/COM_CropNode.cpp
@@ -26,12 +26,13 @@
CropNode::CropNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
bNode *node = getbNode();
- NodeTwoXYs *cropSettings = (NodeTwoXYs*)node->storage;
+ NodeTwoXYs *cropSettings = (NodeTwoXYs *)node->storage;
bool relative = (bool)node->custom2;
bool cropImage = (bool)node->custom1;
CropBaseOperation *operation;
diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h
index 0bdfffc8fec..44fdeecc180 100644
--- a/source/blender/compositor/nodes/COM_CropNode.h
+++ b/source/blender/compositor/nodes/COM_CropNode.h
@@ -25,10 +25,10 @@
#include "COM_Node.h"
-class CropNode: public Node {
+class CropNode : public Node {
public:
CropNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index e4e19fdbe27..d1f90b490ad 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -33,16 +33,17 @@
#include "COM_SetValueOperation.h"
#include "COM_GammaCorrectOperation.h"
-DefocusNode::DefocusNode(bNode *editorNode): Node(editorNode)
+DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
bNode *node = this->getbNode();
- Scene *scene = (Scene*)node->id;
- Object *camob = (scene)? scene->camera: NULL;
- NodeDefocus *data = (NodeDefocus*)node->storage;
+ Scene *scene = (Scene *)node->id;
+ Object *camob = (scene) ? scene->camera : NULL;
+ NodeDefocus *data = (NodeDefocus *)node->storage;
NodeOperation *radiusOperation;
if (data->no_zbuf) {
@@ -74,11 +75,11 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
}
BokehImageOperation *bokeh = new BokehImageOperation();
- NodeBokehImage * bokehdata = new NodeBokehImage();
+ NodeBokehImage *bokehdata = new NodeBokehImage();
bokehdata->angle = data->rotation;
bokehdata->rounding = 0.0f;
bokehdata->flaps = data->bktype;
- if (data->bktype<3) {
+ if (data->bktype < 3) {
bokehdata->flaps = 5;
bokehdata->rounding = 1.0f;
}
@@ -96,8 +97,8 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1));
addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2));
if (data->gamco) {
- GammaCorrectOperation * correct = new GammaCorrectOperation();
- GammaUncorrectOperation * inverse = new GammaUncorrectOperation();
+ GammaCorrectOperation *correct = new GammaCorrectOperation();
+ GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
this->getInputSocket(0)->relinkConnections(correct->getInputSocket(0), 0, graph);
addLink(graph, correct->getOutputSocket(), operation->getInputSocket(0));
addLink(graph, operation->getOutputSocket(), inverse->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h
index d52ee3da77b..a3cffbd98c4 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.h
+++ b/source/blender/compositor/nodes/COM_DefocusNode.h
@@ -26,14 +26,14 @@
#include "COM_Node.h"
/**
- * @brief DefocusNode
- * @ingroup Node
- */
+ * @brief DefocusNode
+ * @ingroup Node
+ */
-class DefocusNode: public Node {
+class DefocusNode : public Node {
public:
DefocusNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
index 596fefff77c..6dca049a6ae 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
@@ -25,10 +25,12 @@
#include "COM_DifferenceMatteOperation.h"
#include "COM_SetAlphaOperation.h"
-DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode): Node(editorNode)
-{}
+DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
-void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
InputSocket *inputSocket2 = this->getInputSocket(1);
@@ -36,15 +38,15 @@ void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, Compositor
OutputSocket *outputSocketMatte = this->getOutputSocket(1);
bNode *editorNode = this->getbNode();
- DifferenceMatteOperation * operationSet = new DifferenceMatteOperation();
- operationSet->setSettings((NodeChroma*)editorNode->storage);
+ DifferenceMatteOperation *operationSet = new DifferenceMatteOperation();
+ operationSet->setSettings((NodeChroma *)editorNode->storage);
inputSocket->relinkConnections(operationSet->getInputSocket(0), 0, graph);
inputSocket2->relinkConnections(operationSet->getInputSocket(1), 1, graph);
outputSocketMatte->relinkConnections(operationSet->getOutputSocket(0));
graph->addOperation(operationSet);
- SetAlphaOperation * operation = new SetAlphaOperation();
+ SetAlphaOperation *operation = new SetAlphaOperation();
addLink(graph, operationSet->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0));
addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1));
outputSocketImage->relinkConnections(operation->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
index 3b270ebc3b7..faaf235bf34 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
@@ -26,14 +26,14 @@
#include "COM_Node.h"
/**
- * @brief DifferenceMatteNode
- * @ingroup Node
- */
+ * @brief DifferenceMatteNode
+ * @ingroup Node
+ */
class DifferenceMatteNode : public Node
{
public:
DifferenceMatteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif // COM_DifferenceMatteNODE_H
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index 47791956865..6ee5b2a2b0d 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -27,23 +27,24 @@
#include "COM_AntiAliasOperation.h"
#include "BLI_math.h"
-DilateErodeNode::DilateErodeNode(bNode *editorNode): Node(editorNode)
+DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
bNode *editorNode = this->getbNode();
if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) {
- DilateErodeDistanceOperation *operation = new DilateErodeDistanceOperation();
+ DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation();
operation->setDistance(editorNode->custom2);
operation->setInset(editorNode->custom3);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
if (editorNode->custom3 < 2.0f) {
- AntiAliasOperation * antiAlias = new AntiAliasOperation();
+ AntiAliasOperation *antiAlias = new AntiAliasOperation();
addLink(graph, operation->getOutputSocket(), antiAlias->getInputSocket(0));
this->getOutputSocket(0)->relinkConnections(antiAlias->getOutputSocket(0));
graph->addOperation(antiAlias);
@@ -55,14 +56,14 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
}
else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) {
if (editorNode->custom2 > 0) {
- DilateDistanceOperation * operation = new DilateDistanceOperation();
+ DilateDistanceOperation *operation = new DilateDistanceOperation();
operation->setDistance(editorNode->custom2);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
graph->addOperation(operation);
}
else {
- ErodeDistanceOperation * operation = new ErodeDistanceOperation();
+ ErodeDistanceOperation *operation = new ErodeDistanceOperation();
operation->setDistance(-editorNode->custom2);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
@@ -71,14 +72,14 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
}
else {
if (editorNode->custom2 > 0) {
- DilateStepOperation * operation = new DilateStepOperation();
+ DilateStepOperation *operation = new DilateStepOperation();
operation->setIterations(editorNode->custom2);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
graph->addOperation(operation);
}
else {
- ErodeStepOperation * operation = new ErodeStepOperation();
+ ErodeStepOperation *operation = new ErodeStepOperation();
operation->setIterations(-editorNode->custom2);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h
index 496bd0203dd..fa4e368e00d 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.h
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief DilateErodeNode
- * @ingroup Node
- */
-class DilateErodeNode: public Node {
+ * @brief DilateErodeNode
+ * @ingroup Node
+ */
+class DilateErodeNode : public Node {
public:
DilateErodeNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
index d63fbbdb092..dee0e6a88da 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
@@ -26,13 +26,14 @@
#include "COM_ExecutionSystem.h"
#include "COM_DirectionalBlurOperation.h"
-DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode): Node(editorNode)
+DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- NodeDBlurData *data = (NodeDBlurData*)this->getbNode()->storage;
+ NodeDBlurData *data = (NodeDBlurData *)this->getbNode()->storage;
DirectionalBlurOperation *operation = new DirectionalBlurOperation();
operation->setQuality(context->getQuality());
operation->setData(data);
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
index 1cf36fdeae7..d387ecf81dc 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief DirectionalBlurNode
- * @ingroup Node
- */
-class DirectionalBlurNode: public Node {
+ * @brief DirectionalBlurNode
+ * @ingroup Node
+ */
+class DirectionalBlurNode : public Node {
public:
DirectionalBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
index 9604db378bc..41fbfd61981 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.cpp
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
@@ -24,11 +24,12 @@
#include "COM_DisplaceSimpleOperation.h"
#include "COM_ExecutionSystem.h"
-DisplaceNode::DisplaceNode(bNode *editorNode): Node(editorNode)
+DisplaceNode::DisplaceNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void DisplaceNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void DisplaceNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
NodeOperation *operation;
if (context->getQuality() == COM_QUALITY_LOW)
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.h b/source/blender/compositor/nodes/COM_DisplaceNode.h
index 3451f05dd1f..ecbe07b06b9 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.h
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.h
@@ -31,6 +31,6 @@
class DisplaceNode : public Node {
public:
DisplaceNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
index 20a55ae195c..d6730ef6a00 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -24,8 +24,10 @@
#include "COM_DistanceMatteOperation.h"
#include "COM_SetAlphaOperation.h"
-DistanceMatteNode::DistanceMatteNode(bNode *editorNode): Node(editorNode)
-{}
+DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
@@ -36,7 +38,7 @@ void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCo
DistanceMatteOperation *operation = new DistanceMatteOperation();
bNode *editorsnode = getbNode();
- operation->setSettings((NodeChroma*)editorsnode->storage);
+ operation->setSettings((NodeChroma *)editorsnode->storage);
inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph);
inputSocketKey->relinkConnections(operation->getInputSocket(1), 1, graph);
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
index 740eb767a71..42582ef10a0 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
@@ -25,9 +25,9 @@
#include "COM_Node.h"
/**
- * @brief DistanceMatteNode
- * @ingroup Node
- */
+ * @brief DistanceMatteNode
+ * @ingroup Node
+ */
class DistanceMatteNode : public Node
{
public:
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
index ab9e101dad8..57c319e7630 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
@@ -25,11 +25,12 @@
#include "DNA_scene_types.h"
#include "COM_ExecutionSystem.h"
-DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode): Node(editorNode)
+DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
DoubleEdgeMaskOperation *operation;
bNode *bnode = this->getbNode();
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
index 2c52e988946..ebcddc06b05 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief DoubleEdgeMaskNode
- * @ingroup Node
- */
-class DoubleEdgeMaskNode: public Node {
+ * @brief DoubleEdgeMaskNode
+ * @ingroup Node
+ */
+class DoubleEdgeMaskNode : public Node {
public:
DoubleEdgeMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
index f5003c4be94..23410c6a115 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
@@ -25,15 +25,16 @@
#include "COM_EllipseMaskOperation.h"
#include "COM_ExecutionSystem.h"
-EllipseMaskNode::EllipseMaskNode(bNode *editorNode): Node(editorNode)
+EllipseMaskNode::EllipseMaskNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void EllipseMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void EllipseMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
EllipseMaskOperation *operation;
operation = new EllipseMaskOperation();
- operation->setData((NodeEllipseMask*)this->getbNode()->storage);
+ operation->setData((NodeEllipseMask *)this->getbNode()->storage);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.h b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
index be6956e30b5..3e534451b13 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.h
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief EllipseMaskNode
- * @ingroup Node
- */
-class EllipseMaskNode: public Node {
+ * @brief EllipseMaskNode
+ * @ingroup Node
+ */
+class EllipseMaskNode : public Node {
public:
EllipseMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp
index 7700bceb4ab..23f87805821 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cpp
+++ b/source/blender/compositor/nodes/COM_FilterNode.cpp
@@ -27,11 +27,12 @@
#include "BKE_node.h"
#include "COM_MixBlendOperation.h"
-FilterNode::FilterNode(bNode *editorNode): Node(editorNode)
+FilterNode::FilterNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
InputSocket *inputImageSocket = this->getInputSocket(1);
@@ -39,38 +40,38 @@ void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
ConvolutionFilterOperation *operation = NULL;
switch (this->getbNode()->custom1) {
- case CMP_FILT_SOFT:
- operation = new ConvolutionFilterOperation();
- operation->set3x3Filter(1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f);
- break;
- case CMP_FILT_SHARP:
- operation = new ConvolutionFilterOperation();
- operation->set3x3Filter(-1,-1,-1,-1,9,-1,-1,-1,-1);
- break;
- case CMP_FILT_LAPLACE:
- operation = new ConvolutionFilterOperation();
- operation->set3x3Filter(-1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f, 1.0f, -1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f);
- break;
- case CMP_FILT_SOBEL:
- operation = new ConvolutionEdgeFilterOperation();
- operation->set3x3Filter(1,2,1,0,0,0,-1,-2,-1);
- break;
- case CMP_FILT_PREWITT:
- operation = new ConvolutionEdgeFilterOperation();
- operation->set3x3Filter(1,1,1,0,0,0,-1,-1,-1);
- break;
- case CMP_FILT_KIRSCH:
- operation = new ConvolutionEdgeFilterOperation();
- operation->set3x3Filter(5,5,5,-3,-3,-3,-2,-2,-2);
- break;
- case CMP_FILT_SHADOW:
- operation = new ConvolutionFilterOperation();
- operation->set3x3Filter(1,2,1,0,1,0,-1,-2,-1);
- break;
- default:
- operation = new ConvolutionFilterOperation();
- operation->set3x3Filter(0,0,0,0,1,0,0,0,0);
- break;
+ case CMP_FILT_SOFT:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(1 / 16.0f, 2 / 16.0f, 1 / 16.0f, 2 / 16.0f, 4 / 16.0f, 2 / 16.0f, 1 / 16.0f, 2 / 16.0f, 1 / 16.0f);
+ break;
+ case CMP_FILT_SHARP:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1);
+ break;
+ case CMP_FILT_LAPLACE:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(-1 / 8.0f, -1 / 8.0f, -1 / 8.0f, -1 / 8.0f, 1.0f, -1 / 8.0f, -1 / 8.0f, -1 / 8.0f, -1 / 8.0f);
+ break;
+ case CMP_FILT_SOBEL:
+ operation = new ConvolutionEdgeFilterOperation();
+ operation->set3x3Filter(1, 2, 1, 0, 0, 0, -1, -2, -1);
+ break;
+ case CMP_FILT_PREWITT:
+ operation = new ConvolutionEdgeFilterOperation();
+ operation->set3x3Filter(1, 1, 1, 0, 0, 0, -1, -1, -1);
+ break;
+ case CMP_FILT_KIRSCH:
+ operation = new ConvolutionEdgeFilterOperation();
+ operation->set3x3Filter(5, 5, 5, -3, -3, -3, -2, -2, -2);
+ break;
+ case CMP_FILT_SHADOW:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1);
+ break;
+ default:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0);
+ break;
}
inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h
index 080682dcefe..17f590b9cfc 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.h
+++ b/source/blender/compositor/nodes/COM_FilterNode.h
@@ -26,14 +26,14 @@
#include "COM_Node.h"
/**
- * @brief FilterNode
- * @ingroup Node
- */
+ * @brief FilterNode
+ * @ingroup Node
+ */
class FilterNode : public Node
{
public:
FilterNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif // COM_FILTERNODE_H
diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp
index 0830c757833..a50297aae1a 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.cpp
+++ b/source/blender/compositor/nodes/COM_FlipNode.cpp
@@ -27,26 +27,27 @@
FlipNode::FlipNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void FlipNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void FlipNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
OutputSocket *outputSocket = this->getOutputSocket(0);
FlipOperation *operation = new FlipOperation();
switch (this->getbNode()->custom1) {
- case 0: /// @TODO: I didn't find any constants in the old implementation, should I introduce them.
- operation->setFlipX(true);
- operation->setFlipY(false);
- break;
- case 1:
- operation->setFlipX(false);
- operation->setFlipY(true);
- break;
- case 2:
- operation->setFlipX(true);
- operation->setFlipY(true);
- break;
+ case 0: /// @TODO: I didn't find any constants in the old implementation, should I introduce them.
+ operation->setFlipX(true);
+ operation->setFlipY(false);
+ break;
+ case 1:
+ operation->setFlipX(false);
+ operation->setFlipY(true);
+ break;
+ case 2:
+ operation->setFlipX(true);
+ operation->setFlipY(true);
+ break;
}
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
diff --git a/source/blender/compositor/nodes/COM_FlipNode.h b/source/blender/compositor/nodes/COM_FlipNode.h
index 53bcc504f80..1e372a80b57 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.h
+++ b/source/blender/compositor/nodes/COM_FlipNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief FlipNode
- * @ingroup Node
- */
-class FlipNode: public Node {
+ * @brief FlipNode
+ * @ingroup Node
+ */
+class FlipNode : public Node {
public:
FlipNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GammaNode.cpp b/source/blender/compositor/nodes/COM_GammaNode.cpp
index 58b05607618..52699c83bf9 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.cpp
+++ b/source/blender/compositor/nodes/COM_GammaNode.cpp
@@ -25,11 +25,12 @@
#include "COM_GammaOperation.h"
#include "COM_ExecutionSystem.h"
-GammaNode::GammaNode(bNode *editorNode): Node(editorNode)
+GammaNode::GammaNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void GammaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void GammaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
GammaOperation *operation = new GammaOperation();
diff --git a/source/blender/compositor/nodes/COM_GammaNode.h b/source/blender/compositor/nodes/COM_GammaNode.h
index 121d99cbd57..d4e1f0abd5a 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.h
+++ b/source/blender/compositor/nodes/COM_GammaNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief GammaNode
- * @ingroup Node
- */
-class GammaNode: public Node {
+ * @brief GammaNode
+ * @ingroup Node
+ */
+class GammaNode : public Node {
public:
GammaNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp
index dc367040c9a..7b34fa4d286 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.cpp
+++ b/source/blender/compositor/nodes/COM_GlareNode.cpp
@@ -22,136 +22,63 @@
#include "COM_GlareNode.h"
#include "DNA_node_types.h"
-#include "COM_FogGlowImageOperation.h"
#include "COM_GlareThresholdOperation.h"
#include "COM_GlareSimpleStarOperation.h"
#include "COM_GlareStreaksOperation.h"
#include "COM_SetValueOperation.h"
-#include "COM_MixBlendOperation.h"
+#include "COM_MixGlareOperation.h"
#include "COM_FastGaussianBlurOperation.h"
#include "COM_GlareGhostOperation.h"
+#include "COM_GlareFogGlowOperation.h"
-GlareNode::GlareNode(bNode *editorNode): Node(editorNode)
+GlareNode::GlareNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)\
-{
+void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext *context) \
+ {
bNode *node = this->getbNode();
- NodeGlare *glare = (NodeGlare*)node->storage;
-
- switch (glare->type) {
-
- default:
- case 3:
- {
- GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
- GlareGhostOperation * glareoperation = new GlareGhostOperation();
- SetValueOperation * mixvalueoperation = new SetValueOperation();
- MixBlendOperation * mixoperation = new MixBlendOperation();
-
- this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
- addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
- addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
- addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
- addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
- this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
-
- thresholdOperation->setThreshold(glare->threshold);
- glareoperation->setGlareSettings(glare);
- mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
- mixoperation->setResolutionInputSocketIndex(1);
-
- system->addOperation(glareoperation);
- system->addOperation(thresholdOperation);
- system->addOperation(mixvalueoperation);
- system->addOperation(mixoperation);
- }
- case 2: // streaks
- {
- GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
- GlareStreaksOperation * glareoperation = new GlareStreaksOperation();
- SetValueOperation * mixvalueoperation = new SetValueOperation();
- MixBlendOperation * mixoperation = new MixBlendOperation();
+ NodeGlare *glare = (NodeGlare *)node->storage;
- this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
- addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
- addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
- addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
- addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
- this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+ GlareBaseOperation *glareoperation = NULL;
- thresholdOperation->setThreshold(glare->threshold);
- glareoperation->setGlareSettings(glare);
- mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
- mixoperation->setResolutionInputSocketIndex(1);
-
- system->addOperation(glareoperation);
- system->addOperation(thresholdOperation);
- system->addOperation(mixvalueoperation);
- system->addOperation(mixoperation);
- }
- break;
- case 1: // fog glow
- {
- GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
- FastGaussianBlurOperation* bluroperation = new FastGaussianBlurOperation();
- SetValueOperation * valueoperation = new SetValueOperation();
- SetValueOperation * mixvalueoperation = new SetValueOperation();
- MixBlendOperation * mixoperation = new MixBlendOperation();
- mixoperation->setResolutionInputSocketIndex(1);
- this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
- addLink(system, thresholdOperation->getOutputSocket(), bluroperation->getInputSocket(0));
- addLink(system, valueoperation->getOutputSocket(), bluroperation->getInputSocket(1));
- addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
- addLink(system, bluroperation->getOutputSocket(), mixoperation->getInputSocket(2));
- addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
-
- thresholdOperation->setThreshold(glare->threshold);
- NodeBlurData * data = new NodeBlurData();
- data->relative = 0;
- data->sizex = glare->size;
- data->sizey = glare->size;
- bluroperation->setData(data);
- bluroperation->deleteDataWhenFinished();
- bluroperation->setQuality(context->getQuality());
- valueoperation->setValue(1.0f);
- mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
- this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+ switch (glare->type) {
- system->addOperation(bluroperation);
- system->addOperation(thresholdOperation);
- system->addOperation(mixvalueoperation);
- system->addOperation(valueoperation);
- system->addOperation(mixoperation);
- }
- break;
-
- case 0: // simple star
- {
- GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
- GlareSimpleStarOperation * glareoperation = new GlareSimpleStarOperation();
- SetValueOperation * mixvalueoperation = new SetValueOperation();
- MixBlendOperation * mixoperation = new MixBlendOperation();
-
- this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
- addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
- addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
- addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
- addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
- this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+ default:
+ case 3:
+ glareoperation = new GlareGhostOperation();
+ break;
+ case 2: // streaks
+ glareoperation = new GlareStreaksOperation();
+ break;
+ case 1: // fog glow
+ glareoperation = new GlareFogGlowOperation();
+ break;
+ case 0: // simple star
+ glareoperation = new GlareSimpleStarOperation();
+ break;
+ }
+ GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+ SetValueOperation *mixvalueoperation = new SetValueOperation();
+ MixGlareOperation *mixoperation = new MixGlareOperation();
+ mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT);
- thresholdOperation->setThreshold(glare->threshold);
- glareoperation->setGlareSettings(glare);
- mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
- mixoperation->setResolutionInputSocketIndex(1);
+ this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
+ addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
+ addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+ addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
+ addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+ this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+ thresholdOperation->setGlareSettings(glare);
+ glareoperation->setGlareSettings(glare);
+ mixvalueoperation->setValue(0.5f + glare->mix * 0.5f);
+ mixoperation->setResolutionInputSocketIndex(1);
- system->addOperation(glareoperation);
- system->addOperation(thresholdOperation);
- system->addOperation(mixvalueoperation);
- system->addOperation(mixoperation);
- }
- break;
+ system->addOperation(glareoperation);
+ system->addOperation(thresholdOperation);
+ system->addOperation(mixvalueoperation);
+ system->addOperation(mixoperation);
+
}
-}
diff --git a/source/blender/compositor/nodes/COM_GlareNode.h b/source/blender/compositor/nodes/COM_GlareNode.h
index 97a75445db7..beb01db733a 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.h
+++ b/source/blender/compositor/nodes/COM_GlareNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief GlareNode
- * @ingroup Node
- */
-class GlareNode: public Node {
+ * @brief GlareNode
+ * @ingroup Node
+ */
+class GlareNode : public Node {
public:
GlareNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp
index ec06a3acd7e..e5255b6bb87 100644
--- a/source/blender/compositor/nodes/COM_GroupNode.cpp
+++ b/source/blender/compositor/nodes/COM_GroupNode.cpp
@@ -24,43 +24,46 @@
#include "COM_SocketProxyNode.h"
#include "COM_ExecutionSystemHelper.h"
-GroupNode::GroupNode(bNode *editorNode): Node(editorNode)
+GroupNode::GroupNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
+ /* pass */
}
void GroupNode::ungroup(ExecutionSystem &system)
{
- vector<InputSocket*> &inputsockets = this->getInputSockets();
- vector<OutputSocket*> &outputsockets = this->getOutputSockets();
+ bNode *bnode = this->getbNode();
+ vector<InputSocket *> &inputsockets = this->getInputSockets();
+ vector<OutputSocket *> &outputsockets = this->getOutputSockets();
unsigned int index;
/* get the node list size _before_ adding proxy nodes, so they are available for linking */
int nodes_start = system.getNodes().size();
- for (index = 0 ; index < inputsockets.size();index ++) {
- InputSocket * inputSocket = inputsockets[index];
+ for (index = 0; index < inputsockets.size(); index++) {
+ InputSocket *inputSocket = inputsockets[index];
bNodeSocket *editorInput = inputSocket->getbNodeSocket();
if (editorInput->groupsock) {
- SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock);
+ SocketProxyNode *proxy = new SocketProxyNode(bnode, editorInput, editorInput->groupsock);
inputSocket->relinkConnections(proxy->getInputSocket(0), index, &system);
ExecutionSystemHelper::addNode(system.getNodes(), proxy);
}
}
- for (index = 0 ; index < outputsockets.size();index ++) {
- OutputSocket * outputSocket = outputsockets[index];
+ for (index = 0; index < outputsockets.size(); index++) {
+ OutputSocket *outputSocket = outputsockets[index];
bNodeSocket *editorOutput = outputSocket->getbNodeSocket();
if (editorOutput->groupsock) {
- SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorOutput->groupsock, editorOutput);
+ SocketProxyNode *proxy = new SocketProxyNode(bnode, editorOutput->groupsock, editorOutput);
outputSocket->relinkConnections(proxy->getOutputSocket(0));
ExecutionSystemHelper::addNode(system.getNodes(), proxy);
}
}
- bNodeTree *subtree = (bNodeTree*)this->getbNode()->id;
- ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree);
+ bNodeTree *subtree = (bNodeTree *)bnode->id;
+ ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree, bnode);
}
diff --git a/source/blender/compositor/nodes/COM_GroupNode.h b/source/blender/compositor/nodes/COM_GroupNode.h
index e35c9cbce33..ba270eaf16c 100644
--- a/source/blender/compositor/nodes/COM_GroupNode.h
+++ b/source/blender/compositor/nodes/COM_GroupNode.h
@@ -27,30 +27,30 @@
#include "COM_ExecutionSystem.h"
/**
- * @brief Represents a group node
- * @ingroup Node
- */
-class GroupNode: public Node {
+ * @brief Represents a group node
+ * @ingroup Node
+ */
+class GroupNode : public Node {
public:
GroupNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
/**
- * @brief check if this node a group node.
- * @returns true
- */
+ * @brief check if this node a group node.
+ * @returns true
+ */
bool isGroupNode() const { return true; }
/**
- * @brief ungroup this group node.
- * during ungroup the subtree (internal nodes and links) of the group node
- * are added to the ExecutionSystem.
- *
- * Between the main tree and the subtree proxy nodes will be added
- * to translate between InputSocket and OutputSocket
- *
- * @param system the ExecutionSystem where to add the subtree
- */
+ * @brief ungroup this group node.
+ * during ungroup the subtree (internal nodes and links) of the group node
+ * are added to the ExecutionSystem.
+ *
+ * Between the main tree and the subtree proxy nodes will be added
+ * to translate between InputSocket and OutputSocket
+ *
+ * @param system the ExecutionSystem where to add the subtree
+ */
void ungroup(ExecutionSystem &system);
};
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
index ae96a8c9fb8..6057a7f0e6c 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
@@ -33,23 +33,24 @@
#include "DNA_node_types.h"
#include "COM_HueSaturationValueCorrectOperation.h"
-HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode): Node(editorNode)
+HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *valueSocket = this->getInputSocket(0);
InputSocket *colourSocket = this->getInputSocket(1);
OutputSocket *outputSocket = this->getOutputSocket(0);
bNode *editorsnode = getbNode();
- CurveMapping *storage = (CurveMapping*)editorsnode->storage;
+ CurveMapping *storage = (CurveMapping *)editorsnode->storage;
if (colourSocket->isConnected() && outputSocket->isConnected()) {
- ConvertRGBToHSVOperation * rgbToHSV = new ConvertRGBToHSVOperation();
- ConvertHSVToRGBOperation * hsvToRGB = new ConvertHSVToRGBOperation();
+ ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
+ ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation();
- MixBlendOperation * blend = new MixBlendOperation();
+ MixBlendOperation *blend = new MixBlendOperation();
colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph);
addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
index d69990f712c..ed5f2b51ce3 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
/**
- * @brief HueSaturationValueCorrectNode
- * @ingroup Node
- */
+ * @brief HueSaturationValueCorrectNode
+ * @ingroup Node
+ */
class HueSaturationValueCorrectNode : public Node {
public:
HueSaturationValueCorrectNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
index 32c7d4719a4..ef501317e48 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
@@ -32,22 +32,23 @@
#include "COM_ChangeHSVOperation.h"
#include "DNA_node_types.h"
-HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode): Node(editorNode)
+HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *valueSocket = this->getInputSocket(0);
InputSocket *colourSocket = this->getInputSocket(1);
OutputSocket *outputSocket = this->getOutputSocket(0);
bNode *editorsnode = getbNode();
- NodeHueSat *storage = (NodeHueSat*)editorsnode->storage;
+ NodeHueSat *storage = (NodeHueSat *)editorsnode->storage;
- ConvertRGBToHSVOperation * rgbToHSV = new ConvertRGBToHSVOperation();
- ConvertHSVToRGBOperation * hsvToRGB = new ConvertHSVToRGBOperation();
+ ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
+ ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
ChangeHSVOperation *changeHSV = new ChangeHSVOperation();
- MixBlendOperation * blend = new MixBlendOperation();
+ MixBlendOperation *blend = new MixBlendOperation();
colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 0, graph);
addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
index 4fa1a4f547c..92c18019196 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
/**
- * @brief HueSaturationValueNode
- * @ingroup Node
- */
+ * @brief HueSaturationValueNode
+ * @ingroup Node
+ */
class HueSaturationValueNode : public Node {
public:
HueSaturationValueNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
index 82d3ae8ca29..4005e5d2900 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
@@ -26,10 +26,11 @@
#include "COM_ExecutionSystem.h"
#include "COM_AntiAliasOperation.h"
-IDMaskNode::IDMaskNode(bNode *editorNode): Node(editorNode)
+IDMaskNode::IDMaskNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
bNode *bnode = this->getbNode();
IDMaskOperation *operation;
@@ -37,11 +38,11 @@ void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
operation->setObjectIndex(bnode->custom1);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- if (bnode->custom2==0 || context->getScene()->r.scemode & R_FULL_SAMPLE) {
+ if (bnode->custom2 == 0 || context->getScene()->r.scemode & R_FULL_SAMPLE) {
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
}
else {
- AntiAliasOperation * antiAliasOperation = new AntiAliasOperation();
+ AntiAliasOperation *antiAliasOperation = new AntiAliasOperation();
addLink(graph, operation->getOutputSocket(), antiAliasOperation->getInputSocket(0));
this->getOutputSocket(0)->relinkConnections(antiAliasOperation->getOutputSocket(0));
graph->addOperation(antiAliasOperation);
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.h b/source/blender/compositor/nodes/COM_IDMaskNode.h
index 2ccbbc08f9a..9fd52be2120 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.h
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief IDMaskNode
- * @ingroup Node
- */
-class IDMaskNode: public Node {
+ * @brief IDMaskNode
+ * @ingroup Node
+ */
+class IDMaskNode : public Node {
public:
IDMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index cfd530173a9..addde140b9f 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -28,25 +28,27 @@
#include "BKE_node.h"
#include "BLI_utildefines.h"
-ImageNode::ImageNode(bNode *editorNode): Node(editorNode)
+ImageNode::ImageNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
+
}
NodeOperation *ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer *rl, Image *image, ImageUser *user, int framenumber, int outputsocketIndex, int pass, DataType datatype)
{
OutputSocket *outputSocket = this->getOutputSocket(outputsocketIndex);
- MultilayerBaseOperation * operation = NULL;
+ MultilayerBaseOperation *operation = NULL;
switch (datatype) {
- case COM_DT_VALUE:
- operation = new MultilayerValueOperation(pass);
- break;
- case COM_DT_VECTOR:
- operation = new MultilayerVectorOperation(pass);
- break;
- case COM_DT_COLOR:
- operation = new MultilayerColorOperation(pass);
- break;
- default:
- break;
+ case COM_DT_VALUE:
+ operation = new MultilayerValueOperation(pass);
+ break;
+ case COM_DT_VECTOR:
+ operation = new MultilayerVectorOperation(pass);
+ break;
+ case COM_DT_COLOR:
+ operation = new MultilayerColorOperation(pass);
+ break;
+ default:
+ break;
}
operation->setImage(image);
operation->setRenderLayer(rl);
@@ -57,52 +59,52 @@ NodeOperation *ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer
return operation;
}
-void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
/// Image output
OutputSocket *outputImage = this->getOutputSocket(0);
bNode *editorNode = this->getbNode();
- Image *image = (Image*)editorNode->id;
- ImageUser *imageuser = (ImageUser*)editorNode->storage;
+ Image *image = (Image *)editorNode->id;
+ ImageUser *imageuser = (ImageUser *)editorNode->storage;
int framenumber = context->getFramenumber();
int numberOfOutputs = this->getNumberOfOutputSockets();
BKE_image_user_frame_calc(imageuser, context->getFramenumber(), 0);
/* force a load, we assume iuser index will be set OK anyway */
- if (image && image->type==IMA_TYPE_MULTILAYER) {
+ if (image && image->type == IMA_TYPE_MULTILAYER) {
BKE_image_get_ibuf(image, imageuser);
if (image->rr) {
- RenderLayer *rl = (RenderLayer*)BLI_findlink(&image->rr->layers, imageuser->layer);
+ RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
if (rl) {
- OutputSocket * socket;
+ OutputSocket *socket;
int index;
- for (index = 0 ; index < numberOfOutputs ; index ++) {
+ for (index = 0; index < numberOfOutputs; index++) {
socket = this->getOutputSocket(index);
if (socket->isConnected() || index == 0) {
bNodeSocket *bnodeSocket = socket->getbNodeSocket();
- NodeImageLayer *storage = (NodeImageLayer*)bnodeSocket->storage;
+ NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;
int passindex = storage->pass_index;
RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);
if (rpass) {
- NodeOperation * operation = NULL;
+ NodeOperation *operation = NULL;
imageuser->pass = passindex;
switch (rpass->channels) {
- case 1:
- operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE);
- break;
- /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
- /* XXX any way to detect actual vector images? */
- case 3:
- operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);
- break;
- case 4:
- operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);
- break;
-
- default:
- /* XXX add a dummy operation? */
- break;
+ case 1:
+ operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE);
+ break;
+ /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
+ /* XXX any way to detect actual vector images? */
+ case 3:
+ operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);
+ break;
+ case 4:
+ operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);
+ break;
+
+ default:
+ /* XXX add a dummy operation? */
+ break;
}
if (index == 0 && operation) {
addPreviewOperation(graph, operation->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h
index 70c3ab7f4b0..384dd6c09ff 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.h
+++ b/source/blender/compositor/nodes/COM_ImageNode.h
@@ -30,15 +30,15 @@ extern "C" {
}
/**
- * @brief ImageNode
- * @ingroup Node
- */
+ * @brief ImageNode
+ * @ingroup Node
+ */
class ImageNode : public Node {
private:
NodeOperation *doMultilayerCheck(ExecutionSystem *system, RenderLayer *rl, Image *image, ImageUser *user, int framenumber, int outputsocketIndex, int pass, DataType datatype);
public:
ImageNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp
index 5d039239fbe..c468bda1b67 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.cpp
+++ b/source/blender/compositor/nodes/COM_InvertNode.cpp
@@ -26,11 +26,12 @@
#include "COM_ExecutionSystem.h"
#include "BKE_node.h"
-InvertNode::InvertNode(bNode *editorNode): Node(editorNode)
+InvertNode::InvertNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void InvertNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void InvertNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InvertOperation *operation = new InvertOperation();
bNode *node = this->getbNode();
diff --git a/source/blender/compositor/nodes/COM_InvertNode.h b/source/blender/compositor/nodes/COM_InvertNode.h
index 570e86445e6..d061f1c12bd 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.h
+++ b/source/blender/compositor/nodes/COM_InvertNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief InvertNode
- * @ingroup Node
- */
-class InvertNode: public Node {
+ * @brief InvertNode
+ * @ingroup Node
+ */
+class InvertNode : public Node {
public:
InvertNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
new file mode 100644
index 00000000000..50c1903982e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingNode.h"
+
+#include "COM_ExecutionSystem.h"
+
+#include "COM_KeyingOperation.h"
+#include "COM_KeyingBlurOperation.h"
+#include "COM_KeyingDespillOperation.h"
+#include "COM_KeyingClipOperation.h"
+
+#include "COM_SeparateChannelOperation.h"
+#include "COM_CombineChannelsOperation.h"
+#include "COM_ConvertRGBToYCCOperation.h"
+#include "COM_ConvertYCCToRGBOperation.h"
+#include "COM_GaussianBokehBlurOperation.h"
+#include "COM_SetValueOperation.h"
+
+#include "COM_DilateErodeOperation.h"
+
+#include "COM_SetAlphaOperation.h"
+
+KeyingNode::KeyingNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
+
+OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage)
+{
+ ConvertRGBToYCCOperation *convertRGBToYCCOperation = new ConvertRGBToYCCOperation();
+ convertRGBToYCCOperation->setMode(0); /* ITU 601 */
+
+ inputImage->relinkConnections(convertRGBToYCCOperation->getInputSocket(0), 0, graph);
+ graph->addOperation(convertRGBToYCCOperation);
+
+ CombineChannelsOperation *combineOperation = new CombineChannelsOperation();
+ graph->addOperation(combineOperation);
+
+ for (int channel = 0; channel < 4; channel++) {
+ SeparateChannelOperation *separateOperation = new SeparateChannelOperation();
+ separateOperation->setChannel(channel);
+ addLink(graph, convertRGBToYCCOperation->getOutputSocket(0), separateOperation->getInputSocket(0));
+ graph->addOperation(separateOperation);
+
+ if (channel == 0 || channel == 3) {
+ addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
+ }
+ else {
+ KeyingBlurOperation *blurOperation = new KeyingBlurOperation();
+
+ blurOperation->setSize(size);
+
+ addLink(graph, separateOperation->getOutputSocket(0), blurOperation->getInputSocket(0));
+ addLink(graph, blurOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
+ graph->addOperation(blurOperation);
+ }
+ }
+
+ ConvertYCCToRGBOperation *convertYCCToRGBOperation = new ConvertYCCToRGBOperation();
+ convertYCCToRGBOperation->setMode(0); /* ITU 601 */
+ addLink(graph, combineOperation->getOutputSocket(0), convertYCCToRGBOperation->getInputSocket(0));
+ graph->addOperation(convertYCCToRGBOperation);
+
+ *originalImage = convertRGBToYCCOperation->getInputSocket(0)->getConnection()->getFromSocket();
+
+ return convertYCCToRGBOperation->getOutputSocket(0);
+}
+
+OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size)
+{
+ KeyingBlurOperation *blurOperation = new KeyingBlurOperation();
+
+ blurOperation->setSize(size);
+
+ addLink(graph, postBLurInput, blurOperation->getInputSocket(0));
+
+ graph->addOperation(blurOperation);
+
+ return blurOperation->getOutputSocket();
+}
+
+OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance)
+{
+ DilateStepOperation *dilateErodeOperation;
+
+ if (distance > 0) {
+ dilateErodeOperation = new DilateStepOperation();
+ dilateErodeOperation->setIterations(distance);
+ }
+ else {
+ dilateErodeOperation = new ErodeStepOperation();
+ dilateErodeOperation->setIterations(-distance);
+ }
+
+ addLink(graph, dilateErodeInput, dilateErodeOperation->getInputSocket(0));
+
+ graph->addOperation(dilateErodeOperation);
+
+ return dilateErodeOperation->getOutputSocket(0);
+}
+
+OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, float factor)
+{
+ KeyingDespillOperation *despillOperation = new KeyingDespillOperation();
+
+ despillOperation->setDespillFactor(factor);
+
+ addLink(graph, despillInput, despillOperation->getInputSocket(0));
+ addLink(graph, inputScreen, despillOperation->getInputSocket(1));
+
+ graph->addOperation(despillOperation);
+
+ return despillOperation->getOutputSocket(0);
+}
+
+OutputSocket *KeyingNode::setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance,
+ float clipBlack, float clipWhite, bool edgeMatte)
+{
+ KeyingClipOperation *clipOperation = new KeyingClipOperation();
+
+ clipOperation->setKernelRadius(kernelRadius);
+ clipOperation->setKernelTolerance(kernelTolerance);
+
+ clipOperation->setClipBlack(clipBlack);
+ clipOperation->setClipWhite(clipWhite);
+ clipOperation->setIsEdgeMatte(edgeMatte);
+
+ addLink(graph, clipInput, clipOperation->getInputSocket(0));
+
+ graph->addOperation(clipOperation);
+
+ return clipOperation->getOutputSocket(0);
+}
+
+void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+ InputSocket *inputImage = this->getInputSocket(0);
+ InputSocket *inputScreen = this->getInputSocket(1);
+ InputSocket *inputGarbageMatte = this->getInputSocket(2);
+ InputSocket *inputCoreMatte = this->getInputSocket(3);
+ OutputSocket *outputImage = this->getOutputSocket(0);
+ OutputSocket *outputMatte = this->getOutputSocket(1);
+ OutputSocket *outputEdges = this->getOutputSocket(2);
+ OutputSocket *postprocessedMatte, *postprocessedImage, *originalImage, *edgesMatte;
+
+ bNode *editorNode = this->getbNode();
+ NodeKeyingData *keying_data = (NodeKeyingData *) editorNode->storage;
+
+ /* keying operation */
+ KeyingOperation *keyingOperation = new KeyingOperation();
+
+ keyingOperation->setScreenBalance(keying_data->screen_balance);
+
+ inputScreen->relinkConnections(keyingOperation->getInputSocket(1), 1, graph);
+ inputGarbageMatte->relinkConnections(keyingOperation->getInputSocket(2), 2, graph);
+ inputCoreMatte->relinkConnections(keyingOperation->getInputSocket(3), 3, graph);
+
+ if (keying_data->blur_pre) {
+ /* chroma preblur operation for input of keying operation */
+ OutputSocket *preBluredImage = setupPreBlur(graph, inputImage, keying_data->blur_pre, &originalImage);
+ addLink(graph, preBluredImage, keyingOperation->getInputSocket(0));
+ }
+ else {
+ inputImage->relinkConnections(keyingOperation->getInputSocket(0), 0, graph);
+ originalImage = keyingOperation->getInputSocket(0)->getConnection()->getFromSocket();
+ }
+
+ graph->addOperation(keyingOperation);
+
+ postprocessedMatte = keyingOperation->getOutputSocket();
+
+ if (keying_data->clip_black > 0.0f || keying_data->clip_white < 1.0f) {
+ postprocessedMatte = setupClip(graph, postprocessedMatte,
+ keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
+ keying_data->clip_black, keying_data->clip_white, false);
+ }
+
+ edgesMatte = setupClip(graph, postprocessedMatte,
+ keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
+ keying_data->clip_black, keying_data->clip_white, true);
+
+ /* apply blur on matte if needed */
+ if (keying_data->blur_post)
+ postprocessedMatte = setupPostBlur(graph, postprocessedMatte, keying_data->blur_post);
+
+ /* matte dilate/erode */
+ if (keying_data->dilate_distance != 0) {
+ postprocessedMatte = setupDilateErode(graph, postprocessedMatte, keying_data->dilate_distance);
+ }
+
+ /* set alpha channel to output image */
+ SetAlphaOperation *alphaOperation = new SetAlphaOperation();
+ addLink(graph, originalImage, alphaOperation->getInputSocket(0));
+ addLink(graph, postprocessedMatte, alphaOperation->getInputSocket(1));
+
+ postprocessedImage = alphaOperation->getOutputSocket();
+
+ /* despill output image */
+ if (keying_data->despill_factor > 0.0f) {
+ postprocessedImage = setupDespill(graph, postprocessedImage,
+ keyingOperation->getInputSocket(1)->getConnection()->getFromSocket(),
+ keying_data->despill_factor);
+ }
+
+ /* connect result to output sockets */
+ outputImage->relinkConnections(postprocessedImage);
+ outputMatte->relinkConnections(postprocessedMatte);
+ outputEdges->relinkConnections(edgesMatte);
+
+ graph->addOperation(alphaOperation);
+}
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h
new file mode 100644
index 00000000000..cc1d447c66e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_KeyingNode.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_Node.h"
+
+/**
+ * @brief KeyingNode
+ * @ingroup Node
+ */
+class KeyingNode : public Node {
+protected:
+ OutputSocket *setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage);
+ OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size);
+ OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance);
+ OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, float factor);
+ OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance,
+ float clipBlack, float clipWhite, bool edgeMatte);
+public:
+ KeyingNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+
+};
diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
new file mode 100644
index 00000000000..0fb8d45d066
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingScreenNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_KeyingScreenOperation.h"
+
+extern "C" {
+ #include "DNA_movieclip_types.h"
+}
+
+KeyingScreenNode::KeyingScreenNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
+
+void KeyingScreenNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+ OutputSocket *outputScreen = this->getOutputSocket(0);
+
+ bNode *editorNode = this->getbNode();
+ MovieClip *clip = (MovieClip *) editorNode->id;
+
+ NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *) editorNode->storage;
+
+ // always connect the output image
+ KeyingScreenOperation *operation = new KeyingScreenOperation();
+
+ if (outputScreen->isConnected()) {
+ outputScreen->relinkConnections(operation->getOutputSocket());
+ }
+
+ operation->setMovieClip(clip);
+ operation->setTrackingObject(keyingscreen_data->tracking_object);
+ operation->setFramenumber(context->getFramenumber());
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.h b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
new file mode 100644
index 00000000000..7c87219ef6e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief KeyingScreenNode
+ * @ingroup Node
+ */
+class KeyingScreenNode : public Node {
+public:
+ KeyingScreenNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+
+};
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
index e55dd5e64d8..03034e34eb7 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
@@ -26,14 +26,15 @@
#include "COM_ProjectorLensDistortionOperation.h"
#include "COM_ScreenLensDistortionOperation.h"
-LensDistortionNode::LensDistortionNode(bNode *editorNode): Node(editorNode)
+LensDistortionNode::LensDistortionNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
bNode *editorNode = this->getbNode();
- NodeLensDist * data = (NodeLensDist*)editorNode->storage;
+ NodeLensDist *data = (NodeLensDist *)editorNode->storage;
if (data->proj) {
ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.h b/source/blender/compositor/nodes/COM_LensDistortionNode.h
index 64de740fde8..52529823441 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief LensDistortionNode
- * @ingroup Node
- */
-class LensDistortionNode: public Node {
+ * @brief LensDistortionNode
+ * @ingroup Node
+ */
+class LensDistortionNode : public Node {
public:
LensDistortionNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
index 37976216106..be949e2cacb 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
@@ -25,8 +25,10 @@
#include "COM_ConvertRGBToYUVOperation.h"
#include "COM_SetAlphaOperation.h"
-LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode): Node(editorNode)
-{}
+LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
void LuminanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
@@ -37,7 +39,7 @@ void LuminanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorC
ConvertRGBToYUVOperation *rgbToYUV = new ConvertRGBToYUVOperation();
LuminanceMatteOperation *operationSet = new LuminanceMatteOperation();
bNode *editorsnode = getbNode();
- operationSet->setSettings((NodeChroma*)editorsnode->storage);
+ operationSet->setSettings((NodeChroma *)editorsnode->storage);
inputSocket->relinkConnections(rgbToYUV->getInputSocket(0), 0, graph);
addLink(graph, rgbToYUV->getOutputSocket(), operationSet->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
index e2dd8b47833..c699a0d1168 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
@@ -25,9 +25,9 @@
#include "COM_Node.h"
/**
- * @brief LuminanceMatteNode
- * @ingroup Node
- */
+ * @brief LuminanceMatteNode
+ * @ingroup Node
+ */
class LuminanceMatteNode : public Node
{
public:
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cpp b/source/blender/compositor/nodes/COM_MapUVNode.cpp
index e0e7e2594ed..447b8239a93 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapUVNode.cpp
@@ -23,11 +23,12 @@
#include "COM_MapUVOperation.h"
#include "COM_ExecutionSystem.h"
-MapUVNode::MapUVNode(bNode *editorNode): Node(editorNode)
+MapUVNode::MapUVNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void MapUVNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void MapUVNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
MapUVOperation *operation = new MapUVOperation();
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.h b/source/blender/compositor/nodes/COM_MapUVNode.h
index 3092e84990f..a1df790f192 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.h
+++ b/source/blender/compositor/nodes/COM_MapUVNode.h
@@ -31,6 +31,6 @@
class MapUVNode : public Node {
public:
MapUVNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp
index f56662b1d64..ba2fc804f42 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp
@@ -25,15 +25,16 @@
#include "COM_MapValueOperation.h"
#include "COM_ExecutionSystem.h"
-MapValueNode::MapValueNode(bNode *editorNode): Node(editorNode)
+MapValueNode::MapValueNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *colourSocket = this->getInputSocket(0);
OutputSocket *valueSocket = this->getOutputSocket(0);
- TexMapping *storage = (TexMapping*)this->getbNode()->storage;
+ TexMapping *storage = (TexMapping *)this->getbNode()->storage;
MapValueOperation *convertProg = new MapValueOperation();
convertProg->setSettings(storage);
colourSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h
index 47a6ea6adce..c7a842dff95 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.h
+++ b/source/blender/compositor/nodes/COM_MapValueNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief MapValueNode
- * @ingroup Node
- */
+ * @brief MapValueNode
+ * @ingroup Node
+ */
class MapValueNode : public Node {
public:
MapValueNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp
index 991c3f75e05..ed07e41a649 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_MaskNode.cpp
@@ -29,15 +29,15 @@ extern "C" {
#include "DNA_mask_types.h"
}
-MaskNode::MaskNode(bNode *editorNode): Node(editorNode)
+MaskNode::MaskNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
const RenderData *data = &context->getScene()->r;
- InputSocket *inputImage = this->getInputSocket(0);
OutputSocket *outputMask = this->getOutputSocket(0);
bNode *editorNode = this->getbNode();
@@ -46,13 +46,8 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * c
// always connect the output image
MaskOperation *operation = new MaskOperation();
- if (inputImage->isConnected()) {
- inputImage->relinkConnections(operation->getInputSocket(0), 0, graph);
- }
- else {
- operation->setMaskWidth(data->xsch * data->size / 100.0f);
- operation->setMaskHeight(data->ysch * data->size / 100.0f);
- }
+ operation->setMaskWidth(data->xsch * data->size / 100.0f);
+ operation->setMaskHeight(data->ysch * data->size / 100.0f);
if (outputMask->isConnected()) {
outputMask->relinkConnections(operation->getOutputSocket());
@@ -60,6 +55,7 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * c
operation->setMask(mask);
operation->setFramenumber(context->getFramenumber());
+ operation->setSmooth((bool)editorNode->custom1);
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_MaskNode.h b/source/blender/compositor/nodes/COM_MaskNode.h
index 9d2ea1889d9..8a9bc50eac7 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.h
+++ b/source/blender/compositor/nodes/COM_MaskNode.h
@@ -25,9 +25,9 @@
#include "DNA_node_types.h"
/**
- * @brief MaskNode
- * @ingroup Node
- */
+ * @brief MaskNode
+ * @ingroup Node
+ */
class MaskNode : public Node {
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
index eabd0481e38..6e9b49253e7 100644
--- a/source/blender/compositor/nodes/COM_MathNode.cpp
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -24,61 +24,61 @@
#include "COM_MathBaseOperation.h"
#include "COM_ExecutionSystem.h"
-void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- MathBaseOperation *operation=NULL;
+ MathBaseOperation *operation = NULL;
switch (this->getbNode()->custom1)
{
- case 0: /* Add */
+ case 0: /* Add */
operation = new MathAddOperation();
break;
- case 1: /* Subtract */
+ case 1: /* Subtract */
operation = new MathSubtractOperation();
break;
- case 2: /* Multiply */
+ case 2: /* Multiply */
operation = new MathMultiplyOperation();
break;
- case 3: /* Divide */
+ case 3: /* Divide */
operation = new MathDivideOperation();
break;
- case 4: /* Sine */
+ case 4: /* Sine */
operation = new MathSineOperation();
break;
- case 5: /* Cosine */
+ case 5: /* Cosine */
operation = new MathCosineOperation();
break;
- case 6: /* Tangent */
+ case 6: /* Tangent */
operation = new MathTangentOperation();
break;
- case 7: /* Arc-Sine */
+ case 7: /* Arc-Sine */
operation = new MathArcSineOperation();
break;
- case 8: /* Arc-Cosine */
+ case 8: /* Arc-Cosine */
operation = new MathArcCosineOperation();
break;
- case 9: /* Arc-Tangent */
+ case 9: /* Arc-Tangent */
operation = new MathArcTangentOperation();
break;
- case 10: /* Power */
+ case 10: /* Power */
operation = new MathPowerOperation();
break;
- case 11: /* Logarithm */
+ case 11: /* Logarithm */
operation = new MathLogarithmOperation();
break;
- case 12: /* Minimum */
+ case 12: /* Minimum */
operation = new MathMinimumOperation();
break;
- case 13: /* Maximum */
+ case 13: /* Maximum */
operation = new MathMaximumOperation();
break;
- case 14: /* Round */
+ case 14: /* Round */
operation = new MathRoundOperation();
break;
- case 15: /* Less Than */
+ case 15: /* Less Than */
operation = new MathLessThanOperation();
break;
- case 16: /* Greater Than */
+ case 16: /* Greater Than */
operation = new MathGreaterThanOperation();
break;
}
diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h
index 1e2cccda396..16d65843b0d 100644
--- a/source/blender/compositor/nodes/COM_MathNode.h
+++ b/source/blender/compositor/nodes/COM_MathNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief MathNode
- * @ingroup Node
- */
-class MathNode: public Node {
+ * @brief MathNode
+ * @ingroup Node
+ */
+class MathNode : public Node {
public:
- MathNode(bNode *editorNode) :Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ MathNode(bNode *editorNode) : Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp
index 42e32a4e55e..eb62ebd2635 100644
--- a/source/blender/compositor/nodes/COM_MixNode.cpp
+++ b/source/blender/compositor/nodes/COM_MixNode.cpp
@@ -46,12 +46,12 @@
#include "DNA_material_types.h" // the ramp types
-MixNode::MixNode(bNode *editorNode): Node(editorNode)
+MixNode::MixNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-
-void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *valueSocket = this->getInputSocket(0);
InputSocket *color1Socket = this->getInputSocket(1);
@@ -62,62 +62,62 @@ void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext * co
MixBaseOperation *convertProg;
switch (editorNode->custom1) {
- case MA_RAMP_ADD:
- convertProg = new MixAddOperation();
- break;
- case MA_RAMP_MULT:
- convertProg = new MixMultiplyOperation();
- break;
- case MA_RAMP_LIGHT:
- convertProg = new MixLightenOperation();
- break;
- case MA_RAMP_BURN:
- convertProg = new MixBurnOperation();
- break;
- case MA_RAMP_HUE:
- convertProg = new MixHueOperation();
- break;
- case MA_RAMP_COLOR:
- convertProg = new MixColorOperation();
- break;
- case MA_RAMP_SOFT:
- convertProg = new MixSoftLightOperation();
- break;
- case MA_RAMP_SCREEN:
- convertProg = new MixScreenOperation();
- break;
- case MA_RAMP_LINEAR:
- convertProg = new MixLinearLightOperation();
- break;
- case MA_RAMP_DIFF:
- convertProg = new MixDifferenceOperation();
- break;
- case MA_RAMP_SAT:
- convertProg = new MixSaturationOperation();
- break;
- case MA_RAMP_DIV:
- convertProg = new MixDivideOperation();
- break;
- case MA_RAMP_SUB:
- convertProg = new MixSubtractOperation();
- break;
- case MA_RAMP_DARK:
- convertProg = new MixDarkenOperation();
- break;
- case MA_RAMP_OVERLAY:
- convertProg = new MixOverlayOperation();
- break;
- case MA_RAMP_VAL:
- convertProg = new MixValueOperation();
- break;
- case MA_RAMP_DODGE:
- convertProg = new MixDodgeOperation();
- break;
-
- case MA_RAMP_BLEND:
- default:
- convertProg = new MixBlendOperation();
- break;
+ case MA_RAMP_ADD:
+ convertProg = new MixAddOperation();
+ break;
+ case MA_RAMP_MULT:
+ convertProg = new MixMultiplyOperation();
+ break;
+ case MA_RAMP_LIGHT:
+ convertProg = new MixLightenOperation();
+ break;
+ case MA_RAMP_BURN:
+ convertProg = new MixBurnOperation();
+ break;
+ case MA_RAMP_HUE:
+ convertProg = new MixHueOperation();
+ break;
+ case MA_RAMP_COLOR:
+ convertProg = new MixColorOperation();
+ break;
+ case MA_RAMP_SOFT:
+ convertProg = new MixSoftLightOperation();
+ break;
+ case MA_RAMP_SCREEN:
+ convertProg = new MixScreenOperation();
+ break;
+ case MA_RAMP_LINEAR:
+ convertProg = new MixLinearLightOperation();
+ break;
+ case MA_RAMP_DIFF:
+ convertProg = new MixDifferenceOperation();
+ break;
+ case MA_RAMP_SAT:
+ convertProg = new MixSaturationOperation();
+ break;
+ case MA_RAMP_DIV:
+ convertProg = new MixDivideOperation();
+ break;
+ case MA_RAMP_SUB:
+ convertProg = new MixSubtractOperation();
+ break;
+ case MA_RAMP_DARK:
+ convertProg = new MixDarkenOperation();
+ break;
+ case MA_RAMP_OVERLAY:
+ convertProg = new MixOverlayOperation();
+ break;
+ case MA_RAMP_VAL:
+ convertProg = new MixValueOperation();
+ break;
+ case MA_RAMP_DODGE:
+ convertProg = new MixDodgeOperation();
+ break;
+
+ case MA_RAMP_BLEND:
+ default:
+ convertProg = new MixBlendOperation();
+ break;
}
convertProg->setUseValueAlphaMultiply(this->getbNode()->custom2);
diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h
index 4b57bdbc02a..99e8b4d48f0 100644
--- a/source/blender/compositor/nodes/COM_MixNode.h
+++ b/source/blender/compositor/nodes/COM_MixNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief MixNode
- * @ingroup Node
- */
+ * @brief MixNode
+ * @ingroup Node
+ */
class MixNode : public Node {
public:
MixNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
index eac581dc903..89bd0e8549e 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -33,11 +33,12 @@ extern "C" {
#include "IMB_imbuf.h"
}
-MovieClipNode::MovieClipNode(bNode *editorNode): Node(editorNode)
+MovieClipNode::MovieClipNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
OutputSocket *outputMovieClip = this->getOutputSocket(0);
OutputSocket *offsetXMovieClip = this->getOutputSocket(1);
@@ -46,10 +47,10 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex
OutputSocket *angleMovieClip = this->getOutputSocket(4);
bNode *editorNode = this->getbNode();
- MovieClip *movieClip = (MovieClip*)editorNode->id;
- MovieClipUser *movieClipUser = (MovieClipUser*)editorNode->storage;
+ MovieClip *movieClip = (MovieClip *)editorNode->id;
+ MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage;
- ImBuf * ibuf = NULL;
+ ImBuf *ibuf = NULL;
if (movieClip) {
ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser);
}
@@ -90,31 +91,33 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex
angle = 0.0f;
if (ibuf) {
- if (stab->flag&TRACKING_2D_STABILIZATION) {
- BKE_tracking_stabilization_data(&movieClip->tracking, context->getFramenumber(), ibuf->x, ibuf->y, loc, &scale, &angle);
+ if (stab->flag & TRACKING_2D_STABILIZATION) {
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, context->getFramenumber());
+
+ BKE_tracking_stabilization_data_get(&movieClip->tracking, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle);
}
}
if (offsetXMovieClip->isConnected()) {
- SetValueOperation * operationSetValue = new SetValueOperation();
+ SetValueOperation *operationSetValue = new SetValueOperation();
operationSetValue->setValue(loc[0]);
offsetXMovieClip->relinkConnections(operationSetValue->getOutputSocket());
graph->addOperation(operationSetValue);
}
if (offsetYMovieClip->isConnected()) {
- SetValueOperation * operationSetValue = new SetValueOperation();
+ SetValueOperation *operationSetValue = new SetValueOperation();
operationSetValue->setValue(loc[1]);
offsetYMovieClip->relinkConnections(operationSetValue->getOutputSocket());
graph->addOperation(operationSetValue);
}
if (scaleMovieClip->isConnected()) {
- SetValueOperation * operationSetValue = new SetValueOperation();
+ SetValueOperation *operationSetValue = new SetValueOperation();
operationSetValue->setValue(scale);
scaleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
graph->addOperation(operationSetValue);
}
if (angleMovieClip->isConnected()) {
- SetValueOperation * operationSetValue = new SetValueOperation();
+ SetValueOperation *operationSetValue = new SetValueOperation();
operationSetValue->setValue(angle);
angleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
graph->addOperation(operationSetValue);
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h
index 8ad2fa8cbb0..d70881a6725 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.h
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.h
@@ -24,14 +24,14 @@
#include "DNA_node_types.h"
/**
- * @brief MovieClipNode
- * @ingroup Node
- */
+ * @brief MovieClipNode
+ * @ingroup Node
+ */
class MovieClipNode : public Node {
public:
MovieClipNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
index bdf4c53fa72..c29bc27cd80 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
@@ -28,16 +28,17 @@
MovieDistortionNode::MovieDistortionNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void MovieDistortionNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void MovieDistortionNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
OutputSocket *outputSocket = this->getOutputSocket(0);
bNode *bnode = this->getbNode();
- MovieClip * clip = (MovieClip*)bnode->id;
+ MovieClip *clip = (MovieClip *)bnode->id;
- MovieDistortionOperation * operation = new MovieDistortionOperation(bnode->custom1 == 1);
+ MovieDistortionOperation *operation = new MovieDistortionOperation(bnode->custom1 == 1);
operation->setMovieClip(clip);
operation->setFramenumber(context->getFramenumber());
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.h b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
index 5ee328c9df3..b97600bb64e 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief MovieDistortionNode
- * @ingroup Node
- */
-class MovieDistortionNode: public Node {
+ * @brief MovieDistortionNode
+ * @ingroup Node
+ */
+class MovieDistortionNode : public Node {
public:
MovieDistortionNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp
index 72303a4d6ee..ccf7721b989 100644
--- a/source/blender/compositor/nodes/COM_MuteNode.cpp
+++ b/source/blender/compositor/nodes/COM_MuteNode.cpp
@@ -27,14 +27,15 @@
#include "COM_SetVectorOperation.h"
#include "COM_SetColorOperation.h"
-MuteNode::MuteNode(bNode *editorNode): Node(editorNode)
+MuteNode::MuteNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void MuteNode::reconnect(ExecutionSystem * graph, OutputSocket * output)
+void MuteNode::reconnect(ExecutionSystem *graph, OutputSocket *output)
{
- vector<InputSocket*> &inputsockets = this->getInputSockets();
- for (unsigned int index = 0; index < inputsockets.size() ; index ++) {
+ vector<InputSocket *> &inputsockets = this->getInputSockets();
+ for (unsigned int index = 0; index < inputsockets.size(); index++) {
InputSocket *input = inputsockets[index];
if (input->getDataType() == output->getDataType()) {
if (input->isConnected()) {
@@ -44,37 +45,34 @@ void MuteNode::reconnect(ExecutionSystem * graph, OutputSocket * output)
}
}
- NodeOperation * operation;
+ NodeOperation *operation = NULL;
switch (output->getDataType()) {
- case COM_DT_VALUE:
- {
- SetValueOperation *valueoperation = new SetValueOperation();
- valueoperation->setValue(0.0f);
- operation = valueoperation;
- break;
- }
- case COM_DT_VECTOR:
- {
- SetVectorOperation *vectoroperation = new SetVectorOperation();
- vectoroperation->setX(0.0f);
- vectoroperation->setY(0.0f);
- vectoroperation->setW(0.0f);
- operation = vectoroperation;
- break;
- }
- case COM_DT_COLOR:
- {
- SetColorOperation *coloroperation = new SetColorOperation();
- coloroperation->setChannel1(0.0f);
- coloroperation->setChannel2(0.0f);
- coloroperation->setChannel3(0.0f);
- coloroperation->setChannel4(0.0f);
- operation = coloroperation;
- break;
- }
- /* quiet warnings */
- case COM_DT_UNKNOWN:
- break;
+ case COM_DT_VALUE:
+ {
+ SetValueOperation *valueoperation = new SetValueOperation();
+ valueoperation->setValue(0.0f);
+ operation = valueoperation;
+ break;
+ }
+ case COM_DT_VECTOR:
+ {
+ SetVectorOperation *vectoroperation = new SetVectorOperation();
+ vectoroperation->setX(0.0f);
+ vectoroperation->setY(0.0f);
+ vectoroperation->setW(0.0f);
+ operation = vectoroperation;
+ break;
+ }
+ case COM_DT_COLOR:
+ {
+ SetColorOperation *coloroperation = new SetColorOperation();
+ coloroperation->setChannel1(0.0f);
+ coloroperation->setChannel2(0.0f);
+ coloroperation->setChannel3(0.0f);
+ coloroperation->setChannel4(0.0f);
+ operation = coloroperation;
+ break;
+ }
}
if (operation) {
@@ -85,12 +83,12 @@ void MuteNode::reconnect(ExecutionSystem * graph, OutputSocket * output)
output->clearConnections();
}
-void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- vector<OutputSocket*> &outputsockets = this->getOutputSockets();
+ vector<OutputSocket *> &outputsockets = this->getOutputSockets();
- for (unsigned int index = 0 ; index < outputsockets.size() ; index ++) {
- OutputSocket * output = outputsockets[index];
+ for (unsigned int index = 0; index < outputsockets.size(); index++) {
+ OutputSocket *output = outputsockets[index];
if (output->isConnected()) {
reconnect(graph, output);
}
diff --git a/source/blender/compositor/nodes/COM_MuteNode.h b/source/blender/compositor/nodes/COM_MuteNode.h
index 2dfc786ef2b..aab37e5f888 100644
--- a/source/blender/compositor/nodes/COM_MuteNode.h
+++ b/source/blender/compositor/nodes/COM_MuteNode.h
@@ -26,15 +26,15 @@
#include "COM_Node.h"
/**
- * @brief MuteNode
- * @ingroup Node
- */
-class MuteNode: public Node {
+ * @brief MuteNode
+ * @ingroup Node
+ */
+class MuteNode : public Node {
public:
MuteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
private:
- void reconnect(ExecutionSystem *graph, OutputSocket * output);
+ void reconnect(ExecutionSystem *graph, OutputSocket *output);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp
index 0b1faafe302..e00e71e50e9 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.cpp
+++ b/source/blender/compositor/nodes/COM_NormalNode.cpp
@@ -26,19 +26,21 @@
#include "COM_DotproductOperation.h"
#include "COM_SetVectorOperation.h"
-NormalNode::NormalNode(bNode *editorNode): Node(editorNode)
-{}
+NormalNode::NormalNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
-void NormalNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void NormalNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
OutputSocket *outputSocket = this->getOutputSocket(0);
OutputSocket *outputSocketDotproduct = this->getOutputSocket(1);
bNode *editorNode = this->getbNode();
- SetVectorOperation * operationSet = new SetVectorOperation();
- bNodeSocket * insock = (bNodeSocket*)editorNode->outputs.first;
- bNodeSocketValueVector *dval = (bNodeSocketValueVector*)insock->default_value;
+ SetVectorOperation *operationSet = new SetVectorOperation();
+ bNodeSocket *insock = (bNodeSocket *)editorNode->outputs.first;
+ bNodeSocketValueVector *dval = (bNodeSocketValueVector *)insock->default_value;
operationSet->setX(dval->value[0]);
operationSet->setY(dval->value[1]);
operationSet->setZ(dval->value[2]);
diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h
index 1e7c7c584c3..bf684298e65 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.h
+++ b/source/blender/compositor/nodes/COM_NormalNode.h
@@ -26,14 +26,14 @@
#include "COM_Node.h"
/**
- * @brief NormalNode
- * @ingroup Node
- */
+ * @brief NormalNode
+ * @ingroup Node
+ */
class NormalNode : public Node
{
public:
NormalNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif // COM_NormalNODE_H
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.cpp b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
index 11173b3a73f..7c1c695f8b6 100644
--- a/source/blender/compositor/nodes/COM_NormalizeNode.cpp
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
@@ -23,11 +23,12 @@
#include "COM_NormalizeOperation.h"
#include "COM_ExecutionSystem.h"
-NormalizeNode::NormalizeNode(bNode *editorNode): Node(editorNode)
+NormalizeNode::NormalizeNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void NormalizeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void NormalizeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
NormalizeOperation *operation = new NormalizeOperation();
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.h b/source/blender/compositor/nodes/COM_NormalizeNode.h
index ce7a6e1f7ab..ea1497efdc6 100644
--- a/source/blender/compositor/nodes/COM_NormalizeNode.h
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.h
@@ -25,13 +25,13 @@
#include "COM_Node.h"
/**
- * @brief NormalizeNode
- * @ingroup Node
- */
-class NormalizeNode: public Node {
+ * @brief NormalizeNode
+ * @ingroup Node
+ */
+class NormalizeNode : public Node {
public:
NormalizeNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index ca18ea5fbf7..402529b9186 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -27,13 +27,14 @@
#include "BLI_path_util.h"
#include "BKE_utildefines.h"
-OutputFileNode::OutputFileNode(bNode *editorNode): Node(editorNode)
+OutputFileNode::OutputFileNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- NodeImageMultiFile *storage = (NodeImageMultiFile*)this->getbNode()->storage;
+ NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage;
if (!context->isRendering()) {
/* XXX TODO as in previous implementation?
@@ -41,14 +42,14 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
*/
}
- if (storage->format.imtype==R_IMF_IMTYPE_MULTILAYER) {
+ if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) {
/* single output operation for the multilayer file */
OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation(
- context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec);
+ context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec);
int num_inputs = getNumberOfInputSockets();
bool hasConnections = false;
- for (int i=0; i < num_inputs; ++i) {
+ for (int i = 0; i < num_inputs; ++i) {
InputSocket *input = getInputSocket(i);
if (input->isConnected()) {
hasConnections = true;
@@ -63,10 +64,10 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
graph->addOperation(outputOperation);
}
- else { /* single layer format */
+ else { /* single layer format */
int num_inputs = getNumberOfInputSockets();
bool previewAdded = false;
- for (int i=0; i < num_inputs; ++i) {
+ for (int i = 0; i < num_inputs; ++i) {
InputSocket *input = getInputSocket(i);
if (input->isConnected()) {
NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
@@ -77,7 +78,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation(
- context->getScene(), context->getbNodeTree(), input->getActualDataType(), format, path);
+ context->getScene(), context->getbNodeTree(), input->getDataType(), format, path);
input->relinkConnections(outputOperation->getInputSocket(0));
graph->addOperation(outputOperation);
if (!previewAdded) {
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h
index 10cbba7d50f..79c9b577643 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.h
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.h
@@ -28,13 +28,13 @@
#include "DNA_node_types.h"
/**
- * @brief OutputFileNode
- * @ingroup Node
- */
+ * @brief OutputFileNode
+ * @ingroup Node
+ */
class OutputFileNode : public Node {
public:
OutputFileNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index 8216205b925..95e759fde24 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -47,14 +47,15 @@
#include "COM_ScaleOperation.h"
#include "COM_SetValueOperation.h"
-RenderLayersNode::RenderLayersNode(bNode *editorNode): Node(editorNode)
+RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputSocketNumber, RenderLayersBaseProg * operation)
+void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputSocketNumber, RenderLayersBaseProg *operation)
{
OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber);
- Scene *scene = (Scene*)this->getbNode()->id;
+ Scene *scene = (Scene *)this->getbNode()->id;
short layerId = this->getbNode()->custom1;
if (outputSocket->isConnected()) {
@@ -79,7 +80,7 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS
}
}
-void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
testSocketConnection(graph, 0, new RenderLayersColourProg());
testSocketConnection(graph, 1, new RenderLayersAlphaProg());
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
index f796a7147d9..32672c8ba2d 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.h
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -25,13 +25,13 @@
#include "COM_RenderLayersBaseProg.h"
/**
- * @brief RenderLayersNode
- * @ingroup Node
- */
+ * @brief RenderLayersNode
+ * @ingroup Node
+ */
class RenderLayersNode : public Node {
public:
RenderLayersNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
private:
- void testSocketConnection(ExecutionSystem *graph, int outputSocketNumber, RenderLayersBaseProg * operation);
+ void testSocketConnection(ExecutionSystem *graph, int outputSocketNumber, RenderLayersBaseProg *operation);
};
diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp
index 48acc567739..bb058d18b80 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.cpp
+++ b/source/blender/compositor/nodes/COM_RotateNode.cpp
@@ -28,9 +28,10 @@
RotateNode::RotateNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
InputSocket *inputDegreeSocket = this->getInputSocket(1);
@@ -39,15 +40,15 @@ void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext
SetSamplerOperation *sampler = new SetSamplerOperation();
switch (this->getbNode()->custom1) {
- case 0:
- sampler->setSampler(COM_PS_NEAREST);
- break ;
- case 1:
- sampler->setSampler(COM_PS_BILINEAR);
- break;
- case 2:
- sampler->setSampler(COM_PS_BICUBIC);
- break;
+ case 0:
+ sampler->setSampler(COM_PS_NEAREST);
+ break;
+ case 1:
+ sampler->setSampler(COM_PS_BILINEAR);
+ break;
+ case 2:
+ sampler->setSampler(COM_PS_BICUBIC);
+ break;
}
diff --git a/source/blender/compositor/nodes/COM_RotateNode.h b/source/blender/compositor/nodes/COM_RotateNode.h
index 9b471742aab..6e3801e5353 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.h
+++ b/source/blender/compositor/nodes/COM_RotateNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief RotateNode
- * @ingroup Node
- */
-class RotateNode: public Node {
+ * @brief RotateNode
+ * @ingroup Node
+ */
+class RotateNode : public Node {
public:
RotateNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp
index d709781299f..17b521c589d 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.cpp
+++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -29,9 +29,10 @@
ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
InputSocket *inputXSocket = this->getInputSocket(1);
@@ -39,50 +40,56 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
OutputSocket *outputSocket = this->getOutputSocket(0);
bNode *bnode = this->getbNode();
switch (bnode->custom1) {
- case CMP_SCALE_RELATIVE: {
- ScaleOperation *operation = new ScaleOperation();
-
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- }
+ case CMP_SCALE_RELATIVE: {
+ ScaleOperation *operation = new ScaleOperation();
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+ inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
+ inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
break;
- case CMP_SCALE_SCENEPERCENT: {
- SetValueOperation * scaleFactorOperation = new SetValueOperation();
- scaleFactorOperation->setValue(context->getScene()->r.size/100.0f);
- ScaleOperation * operation = new ScaleOperation();
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
- addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(scaleFactorOperation);
- graph->addOperation(operation);
- }
+ case CMP_SCALE_SCENEPERCENT: {
+ SetValueOperation *scaleFactorOperation = new SetValueOperation();
+ scaleFactorOperation->setValue(context->getScene()->r.size / 100.0f);
+ ScaleOperation *operation = new ScaleOperation();
+ inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+ addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
+ addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(scaleFactorOperation);
+ graph->addOperation(operation);
+ }
break;
-
- case CMP_SCALE_RENDERPERCENT: {
- const RenderData *data = &context->getScene()->r;
- ScaleFixedSizeOperation * operation = new ScaleFixedSizeOperation();
- operation->setNewWidth(data->xsch*data->size/100.0f);
- operation->setNewHeight(data->ysch*data->size/100.0f);
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
- graph->addOperation(operation);
- }
+
+ case CMP_SCALE_RENDERPERCENT: {
+ const RenderData *data = &context->getScene()->r;
+ ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation();
+
+ /* framing options */
+ operation->setIsAspect((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) != 0);
+ operation->setIsCrop((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_CROP) != 0);
+ operation->setOffset(bnode->custom3, bnode->custom4);
+
+ operation->setNewWidth(data->xsch * data->size / 100.0f);
+ operation->setNewHeight(data->ysch * data->size / 100.0f);
+ inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
+ graph->addOperation(operation);
+ }
break;
-
- case CMP_SCALE_ABSOLUTE: {
- ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); // TODO: what is the use of this one.... perhaps some issues when the ui was updated....
-
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- }
+
+ case CMP_SCALE_ABSOLUTE: {
+ ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); // TODO: what is the use of this one.... perhaps some issues when the ui was updated....
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+ inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
+ inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
break;
}
}
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.h b/source/blender/compositor/nodes/COM_ScaleNode.h
index 310ae96a65e..17c7b672a59 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.h
+++ b/source/blender/compositor/nodes/COM_ScaleNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief ScaleNode
- * @ingroup Node
- */
-class ScaleNode: public Node {
+ * @brief ScaleNode
+ * @ingroup Node
+ */
+class ScaleNode : public Node {
public:
ScaleNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp b/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp
index cfce56a080a..4f93b226fa1 100644
--- a/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp
@@ -27,11 +27,12 @@
#include "COM_SetValueOperation.h"
#include "COM_ConvertRGBToHSVOperation.h"
-SeparateHSVANode::SeparateHSVANode(bNode *editorNode): SeparateRGBANode(editorNode)
+SeparateHSVANode::SeparateHSVANode(bNode *editorNode) : SeparateRGBANode(editorNode)
{
+ /* pass */
}
-void SeparateHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void SeparateHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
ConvertRGBToHSVOperation *operation = new ConvertRGBToHSVOperation();
InputSocket *inputSocket = this->getInputSocket(0);
diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.h b/source/blender/compositor/nodes/COM_SeparateHSVANode.h
index 9fbd0212509..4a7e86849dc 100644
--- a/source/blender/compositor/nodes/COM_SeparateHSVANode.h
+++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.h
@@ -28,12 +28,12 @@
#include "COM_SeparateRGBANode.h"
/**
- * @brief SeparateHSVANode
- * @ingroup Node
- */
+ * @brief SeparateHSVANode
+ * @ingroup Node
+ */
class SeparateHSVANode : public SeparateRGBANode {
public:
SeparateHSVANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
index dd154fe604d..67ac6ffc388 100644
--- a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
@@ -28,12 +28,13 @@
#include "DNA_material_types.h" // the ramp types
-SeparateRGBANode::SeparateRGBANode(bNode *editorNode): Node(editorNode)
+SeparateRGBANode::SeparateRGBANode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *imageSocket = this->getInputSocket(0);
OutputSocket *outputRSocket = this->getOutputSocket(0);
diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.h b/source/blender/compositor/nodes/COM_SeparateRGBANode.h
index 5fb00600790..c1be02753da 100644
--- a/source/blender/compositor/nodes/COM_SeparateRGBANode.h
+++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief SeparateRGBANode
- * @ingroup Node
- */
+ * @brief SeparateRGBANode
+ * @ingroup Node
+ */
class SeparateRGBANode : public Node {
public:
SeparateRGBANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp b/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp
index 68d20235de7..154e2bcd550 100644
--- a/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp
@@ -25,8 +25,9 @@
#include "COM_SetValueOperation.h"
#include "COM_ConvertRGBToYCCOperation.h"
-SeparateYCCANode::SeparateYCCANode(bNode *editorNode): SeparateRGBANode(editorNode)
+SeparateYCCANode::SeparateYCCANode(bNode *editorNode) : SeparateRGBANode(editorNode)
{
+ /* pass */
}
void SeparateYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.h b/source/blender/compositor/nodes/COM_SeparateYCCANode.h
index 441eba9bc93..4b216841e2a 100644
--- a/source/blender/compositor/nodes/COM_SeparateYCCANode.h
+++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.h
@@ -27,9 +27,9 @@
#include "COM_SeparateRGBANode.h"
/**
- * @brief SeparateYCCANode
- * @ingroup Node
- */
+ * @brief SeparateYCCANode
+ * @ingroup Node
+ */
class SeparateYCCANode : public SeparateRGBANode {
public:
SeparateYCCANode(bNode *editorNode);
diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp b/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp
index 650e5d1340b..8a647b7f849 100644
--- a/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp
@@ -25,8 +25,9 @@
#include "COM_SetValueOperation.h"
#include "COM_ConvertRGBToYUVOperation.h"
-SeparateYUVANode::SeparateYUVANode(bNode *editorNode): SeparateRGBANode(editorNode)
+SeparateYUVANode::SeparateYUVANode(bNode *editorNode) : SeparateRGBANode(editorNode)
{
+ /* pass */
}
void SeparateYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.h b/source/blender/compositor/nodes/COM_SeparateYUVANode.h
index 136ce1b4f20..e1763e37dff 100644
--- a/source/blender/compositor/nodes/COM_SeparateYUVANode.h
+++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.h
@@ -27,9 +27,9 @@
#include "COM_SeparateRGBANode.h"
/**
- * @brief SeparateYUVANode
- * @ingroup Node
- */
+ * @brief SeparateYUVANode
+ * @ingroup Node
+ */
class SeparateYUVANode : public SeparateRGBANode {
public:
SeparateYUVANode(bNode *editorNode);
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
index 1d09b81c4d2..709dc75b502 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
@@ -24,7 +24,7 @@
#include "COM_SetAlphaOperation.h"
#include "COM_ExecutionSystem.h"
-void SetAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void SetAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
SetAlphaOperation *operation = new SetAlphaOperation();
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h
index c6b603049c5..0707cf5dac1 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief SetAlphaNode
- * @ingroup Node
- */
-class SetAlphaNode: public Node {
+ * @brief SetAlphaNode
+ * @ingroup Node
+ */
+class SetAlphaNode : public Node {
public:
- SetAlphaNode(bNode *editorNode) :Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ SetAlphaNode(bNode *editorNode) : Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
index fbb25afe266..bfb32a96156 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
@@ -28,7 +28,7 @@
#include "COM_SetVectorOperation.h"
#include "COM_SetColorOperation.h"
-SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput): Node(editorNode, false)
+SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput) : Node(editorNode, false)
{
DataType dt;
@@ -43,50 +43,47 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bN
this->addOutputSocket(dt, editorOutput);
}
-void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- OutputSocket * outputsocket = this->getOutputSocket(0);
- InputSocket * inputsocket = this->getInputSocket(0);
+ OutputSocket *outputsocket = this->getOutputSocket(0);
+ InputSocket *inputsocket = this->getInputSocket(0);
if (outputsocket->isConnected()) {
if (inputsocket->isConnected()) {
- SocketProxyOperation *operation = new SocketProxyOperation();
+ SocketProxyOperation *operation = new SocketProxyOperation(this->getOutputSocket()->getDataType());
inputsocket->relinkConnections(operation->getInputSocket(0));
outputsocket->relinkConnections(operation->getOutputSocket(0));
graph->addOperation(operation);
}
else {
/* If input is not connected, add a constant value operation instead */
- switch (outputsocket->getActualDataType()) {
- case COM_DT_VALUE:
- {
- SetValueOperation *operation = new SetValueOperation();
- bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)inputsocket->getbNodeSocket()->default_value;
- operation->setValue(dval->value);
- outputsocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- break;
- }
- case COM_DT_COLOR:
- {
- SetColorOperation *operation = new SetColorOperation();
- bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)inputsocket->getbNodeSocket()->default_value;
- operation->setChannels(dval->value);
- outputsocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- break;
- }
- case COM_DT_VECTOR:
- {
- SetVectorOperation *operation = new SetVectorOperation();
- bNodeSocketValueVector *dval = (bNodeSocketValueVector*)inputsocket->getbNodeSocket()->default_value;
- operation->setVector(dval->value);
- outputsocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- break;
- }
- /* quiet warnings */
- case COM_DT_UNKNOWN:
- break;
+ switch (outputsocket->getDataType()) {
+ case COM_DT_VALUE:
+ {
+ SetValueOperation *operation = new SetValueOperation();
+ bNodeSocketValueFloat *dval = (bNodeSocketValueFloat *)inputsocket->getbNodeSocket()->default_value;
+ operation->setValue(dval->value);
+ outputsocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ break;
+ }
+ case COM_DT_COLOR:
+ {
+ SetColorOperation *operation = new SetColorOperation();
+ bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)inputsocket->getbNodeSocket()->default_value;
+ operation->setChannels(dval->value);
+ outputsocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ break;
+ }
+ case COM_DT_VECTOR:
+ {
+ SetVectorOperation *operation = new SetVectorOperation();
+ bNodeSocketValueVector *dval = (bNodeSocketValueVector *)inputsocket->getbNodeSocket()->default_value;
+ operation->setVector(dval->value);
+ outputsocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ break;
+ }
}
}
}
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h
index b73ca24a45e..ea50be418e2 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.h
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief SocketProxyNode
- * @ingroup Node
- */
-class SocketProxyNode: public Node {
+ * @brief SocketProxyNode
+ * @ingroup Node
+ */
+class SocketProxyNode : public Node {
public:
SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
virtual bool isProxyNode() const { return true; }
};
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
index bf434c164c0..22a00410384 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
@@ -26,22 +26,32 @@
#include "COM_SplitViewerOperation.h"
#include "COM_ExecutionSystem.h"
-SplitViewerNode::SplitViewerNode(bNode *editorNode): Node(editorNode)
+SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *image1Socket = this->getInputSocket(0);
InputSocket *image2Socket = this->getInputSocket(1);
- Image *image = (Image*)this->getbNode()->id;
- ImageUser * imageUser = (ImageUser*) this->getbNode()->storage;
+ Image *image = (Image *)this->getbNode()->id;
+ ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
if (image1Socket->isConnected() && image2Socket->isConnected()) {
SplitViewerOperation *splitViewerOperation = new SplitViewerOperation();
+ splitViewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ splitViewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
splitViewerOperation->setImage(image);
splitViewerOperation->setImageUser(imageUser);
- splitViewerOperation->setActive(this->getbNode()->flag & NODE_DO_OUTPUT);
+ splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());
splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
+
+ /* defaults - the viewer node has these options but not exposed for split view
+ * we could use the split to define an area of interest on one axis at least */
+ splitViewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
+ splitViewerOperation->setCenterX(0.5f);
+ splitViewerOperation->setCenterY(0.5f);
+
splitViewerOperation->setXSplit(!this->getbNode()->custom2);
image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph);
image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1, graph);
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h
index e2d7a8c0dc9..6c532d4e813 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.h
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief SplitViewerNode
- * @ingroup Node
- */
+ * @brief SplitViewerNode
+ * @ingroup Node
+ */
class SplitViewerNode : public Node {
public:
SplitViewerNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
index 7234e71a43c..85b8695263f 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
@@ -32,18 +32,19 @@ extern "C" {
#include "BKE_tracking.h"
}
-Stabilize2dNode::Stabilize2dNode(bNode *editorNode): Node(editorNode)
+Stabilize2dNode::Stabilize2dNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *imageInput = this->getInputSocket(0);
MovieClip *clip = (MovieClip *)getbNode()->id;
- ScaleOperation * scaleOperation = new ScaleOperation();
- RotateOperation * rotateOperation = new RotateOperation();
- TranslateOperation * translateOperation = new TranslateOperation();
+ ScaleOperation *scaleOperation = new ScaleOperation();
+ RotateOperation *rotateOperation = new RotateOperation();
+ TranslateOperation *translateOperation = new TranslateOperation();
MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation();
MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation();
MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation();
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
index 63bf50b4d69..589e090b48c 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.h
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
@@ -24,11 +24,11 @@
#include "DNA_node_types.h"
/**
- * @brief Stabilize2dNode
- * @ingroup Node
- */
+ * @brief Stabilize2dNode
+ * @ingroup Node
+ */
class Stabilize2dNode : public Node {
public:
Stabilize2dNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp
index 58c60a96de8..2a4616fcd3e 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.cpp
+++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp
@@ -24,14 +24,15 @@
#include "COM_ExecutionSystem.h"
#include "COM_SocketProxyOperation.h"
-SwitchNode::SwitchNode(bNode *editorNode): Node(editorNode)
+SwitchNode::SwitchNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void SwitchNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void SwitchNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- SocketProxyOperation * operation = new SocketProxyOperation();
+ SocketProxyOperation *operation = new SocketProxyOperation(COM_DT_COLOR);
int switchFrame = this->getbNode()->custom1;
if (!switchFrame) {
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h
index da93af42489..be3d54c3000 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.h
+++ b/source/blender/compositor/nodes/COM_SwitchNode.h
@@ -27,12 +27,12 @@
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
/**
- * @brief SwitchNode
- * @ingroup Node
- */
+ * @brief SwitchNode
+ * @ingroup Node
+ */
class SwitchNode : public Node {
public:
SwitchNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp
index fe8a8e2250e..a3526e3c1a1 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.cpp
+++ b/source/blender/compositor/nodes/COM_TextureNode.cpp
@@ -24,14 +24,15 @@
#include "COM_ExecutionSystem.h"
#include "COM_TextureOperation.h"
-TextureNode::TextureNode(bNode *editorNode): Node(editorNode)
+TextureNode::TextureNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
bNode *editorNode = this->getbNode();
- Tex *texture = (Tex*)editorNode->id;
+ Tex *texture = (Tex *)editorNode->id;
TextureOperation *operation = new TextureOperation();
this->getOutputSocket(1)->relinkConnections(operation->getOutputSocket());
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
diff --git a/source/blender/compositor/nodes/COM_TextureNode.h b/source/blender/compositor/nodes/COM_TextureNode.h
index 15c39db9077..e0d931c65da 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.h
+++ b/source/blender/compositor/nodes/COM_TextureNode.h
@@ -24,11 +24,11 @@
#include "DNA_node_types.h"
/**
- * @brief TextureNode
- * @ingroup Node
- */
+ * @brief TextureNode
+ * @ingroup Node
+ */
class TextureNode : public Node {
public:
TextureNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp
index b3ce27a3829..8e155e375e1 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.cpp
+++ b/source/blender/compositor/nodes/COM_TimeNode.cpp
@@ -29,11 +29,12 @@ extern "C" {
}
#include "BLI_utildefines.h"
-TimeNode::TimeNode(bNode *editorNode): Node(editorNode)
+TimeNode::TimeNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
SetValueOperation *operation = new SetValueOperation();
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
@@ -50,10 +51,10 @@ void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * c
fac = 1.0f;
}
else if (node->custom1 < node->custom2) {
- fac = (context->getFramenumber() - node->custom1)/(float)(node->custom2-node->custom1);
+ fac = (context->getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
}
- fac = curvemapping_evaluateF((CurveMapping*)node->storage, 0, fac);
+ fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
operation->setValue(CLAMPIS(fac, 0.0f, 1.0f));
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_TimeNode.h b/source/blender/compositor/nodes/COM_TimeNode.h
index 26751f6f104..df3cf024714 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.h
+++ b/source/blender/compositor/nodes/COM_TimeNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief TimeNode
- * @ingroup Node
- */
-class TimeNode: public Node {
+ * @brief TimeNode
+ * @ingroup Node
+ */
+class TimeNode : public Node {
public:
TimeNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp
index 80f02f3edbb..a1f33ed464b 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.cpp
+++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp
@@ -25,14 +25,15 @@
#include "COM_TonemapOperation.h"
#include "COM_ExecutionSystem.h"
-TonemapNode::TonemapNode(bNode *editorNode): Node(editorNode)
+TonemapNode::TonemapNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
- NodeTonemap *data = (NodeTonemap*)this->getbNode()->storage;
- TonemapOperation *operation = data->type==1?new PhotoreceptorTonemapOperation():new TonemapOperation();
+ NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage;
+ TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : new TonemapOperation();
operation->setData(data);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.h b/source/blender/compositor/nodes/COM_TonemapNode.h
index d6dd8474afa..ad0d218826a 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.h
+++ b/source/blender/compositor/nodes/COM_TonemapNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief TonemapNode
- * @ingroup Node
- */
-class TonemapNode: public Node {
+ * @brief TonemapNode
+ * @ingroup Node
+ */
+class TonemapNode : public Node {
public:
TonemapNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp
index da3e85036a5..ff6e276d1ac 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.cpp
+++ b/source/blender/compositor/nodes/COM_TransformNode.cpp
@@ -28,11 +28,12 @@
#include "COM_SetValueOperation.h"
#include "COM_SetSamplerOperation.h"
-TransformNode::TransformNode(bNode *editorNode): Node(editorNode)
+TransformNode::TransformNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *imageInput = this->getInputSocket(0);
InputSocket *xInput = this->getInputSocket(1);
@@ -40,21 +41,21 @@ void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContex
InputSocket *angleInput = this->getInputSocket(3);
InputSocket *scaleInput = this->getInputSocket(4);
- ScaleOperation * scaleOperation = new ScaleOperation();
- RotateOperation * rotateOperation = new RotateOperation();
- TranslateOperation * translateOperation = new TranslateOperation();
+ ScaleOperation *scaleOperation = new ScaleOperation();
+ RotateOperation *rotateOperation = new RotateOperation();
+ TranslateOperation *translateOperation = new TranslateOperation();
SetSamplerOperation *sampler = new SetSamplerOperation();
switch (this->getbNode()->custom1) {
- case 0:
- sampler->setSampler(COM_PS_NEAREST);
- break ;
- case 1:
- sampler->setSampler(COM_PS_BILINEAR);
- break;
- case 2:
- sampler->setSampler(COM_PS_BICUBIC);
- break;
+ case 0:
+ sampler->setSampler(COM_PS_NEAREST);
+ break;
+ case 1:
+ sampler->setSampler(COM_PS_BILINEAR);
+ break;
+ case 2:
+ sampler->setSampler(COM_PS_BICUBIC);
+ break;
}
imageInput->relinkConnections(sampler->getInputSocket(0), 0, graph);
diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h
index 237da44afd9..da40b655f29 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.h
+++ b/source/blender/compositor/nodes/COM_TransformNode.h
@@ -24,11 +24,11 @@
#include "DNA_node_types.h"
/**
- * @brief TransformNode
- * @ingroup Node
- */
+ * @brief TransformNode
+ * @ingroup Node
+ */
class TransformNode : public Node {
public:
TransformNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp
index 407c6da4e4d..c805f8f8baa 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.cpp
+++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp
@@ -27,9 +27,10 @@
TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void TranslateNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void TranslateNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *inputSocket = this->getInputSocket(0);
InputSocket *inputXSocket = this->getInputSocket(1);
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.h b/source/blender/compositor/nodes/COM_TranslateNode.h
index 295024d6beb..8c350e9cfb3 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.h
+++ b/source/blender/compositor/nodes/COM_TranslateNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief TranslateNode
- * @ingroup Node
- */
-class TranslateNode: public Node {
+ * @brief TranslateNode
+ * @ingroup Node
+ */
+class TranslateNode : public Node {
public:
TranslateNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ValueNode.cpp b/source/blender/compositor/nodes/COM_ValueNode.cpp
index 39245e75a2f..89b0602f8b0 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_ValueNode.cpp
@@ -25,15 +25,16 @@
#include "COM_SetValueOperation.h"
#include "COM_ExecutionSystem.h"
-ValueNode::ValueNode(bNode *editorNode): Node(editorNode)
+ValueNode::ValueNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
SetValueOperation *operation = new SetValueOperation();
bNodeSocket *socket = this->getEditorOutputSocket(0);
- bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)socket->default_value;
+ bNodeSocketValueFloat *dval = (bNodeSocketValueFloat *)socket->default_value;
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
operation->setValue(dval->value);
graph->addOperation(operation);
diff --git a/source/blender/compositor/nodes/COM_ValueNode.h b/source/blender/compositor/nodes/COM_ValueNode.h
index 4faf193fc8e..4f478ae93af 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.h
+++ b/source/blender/compositor/nodes/COM_ValueNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief ValueNode
- * @ingroup Node
- */
-class ValueNode: public Node {
+ * @brief ValueNode
+ * @ingroup Node
+ */
+class ValueNode : public Node {
public:
ValueNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
index 596256eb6af..5ef384a9984 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
@@ -22,20 +22,17 @@
#include "COM_VectorBlurNode.h"
#include "DNA_node_types.h"
-#include "COM_FogGlowImageOperation.h"
-#include "COM_BokehBlurOperation.h"
#include "COM_VectorBlurOperation.h"
-#include "COM_SetValueOperation.h"
-#include "COM_MixBlendOperation.h"
-VectorBlurNode::VectorBlurNode(bNode *editorNode): Node(editorNode)
+VectorBlurNode::VectorBlurNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
bNode *node = this->getbNode();
- NodeBlurData *vectorBlurSettings = (NodeBlurData*)node->storage;
+ NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage;
VectorBlurOperation *operation = new VectorBlurOperation();
operation->setVectorBlurSettings(vectorBlurSettings);
operation->setQuality(context->getQuality());
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.h b/source/blender/compositor/nodes/COM_VectorBlurNode.h
index 1df945731ce..6b5d277a54b 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.h
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief VectorBlurNode
- * @ingroup Node
- */
-class VectorBlurNode: public Node {
+ * @brief VectorBlurNode
+ * @ingroup Node
+ */
+class VectorBlurNode : public Node {
public:
VectorBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
index 908e1a19f16..ee32c3b77a3 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
@@ -25,18 +25,19 @@
#include "COM_VectorCurveOperation.h"
#include "COM_ExecutionSystem.h"
-VectorCurveNode::VectorCurveNode(bNode *editorNode): Node(editorNode)
+VectorCurveNode::VectorCurveNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void VectorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void VectorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
VectorCurveOperation *operation = new VectorCurveOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- operation->setCurveMapping((CurveMapping*)this->getbNode()->storage);
+ operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.h b/source/blender/compositor/nodes/COM_VectorCurveNode.h
index 9fbcfd50156..3201090df14 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief VectorCurveNode
- * @ingroup Node
- */
-class VectorCurveNode: public Node {
+ * @brief VectorCurveNode
+ * @ingroup Node
+ */
+class VectorCurveNode : public Node {
public:
VectorCurveNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
index cedf81e3f2a..309568c3aec 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
@@ -26,21 +26,23 @@
#include "COM_CalculateMeanOperation.h"
#include "COM_CalculateStandardDeviationOperation.h"
-ViewLevelsNode::ViewLevelsNode(bNode *editorNode): Node(editorNode)
+ViewLevelsNode::ViewLevelsNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ViewLevelsNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+
+void ViewLevelsNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- InputSocket * input = this->getInputSocket(0);
+ InputSocket *input = this->getInputSocket(0);
bool firstOperationConnected = false;
if (input->isConnected()) {
OutputSocket *inputSocket = input->getConnection()->getFromSocket();
// add preview to inputSocket;
- OutputSocket * socket = this->getOutputSocket(0);
+ OutputSocket *socket = this->getOutputSocket(0);
if (socket->isConnected()) {
// calculate mean operation
- CalculateMeanOperation * operation = new CalculateMeanOperation();
+ CalculateMeanOperation *operation = new CalculateMeanOperation();
input->relinkConnections(operation->getInputSocket(0), 0, graph);
firstOperationConnected = true;
operation->setSetting(this->getbNode()->custom1);
@@ -51,7 +53,7 @@ void ViewLevelsNode::convertToOperations(ExecutionSystem *graph, CompositorConte
socket = this->getOutputSocket(1);
if (socket->isConnected()) {
// calculate standard deviation operation
- CalculateStandardDeviationOperation * operation = new CalculateStandardDeviationOperation();
+ CalculateStandardDeviationOperation *operation = new CalculateStandardDeviationOperation();
if (firstOperationConnected) {
addLink(graph, inputSocket, operation->getInputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.h b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
index 11be6216cba..2ac84fad22f 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.h
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief ViewLevelsNode
- * @ingroup Node
- */
-class ViewLevelsNode: public Node {
+ * @brief ViewLevelsNode
+ * @ingroup Node
+ */
+class ViewLevelsNode : public Node {
public:
ViewLevelsNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
index f5dab52d021..9228fdbef85 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -26,16 +26,17 @@
#include "COM_ViewerOperation.h"
#include "COM_ExecutionSystem.h"
-ViewerNode::ViewerNode(bNode *editorNode): Node(editorNode)
+ViewerNode::ViewerNode(bNode *editorNode) : Node(editorNode)
{
+ /* pass */
}
-void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)\
+void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
InputSocket *imageSocket = this->getInputSocket(0);
InputSocket *alphaSocket = this->getInputSocket(1);
- Image *image = (Image*)this->getbNode()->id;
- ImageUser * imageUser = (ImageUser*) this->getbNode()->storage;
+ Image *image = (Image *)this->getbNode()->id;
+ ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
bNode *editorNode = this->getbNode();
if (imageSocket->isConnected()) {
ViewerOperation *viewerOperation = new ViewerOperation();
@@ -44,7 +45,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
viewerOperation->setbNodeTree(context->getbNodeTree());
viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser);
- viewerOperation->setActive(editorNode->flag & NODE_DO_OUTPUT);
+ viewerOperation->setActive((editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());
viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1);
viewerOperation->setCenterX(editorNode->custom3);
viewerOperation->setCenterY(editorNode->custom4);
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h
index 59371f04e87..e1f1226f1f1 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.h
+++ b/source/blender/compositor/nodes/COM_ViewerNode.h
@@ -26,12 +26,12 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
/**
- * @brief ViewerNode
- * @ingroup Node
- */
+ * @brief ViewerNode
+ * @ingroup Node
+ */
class ViewerNode : public Node {
public:
ViewerNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
index 2495d1a5ab2..f48fca72c05 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
@@ -30,10 +30,10 @@
#include "DNA_material_types.h" // the ramp types
-void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
if (this->getOutputSocket(0)->isConnected()) {
- ZCombineOperation * operation = NULL;
+ ZCombineOperation *operation = NULL;
if (this->getbNode()->custom1) {
operation = new ZCombineAlphaOperation();
}
@@ -48,7 +48,7 @@ void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContex
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
system->addOperation(operation);
if (this->getOutputSocket(1)->isConnected()) {
- MathMinimumOperation * zoperation = new MathMinimumOperation();
+ MathMinimumOperation *zoperation = new MathMinimumOperation();
addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
@@ -57,7 +57,7 @@ void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContex
}
else {
if (this->getOutputSocket(1)->isConnected()) {
- MathMinimumOperation * zoperation = new MathMinimumOperation();
+ MathMinimumOperation *zoperation = new MathMinimumOperation();
this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), 1, system);
this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), 3, system);
this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h
index e9ce2f27469..a2ceedfc2cd 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.h
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.h
@@ -26,13 +26,13 @@
#include "COM_Node.h"
/**
- * @brief ZCombineNode
- * @ingroup Node
- */
-class ZCombineNode: public Node {
+ * @brief ZCombineNode
+ * @ingroup Node
+ */
+class ZCombineNode : public Node {
public:
- ZCombineNode(bNode *editorNode) :Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+ ZCombineNode(bNode *editorNode) : Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
index c891142b808..e614e1fa15a 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_AlphaOverKeyOperation.h"
-AlphaOverKeyOperation::AlphaOverKeyOperation(): MixBaseOperation()
+AlphaOverKeyOperation::AlphaOverKeyOperation() : MixBaseOperation()
{
+ /* pass */
}
void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -37,24 +38,18 @@ void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, P
inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
if (inputOverColor[3] <= 0.0f) {
- outputValue[0] = inputColor1[0];
- outputValue[1] = inputColor1[1];
- outputValue[2] = inputColor1[2];
- outputValue[3] = inputColor1[3];
+ copy_v4_v4(outputValue, inputColor1);
}
else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
- outputValue[0] = inputOverColor[0];
- outputValue[1] = inputOverColor[1];
- outputValue[2] = inputOverColor[2];
- outputValue[3] = inputOverColor[3];
+ copy_v4_v4(outputValue, inputOverColor);
}
else {
- float premul = value[0]*inputOverColor[3];
+ float premul = value[0] * inputOverColor[3];
float mul = 1.0f - premul;
- outputValue[0] = (mul*inputColor1[0]) + premul*inputOverColor[0];
- outputValue[1] = (mul*inputColor1[1]) + premul*inputOverColor[1];
- outputValue[2] = (mul*inputColor1[2]) + premul*inputOverColor[2];
- outputValue[3] = (mul*inputColor1[3]) + value[0]*inputOverColor[3];
+ outputValue[0] = (mul * inputColor1[0]) + premul * inputOverColor[0];
+ outputValue[1] = (mul * inputColor1[1]) + premul * inputOverColor[1];
+ outputValue[2] = (mul * inputColor1[2]) + premul * inputOverColor[2];
+ outputValue[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
}
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
index d3077a05706..e5b1f56f06c 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
@@ -26,19 +26,19 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class AlphaOverKeyOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
AlphaOverKeyOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
index 7d489ce856e..81c1e4d2587 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_AlphaOverMixedOperation.h"
-AlphaOverMixedOperation::AlphaOverMixedOperation(): MixBaseOperation()
+AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation()
{
this->x = 0.0f;
}
@@ -38,26 +38,20 @@ void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float
inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
if (inputOverColor[3] <= 0.0f) {
- outputValue[0] = inputColor1[0];
- outputValue[1] = inputColor1[1];
- outputValue[2] = inputColor1[2];
- outputValue[3] = inputColor1[3];
+ copy_v4_v4(outputValue, inputColor1);
}
else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
- outputValue[0] = inputOverColor[0];
- outputValue[1] = inputOverColor[1];
- outputValue[2] = inputOverColor[2];
- outputValue[3] = inputOverColor[3];
+ copy_v4_v4(outputValue, inputOverColor);
}
else {
- float addfac = 1.0f - this->x + inputOverColor[3]*this->x;
- float premul = value[0]*addfac;
- float mul = 1.0f - value[0]*inputOverColor[3];
-
- outputValue[0] = (mul*inputColor1[0]) + premul*inputOverColor[0];
- outputValue[1] = (mul*inputColor1[1]) + premul*inputOverColor[1];
- outputValue[2] = (mul*inputColor1[2]) + premul*inputOverColor[2];
- outputValue[3] = (mul*inputColor1[3]) + value[0]*inputOverColor[3];
+ float addfac = 1.0f - this->x + inputOverColor[3] * this->x;
+ float premul = value[0] * addfac;
+ float mul = 1.0f - value[0] * inputOverColor[3];
+
+ outputValue[0] = (mul * inputColor1[0]) + premul * inputOverColor[0];
+ outputValue[1] = (mul * inputColor1[1]) + premul * inputOverColor[1];
+ outputValue[2] = (mul * inputColor1[2]) + premul * inputOverColor[2];
+ outputValue[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
}
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
index 92936a20b79..2807b3b489a 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
@@ -26,23 +26,23 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class AlphaOverMixedOperation : public MixBaseOperation {
private:
float x;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
AlphaOverMixedOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
- void setX(float x) {this->x = x;}
+ void setX(float x) { this->x = x; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
index 6cc33387917..a6bf8b8834c 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_AlphaOverPremultiplyOperation.h"
-AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation(): MixBaseOperation()
+AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation() : MixBaseOperation()
{
+ /* pass */
}
void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -37,25 +38,19 @@ void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, fl
inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
/* Zero alpha values should still permit an add of RGB data */
- if (inputOverColor[3]<0.0f) {
- outputValue[0] = inputColor1[0];
- outputValue[1] = inputColor1[1];
- outputValue[2] = inputColor1[2];
- outputValue[3] = inputColor1[3];
+ if (inputOverColor[3] < 0.0f) {
+ copy_v4_v4(outputValue, inputColor1);
}
else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
- outputValue[0] = inputOverColor[0];
- outputValue[1] = inputOverColor[1];
- outputValue[2] = inputOverColor[2];
- outputValue[3] = inputOverColor[3];
+ copy_v4_v4(outputValue, inputOverColor);
}
else {
- float mul = 1.0f - value[0]*inputOverColor[3];
+ float mul = 1.0f - value[0] * inputOverColor[3];
- outputValue[0] = (mul*inputColor1[0]) + value[0]*inputOverColor[0];
- outputValue[1] = (mul*inputColor1[1]) + value[0]*inputOverColor[1];
- outputValue[2] = (mul*inputColor1[2]) + value[0]*inputOverColor[2];
- outputValue[3] = (mul*inputColor1[3]) + value[0]*inputOverColor[3];
+ outputValue[0] = (mul * inputColor1[0]) + value[0] * inputOverColor[0];
+ outputValue[1] = (mul * inputColor1[1]) + value[0] * inputOverColor[1];
+ outputValue[2] = (mul * inputColor1[2]) + value[0] * inputOverColor[2];
+ outputValue[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
}
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
index 2fe4422d03e..bba3b714f6b 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class AlphaOverPremultiplyOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
AlphaOverPremultiplyOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
index 62639eeb24a..458d11f2616 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -28,7 +28,7 @@ extern "C" {
}
-AntiAliasOperation::AntiAliasOperation(): NodeOperation()
+AntiAliasOperation::AntiAliasOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -42,14 +42,14 @@ void AntiAliasOperation::initExecution()
NodeOperation::initMutex();
}
-void AntiAliasOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data)
+void AntiAliasOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- if (y < 0 || y >= this->height || x < 0 || x >= this->width) {
+ if (y < 0 || (unsigned int)y >= this->height || x < 0 || (unsigned int)x >= this->width) {
color[0] = 0.0f;
}
else {
- int offset = y*this->width + x;
- color[0] = buffer[offset]/255.0f;
+ int offset = y * this->width + x;
+ color[0] = buffer[offset] / 255.0f;
}
}
@@ -84,22 +84,22 @@ bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe
void *AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
- if (this->buffer) {return buffer;}
- BLI_mutex_lock(getMutex());
+ if (this->buffer) {return buffer; }
+ lockMutex();
if (this->buffer == NULL) {
- MemoryBuffer *tile = (MemoryBuffer*)valueReader->initializeTileData(rect, memoryBuffers);
- int size = tile->getHeight()*tile->getWidth();
- float * input = tile->getBuffer();
+ MemoryBuffer *tile = (MemoryBuffer *)valueReader->initializeTileData(rect, memoryBuffers);
+ int size = tile->getHeight() * tile->getWidth();
+ float *input = tile->getBuffer();
char *valuebuffer = new char[size];
- for (int i = 0 ; i < size ; i ++) {
+ for (int i = 0; i < size; i++) {
float in = input[i * COM_NUMBER_OF_CHANNELS];
- if (in < 0.0f) { in = 0.0f;}
- if (in > 1.0f) {in = 1.0f;}
+ if (in < 0.0f) { in = 0.0f; }
+ if (in > 1.0f) {in = 1.0f; }
valuebuffer[i] = in * 255;
}
antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer);
this->buffer = valuebuffer;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return this->buffer;
}
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h
index fe160763828..906da598da1 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.h
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h
@@ -26,35 +26,35 @@
#include "DNA_node_types.h"
/**
- * @brief AntiAlias operations
- * it only supports anti aliasing on BW buffers.
- * @ingroup operation
- */
+ * @brief AntiAlias operations
+ * it only supports anti aliasing on BW buffers.
+ * @ingroup operation
+ */
class AntiAliasOperation : public NodeOperation {
protected:
/**
- * @brief Cached reference to the reader
- */
- SocketReader * valueReader;
+ * @brief Cached reference to the reader
+ */
+ SocketReader *valueReader;
char *buffer;
public:
AntiAliasOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
};
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index 88fe17f633e..3628c399581 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -62,36 +62,27 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
int maxy = ceil(y + space);
float deltaColor;
this->inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data);
-
- blurColor[0] = 0.0f;
- blurColor[1] = 0.0f;
- blurColor[2] = 0.0f;
- blurColor[3] = 0.0f;
+
+ zero_v4(blurColor);
blurDivider = 0.0f;
- for (int yi = miny ; yi < maxy ; yi+=QualityStepHelper::getStep()) {
- for (int xi = minx ; xi < maxx ; xi+=QualityStepHelper::getStep()) {
+ for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) {
+ for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) {
// read determinator
this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data);
- deltaColor = fabsf(determinatorReferenceColor[0] - determinator[0])+
- fabsf(determinatorReferenceColor[1] - determinator[1])+
- fabsf(determinatorReferenceColor[2] - determinator[2]); // do not take the alpha channel into account
- if (deltaColor< sigmacolor) {
+ deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) +
+ fabsf(determinatorReferenceColor[1] - determinator[1]) +
+ fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account
+ if (deltaColor < sigmacolor) {
// add this to the blur
this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data);
- blurColor[0]+=tempColor[0];
- blurColor[1]+=tempColor[1];
- blurColor[2]+=tempColor[2];
- blurColor[3]+=tempColor[3];
+ add_v4_v4(blurColor, tempColor);
blurDivider += 1.0f;
}
}
}
if (blurDivider > 0.0f) {
- color[0] = blurColor[0]/blurDivider;
- color[1] = blurColor[1]/blurDivider;
- color[2] = blurColor[2]/blurDivider;
- color[3] = blurColor[3]/blurDivider;
+ mul_v4_v4fl(color, blurColor, 1.0f / blurDivider);
}
else {
color[0] = 0.0f;
@@ -110,7 +101,7 @@ void BilateralBlurOperation::deinitExecution()
bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- int add = ceil(this->space)+1;
+ int add = ceil(this->space) + 1;
newInput.xmax = input->xmax + (add);
newInput.xmin = input->xmin - (add);
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
index 8ec1ba8df99..08b379dc4ea 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
@@ -36,22 +36,22 @@ public:
BilateralBlurOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void setData(NodeBilateralBlurData *data) {this->data = data;}
+ void setData(NodeBilateralBlurData *data) { this->data = data; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index 2280ee3a435..bb915fec590 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-BlurBaseOperation::BlurBaseOperation(): NodeOperation()
+BlurBaseOperation::BlurBaseOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -37,7 +37,7 @@ BlurBaseOperation::BlurBaseOperation(): NodeOperation()
this->data = NULL;
this->size = 1.0f;
this->deleteData = false;
- this->sizeavailable=false;
+ this->sizeavailable = false;
}
void BlurBaseOperation::initExecution()
{
@@ -47,18 +47,18 @@ void BlurBaseOperation::initExecution()
this->data->image_in_height = this->getHeight();
if (this->data->relative) {
switch (this->data->aspect) {
- case CMP_NODE_BLUR_ASPECT_NONE:
- this->data->sizex = (int)(this->data->percentx*0.01f*this->data->image_in_width);
- this->data->sizey = (int)(this->data->percenty*0.01f*this->data->image_in_height);
- break;
- case CMP_NODE_BLUR_ASPECT_Y:
- this->data->sizex = (int)(this->data->percentx*0.01f*this->data->image_in_width);
- this->data->sizey = (int)(this->data->percenty*0.01f*this->data->image_in_width);
- break;
- case CMP_NODE_BLUR_ASPECT_X:
- this->data->sizex = (int)(this->data->percentx*0.01f*this->data->image_in_height);
- this->data->sizey = (int)(this->data->percenty*0.01f*this->data->image_in_height);
- break;
+ case CMP_NODE_BLUR_ASPECT_NONE:
+ this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width);
+ this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height);
+ break;
+ case CMP_NODE_BLUR_ASPECT_Y:
+ this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width);
+ this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_width);
+ break;
+ case CMP_NODE_BLUR_ASPECT_X:
+ this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_height);
+ this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height);
+ break;
}
}
@@ -77,14 +77,14 @@ float *BlurBaseOperation::make_gausstab(int rad)
sum = 0.0f;
for (i = -rad; i <= rad; i++) {
- val = RE_filter_value(this->data->filtertype, (float)i/(float)rad);
+ val = RE_filter_value(this->data->filtertype, (float)i / (float)rad);
sum += val;
- gausstab[i+rad] = val;
+ gausstab[i + rad] = val;
}
- sum = 1.0f/sum;
- for (i=0; i<n; i++)
- gausstab[i]*= sum;
+ sum = 1.0f / sum;
+ for (i = 0; i < n; i++)
+ gausstab[i] *= sum;
return gausstab;
}
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
index 24002588413..84fc243a5af 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.h
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -30,11 +30,11 @@ private:
protected:
/**
- * Cached reference to the inputProgram
- */
+ * Cached reference to the inputProgram
+ */
SocketReader *inputProgram;
SocketReader *inputSize;
- NodeBlurData * data;
+ NodeBlurData *data;
BlurBaseOperation();
float *make_gausstab(int rad);
float size;
@@ -43,19 +43,19 @@ protected:
void updateSize(MemoryBuffer **memoryBuffers);
public:
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setData(NodeBlurData *data) {this->data = data;}
-
- void deleteDataWhenFinished() {this->deleteData = true;}
+ void setData(NodeBlurData *data) { this->data = data; }
+
+ void deleteDataWhenFinished() { this->deleteData = true; }
- void setSize(float size) {this->size = size; sizeavailable = true;}
+ void setSize(float size) { this->size = size; sizeavailable = true; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index 71a87dce2a7..dca087bb587 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -59,15 +59,15 @@ void BokehBlurOperation::initExecution()
int height = inputBokehProgram->getHeight();
float dimension;
- if (width<height) {
+ if (width < height) {
dimension = width;
}
else {
dimension = height;
}
- this->bokehMidX = width/2.0f;
- this->bokehMidY = height/2.0f;
- this->bokehDimension = dimension/2.0f;
+ this->bokehMidX = width / 2.0f;
+ this->bokehMidY = height / 2.0f;
+ this->bokehDimension = dimension / 2.0f;
QualityStepHelper::initExecution(COM_QH_INCREASE);
}
@@ -78,20 +78,14 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
float bokeh[4];
inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers);
- if (tempBoundingBox[0] >0.0f) {
- tempColor[0] = 0;
- tempColor[1] = 0;
- tempColor[2] = 0;
- tempColor[3] = 0;
- float overallmultiplyerr = 0;
- float overallmultiplyerg = 0;
- float overallmultiplyerb = 0;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ if (tempBoundingBox[0] > 0.0f) {
+ float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
- int pixelSize = this->size*this->getWidth()/100.0f;
+ int pixelSize = this->size * this->getWidth() / 100.0f;
int miny = y - pixelSize;
int maxy = y + pixelSize;
@@ -102,29 +96,27 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
+ zero_v4(tempColor);
+
int step = getStep();
int offsetadd = getOffsetAdd();
- float m = this->bokehDimension/pixelSize;
- for (int ny = miny ; ny < maxy ; ny +=step) {
- int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
- for (int nx = minx ; nx < maxx ; nx +=step) {
- float u = this->bokehMidX - (nx-x) *m;
- float v = this->bokehMidY - (ny-y) *m;
+ float m = this->bokehDimension / pixelSize;
+ for (int ny = miny; ny < maxy; ny += step) {
+ int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
+ for (int nx = minx; nx < maxx; nx += step) {
+ float u = this->bokehMidX - (nx - x) * m;
+ float v = this->bokehMidY - (ny - y) * m;
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
- tempColor[0] += bokeh[0] * buffer[bufferindex];
- tempColor[1] += bokeh[1] * buffer[bufferindex+1];
- tempColor[2] += bokeh[2]* buffer[bufferindex+2];
- overallmultiplyerr += bokeh[0];
- overallmultiplyerg += bokeh[1];
- overallmultiplyerb += bokeh[2];
- bufferindex +=offsetadd;
+ madd_v4_v4v4(tempColor, bokeh, &buffer[bufferindex]);
+ add_v4_v4(overallmultiplyer, bokeh);
+ bufferindex += offsetadd;
}
}
- color[0] = tempColor[0] * (1.0f / overallmultiplyerr);
- color[1] = tempColor[1] * (1.0f / overallmultiplyerg);
- color[2] = tempColor[2] * (1.0f / overallmultiplyerb);
- color[3] = 1.0f;
+ color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]);
+ color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]);
+ color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]);
+ color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]);
}
else {
inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers);
@@ -143,10 +135,10 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe
rcti newInput;
rcti bokehInput;
- newInput.xmax = input->xmax + (size*this->getWidth()/100.0f);
- newInput.xmin = input->xmin - (size*this->getWidth()/100.0f);
- newInput.ymax = input->ymax + (size*this->getWidth()/100.0f);
- newInput.ymin = input->ymin - (size*this->getWidth()/100.0f);
+ newInput.xmax = input->xmax + (size * this->getWidth() / 100.0f);
+ newInput.xmin = input->xmin - (size * this->getWidth() / 100.0f);
+ newInput.ymax = input->ymax + (size * this->getWidth() / 100.0f);
+ newInput.ymin = input->ymin - (size * this->getWidth() / 100.0f);
NodeOperation *operation = getInputOperation(1);
bokehInput.xmax = operation->getWidth();
@@ -176,7 +168,7 @@ void BokehBlurOperation::executeOpenCL(cl_context context, cl_program program, c
if (!kernel) {
kernel = COM_clCreateKernel(program, "bokehBlurKernel", NULL);
}
- cl_int radius = this->getWidth()*this->size/100.0f;
+ cl_int radius = this->getWidth() * this->size / 100.0f;
cl_int step = this->getStep();
COM_clAttachMemoryBufferToKernelParameter(context, kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader);
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
index 3cdd995b1df..3ec61c5ce01 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -39,23 +39,23 @@ public:
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void setSize(float size) {this->size = size;}
+ void setSize(float size) { this->size = size; }
void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp);
};
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index a0297b12961..abb378e2adb 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_BokehImageOperation.h"
#include "BLI_math.h"
-BokehImageOperation::BokehImageOperation(): NodeOperation()
+BokehImageOperation::BokehImageOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_COLOR);
this->deleteData = false;
@@ -35,7 +35,7 @@ void BokehImageOperation::initExecution()
this->center[0] = this->centerX;
this->center[1] = this->centerY;
this->inverseRounding = 1.0f - this->data->rounding;
- this->circularDistance = getWidth()/2;
+ this->circularDistance = getWidth() / 2;
this->flapRad = (float)(M_PI * 2) / this->data->flaps;
this->flapRadAdd = (this->data->angle / 360.0f) * (float)(M_PI * 2.0);
while (this->flapRadAdd < 0.0f) {
@@ -64,19 +64,19 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y)
const float distanceToCenter = len_v2v2(point, center);
const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0));
- int flapNumber = (int)((bearing-flapRadAdd)/flapRad);
+ int flapNumber = (int)((bearing - flapRadAdd) / flapRad);
detemineStartPointOfFlap(lineP1, flapNumber, distance);
- detemineStartPointOfFlap(lineP2, flapNumber+1, distance);
+ detemineStartPointOfFlap(lineP2, flapNumber + 1, distance);
closest_to_line_v2(closestPoint, point, lineP1, lineP2);
const float distanceLineToCenter = len_v2v2(center, closestPoint);
- const float distanceRoundingToCenter = inverseRounding*distanceLineToCenter+this->data->rounding*distance;
+ const float distanceRoundingToCenter = inverseRounding * distanceLineToCenter + this->data->rounding * distance;
const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->data->catadioptric;
- if (distanceRoundingToCenter>=distanceToCenter && catadioptricDistanceToCenter <= distanceToCenter) {
+ if (distanceRoundingToCenter >= distanceToCenter && catadioptricDistanceToCenter <= distanceToCenter) {
if (distanceRoundingToCenter - distanceToCenter < 1.0f) {
- insideBokeh = (distanceRoundingToCenter-distanceToCenter);
+ insideBokeh = (distanceRoundingToCenter - distanceToCenter);
}
else if (this->data->catadioptric != 0.0f && distanceToCenter - catadioptricDistanceToCenter < 1.0f) {
insideBokeh = (distanceToCenter - catadioptricDistanceToCenter);
@@ -95,7 +95,7 @@ void BokehImageOperation::executePixel(float *color, float x, float y, PixelSamp
float insideBokehMax = isInsideBokeh(distance, x, y);
float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), x, y);
float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), x, y);
- if (shift<0) {
+ if (shift < 0) {
color[0] = insideBokehMax;
color[1] = insideBokehMed;
color[2] = insideBokehMin;
@@ -105,7 +105,7 @@ void BokehImageOperation::executePixel(float *color, float x, float y, PixelSamp
color[1] = insideBokehMed;
color[2] = insideBokehMax;
}
- color[3] = 1.0f;
+ color[3] = (insideBokehMax + insideBokehMed + insideBokehMin) / 3.0f;
}
void BokehImageOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index 516cc1da4f0..8edd32a4f77 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -45,23 +45,23 @@ public:
BokehImageOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- void setData(NodeBokehImage *data) {this->data = data;}
- void deleteDataOnFinish() {this->deleteData = true;}
+ void setData(NodeBokehImage *data) { this->data = data; }
+ void deleteDataOnFinish() { this->deleteData = true; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index ae83115ff69..3b99fc9a2a0 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -24,7 +24,7 @@
#include "BLI_math.h"
#include "DNA_node_types.h"
-BoxMaskOperation::BoxMaskOperation(): NodeOperation()
+BoxMaskOperation::BoxMaskOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
@@ -41,7 +41,7 @@ void BoxMaskOperation::initExecution()
const double rad = DEG2RAD((double)this->data->rotation);
this->cosine = cos(rad);
this->sine = sin(rad);
- this->aspectRatio = ((float)this->getWidth())/this->getHeight();
+ this->aspectRatio = ((float)this->getWidth()) / this->getHeight();
}
void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -49,13 +49,13 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler
float inputMask[4];
float inputValue[4];
- float rx = x/this->getWidth();
- float ry = y/this->getHeight();
+ float rx = x / this->getWidth();
+ float ry = y / this->getHeight();
- const float dy = (ry - this->data->y)/this->aspectRatio;
+ const float dy = (ry - this->data->y) / this->aspectRatio;
const float dx = rx - this->data->x;
- rx = this->data->x+(this->cosine*dx + this->sine*dy);
- ry = this->data->y+(-this->sine*dx + this->cosine*dy);
+ rx = this->data->x + (this->cosine * dx + this->sine * dy);
+ ry = this->data->y + (-this->sine * dx + this->cosine * dy);
this->inputMask->read(inputMask, x, y, sampler, inputBuffers);
this->inputValue->read(inputValue, x, y, sampler, inputBuffers);
@@ -70,7 +70,7 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler
switch (this->maskType) {
case CMP_NODE_MASKTYPE_ADD:
if (inside) {
- color[0] = max(inputMask[0],inputValue[0]);
+ color[0] = max(inputMask[0], inputValue[0]);
}
else {
color[0] = inputMask[0];
@@ -78,7 +78,7 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler
break;
case CMP_NODE_MASKTYPE_SUBTRACT:
if (inside) {
- color[0] = inputMask[0]-inputValue[0];
+ color[0] = inputMask[0] - inputValue[0];
CLAMP(color[0], 0, 1);
}
else {
@@ -87,24 +87,24 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler
break;
case CMP_NODE_MASKTYPE_MULTIPLY:
if (inside) {
- color[0] = inputMask[0]*inputValue[0];
+ color[0] = inputMask[0] * inputValue[0];
}
else {
color[0] = 0;
}
break;
case CMP_NODE_MASKTYPE_NOT:
- if (inside) {
- if (inputMask[0]>0.0f) {
- color[0] = 0;
+ if (inside) {
+ if (inputMask[0] > 0.0f) {
+ color[0] = 0;
+ }
+ else {
+ color[0] = inputValue[0];
+ }
}
else {
- color[0] = inputValue[0];
+ color[0] = inputMask[0];
}
- }
- else {
- color[0] = inputMask[0];
- }
break;
}
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h
index c3af95578d4..65327abc9a6 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.h
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h
@@ -28,10 +28,10 @@
class BoxMaskOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputMask;
- SocketReader * inputValue;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputMask;
+ SocketReader *inputValue;
float sine;
float cosine;
@@ -43,23 +43,23 @@ public:
BoxMaskOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setData(NodeBoxMask *data) {this->data = data;}
-
- void setMaskType(int maskType) {this->maskType = maskType;}
+ void setData(NodeBoxMask *data) { this->data = data; }
+
+ void setMaskType(int maskType) { this->maskType = maskType; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
index a4396a43cf7..95862a1fd83 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_BrightnessOperation.h"
-BrightnessOperation::BrightnessOperation(): NodeOperation()
+BrightnessOperation::BrightnessOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -52,10 +52,10 @@ void BrightnessOperation::executePixel(float *color, float x, float y, PixelSamp
float delta = contrast / 200.0f;
a = 1.0f - delta * 2.0f;
/*
- * The algorithm is by Werner D. Streidt
- * (http://visca.com/ffactory/archives/5-99/msg00021.html)
- * Extracted of OpenCV demhist.c
- */
+ * The algorithm is by Werner D. Streidt
+ * (http://visca.com/ffactory/archives/5-99/msg00021.html)
+ * Extracted of OpenCV demhist.c
+ */
if (contrast > 0) {
a = 1.0f / a;
b = a * (brightness - delta);
@@ -65,9 +65,9 @@ void BrightnessOperation::executePixel(float *color, float x, float y, PixelSamp
b = a * (brightness + delta);
}
- color[0] = a*inputValue[0]+b;
- color[1] = a*inputValue[1]+b;
- color[2] = a*inputValue[2]+b;
+ color[0] = a * inputValue[0] + b;
+ color[1] = a * inputValue[1] + b;
+ color[2] = a * inputValue[2] + b;
color[3] = inputValue[3];
}
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h
index 0c718a8b131..74c648fd8fb 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.h
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.h
@@ -28,8 +28,8 @@
class BrightnessOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
+ * Cached reference to the inputProgram
+ */
SocketReader *inputProgram;
SocketReader *inputBrightnessProgram;
SocketReader *inputContrastProgram;
@@ -38,18 +38,18 @@ public:
BrightnessOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index a3438cea27b..3f9003b8c48 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -26,7 +26,7 @@
-CalculateMeanOperation::CalculateMeanOperation(): NodeOperation()
+CalculateMeanOperation::CalculateMeanOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_VALUE);
@@ -42,7 +42,7 @@ void CalculateMeanOperation::initExecution()
NodeOperation::initMutex();
}
-void CalculateMeanOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data)
+void CalculateMeanOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
color[0] = this->result;
}
@@ -72,54 +72,54 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti *input, ReadB
void *CalculateMeanOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (!this->iscalculated) {
- MemoryBuffer *tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers);
calculateMean(tile);
this->iscalculated = true;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return NULL;
}
-void CalculateMeanOperation::calculateMean(MemoryBuffer * tile)
+void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
{
this->result = 0.0f;
float *buffer = tile->getBuffer();
- int size = tile->getWidth()*tile->getHeight();
+ int size = tile->getWidth() * tile->getHeight();
int pixels = 0;
float sum;
- for (int i = 0, offset = 0 ; i < size ; i ++, offset +=4) {
- if (buffer[offset+3] > 0) {
- pixels ++;
+ for (int i = 0, offset = 0; i < size; i++, offset += 4) {
+ if (buffer[offset + 3] > 0) {
+ pixels++;
switch (this->setting)
{
- case 1:
+ case 1:
{
- sum += buffer[offset]*0.35f + buffer[offset+1]*0.45f + buffer[offset+2]*0.2f;
+ sum += buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f;
break;
}
- case 2:
+ case 2:
{
- sum+= buffer[offset];
+ sum += buffer[offset];
break;
}
- case 3:
+ case 3:
{
- sum+= buffer[offset+1];
+ sum += buffer[offset + 1];
break;
}
- case 4:
+ case 4:
{
- sum+= buffer[offset+2];
+ sum += buffer[offset + 2];
break;
}
- case 5:
+ case 5:
{
float yuv[3];
- rgb_to_yuv(buffer[offset], buffer[offset+1], buffer[offset+2], &yuv[0], &yuv[1], &yuv[2]);
- sum+=yuv[0];
+ rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2]);
+ sum += yuv[0];
break;
}
}
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
index b21743aa8bc..7a28eb3774a 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
@@ -26,15 +26,15 @@
#include "DNA_node_types.h"
/**
- * @brief base class of CalculateMean, implementing the simple CalculateMean
- * @ingroup operation
- */
+ * @brief base class of CalculateMean, implementing the simple CalculateMean
+ * @ingroup operation
+ */
class CalculateMeanOperation : public NodeOperation {
protected:
/**
- * @brief Cached reference to the reader
- */
- SocketReader * imageReader;
+ * @brief Cached reference to the reader
+ */
+ SocketReader *imageReader;
bool iscalculated;
float result;
@@ -44,24 +44,24 @@ public:
CalculateMeanOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void setSetting(int setting) {this->setting = setting;}
+ void setSetting(int setting) { this->setting = setting; }
protected:
void calculateMean(MemoryBuffer *tile);
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 651c6674fdb..b0739cd7567 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -26,72 +26,73 @@
-CalculateStandardDeviationOperation::CalculateStandardDeviationOperation(): CalculateMeanOperation()
+CalculateStandardDeviationOperation::CalculateStandardDeviationOperation() : CalculateMeanOperation()
{
+ /* pass */
}
-void CalculateStandardDeviationOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data)
+void CalculateStandardDeviationOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
color[0] = this->standardDeviation;
}
void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (!this->iscalculated) {
- MemoryBuffer *tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers);
CalculateMeanOperation::calculateMean(tile);
this->standardDeviation = 0.0f;
float *buffer = tile->getBuffer();
- int size = tile->getWidth()*tile->getHeight();
+ int size = tile->getWidth() * tile->getHeight();
int pixels = 0;
float sum;
float mean = this->result;
- for (int i = 0, offset = 0 ; i < size ; i ++, offset +=4) {
- if (buffer[offset+3] > 0) {
- pixels ++;
+ for (int i = 0, offset = 0; i < size; i++, offset += 4) {
+ if (buffer[offset + 3] > 0) {
+ pixels++;
switch (this->setting)
{
- case 1:
+ case 1:
{
- float value = buffer[offset]*0.35f + buffer[offset+1]*0.45f + buffer[offset+2]*0.2f;
- sum+=(value-mean)*(value-mean);
+ float value = buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f;
+ sum += (value - mean) * (value - mean);
break;
}
- case 2:
+ case 2:
{
float value = buffer[offset];
- sum+=value;
- sum+=(value-mean)*(value-mean);
+ sum += value;
+ sum += (value - mean) * (value - mean);
break;
}
- case 3:
+ case 3:
{
- float value = buffer[offset+1];
- sum+=value;
- sum+=(value-mean)*(value-mean);
+ float value = buffer[offset + 1];
+ sum += value;
+ sum += (value - mean) * (value - mean);
break;
}
- case 4:
+ case 4:
{
- float value = buffer[offset+2];
- sum+=value;
- sum+=(value-mean)*(value-mean);
+ float value = buffer[offset + 2];
+ sum += value;
+ sum += (value - mean) * (value - mean);
}
- case 5:
+ case 5:
{
float yuv[3];
- rgb_to_yuv(buffer[offset], buffer[offset+1], buffer[offset+2], &yuv[0], &yuv[1], &yuv[2]);
- sum+=(yuv[0]-mean)*(yuv[0]-mean);
+ rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2]);
+ sum += (yuv[0] - mean) * (yuv[0] - mean);
break;
}
}
}
}
- this->standardDeviation = sqrt(sum / (float)(pixels-1));
+ this->standardDeviation = sqrt(sum / (float)(pixels - 1));
this->iscalculated = true;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return NULL;
}
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
index 05c94401c86..d3163d4cc32 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
@@ -26,9 +26,9 @@
#include "DNA_node_types.h"
#include "COM_CalculateMeanOperation.h"
/**
- * @brief base class of CalculateStandardDeviation, implementing the simple CalculateStandardDeviation
- * @ingroup operation
- */
+ * @brief base class of CalculateStandardDeviation, implementing the simple CalculateStandardDeviation
+ * @ingroup operation
+ */
class CalculateStandardDeviationOperation : public CalculateMeanOperation {
protected:
float standardDeviation;
@@ -37,9 +37,9 @@ public:
CalculateStandardDeviationOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
index f949b0a55fa..487c1869782 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ChangeHSVOperation.h"
-ChangeHSVOperation::ChangeHSVOperation(): NodeOperation()
+ChangeHSVOperation::ChangeHSVOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -46,8 +46,8 @@ void ChangeHSVOperation::executePixel(float *outputValue, float x, float y, Pixe
inputOperation->read(inputColor1, x, y, sampler, inputBuffers);
outputValue[0] = inputColor1[0] + (this->hue - 0.5f);
- if (outputValue[0] > 1.0f) outputValue[0] -= 1.0f;
- else if (outputValue[0] < 0.0f) outputValue[0] += 1.0f;
+ if (outputValue[0] > 1.0f) outputValue[0] -= 1.0f;
+ else if (outputValue[0] < 0.0f) outputValue[0] += 1.0f;
outputValue[1] = inputColor1[1] * this->saturation;
outputValue[2] = inputColor1[2] * this->value;
outputValue[3] = inputColor1[3];
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
index a89487f9d7b..a2a6c034a82 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
@@ -26,12 +26,12 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ChangeHSVOperation : public NodeOperation {
private:
- SocketReader * inputOperation;
+ SocketReader *inputOperation;
float hue;
float saturation;
@@ -39,21 +39,21 @@ private:
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ChangeHSVOperation();
void initExecution();
void deinitExecution();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
-
- void setHue(float hue) {this->hue = hue;}
- void setSaturation(float saturation) {this->saturation = saturation;}
- void setValue(float value) {this->value = value;}
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
+
+ void setHue(float hue) { this->hue = hue; }
+ void setSaturation(float saturation) { this->saturation = saturation; }
+ void setValue(float value) { this->value = value; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
index 70bfc8f8cfa..24af1a3aa53 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ChannelMatteOperation.h"
#include "BLI_math.h"
-ChannelMatteOperation::ChannelMatteOperation(): NodeOperation()
+ChannelMatteOperation::ChannelMatteOperation() : NodeOperation()
{
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
@@ -39,9 +39,9 @@ void ChannelMatteOperation::initExecution()
switch (this->limit_method) {
/* SINGLE */
case 0: {
- /* 123 / RGB / HSV / YUV / YCC */
- const int matte_channel=this->matte_channel-1;
- const int limit_channel=this->limit_channel-1;
+ /* 123 / RGB / HSV / YUV / YCC */
+ const int matte_channel = this->matte_channel - 1;
+ const int limit_channel = this->limit_channel - 1;
this->ids[0] = matte_channel;
this->ids[1] = limit_channel;
this->ids[2] = limit_channel;
@@ -107,7 +107,7 @@ void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, P
else if (alpha < limit_min) {
alpha = 0.f;
}
- else {/*blend */
+ else { /*blend */
alpha = (alpha - limit_min) / limit_range;
}
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
index a4b5f454f92..17db0f9ffe2 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
@@ -25,9 +25,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ChannelMatteOperation : public NodeOperation {
private:
SocketReader *inputImageProgram;
@@ -42,24 +42,24 @@ private:
float limit_range;
/** ids to use for the operations (max and simple)
- * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
- * the simple operation is using:
- * alpha = in[ids[0]] - in[ids[1]]
- * but to use the same formula and operation for both we do:
- * ids[2] = ids[1]
- * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
- */
+ * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
+ * the simple operation is using:
+ * alpha = in[ids[0]] - in[ids[1]]
+ * but to use the same formula and operation for both we do:
+ * ids[2] = ids[1]
+ * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
+ */
int ids[3];
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ChannelMatteOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
index e082ffed2b6..0ce1a585598 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ChromaMatteOperation.h"
#include "BLI_math.h"
-ChromaMatteOperation::ChromaMatteOperation(): NodeOperation()
+ChromaMatteOperation::ChromaMatteOperation() : NodeOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
@@ -66,36 +66,36 @@ void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, Pi
/* Algorithm from book "Video Demistified," does not include the spill reduction part */
/* find theta, the angle that the color space should be rotated based on key*/
- theta=atan2(inKey[2], inKey[1]);
+ theta = atan2(inKey[2], inKey[1]);
/*rotate the cb and cr into x/z space */
- x_angle=inImage[1]*cosf(theta)+inImage[2]*sinf(theta);
- z_angle=inImage[2]*cosf(theta)-inImage[1]*sinf(theta);
+ x_angle = inImage[1] * cosf(theta) + inImage[2] * sinf(theta);
+ z_angle = inImage[2] * cosf(theta) - inImage[1] * sinf(theta);
/*if within the acceptance angle */
/* if kfg is <0 then the pixel is outside of the key color */
- kfg = x_angle-(fabsf(z_angle)/tanf(acceptance/2.f));
+ kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.f));
- if (kfg>0.f) { /* found a pixel that is within key color */
- alpha=(1.f-kfg)*(gain);
+ if (kfg > 0.f) { /* found a pixel that is within key color */
+ alpha = (1.f - kfg) * (gain);
- beta=atan2(z_angle,x_angle);
+ beta = atan2(z_angle, x_angle);
/* if beta is within the cutoff angle */
- if (fabsf(beta) < (cutoff/2.f)) {
- alpha=0.f;
+ if (fabsf(beta) < (cutoff / 2.f)) {
+ alpha = 0.f;
}
/* don't make something that was more transparent less transparent */
- if (alpha<inImage[3]) {
- outputValue[0]=alpha;
+ if (alpha < inImage[3]) {
+ outputValue[0] = alpha;
}
else {
- outputValue[0]=inImage[3];
+ outputValue[0] = inImage[3];
}
}
else { /*pixel is outside key color */
- outputValue[0]=inImage[3]; /* make pixel just as transparent as it was before */
+ outputValue[0] = inImage[3]; /* make pixel just as transparent as it was before */
}
}
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
index 9c5a5ff997b..a09203f29b3 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
@@ -25,9 +25,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ChromaMatteOperation : public NodeOperation {
private:
NodeChroma *settings;
@@ -35,18 +35,18 @@ private:
SocketReader *inputKeyProgram;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ChromaMatteOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) {this->settings = nodeChroma;}
+ void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
index 6fe6bde7c09..a48fe169fd7 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -33,7 +33,7 @@ inline float colorbalance_cdl(float in, float offset, float power, float slope)
return powf(x, power);
}
-ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation(): NodeOperation()
+ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -61,9 +61,9 @@ void ColorBalanceASCCDLOperation::executePixel(float *outputColor, float x, floa
fac = min(1.0f, fac);
const float mfac = 1.0f - fac;
- outputColor[0] = mfac*inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->lift[0], this->gamma[0], this->gain[0]);
- outputColor[1] = mfac*inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->lift[1], this->gamma[1], this->gain[1]);
- outputColor[2] = mfac*inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->lift[2], this->gamma[2], this->gain[2]);
+ outputColor[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->lift[0], this->gamma[0], this->gain[0]);
+ outputColor[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->lift[1], this->gamma[1], this->gain[1]);
+ outputColor[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->lift[2], this->gamma[2], this->gain[2]);
outputColor[3] = inputColor[3];
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
index fb973e75c15..9e7db59d99d 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
@@ -24,18 +24,17 @@
#define _COM_ColorBalanceASCCDLOperation_h
#include "COM_NodeOperation.h"
-
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ColorBalanceASCCDLOperation : public NodeOperation {
protected:
/**
- * Prefetched reference to the inputProgram
- */
- SocketReader * inputValueOperation;
- SocketReader * inputColorOperation;
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader *inputValueOperation;
+ SocketReader *inputColorOperation;
float gain[3];
float lift[3];
@@ -43,39 +42,27 @@ protected:
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ColorBalanceASCCDLOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setGain(float gain[3]) {
- this->gain[0] = gain[0];
- this->gain[1] = gain[1];
- this->gain[2] = gain[2];
- }
- void setLift(float lift[3]) {
- this->lift[0] = lift[0];
- this->lift[1] = lift[1];
- this->lift[2] = lift[2];
- }
- void setGamma(float gamma[3]) {
- this->gamma[0] = gamma[0];
- this->gamma[1] = gamma[1];
- this->gamma[2] = gamma[2];
- }
+ void setGain(float gain[3]) { copy_v3_v3(this->gain, gain); }
+ void setLift(float lift[3]) { copy_v3_v3(this->lift, lift); }
+ void setGamma(float gamma[3]) { copy_v3_v3(this->gamma, gamma); }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index 82958a7086e..7a8d62dfe21 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -38,7 +38,7 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
return powf(srgb_to_linearrgb(x), gamma_inv);
}
-ColorBalanceLGGOperation::ColorBalanceLGGOperation(): NodeOperation()
+ColorBalanceLGGOperation::ColorBalanceLGGOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -66,9 +66,9 @@ void ColorBalanceLGGOperation::executePixel(float *outputColor, float x, float y
fac = min(1.0f, fac);
const float mfac = 1.0f - fac;
- outputColor[0] = mfac*inputColor[0] + fac * colorbalance_lgg(inputColor[0], this->lift[0], this->gamma_inv[0], this->gain[0]);
- outputColor[1] = mfac*inputColor[1] + fac * colorbalance_lgg(inputColor[1], this->lift[1], this->gamma_inv[1], this->gain[1]);
- outputColor[2] = mfac*inputColor[2] + fac * colorbalance_lgg(inputColor[2], this->lift[2], this->gamma_inv[2], this->gain[2]);
+ outputColor[0] = mfac * inputColor[0] + fac *colorbalance_lgg(inputColor[0], this->lift[0], this->gamma_inv[0], this->gain[0]);
+ outputColor[1] = mfac * inputColor[1] + fac *colorbalance_lgg(inputColor[1], this->lift[1], this->gamma_inv[1], this->gain[1]);
+ outputColor[2] = mfac * inputColor[2] + fac *colorbalance_lgg(inputColor[2], this->lift[2], this->gamma_inv[2], this->gain[2]);
outputColor[3] = inputColor[3];
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
index e0df76cf2c5..54cfb49327f 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
@@ -26,16 +26,16 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ColorBalanceLGGOperation : public NodeOperation {
protected:
/**
- * Prefetched reference to the inputProgram
- */
- SocketReader * inputValueOperation;
- SocketReader * inputColorOperation;
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader *inputValueOperation;
+ SocketReader *inputColorOperation;
float gain[3];
float lift[3];
@@ -43,23 +43,23 @@ protected:
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ColorBalanceLGGOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
void setGain(float gain[3]) {
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index 82a71f6a7a8..5f62f9ec403 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_ColorCorrectionOperation.h"
#include "BLI_math.h"
-ColorCorrectionOperation::ColorCorrectionOperation(): NodeOperation()
+ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -47,7 +47,7 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix
this->inputImage->read(inputImageColor, x, y, sampler, inputBuffers);
this->inputMask->read(inputMask, x, y, sampler, inputBuffers);
- float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2])/3.0f;
+ float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f;
float contrast = this->data->master.contrast;
float saturation = this->data->master.saturation;
float gamma = this->data->master.gamma;
@@ -83,18 +83,19 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix
}
#undef MARGIN
#undef MARGIN_DIV
- contrast *= (levelShadows*this->data->shadows.contrast)+(levelMidtones*this->data->midtones.contrast)+(levelHighlights*this->data->highlights.contrast);
- saturation *= (levelShadows*this->data->shadows.saturation)+(levelMidtones*this->data->midtones.saturation)+(levelHighlights*this->data->highlights.saturation);
- gamma *= (levelShadows*this->data->shadows.gamma)+(levelMidtones*this->data->midtones.gamma)+(levelHighlights*this->data->highlights.gamma);
- gain *= (levelShadows*this->data->shadows.gain)+(levelMidtones*this->data->midtones.gain)+(levelHighlights*this->data->highlights.gain);
- lift += (levelShadows*this->data->shadows.lift)+(levelMidtones*this->data->midtones.lift)+(levelHighlights*this->data->highlights.lift);
+ contrast *= (levelShadows * this->data->shadows.contrast) + (levelMidtones * this->data->midtones.contrast) + (levelHighlights * this->data->highlights.contrast);
+ saturation *= (levelShadows * this->data->shadows.saturation) + (levelMidtones * this->data->midtones.saturation) + (levelHighlights * this->data->highlights.saturation);
+ gamma *= (levelShadows * this->data->shadows.gamma) + (levelMidtones * this->data->midtones.gamma) + (levelHighlights * this->data->highlights.gamma);
+ gain *= (levelShadows * this->data->shadows.gain) + (levelMidtones * this->data->midtones.gain) + (levelHighlights * this->data->highlights.gain);
+ lift += (levelShadows * this->data->shadows.lift) + (levelMidtones * this->data->midtones.lift) + (levelHighlights * this->data->highlights.lift);
+ float invgamma = 1.0f / gamma;
+ float luma = rgb_to_luma_y(inputImageColor);
+
r = inputImageColor[0];
g = inputImageColor[1];
b = inputImageColor[2];
-
- float invgamma = 1.0f / gamma;
- float luma = 0.2126f * r + 0.7152f * g + 0.0722f * b;
+
r = (luma + saturation * (r - luma));
g = (luma + saturation * (g - luma));
b = (luma + saturation * (b - luma));
@@ -103,15 +104,15 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix
g = 0.5f + ((g - 0.5f) * contrast);
b = 0.5f + ((b - 0.5f) * contrast);
- r = powf(r*gain+lift, invgamma);
- g = powf(g*gain+lift, invgamma);
- b = powf(b*gain+lift, invgamma);
+ r = powf(r * gain + lift, invgamma);
+ g = powf(g * gain + lift, invgamma);
+ b = powf(b * gain + lift, invgamma);
// mix with mask
- r = mvalue*inputImageColor[0] + value * r;
- g = mvalue*inputImageColor[1] + value * g;
- b = mvalue*inputImageColor[2] + value * b;
+ r = mvalue * inputImageColor[0] + value * r;
+ g = mvalue * inputImageColor[1] + value * g;
+ b = mvalue * inputImageColor[2] + value * b;
if (this->redChannelEnabled) {
output[0] = r;
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
index 89107150ebd..c0c33f7f2fa 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
@@ -28,8 +28,8 @@
class ColorCorrectionOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
+ * Cached reference to the inputProgram
+ */
SocketReader *inputImage;
SocketReader *inputMask;
NodeColorCorrection *data;
@@ -42,23 +42,23 @@ public:
ColorCorrectionOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setData(NodeColorCorrection * data) {this->data = data;}
- void setRedChannelEnabled(bool enabled) {this->redChannelEnabled = enabled;}
- void setGreenChannelEnabled(bool enabled) {this->greenChannelEnabled = enabled;}
- void setBlueChannelEnabled(bool enabled) {this->blueChannelEnabled = enabled;}
+ void setData(NodeColorCorrection *data) { this->data = data; }
+ void setRedChannelEnabled(bool enabled) { this->redChannelEnabled = enabled; }
+ void setGreenChannelEnabled(bool enabled) { this->greenChannelEnabled = enabled; }
+ void setBlueChannelEnabled(bool enabled) { this->blueChannelEnabled = enabled; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
index a38012271f1..4feac3e7273 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
@@ -31,7 +31,7 @@ extern "C" {
#include "MEM_guardedalloc.h"
#endif
-ColorCurveOperation::ColorCurveOperation(): CurveBaseOperation()
+ColorCurveOperation::ColorCurveOperation() : CurveBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -60,8 +60,8 @@ void ColorCurveOperation::initExecution()
void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
- CurveMapping* cumap = this->curveMapping;
- CurveMapping* workingCopy = (CurveMapping*)MEM_dupallocN(cumap);
+ CurveMapping *cumap = this->curveMapping;
+ CurveMapping *workingCopy = (CurveMapping *)MEM_dupallocN(cumap);
float black[4];
float white[4];
@@ -79,9 +79,7 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp
if (*fac >= 1.0f)
curvemapping_evaluate_premulRGBF(workingCopy, color, image);
else if (*fac <= 0.0f) {
- color[0] = image[0];
- color[1] = image[1];
- color[2] = image[2];
+ copy_v3_v3(color, image);
}
else {
float col[4], mfac = 1.0f - *fac;
@@ -106,7 +104,7 @@ void ColorCurveOperation::deinitExecution()
// Constant level curve mapping
-ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation(): CurveBaseOperation()
+ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() : CurveBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -140,9 +138,7 @@ void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float
if (*fac >= 1.0f)
curvemapping_evaluate_premulRGBF(this->curveMapping, color, image);
else if (*fac <= 0.0f) {
- color[0] = image[0];
- color[1] = image[1];
- color[2] = image[2];
+ copy_v3_v3(color, image);
}
else {
float col[4], mfac = 1.0f - *fac;
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h
index 6ce5befb14a..fcd78be8372 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h
@@ -29,38 +29,38 @@
class ColorCurveOperation : public CurveBaseOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputFacProgram;
- SocketReader * inputImageProgram;
- SocketReader * inputBlackProgram;
- SocketReader * inputWhiteProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputFacProgram;
+ SocketReader *inputImageProgram;
+ SocketReader *inputBlackProgram;
+ SocketReader *inputWhiteProgram;
public:
ColorCurveOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
class ConstantLevelColorCurveOperation : public CurveBaseOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputFacProgram;
- SocketReader * inputImageProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputFacProgram;
+ SocketReader *inputImageProgram;
float black[3];
float white[3];
@@ -68,22 +68,22 @@ public:
ConstantLevelColorCurveOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setBlackLevel(float black[3]) {this->black[0] =black[0];this->black[1] =black[1];this->black[2] =black[2]; }
- void setWhiteLevel(float white[3]) {this->white[0] =white[0];this->white[1] =white[1];this->white[2] =white[2]; }
+ void setBlackLevel(float black[3]) { this->black[0] = black[0]; this->black[1] = black[1]; this->black[2] = black[2]; }
+ void setWhiteLevel(float white[3]) { this->white[0] = white[0]; this->white[1] = white[1]; this->white[2] = white[2]; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
index 7706559be00..afb362dbdcd 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ColorMatteOperation.h"
#include "BLI_math.h"
-ColorMatteOperation::ColorMatteOperation(): NodeOperation()
+ColorMatteOperation::ColorMatteOperation() : NodeOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
@@ -64,16 +64,17 @@ void ColorMatteOperation::executePixel(float *outputValue, float x, float y, Pix
*/
if (
- /* do hue last because it needs to wrap, and does some more checks */
+ /* do hue last because it needs to wrap, and does some more checks */
- /* sat */ (fabsf(inColor[1] - inKey[1]) < sat) &&
- /* val */ (fabsf(inColor[2] - inKey[2]) < val) &&
+ /* sat */ (fabsf(inColor[1] - inKey[1]) < sat) &&
+ /* val */ (fabsf(inColor[2] - inKey[2]) < val) &&
- /* multiply by 2 because it wraps on both sides of the hue,
- * otherwise 0.5 would key all hue's */
+ /* multiply by 2 because it wraps on both sides of the hue,
+ * otherwise 0.5 would key all hue's */
- /* hue */ ((h_wrap = 2.f * fabsf(inColor[0]-inKey[0])) < hue || (2.f - h_wrap) < hue)
- ) {
+ /* hue */ ((h_wrap = 2.f * fabsf(inColor[0] - inKey[0])) < hue || (2.f - h_wrap) < hue)
+ )
+ {
outputValue[0] = 0.0f; /*make transparent*/
}
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h
index 904a51128c8..e5dd9efd820 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h
@@ -25,9 +25,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ColorMatteOperation : public NodeOperation {
private:
NodeChroma *settings;
@@ -35,18 +35,18 @@ private:
SocketReader *inputKeyProgram;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ColorMatteOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) {this->settings = nodeChroma;}
+ void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
index 992bf3b9d1d..9af70ddc5a7 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
@@ -30,7 +30,7 @@ extern "C" {
}
#endif
-ColorRampOperation::ColorRampOperation(): NodeOperation()
+ColorRampOperation::ColorRampOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h
index 8b8635cc5cd..eef5321eb19 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.h
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.h
@@ -28,29 +28,31 @@
class ColorRampOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
ColorBand *colorBand;
public:
ColorRampOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setColorBand(ColorBand *colorBand) {this->colorBand = colorBand;}
+ void setColorBand(ColorBand *colorBand) {
+ this->colorBand = colorBand;
+ }
};
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
index 9b57d64eb40..1a534d778c0 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -22,9 +22,9 @@
#include "COM_ColorSpillOperation.h"
#include "BLI_math.h"
-#define avg(a,b) ((a+b)/2)
+#define AVG(a, b) ((a + b) / 2)
-ColorSpillOperation::ColorSpillOperation(): NodeOperation()
+ColorSpillOperation::ColorSpillOperation() : NodeOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_VALUE);
@@ -104,11 +104,11 @@ void ColorSpillOperation::executePixel(float *outputValue, float x, float y, Pix
}
float ColorSpillOperation::calculateMapValue(float fac, float *input)
{
- return fac * (input[this->spillChannel]-(this->settings->limscale*input[this->settings->limchan]));
+ return fac * (input[this->spillChannel] - (this->settings->limscale * input[this->settings->limchan]));
}
float ColorSpillAverageOperation::calculateMapValue(float fac, float *input)
{
- return fac * (input[this->spillChannel]-(this->settings->limscale*avg(input[this->channel2], input[this->channel3])));
+ return fac * (input[this->spillChannel] - (this->settings->limscale * AVG(input[this->channel2], input[this->channel3])));
}
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h
index 69f51882496..e890a1e1564 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.h
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h
@@ -25,9 +25,9 @@
#include "COM_NodeOperation.h"
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ColorSpillOperation : public NodeOperation {
protected:
NodeColorspill *settings;
@@ -39,25 +39,25 @@ protected:
float rmut, gmut, bmut;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ColorSpillOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setSettings(NodeColorspill *nodeColorSpill) {this->settings = nodeColorSpill;}
- void setSpillChannel(int channel) {this->spillChannel = channel;}
+ void setSettings(NodeColorspill *nodeColorSpill) { this->settings = nodeColorSpill; }
+ void setSpillChannel(int channel) { this->spillChannel = channel; }
float calculateMapValue(float fac, float *input);
};
-class ColorSpillAverageOperation: public ColorSpillOperation {
+class ColorSpillAverageOperation : public ColorSpillOperation {
public:
float calculateMapValue(float fac, float *input);
};
diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp
index 6b64934f0b8..dff8ccf7e73 100644
--- a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp
+++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp
@@ -53,7 +53,7 @@ void CombineChannelsOperation::deinitExecution()
}
-void CombineChannelsOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void CombineChannelsOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
float input[4];
/// @todo: remove if statements
diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.h b/source/blender/compositor/operations/COM_CombineChannelsOperation.h
index 18dd1fd2ec9..d2977155e14 100644
--- a/source/blender/compositor/operations/COM_CombineChannelsOperation.h
+++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.h
@@ -25,7 +25,7 @@
#include "COM_NodeOperation.h"
-class CombineChannelsOperation: public NodeOperation {
+class CombineChannelsOperation : public NodeOperation {
private:
SocketReader *inputChannel1Operation;
SocketReader *inputChannel2Operation;
@@ -33,7 +33,7 @@ private:
SocketReader *inputChannel4Operation;
public:
CombineChannelsOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index d75cb39325f..2b1a804b432 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -53,14 +53,14 @@ void CompositorOperation::initExecution()
this->imageInput = getInputSocketReader(0);
this->alphaInput = getInputSocketReader(1);
if (this->getWidth() * this->getHeight() != 0) {
- this->outputBuffer=(float*) MEM_callocN(this->getWidth()*this->getHeight()*4*sizeof(float), "CompositorOperation");
+ this->outputBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation");
}
}
void CompositorOperation::deinitExecution()
{
- if (tree->test_break && !tree->test_break(tree->tbh)) {
- const Scene * scene = this->scene;
+ if (!isBreaked()) {
+ const Scene *scene = this->scene;
Render *re = RE_GetRender(scene->id.name);
RenderResult *rr = RE_AcquireResultWrite(re);
if (rr) {
@@ -74,25 +74,27 @@ void CompositorOperation::deinitExecution()
MEM_freeN(this->outputBuffer);
}
}
+
+ BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
+
if (re) {
RE_ReleaseResult(re);
re = NULL;
}
- BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
}
else {
if (this->outputBuffer) {
MEM_freeN(this->outputBuffer);
}
}
-
+
this->outputBuffer = NULL;
this->imageInput = NULL;
this->alphaInput = NULL;
}
-void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers)
+void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers)
{
float color[8]; // 7 is enough
float *buffer = this->outputBuffer;
@@ -102,37 +104,47 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem
int y1 = rect->ymin;
int x2 = rect->xmax;
int y2 = rect->ymax;
- int offset = (y1*this->getWidth() + x1 ) * 4;
+ int offset = (y1 * this->getWidth() + x1) * COM_NUMBER_OF_CHANNELS;
int x;
int y;
bool breaked = false;
- for (y = y1 ; y < y2 && (!breaked); y++) {
- for (x = x1 ; x < x2 && (!breaked) ; x++) {
+ for (y = y1; y < y2 && (!breaked); y++) {
+ for (x = x1; x < x2 && (!breaked); x++) {
imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers);
if (alphaInput != NULL) {
alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers);
}
- buffer[offset] = color[0];
- buffer[offset+1] = color[1];
- buffer[offset+2] = color[2];
- buffer[offset+3] = color[3];
- offset +=4;
- if (tree->test_break && tree->test_break(tree->tbh)) {
+ copy_v4_v4(buffer + offset, color);
+ offset += COM_NUMBER_OF_CHANNELS;
+ if (isBreaked()) {
breaked = true;
}
}
- offset += (this->getWidth()-(x2-x1))*4;
+ offset += (this->getWidth() - (x2 - x1)) * COM_NUMBER_OF_CHANNELS;
}
}
void CompositorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
- int width = this->scene->r.xsch*this->scene->r.size/100;
- int height = this->scene->r.ysch*this->scene->r.size/100;
+ int width = this->scene->r.xsch * this->scene->r.size / 100;
+ int height = this->scene->r.ysch * this->scene->r.size / 100;
+
+ // check actual render resolution with cropping it may differ with cropped border.rendering
+ // FIX for: [31777] Border Crop gives black (easy)
+ Render *re = RE_GetRender(this->scene->id.name);
+ if (re) {
+ RenderResult *rr = RE_AcquireResultRead(re);
+ if (rr) {
+ width = rr->rectx;
+ height = rr->recty;
+ }
+ RE_ReleaseResult(re);
+ }
+
preferredResolution[0] = width;
preferredResolution[1] = height;
-
+
NodeOperation::determineResolution(resolution, preferredResolution);
resolution[0] = width;
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
index 13cb4f28324..0129c953946 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.h
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -27,43 +27,37 @@
#include "BLI_rect.h"
/**
- * @brief Compositor output operation
- */
+ * @brief Compositor output operation
+ */
class CompositorOperation : public NodeOperation {
private:
/**
- * @brief local reference to the scene
- */
+ * @brief local reference to the scene
+ */
const Scene *scene;
-
- /**
- * @brief local reference to the node tree
- */
- const bNodeTree *tree;
-
+
/**
- * @brief reference to the output float buffer
- */
+ * @brief reference to the output float buffer
+ */
float *outputBuffer;
-
+
/**
- * @brief local reference to the input image operation
- */
+ * @brief local reference to the input image operation
+ */
SocketReader *imageInput;
/**
- * @brief local reference to the input alpha operation
- */
+ * @brief local reference to the input alpha operation
+ */
SocketReader *alphaInput;
public:
CompositorOperation();
- void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
- void setScene(const Scene *scene) {this->scene = scene;}
- void setbNodeTree(const bNodeTree *tree) {this->tree = tree;}
- bool isOutputOperation(bool rendering) const {return true;}
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
+ void setScene(const Scene *scene) { this->scene = scene; }
+ bool isOutputOperation(bool rendering) const { return true; }
void initExecution();
void deinitExecution();
- const CompositorPriority getRenderPriority() const {return COM_PRIORITY_MEDIUM;}
+ const CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; }
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
index df12a7d6b49..2e8fc9005b8 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
@@ -25,7 +25,7 @@
extern "C" {
#include "IMB_imbuf.h"
}
-ConvertColorProfileOperation::ConvertColorProfileOperation(): NodeOperation()
+ConvertColorProfileOperation::ConvertColorProfileOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
index 1868de6d815..b11a06f7749 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
@@ -26,53 +26,53 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertColorProfileOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
/**
- * @brief color profile where to convert from
- */
+ * @brief color profile where to convert from
+ */
int fromProfile;
/**
- * @brief color profile where to convert to
- */
+ * @brief color profile where to convert to
+ */
int toProfile;
/**
- * @brief is color predivided
- */
+ * @brief is color predivided
+ */
bool predivided;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertColorProfileOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setFromColorProfile(int colorProfile) {this->fromProfile = colorProfile;}
- void setToColorProfile(int colorProfile) {this->toProfile = colorProfile;}
- void setPredivided(bool predivided) {this->predivided = predivided;}
+ void setFromColorProfile(int colorProfile) { this->fromProfile = colorProfile; }
+ void setToColorProfile(int colorProfile) { this->toProfile = colorProfile; }
+ void setPredivided(bool predivided) { this->predivided = predivided; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
index f4be7d2e65b..c66cb8df9be 100644
--- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertColorToBWOperation.h"
-ConvertColorToBWOperation::ConvertColorToBWOperation(): NodeOperation()
+ConvertColorToBWOperation::ConvertColorToBWOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
@@ -38,7 +38,7 @@ void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float
{
float inputColor[4];
inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers);
- outputValue[0] = inputColor[0]*0.35f + inputColor[1]*0.45f + inputColor[2]*0.2f;
+ outputValue[0] = inputColor[0] * 0.35f + inputColor[1] * 0.45f + inputColor[2] * 0.2f;
}
void ConvertColorToBWOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h
index 616cf0f2d01..814c0c2e808 100644
--- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertColorToBWOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertColorToBWOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp
index ce45266ace0..613bfe68fbb 100644
--- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertColorToVectorOperation.h"
-ConvertColorToVectorOperation::ConvertColorToVectorOperation(): NodeOperation()
+ConvertColorToVectorOperation::ConvertColorToVectorOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VECTOR);
diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h
index 11a1bf30a07..1167b565a8e 100644
--- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertColorToVectorOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertColorToVectorOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp b/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp
index 0d4f2df22d8..2c8caec6f61 100644
--- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertColourToValueProg.h"
-ConvertColourToValueProg::ConvertColourToValueProg(): NodeOperation()
+ConvertColourToValueProg::ConvertColourToValueProg() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
@@ -38,7 +38,7 @@ void ConvertColourToValueProg::executePixel(float *outputValue, float x, float y
{
float inputColor[4];
inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers);
- outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2])/3.0f;
+ outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
}
void ConvertColourToValueProg::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h b/source/blender/compositor/operations/COM_ConvertColourToValueProg.h
index 7aa07dd46f2..9c43ec47604 100644
--- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h
+++ b/source/blender/compositor/operations/COM_ConvertColourToValueProg.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertColourToValueProg : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertColourToValueProg();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index f64f0c054b1..1746afea713 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -24,7 +24,7 @@
#include "BLI_math.h"
#include "DNA_camera_types.h"
-ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation(): NodeOperation()
+ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -41,7 +41,7 @@ float ConvertDepthToRadiusOperation::determineFocalDistance()
return 10.0f;
}
else {
- Camera *camera = (Camera*)this->cameraObject->data;
+ Camera *camera = (Camera *)this->cameraObject->data;
cam_lens = camera->lens;
if (camera->dof_ob) {
/* too simple, better to return the distance on the view axis only
@@ -62,12 +62,12 @@ void ConvertDepthToRadiusOperation::initExecution()
{
this->inputOperation = this->getInputSocketReader(0);
float focalDistance = determineFocalDistance();
- if (focalDistance == 0.0f) focalDistance = 1e10f; /* if the dof is 0.0 then set it be be far away */
- inverseFocalDistance = 1.f/focalDistance;
+ if (focalDistance == 0.0f) focalDistance = 1e10f; /* if the dof is 0.0 then set it be be far away */
+ inverseFocalDistance = 1.f / focalDistance;
this->aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight());
- this->aperture = 0.5f*(this->cam_lens / (this->aspect*32.f)) / this->fStop;
+ this->aperture = 0.5f * (this->cam_lens / (this->aspect * 32.f)) / this->fStop;
float minsz = MIN2(getWidth(), getHeight());
- this->dof_sp = (float)minsz / (16.f / cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov);
+ this->dof_sp = (float)minsz / (16.f / cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov);
}
void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -77,16 +77,16 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl
float radius;
inputOperation->read(inputValue, x, y, sampler, inputBuffers);
z = inputValue[0];
- if (z!=0.f) {
- float iZ = (1.f/z);
+ if (z != 0.f) {
+ float iZ = (1.f / z);
// bug #6656 part 2b, do not rescale
- /*
+#if 0
bcrad = 0.5f*fabs(aperture*(dof_sp*(cam_invfdist - iZ) - 1.f));
// scale crad back to original maximum and blend
crad->rect[px] = bcrad + wts->rect[px]*(scf*crad->rect[px] - bcrad);
- */
- radius = 0.5f*fabsf(this->aperture*(dof_sp*(inverseFocalDistance - iZ) - 1.f));
+#endif
+ radius = 0.5f * fabsf(this->aperture * (dof_sp * (inverseFocalDistance - iZ) - 1.f));
// 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
if (radius < 0.5f) radius = 0.5f;
if (radius > maxRadius) {
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
index c199ea87fe3..c6da6bc94a9 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
@@ -26,15 +26,15 @@
#include "DNA_object_types.h"
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertDepthToRadiusOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
float fStop;
float aspect;
float maxRadius;
@@ -45,28 +45,28 @@ private:
Object *cameraObject;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertDepthToRadiusOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setfStop(float fStop) {this->fStop = fStop;}
- void setMaxRadius(float maxRadius) {this->maxRadius = maxRadius;}
- void setCameraObject(Object *camera) {this->cameraObject = camera;}
+ void setfStop(float fStop) { this->fStop = fStop; }
+ void setMaxRadius(float maxRadius) { this->maxRadius = maxRadius; }
+ void setCameraObject(Object *camera) { this->cameraObject = camera; }
float determineFocalDistance();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp
index 97dd7e69092..e8c0061319c 100644
--- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_ConvertHSVToRGBOperation.h"
#include "BLI_math_color.h"
-ConvertHSVToRGBOperation::ConvertHSVToRGBOperation(): NodeOperation()
+ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h
index 327b4089934..29c82361d12 100644
--- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertHSVToRGBOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertHSVToRGBOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
index 547915f58c9..842546a2755 100644
--- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertKeyToPremulOperation.h"
#include "BLI_math.h"
-ConvertKeyToPremulOperation::ConvertKeyToPremulOperation(): NodeOperation()
+ConvertKeyToPremulOperation::ConvertKeyToPremulOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -43,9 +43,7 @@ void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, floa
this->inputColor->read(inputValue, x, y, sampler, inputBuffers);
alpha = inputValue[3];
- outputValue[0] = inputValue[0] * alpha;
- outputValue[1] = inputValue[1] * alpha;
- outputValue[2] = inputValue[2] * alpha;
+ mul_v3_v3fl(outputValue, inputValue, alpha);
/* never touches the alpha */
outputValue[3] = alpha;
diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
index 1d5a1c1c4a6..fe0586f7a88 100644
--- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
@@ -25,22 +25,22 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertKeyToPremulOperation : public NodeOperation {
private:
SocketReader *inputColor;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertKeyToPremulOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp
index 16636ee2afc..3554be53e3f 100644
--- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertPremulToKeyOperation.h"
#include "BLI_math.h"
-ConvertPremulToKeyOperation::ConvertPremulToKeyOperation(): NodeOperation()
+ConvertPremulToKeyOperation::ConvertPremulToKeyOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -44,14 +44,10 @@ void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, floa
alpha = inputValue[3];
if (fabsf(alpha) < 1e-5f) {
- outputValue[0] = 0.f;
- outputValue[1] = 0.f;
- outputValue[2] = 0.f;
+ zero_v3(outputValue);
}
else {
- outputValue[0] = inputValue[0] / alpha;
- outputValue[1] = inputValue[1] / alpha;
- outputValue[2] = inputValue[2] / alpha;
+ mul_v3_v3fl(outputValue, inputValue, 1.0f / alpha);
}
/* never touches the alpha */
diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h
index 17597fa8f15..093f28df3e5 100644
--- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h
@@ -25,22 +25,22 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertPremulToKeyOperation : public NodeOperation {
private:
SocketReader *inputColor;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertPremulToKeyOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp
index 99054efc267..051d9d2b8f9 100644
--- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_ConvertRGBToHSVOperation.h"
#include "BLI_math_color.h"
-ConvertRGBToHSVOperation::ConvertRGBToHSVOperation(): NodeOperation()
+ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h
index 5064bd06993..61270539e70 100644
--- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertRGBToHSVOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertRGBToHSVOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp
index c626dc03000..d984a1ab943 100644
--- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertRGBToYCCOperation.h"
#include "BLI_math_color.h"
-ConvertRGBToYCCOperation::ConvertRGBToYCCOperation(): NodeOperation()
+ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -38,16 +38,16 @@ void ConvertRGBToYCCOperation::setMode(int mode)
{
switch (mode)
{
- case 1:
- this->mode = BLI_YCC_ITU_BT709;
- break;
- case 2:
- this->mode = BLI_YCC_JFIF_0_255;
- break;
- case 0:
- default:
- this->mode = BLI_YCC_ITU_BT601;
- break;
+ case 1:
+ this->mode = BLI_YCC_ITU_BT709;
+ break;
+ case 2:
+ this->mode = BLI_YCC_JFIF_0_255;
+ break;
+ case 0:
+ default:
+ this->mode = BLI_YCC_ITU_BT601;
+ break;
}
}
@@ -60,9 +60,8 @@ void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y
rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->mode);
/* divided by 255 to normalize for viewing in */
- outputValue[0] = color[0]/255.f; /* Y */
- outputValue[1] = color[1]/255.f; /* Cb*/
- outputValue[2] = color[2]/255.f; /* Cr*/
+ /* R,G,B --> Y,Cb,Cr */
+ mul_v3_v3fl(outputValue, color, 1.0f / 255.0f);
outputValue[3] = inputColor[3];
}
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h
index a952627893b..33075cda509 100644
--- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h
@@ -25,44 +25,44 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertRGBToYCCOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
/**
- * YCbCr mode (Jpeg, ITU601, ITU709)
- */
+ * YCbCr mode (Jpeg, ITU601, ITU709)
+ */
int mode;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertRGBToYCCOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
/**
- * Set the YCC mode
- */
+ * Set the YCC mode
+ */
void setMode(int mode);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp
index c4b870d6ad5..e5a8e7de1bb 100644
--- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertRGBToYUVOperation.h"
#include "BLI_math_color.h"
-ConvertRGBToYUVOperation::ConvertRGBToYUVOperation(): NodeOperation()
+ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h
index 5bc763dde00..4fc525456f8 100644
--- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h
@@ -25,34 +25,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertRGBToYUVOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertRGBToYUVOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp b/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp
index dce554efbac..9d95c51a546 100644
--- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp
+++ b/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertValueToColourProg.h"
-ConvertValueToColourProg::ConvertValueToColourProg(): NodeOperation()
+ConvertValueToColourProg::ConvertValueToColourProg() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h b/source/blender/compositor/operations/COM_ConvertValueToColourProg.h
index 4956f7196f5..ff1d1aaeae7 100644
--- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h
+++ b/source/blender/compositor/operations/COM_ConvertValueToColourProg.h
@@ -28,25 +28,25 @@
class ConvertValueToColourProg : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
+ * Cached reference to the inputProgram
+ */
SocketReader *inputProgram;
public:
ConvertValueToColourProg();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp
index ba7913d24ee..5ba3f6ef4a9 100644
--- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertValueToVectorOperation.h"
-ConvertValueToVectorOperation::ConvertValueToVectorOperation(): NodeOperation()
+ConvertValueToVectorOperation::ConvertValueToVectorOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VECTOR);
diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h
index 1e6a7d4b3e7..fbb294d6a26 100644
--- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertValueToVectorOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertValueToVectorOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp
index 5a4cc4d3549..f6a2072932c 100644
--- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertVectorToColorOperation.h"
-ConvertVectorToColorOperation::ConvertVectorToColorOperation(): NodeOperation()
+ConvertVectorToColorOperation::ConvertVectorToColorOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h
index 45ffd0675bd..c26adc5a6b1 100644
--- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertVectorToColorOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertVectorToColorOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp
index 67cc42ac8fc..ef2d45eea03 100644
--- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertVectorToValueOperation.h"
-ConvertVectorToValueOperation::ConvertVectorToValueOperation(): NodeOperation()
+ConvertVectorToValueOperation::ConvertVectorToValueOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_VALUE);
@@ -38,7 +38,7 @@ void ConvertVectorToValueOperation::executePixel(float *outputValue, float x, fl
{
float input[4];
inputOperation->read(input, x, y, sampler, inputBuffers);
- outputValue[0] = (input[0]+input[1]+input[2])/3.0f;
+ outputValue[0] = (input[0] + input[1] + input[2]) / 3.0f;
}
void ConvertVectorToValueOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h
index 59bae18ed26..dd29d1bb9a9 100644
--- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h
@@ -26,34 +26,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertVectorToValueOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertVectorToValueOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp
index d3048c131e4..373de25a276 100644
--- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertYCCToRGBOperation.h"
#include "BLI_math_color.h"
-ConvertYCCToRGBOperation::ConvertYCCToRGBOperation(): NodeOperation()
+ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -38,16 +38,16 @@ void ConvertYCCToRGBOperation::setMode(int mode)
{
switch (mode)
{
- case 1:
- this->mode = BLI_YCC_ITU_BT709;
- break;
- case 2:
- this->mode = BLI_YCC_JFIF_0_255;
- break;
- case 0:
- default:
- this->mode = BLI_YCC_ITU_BT601;
- break;
+ case 1:
+ this->mode = BLI_YCC_ITU_BT709;
+ break;
+ case 2:
+ this->mode = BLI_YCC_JFIF_0_255;
+ break;
+ case 0:
+ default:
+ this->mode = BLI_YCC_ITU_BT601;
+ break;
}
}
@@ -57,9 +57,8 @@ void ConvertYCCToRGBOperation::executePixel(float *outputValue, float x, float y
inputOperation->read(inputColor, x, y, sampler, inputBuffers);
/* need to un-normalize the data */
- inputColor[0] *= 255.f; /* Y */
- inputColor[1] *= 255.f; /* Cb*/
- inputColor[2] *= 255.f; /* Cr*/
+ /* R,G,B --> Y,Cb,Cr */
+ mul_v3_fl(inputColor, 255.0f);
ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->mode);
outputValue[3] = inputColor[3];
diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h
index a13c2826a79..d7ddd910ed7 100644
--- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h
@@ -25,44 +25,44 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertYCCToRGBOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
/**
- * YCbCr mode (Jpeg, ITU601, ITU709)
- */
+ * YCbCr mode (Jpeg, ITU601, ITU709)
+ */
int mode;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertYCCToRGBOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
/**
- * Set the YCC mode
- */
+ * Set the YCC mode
+ */
void setMode(int mode);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp
index d7037a2c2d1..a77806d16d0 100644
--- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_ConvertYUVToRGBOperation.h"
#include "BLI_math_color.h"
-ConvertYUVToRGBOperation::ConvertYUVToRGBOperation(): NodeOperation()
+ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h
index 380510d0100..f77954606cf 100644
--- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h
@@ -25,34 +25,34 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ConvertYUVToRGBOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ConvertYUVToRGBOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
index db67412f3e7..5ac8c2254dc 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
@@ -25,17 +25,12 @@
ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation() : ConvolutionFilterOperation()
{
-}
-inline void addFilter(float *result, float*input, float value)
-{
- result[0] += input[0] * value;
- result[1] += input[1] * value;
- result[2] += input[2] * value;
+ /* pass */
}
-void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
+void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- float in1[4],in2[4], res1[4], res2[4];
+ float in1[4], in2[4], res1[4], res2[4];
int x1 = x - 1;
int x2 = x;
@@ -43,12 +38,12 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, Mem
int y1 = y - 1;
int y2 = y;
int y3 = y + 1;
- CLAMP(x1, 0, getWidth()-1);
- CLAMP(x2, 0, getWidth()-1);
- CLAMP(x3, 0, getWidth()-1);
- CLAMP(y1, 0, getHeight()-1);
- CLAMP(y2, 0, getHeight()-1);
- CLAMP(y3, 0, getHeight()-1);
+ CLAMP(x1, 0, getWidth() - 1);
+ CLAMP(x2, 0, getWidth() - 1);
+ CLAMP(x3, 0, getWidth() - 1);
+ CLAMP(y1, 0, getHeight() - 1);
+ CLAMP(y2, 0, getHeight() - 1);
+ CLAMP(y3, 0, getHeight() - 1);
float value[4];
this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL);
@@ -64,48 +59,48 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, Mem
res2[3] = 0.0f;
this->inputOperation->read(in1, x1, y1, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[0]);
- addFilter(res2, in1, this->filter[0]);
+ madd_v3_v3fl(res1, in1, this->filter[0]);
+ madd_v3_v3fl(res2, in1, this->filter[0]);
this->inputOperation->read(in1, x2, y1, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[1]);
- addFilter(res2, in1, this->filter[3]);
+ madd_v3_v3fl(res1, in1, this->filter[1]);
+ madd_v3_v3fl(res2, in1, this->filter[3]);
this->inputOperation->read(in1, x3, y1, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[2]);
- addFilter(res2, in1, this->filter[6]);
+ madd_v3_v3fl(res1, in1, this->filter[2]);
+ madd_v3_v3fl(res2, in1, this->filter[6]);
this->inputOperation->read(in1, x1, y2, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[3]);
- addFilter(res2, in1, this->filter[1]);
+ madd_v3_v3fl(res1, in1, this->filter[3]);
+ madd_v3_v3fl(res2, in1, this->filter[1]);
this->inputOperation->read(in2, x2, y2, inputBuffers, NULL);
- addFilter(res1, in2, this->filter[4]);
- addFilter(res2, in2, this->filter[4]);
+ madd_v3_v3fl(res1, in2, this->filter[4]);
+ madd_v3_v3fl(res2, in2, this->filter[4]);
this->inputOperation->read(in1, x3, y2, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[5]);
- addFilter(res2, in1, this->filter[7]);
+ madd_v3_v3fl(res1, in1, this->filter[5]);
+ madd_v3_v3fl(res2, in1, this->filter[7]);
this->inputOperation->read(in1, x1, y3, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[6]);
- addFilter(res2, in1, this->filter[2]);
+ madd_v3_v3fl(res1, in1, this->filter[6]);
+ madd_v3_v3fl(res2, in1, this->filter[2]);
this->inputOperation->read(in1, x2, y3, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[7]);
- addFilter(res2, in1, this->filter[5]);
+ madd_v3_v3fl(res1, in1, this->filter[7]);
+ madd_v3_v3fl(res2, in1, this->filter[5]);
this->inputOperation->read(in1, x3, y3, inputBuffers, NULL);
- addFilter(res1, in1, this->filter[8]);
- addFilter(res2, in1, this->filter[8]);
+ madd_v3_v3fl(res1, in1, this->filter[8]);
+ madd_v3_v3fl(res2, in1, this->filter[8]);
- color[0] = sqrt(res1[0]*res1[0]+res2[0]*res2[0]);
- color[1] = sqrt(res1[1]*res1[1]+res2[1]*res2[1]);
- color[2] = sqrt(res1[2]*res1[2]+res2[2]*res2[2]);
+ color[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]);
+ color[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]);
+ color[2] = sqrt(res1[2] * res1[2] + res2[2] * res2[2]);
- color[0] = color[0]*value[0] + in2[0] * mval;
- color[1] = color[1]*value[0] + in2[1] * mval;
- color[2] = color[2]*value[0] + in2[2] * mval;
+ color[0] = color[0] * value[0] + in2[0] * mval;
+ color[1] = color[1] * value[0] + in2[1] * mval;
+ color[2] = color[2] * value[0] + in2[2] * mval;
color[3] = in2[3];
}
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
index a0f9c1b3452..92e45c7104f 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
@@ -25,10 +25,10 @@
#include "COM_ConvolutionFilterOperation.h"
-class ConvolutionEdgeFilterOperation: public ConvolutionFilterOperation {
+class ConvolutionEdgeFilterOperation : public ConvolutionFilterOperation {
public:
ConvolutionEdgeFilterOperation();
- void executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
index 9fec75abafe..b4f2714360e 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
@@ -61,18 +61,14 @@ void ConvolutionFilterOperation::deinitExecution()
this->inputOperation = NULL;
this->inputValueOperation = NULL;
if (this->filter) {
- delete this->filter;
+ delete[] this->filter;
this->filter = NULL;
}
}
-void ConvolutionFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
+void ConvolutionFilterOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- color[0] = 0.0;
- color[1] = 0.0;
- color[2] = 0.0;
- color[3] = 0.0;
float in1[4];
float in2[4];
int x1 = x - 1;
@@ -81,72 +77,47 @@ void ConvolutionFilterOperation::executePixel(float *color,int x, int y, MemoryB
int y1 = y - 1;
int y2 = y;
int y3 = y + 1;
- CLAMP(x1, 0, getWidth()-1);
- CLAMP(x2, 0, getWidth()-1);
- CLAMP(x3, 0, getWidth()-1);
- CLAMP(y1, 0, getHeight()-1);
- CLAMP(y2, 0, getHeight()-1);
- CLAMP(y3, 0, getHeight()-1);
+ CLAMP(x1, 0, getWidth() - 1);
+ CLAMP(x2, 0, getWidth() - 1);
+ CLAMP(x3, 0, getWidth() - 1);
+ CLAMP(y1, 0, getHeight() - 1);
+ CLAMP(y2, 0, getHeight() - 1);
+ CLAMP(y3, 0, getHeight() - 1);
float value[4];
this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL);
- float mval = 1.0f - value[0];
+ const float mval = 1.0f - value[0];
+
+ zero_v4(color);
this->inputOperation->read(in1, x1, y1, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[0];
- color[1] += in1[1] * this->filter[0];
- color[2] += in1[2] * this->filter[0];
- color[3] += in1[3] * this->filter[0];
+ madd_v4_v4fl(color, in1, this->filter[0]);
this->inputOperation->read(in1, x2, y1, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[1];
- color[1] += in1[1] * this->filter[1];
- color[2] += in1[2] * this->filter[1];
- color[3] += in1[3] * this->filter[1];
+ madd_v4_v4fl(color, in1, this->filter[1]);
this->inputOperation->read(in1, x3, y1, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[2];
- color[1] += in1[1] * this->filter[2];
- color[2] += in1[2] * this->filter[2];
- color[3] += in1[3] * this->filter[2];
+ madd_v4_v4fl(color, in1, this->filter[2]);
this->inputOperation->read(in1, x1, y2, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[3];
- color[1] += in1[1] * this->filter[3];
- color[2] += in1[2] * this->filter[3];
- color[3] += in1[3] * this->filter[3];
+ madd_v4_v4fl(color, in1, this->filter[3]);
this->inputOperation->read(in2, x2, y2, inputBuffers, NULL);
- color[0] += in2[0] * this->filter[4];
- color[1] += in2[1] * this->filter[4];
- color[2] += in2[2] * this->filter[4];
- color[3] += in2[3] * this->filter[4];
+ madd_v4_v4fl(color, in2, this->filter[4]);
this->inputOperation->read(in1, x3, y2, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[5];
- color[1] += in1[1] * this->filter[5];
- color[2] += in1[2] * this->filter[5];
- color[3] += in1[3] * this->filter[5];
+ madd_v4_v4fl(color, in1, this->filter[5]);
this->inputOperation->read(in1, x1, y3, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[6];
- color[1] += in1[1] * this->filter[6];
- color[2] += in1[2] * this->filter[6];
- color[3] += in1[3] * this->filter[6];
+ madd_v4_v4fl(color, in1, this->filter[6]);
this->inputOperation->read(in1, x2, y3, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[7];
- color[1] += in1[1] * this->filter[7];
- color[2] += in1[2] * this->filter[7];
- color[3] += in1[3] * this->filter[7];
+ madd_v4_v4fl(color, in1, this->filter[7]);
this->inputOperation->read(in1, x3, y3, inputBuffers, NULL);
- color[0] += in1[0] * this->filter[8];
- color[1] += in1[1] * this->filter[8];
- color[2] += in1[2] * this->filter[8];
- color[3] += in1[3] * this->filter[8];
+ madd_v4_v4fl(color, in1, this->filter[8]);
- color[0] = color[0]*value[0] + in2[0] * mval;
- color[1] = color[1]*value[0] + in2[1] * mval;
- color[2] = color[2]*value[0] + in2[2] * mval;
- color[3] = color[3]*value[0] + in2[3] * mval;
+ color[0] = color[0] * value[0] + in2[0] * mval;
+ color[1] = color[1] * value[0] + in2[1] * mval;
+ color[2] = color[2] * value[0] + in2[2] * mval;
+ color[3] = color[3] * value[0] + in2[3] * mval;
}
bool ConvolutionFilterOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- int addx = (this->filterWidth-1)/2+1;
- int addy = (this->filterHeight-1)/2+1;
+ int addx = (this->filterWidth - 1) / 2 + 1;
+ int addy = (this->filterHeight - 1) / 2 + 1;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
index 3276038726b..f3347eb583a 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
@@ -25,7 +25,7 @@
#include "COM_NodeOperation.h"
-class ConvolutionFilterOperation: public NodeOperation {
+class ConvolutionFilterOperation : public NodeOperation {
private:
int filterWidth;
int filterHeight;
@@ -39,7 +39,7 @@ public:
ConvolutionFilterOperation();
void set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9);
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index 192ad8d0bda..0bdd2cfcb51 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_CropOperation.h"
#include "BLI_math.h"
-CropBaseOperation::CropBaseOperation() :NodeOperation()
+CropBaseOperation::CropBaseOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
@@ -33,7 +33,7 @@ CropBaseOperation::CropBaseOperation() :NodeOperation()
void CropBaseOperation::updateArea()
{
- SocketReader * inputReference = this->getInputSocketReader(0);
+ SocketReader *inputReference = this->getInputSocketReader(0);
float width = inputReference->getWidth();
float height = inputReference->getHeight();
if (this->relative) {
@@ -68,8 +68,9 @@ void CropBaseOperation::deinitExecution()
this->inputOperation = NULL;
}
-CropOperation::CropOperation() :CropBaseOperation()
+CropOperation::CropOperation() : CropBaseOperation()
{
+ /* pass */
}
void CropOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -85,8 +86,9 @@ void CropOperation::executePixel(float *color, float x, float y, PixelSampler sa
}
}
-CropImageOperation::CropImageOperation() :CropBaseOperation()
+CropImageOperation::CropImageOperation() : CropBaseOperation()
{
+ /* pass */
}
bool CropImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
index e8edabf08ed..48e5ab7f75b 100644
--- a/source/blender/compositor/operations/COM_CropOperation.h
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -25,7 +25,7 @@
#include "COM_NodeOperation.h"
-class CropBaseOperation: public NodeOperation {
+class CropBaseOperation : public NodeOperation {
protected:
SocketReader *inputOperation;
NodeTwoXYs *settings;
@@ -40,24 +40,24 @@ public:
CropBaseOperation();
void initExecution();
void deinitExecution();
- void setCropSettings(NodeTwoXYs *settings) {this->settings = settings;}
- void setRelative(bool rel) {this->relative = rel;}
+ void setCropSettings(NodeTwoXYs *settings) { this->settings = settings; }
+ void setRelative(bool rel) { this->relative = rel; }
};
-class CropOperation: public CropBaseOperation {
+class CropOperation : public CropBaseOperation {
private:
public:
CropOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class CropImageOperation: public CropBaseOperation {
+class CropImageOperation : public CropBaseOperation {
private:
public:
CropImageOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void determineResolution(unsigned int resolution[], unsigned int preferedResolution[]);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
index fda5b00e2a0..6aa8bc2a0df 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
@@ -30,7 +30,7 @@ extern "C" {
}
#endif
-CurveBaseOperation::CurveBaseOperation(): NodeOperation()
+CurveBaseOperation::CurveBaseOperation() : NodeOperation()
{
this->curveMapping = NULL;
}
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h
index 366af5b07cb..9cddb3be46b 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.h
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h
@@ -28,8 +28,8 @@
class CurveBaseOperation : public NodeOperation {
protected:
/**
- * Cached reference to the inputProgram
- */
+ * Cached reference to the inputProgram
+ */
CurveMapping *curveMapping;
public:
CurveBaseOperation();
@@ -39,6 +39,6 @@ public:
*/
void initExecution();
- void setCurveMapping(CurveMapping *mapping) {this->curveMapping = mapping;}
+ void setCurveMapping(CurveMapping *mapping) { this->curveMapping = mapping; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
index 0b1ac1b2127..c27e699f627 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_DifferenceMatteOperation.h"
#include "BLI_math.h"
-DifferenceMatteOperation::DifferenceMatteOperation(): NodeOperation()
+DifferenceMatteOperation::DifferenceMatteOperation() : NodeOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
@@ -49,8 +49,8 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y
float inColor1[4];
float inColor2[4];
- const float tolerence=this->settings->t1;
- const float falloff=this->settings->t2;
+ const float tolerence = this->settings->t1;
+ const float falloff = this->settings->t2;
float difference;
float alpha;
@@ -69,15 +69,15 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y
outputValue[0] = 0.0f;
}
/*in the falloff region, make partially transparent */
- else if (difference < falloff+tolerence) {
- difference=difference-tolerence;
- alpha=difference/falloff;
+ else if (difference < falloff + tolerence) {
+ difference = difference - tolerence;
+ alpha = difference / falloff;
/*only change if more transparent than before */
if (alpha < inColor1[3]) {
- outputValue[0]=alpha;
+ outputValue[0] = alpha;
}
else { /* leave as before */
- outputValue[0]=inColor1[3];
+ outputValue[0] = inColor1[3];
}
}
else {
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
index 95ebed6f63d..3bdc3384556 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
@@ -26,28 +26,28 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class DifferenceMatteOperation : public NodeOperation {
private:
NodeChroma *settings;
- SocketReader * inputImage1Program;
+ SocketReader *inputImage1Program;
SocketReader *inputImage2Program;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
DifferenceMatteOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) {this->settings = nodeChroma;}
+ void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index 7bc49fa695c..306a2d96985 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -24,7 +24,7 @@
#include "BLI_math.h"
// DilateErode Distance Threshold
-DilateErodeDistanceOperation::DilateErodeDistanceOperation(): NodeOperation()
+DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -34,15 +34,15 @@ DilateErodeDistanceOperation::DilateErodeDistanceOperation(): NodeOperation()
this->_switch = 0.5f;
this->distance = 0.0f;
}
-void DilateErodeDistanceOperation::initExecution()
+void DilateErodeThresholdOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
if (this->distance < 0.0f) {
- this->scope = - this->distance + this->inset;
+ this->scope = -this->distance + this->inset;
}
else {
- if (this->inset*2 > this->distance) {
- this->scope = max(this->inset*2 - this->distance, this->distance);
+ if (this->inset * 2 > this->distance) {
+ this->scope = max(this->inset * 2 - this->distance, this->distance);
}
else {
this->scope = distance;
@@ -53,13 +53,13 @@ void DilateErodeDistanceOperation::initExecution()
}
}
-void *DilateErodeDistanceOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+void *DilateErodeThresholdOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
return buffer;
}
-void DilateErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
float inputValue[4];
const float sw = this->_switch;
@@ -67,45 +67,45 @@ void DilateErodeDistanceOperation::executePixel(float *color, int x, int y, Memo
float pixelvalue;
const float rd = scope * scope;
const float inset = this->inset;
- float mindist = rd*2;
+ float mindist = rd * 2;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - scope, rect->xmin);
const int miny = max(y - scope, rect->ymin);
const int maxx = min(x + scope, rect->xmax);
const int maxy = min(y + scope, rect->ymax);
- const int bufferWidth = rect->xmax-rect->xmin;
+ const int bufferWidth = rect->xmax - rect->xmin;
int offset;
this->inputProgram->read(inputValue, x, y, inputBuffers, NULL);
- if (inputValue[0]>sw) {
- for (int yi = miny ; yi<maxy;yi++) {
- offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4;
- for (int xi = minx ; xi<maxx;xi++) {
- if (buffer[offset]<sw) {
- const float dx = xi-x;
- const float dy = yi-y;
- const float dis = dx*dx+dy*dy;
+ if (inputValue[0] > sw) {
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4;
+ for (int xi = minx; xi < maxx; xi++) {
+ if (buffer[offset] < sw) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
mindist = min(mindist, dis);
}
- offset +=4;
+ offset += 4;
}
}
pixelvalue = -sqrtf(mindist);
}
else {
- for (int yi = miny ; yi<maxy;yi++) {
- offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4;
- for (int xi = minx ; xi<maxx;xi++) {
- if (buffer[offset]>sw) {
- const float dx = xi-x;
- const float dy = yi-y;
- const float dis = dx*dx+dy*dy;
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4;
+ for (int xi = minx; xi < maxx; xi++) {
+ if (buffer[offset] > sw) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
mindist = min(mindist, dis);
}
- offset +=4;
+ offset += 4;
}
}
@@ -119,7 +119,7 @@ void DilateErodeDistanceOperation::executePixel(float *color, int x, int y, Memo
color[0] = 1.0f;
}
else {
- color[0] = delta/inset;
+ color[0] = delta / inset;
}
}
else {
@@ -127,13 +127,13 @@ void DilateErodeDistanceOperation::executePixel(float *color, int x, int y, Memo
}
}
else {
- const float delta = -distance+pixelvalue;
+ const float delta = -distance + pixelvalue;
if (delta < 0.0f) {
if (delta < -inset) {
color[0] = 1.0f;
}
else {
- color[0] = (-delta)/inset;
+ color[0] = (-delta) / inset;
}
}
else {
@@ -142,12 +142,12 @@ void DilateErodeDistanceOperation::executePixel(float *color, int x, int y, Memo
}
}
-void DilateErodeDistanceOperation::deinitExecution()
+void DilateErodeThresholdOperation::deinitExecution()
{
this->inputProgram = NULL;
}
-bool DilateErodeDistanceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
@@ -160,13 +160,14 @@ bool DilateErodeDistanceOperation::determineDependingAreaOfInterest(rcti *input,
}
// Dilate Distance
-DilateDistanceOperation::DilateDistanceOperation(): NodeOperation()
+DilateDistanceOperation::DilateDistanceOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
this->setComplex(true);
this->inputProgram = NULL;
this->distance = 0.0f;
+ this->setOpenCL(true);
}
void DilateDistanceOperation::initExecution()
{
@@ -186,30 +187,30 @@ void *DilateDistanceOperation::initializeTileData(rcti *rect, MemoryBuffer **mem
void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
const float distance = this->distance;
- float mindist = distance * distance;
+ const float mindist = distance * distance;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - scope, rect->xmin);
const int miny = max(y - scope, rect->ymin);
const int maxx = min(x + scope, rect->xmax);
const int maxy = min(y + scope, rect->ymax);
- const int bufferWidth = rect->xmax-rect->xmin;
+ const int bufferWidth = rect->xmax - rect->xmin;
int offset;
float value = 0.0f;
- for (int yi = miny ; yi<maxy;yi++) {
- offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4;
- for (int xi = minx ; xi<maxx;xi++) {
- const float dx = xi-x;
- const float dy = yi-y;
- const float dis = dx*dx+dy*dy;
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4;
+ for (int xi = minx; xi < maxx; xi++) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
if (dis <= mindist) {
value = max(buffer[offset], value);
}
- offset +=4;
+ offset += 4;
}
}
color[0] = value;
@@ -231,45 +232,89 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, Read
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
+
+static cl_kernel dilateKernel = 0;
+void DilateDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp)
+{
+ if (!dilateKernel) {
+ dilateKernel = COM_clCreateKernel(program, "dilateKernel", NULL);
+ }
+ cl_int distanceSquared = this->distance * this->distance;
+ cl_int scope = this->scope;
+
+ COM_clAttachMemoryBufferToKernelParameter(context, dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram);
+ COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer);
+ COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer);
+ clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope);
+ clSetKernelArg(dilateKernel, 5, sizeof(cl_int), &distanceSquared);
+ COM_clAttachSizeToKernelParameter(dilateKernel, 6);
+ COM_clEnqueueRange(queue, dilateKernel, outputMemoryBuffer, 7);
+}
+
// Erode Distance
ErodeDistanceOperation::ErodeDistanceOperation() : DilateDistanceOperation()
{
+ /* pass */
}
void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
const float distance = this->distance;
- float mindist = distance * distance;
+ const float mindist = distance * distance;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - scope, rect->xmin);
const int miny = max(y - scope, rect->ymin);
const int maxx = min(x + scope, rect->xmax);
const int maxy = min(y + scope, rect->ymax);
- const int bufferWidth = rect->xmax-rect->xmin;
+ const int bufferWidth = rect->xmax - rect->xmin;
int offset;
float value = 1.0f;
- for (int yi = miny ; yi<maxy;yi++) {
- offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4;
- for (int xi = minx ; xi<maxx;xi++) {
- const float dx = xi-x;
- const float dy = yi-y;
- const float dis = dx*dx+dy*dy;
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4;
+ for (int xi = minx; xi < maxx; xi++) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
if (dis <= mindist) {
value = min(buffer[offset], value);
}
- offset +=4;
+ offset += 4;
}
}
color[0] = value;
}
+static cl_kernel erodeKernel = 0;
+void ErodeDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp)
+{
+ if (!erodeKernel) {
+ erodeKernel = COM_clCreateKernel(program, "erodeKernel", NULL);
+ }
+ cl_int distanceSquared = this->distance * this->distance;
+ cl_int scope = this->scope;
+
+ COM_clAttachMemoryBufferToKernelParameter(context, erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram);
+ COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer);
+ COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer);
+ clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope);
+ clSetKernelArg(erodeKernel, 5, sizeof(cl_int), &distanceSquared);
+ COM_clAttachSizeToKernelParameter(erodeKernel, 6);
+ COM_clEnqueueRange(queue, erodeKernel, outputMemoryBuffer, 7);
+}
+
// Dilate step
-DilateStepOperation::DilateStepOperation(): NodeOperation()
+DilateStepOperation::DilateStepOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -288,53 +333,53 @@ void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB
if (this->cached_buffer != NULL) {
return this->cached_buffer;
}
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (this->cached_buffer == NULL) {
- MemoryBuffer *buffer = (MemoryBuffer*)inputProgram->initializeTileData(NULL, memoryBuffers);
+ MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers);
float *rectf = buffer->convertToValueBuffer();
int x, y, i;
float *p;
int bwidth = buffer->getWidth();
int bheight = buffer->getHeight();
- for (i = 0 ; i < this->iterations ; i ++) {
- for (y=0; y < bheight; y++) {
- for (x=0; x < bwidth-1; x++) {
- p = rectf + (bwidth*y + x);
+ for (i = 0; i < this->iterations; i++) {
+ for (y = 0; y < bheight; y++) {
+ for (x = 0; x < bwidth - 1; x++) {
+ p = rectf + (bwidth * y + x);
*p = MAX2(*p, *(p + 1));
}
}
- for (y=0; y < bheight; y++) {
- for (x=bwidth-1; x >= 1; x--) {
- p = rectf + (bwidth*y + x);
+ for (y = 0; y < bheight; y++) {
+ for (x = bwidth - 1; x >= 1; x--) {
+ p = rectf + (bwidth * y + x);
*p = MAX2(*p, *(p - 1));
}
}
- for (x=0; x < bwidth; x++) {
- for (y=0; y < bheight-1; y++) {
- p = rectf + (bwidth*y + x);
+ for (x = 0; x < bwidth; x++) {
+ for (y = 0; y < bheight - 1; y++) {
+ p = rectf + (bwidth * y + x);
*p = MAX2(*p, *(p + bwidth));
}
}
- for (x=0; x < bwidth; x++) {
- for (y=bheight-1; y >= 1; y--) {
- p = rectf + (bwidth*y + x);
+ for (x = 0; x < bwidth; x++) {
+ for (y = bheight - 1; y >= 1; y--) {
+ p = rectf + (bwidth * y + x);
*p = MAX2(*p, *(p - bwidth));
}
}
}
this->cached_buffer = rectf;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return this->cached_buffer;
}
void DilateStepOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- color[0] = this->cached_buffer[y*this->getWidth()+x];
+ color[0] = this->cached_buffer[y * this->getWidth() + x];
}
void DilateStepOperation::deinitExecution()
@@ -365,8 +410,9 @@ bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff
}
// Erode step
-ErodeStepOperation::ErodeStepOperation(): DilateStepOperation()
+ErodeStepOperation::ErodeStepOperation() : DilateStepOperation()
{
+ /* pass */
}
void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
@@ -374,45 +420,45 @@ void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu
if (this->cached_buffer != NULL) {
return this->cached_buffer;
}
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (this->cached_buffer == NULL) {
- MemoryBuffer *buffer = (MemoryBuffer*)inputProgram->initializeTileData(NULL, memoryBuffers);
+ MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers);
float *rectf = buffer->convertToValueBuffer();
int x, y, i;
float *p;
int bwidth = buffer->getWidth();
int bheight = buffer->getHeight();
- for (i = 0 ; i < this->iterations ; i ++) {
- for (y=0; y < bheight; y++) {
- for (x=0; x < bwidth-1; x++) {
- p = rectf + (bwidth*y + x);
+ for (i = 0; i < this->iterations; i++) {
+ for (y = 0; y < bheight; y++) {
+ for (x = 0; x < bwidth - 1; x++) {
+ p = rectf + (bwidth * y + x);
*p = MIN2(*p, *(p + 1));
}
}
- for (y=0; y < bheight; y++) {
- for (x=bwidth-1; x >= 1; x--) {
- p = rectf + (bwidth*y + x);
+ for (y = 0; y < bheight; y++) {
+ for (x = bwidth - 1; x >= 1; x--) {
+ p = rectf + (bwidth * y + x);
*p = MIN2(*p, *(p - 1));
}
}
- for (x=0; x < bwidth; x++) {
- for (y=0; y < bheight-1; y++) {
- p = rectf + (bwidth*y + x);
+ for (x = 0; x < bwidth; x++) {
+ for (y = 0; y < bheight - 1; y++) {
+ p = rectf + (bwidth * y + x);
*p = MIN2(*p, *(p + bwidth));
}
}
- for (x=0; x < bwidth; x++) {
- for (y=bheight-1; y >= 1; y--) {
- p = rectf + (bwidth*y + x);
+ for (x = 0; x < bwidth; x++) {
+ for (y = bheight - 1; y >= 1; y--) {
+ p = rectf + (bwidth * y + x);
*p = MIN2(*p, *(p - bwidth));
}
}
}
this->cached_buffer = rectf;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return this->cached_buffer;
}
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h
index 71bbab74a4b..b11356129b4 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.h
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h
@@ -25,44 +25,44 @@
#include "COM_NodeOperation.h"
-class DilateErodeDistanceOperation : public NodeOperation {
+class DilateErodeThresholdOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
float distance;
float _switch;
float inset;
/**
- * determines the area of interest to track pixels
- * keep this one as small as possible for speed gain.
- */
+ * determines the area of interest to track pixels
+ * keep this one as small as possible for speed gain.
+ */
int scope;
public:
- DilateErodeDistanceOperation();
+ DilateErodeThresholdOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setDistance(float distance) {this->distance = distance;}
- void setSwitch(float sw) {this->_switch = sw;}
- void setInset(float inset) {this->inset = inset;}
+ void setDistance(float distance) { this->distance = distance; }
+ void setSwitch(float sw) { this->_switch = sw; }
+ void setInset(float inset) { this->inset = inset; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
@@ -70,51 +70,61 @@ public:
class DilateDistanceOperation : public NodeOperation {
private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
protected:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
float distance;
int scope;
public:
DilateDistanceOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setDistance(float distance) {this->distance = distance;}
+ void setDistance(float distance) { this->distance = distance; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
};
class ErodeDistanceOperation : public DilateDistanceOperation {
public:
ErodeDistanceOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
+
+ void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
};
class DilateStepOperation : public NodeOperation {
protected:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
int iterations;
@@ -123,22 +133,22 @@ public:
DilateStepOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setIterations(int iterations) {this->iterations = iterations;}
+ void setIterations(int iterations) { this->iterations = iterations; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
};
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index 43cba09d16f..271a165f0ff 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -54,12 +54,12 @@ void DirectionalBlurOperation::initExecution()
const float itsc = 1.0f / powf(2.0f, (float)iterations);
float D;
- D = distance * sqrtf(width*width + height*height);
+ D = distance * sqrtf(width * width + height * height);
center_x_pix = center_x * width;
center_y_pix = center_y * height;
tx = itsc * D * cosf(a);
- ty = -itsc * D * sinf(a);
+ ty = -itsc *D *sinf(a);
sc = itsc * zoom;
rot = itsc * spin;
@@ -68,8 +68,8 @@ void DirectionalBlurOperation::initExecution()
void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
const int iterations = pow(2.f, this->data->iter);
- float col[4] = {0,0,0,0};
- float col2[4] = {0,0,0,0};
+ float col[4] = {0, 0, 0, 0};
+ float col2[4] = {0, 0, 0, 0};
this->inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers);
float ltx = tx;
float lty = ty;
@@ -85,10 +85,7 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu
this->inputProgram->read(col, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, COM_PS_NEAREST, inputBuffers);
- col2[0] += col[0];
- col2[1] += col[1];
- col2[2] += col[2];
- col2[3] += col[3];
+ add_v4_v4(col2, col);
/* double transformations */
ltx += tx;
@@ -96,10 +93,8 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu
lrot += rot;
lsc += sc;
}
- color[0] = col2[0]/iterations;
- color[1] = col2[1]/iterations;
- color[2] = col2[2]/iterations;
- color[3] = col2[3]/iterations;
+
+ mul_v4_v4fl(color, col2, 1.0f / iterations);
}
void DirectionalBlurOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
index 280e9247c1b..9cc0a4361f1 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
@@ -38,22 +38,22 @@ public:
DirectionalBlurOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void setData(NodeDBlurData *data) {this->data = data;}
+ void setData(NodeDBlurData *data) { this->data = data; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
index 2add367f39e..be50641a125 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
@@ -23,7 +23,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-DisplaceOperation::DisplaceOperation(): NodeOperation()
+DisplaceOperation::DisplaceOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VECTOR);
@@ -52,14 +52,14 @@ void DisplaceOperation::initExecution()
/* minimum distance (in pixels) a pixel has to be displaced
* in order to take effect */
-#define DISPLACE_EPSILON 0.01f
+#define DISPLACE_EPSILON 0.01f
void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
float inVector[4];
float inScale[4];
- float p_dx, p_dy; /* main displacement in pixel space */
+ float p_dx, p_dy; /* main displacement in pixel space */
float d_dx, d_dy;
float dxt, dyt;
float u, v;
@@ -83,17 +83,17 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i
v = y - p_dy + 0.5f;
/* calc derivatives */
- this->inputVectorProgram->read(inVector, x+1, y, COM_PS_NEAREST, inputBuffers);
+ this->inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST, inputBuffers);
d_dx = inVector[0] * xs;
- this->inputVectorProgram->read(inVector, x, y+1, COM_PS_NEAREST, inputBuffers);
+ this->inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST, inputBuffers);
d_dy = inVector[0] * ys;
/* clamp derivatives to minimum displacement distance in UV space */
dxt = p_dx - d_dx;
dyt = p_dy - d_dy;
- dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/this->getWidth();
- dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/this->getHeight();
+ dxt = signf(dxt) * maxf(fabsf(dxt), DISPLACE_EPSILON) / this->getWidth();
+ dyt = signf(dyt) * maxf(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight();
/* EWA filtering */
this->inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers);
@@ -111,7 +111,7 @@ bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffer
{
rcti colorInput;
rcti vectorInput;
- NodeOperation *operation=NULL;
+ NodeOperation *operation = NULL;
/* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
/* image */
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.h b/source/blender/compositor/operations/COM_DisplaceOperation.h
index 9c59c928854..82788e37e3a 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.h
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.h
@@ -41,14 +41,14 @@ public:
DisplaceOperation();
/**
- * we need a 2x2 differential filter for Vector Input and full buffer for the image
- */
+ * we need a 2x2 differential filter for Vector Input and full buffer for the image
+ */
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
/**
* the inner loop of this program
*/
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
index 8675caca1e2..716646e9c36 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
@@ -23,7 +23,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-DisplaceSimpleOperation::DisplaceSimpleOperation(): NodeOperation()
+DisplaceSimpleOperation::DisplaceSimpleOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VECTOR);
@@ -51,14 +51,14 @@ void DisplaceSimpleOperation::initExecution()
/* minimum distance (in pixels) a pixel has to be displaced
* in order to take effect */
-#define DISPLACE_EPSILON 0.01f
+#define DISPLACE_EPSILON 0.01f
void DisplaceSimpleOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
float inVector[4];
float inScale[4];
- float p_dx, p_dy; /* main displacement in pixel space */
+ float p_dx, p_dy; /* main displacement in pixel space */
float u, v;
this->inputScaleXProgram->read(inScale, x, y, sampler, inputBuffers);
@@ -79,8 +79,8 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel
/* clamp nodes to avoid glitches */
u = x - p_dx + 0.5f;
v = y - p_dy + 0.5f;
- CLAMP(u, 0.f, this->getWidth()-1.f);
- CLAMP(v, 0.f, this->getHeight()-1.f);
+ CLAMP(u, 0.f, this->getWidth() - 1.f);
+ CLAMP(v, 0.f, this->getHeight() - 1.f);
this->inputColorProgram->read(color, u, v, sampler, inputBuffers);
}
@@ -96,7 +96,7 @@ void DisplaceSimpleOperation::deinitExecution()
bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti colorInput;
- NodeOperation *operation=NULL;
+ NodeOperation *operation = NULL;
/* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
/* image */
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
index 0e3bcc1b1f0..1ebb238855b 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
@@ -41,14 +41,14 @@ public:
DisplaceSimpleOperation();
/**
- * we need a full buffer for the image
- */
+ * we need a full buffer for the image
+ */
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
/**
* the inner loop of this program
*/
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp
index 304f7fa5066..ec01ba922b5 100644
--- a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_DistanceMatteOperation.h"
#include "BLI_math.h"
-DistanceMatteOperation::DistanceMatteOperation(): NodeOperation()
+DistanceMatteOperation::DistanceMatteOperation() : NodeOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
@@ -49,8 +49,8 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y,
float inKey[4];
float inImage[4];
- const float tolerence=this->settings->t1;
- const float falloff=this->settings->t2;
+ const float tolerence = this->settings->t1;
+ const float falloff = this->settings->t2;
float distance;
float alpha;
@@ -58,9 +58,9 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y,
this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers);
this->inputImageProgram->read(inImage, x, y, sampler, inputBuffers);
- distance = sqrt(pow((inKey[0]-inImage[0]),2)+
- pow((inKey[1]-inImage[1]),2)+
- pow((inKey[2]-inImage[2]),2));
+ distance = sqrt(pow((inKey[0] - inImage[0]), 2) +
+ pow((inKey[1] - inImage[1]), 2) +
+ pow((inKey[2] - inImage[2]), 2));
/* store matte(alpha) value in [0] to go with
* COM_SetAlphaOperation and the Value output
@@ -68,23 +68,23 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y,
/*make 100% transparent */
if (distance < tolerence) {
- outputValue[0]=0.f;
+ outputValue[0] = 0.f;
}
/*in the falloff region, make partially transparent */
- else if (distance < falloff+tolerence) {
- distance=distance-tolerence;
- alpha=distance/falloff;
+ else if (distance < falloff + tolerence) {
+ distance = distance - tolerence;
+ alpha = distance / falloff;
/*only change if more transparent than before */
if (alpha < inImage[3]) {
- outputValue[0]=alpha;
+ outputValue[0] = alpha;
}
else { /* leave as before */
- outputValue[0]=inImage[3];
+ outputValue[0] = inImage[3];
}
}
else {
- /* leave as before */
- outputValue[0]=inImage[3];
+ /* leave as before */
+ outputValue[0] = inImage[3];
}
}
diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceMatteOperation.h
index 2a668f31f8f..cf1172a8c11 100644
--- a/source/blender/compositor/operations/COM_DistanceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.h
@@ -25,9 +25,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class DistanceMatteOperation : public NodeOperation {
private:
NodeChroma *settings;
@@ -35,18 +35,18 @@ private:
SocketReader *inputKeyProgram;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
DistanceMatteOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) {this->settings = nodeChroma;}
+ void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp
index b03b176f08a..e225a677989 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.cpp
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp
@@ -44,12 +44,12 @@ void DotproductOperation::deinitExecution()
}
/** @todo: current implementation is the inverse of a dotproduct. not 'logically' correct
- */
-void DotproductOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+ */
+void DotproductOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
float input1[4];
float input2[4];
this->input1Operation->read(input1, x, y, sampler, inputBuffers);
this->input2Operation->read(input2, x, y, sampler, inputBuffers);
- color[0] = -(input1[0]*input2[0]+input1[1]*input2[1]+input1[2]*input2[2]);
+ color[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]);
}
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h
index 0244fffa110..849dc83a9cd 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.h
+++ b/source/blender/compositor/operations/COM_DotproductOperation.h
@@ -25,13 +25,13 @@
#include "COM_NodeOperation.h"
-class DotproductOperation: public NodeOperation {
+class DotproductOperation : public NodeOperation {
private:
SocketReader *input1Operation;
SocketReader *input2Operation;
public:
DotproductOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index 9e911e7ba40..ba54c8ad9d6 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -23,741 +23,742 @@
#include "COM_DoubleEdgeMaskOperation.h"
#include "BLI_math.h"
#include "DNA_node_types.h"
+#include "MEM_guardedalloc.h"
// this part has been copied from the double edge mask
// Contributor(s): Peter Larabell.
static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
{
int x;
- unsigned int isz=0; // inner edge size
- unsigned int osz=0; // outer edge size
- unsigned int gsz=0; // gradient fill area size
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
/* Test the four corners */
/* upper left corner */
- x=t-rw+1;
+ x = t - rw + 1;
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or to the right, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
lres[x] = 3; // flag pixel as outer edge
}
/* upper right corner */
- x=t;
+ x = t;
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or to the left, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x-1] && lomask[x-1])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
/* lower left corner */
- x=0;
+ x = 0;
// test if inner mask is filled
if (limask[x]) {
// test if pixel above, or to the right, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x+rw] && lomask[x+rw]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
/* lower right corner */
- x=rw-1;
+ x = rw - 1;
// test if inner mask is filled
if (limask[x]) {
// test if pixel above, or to the left, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x+rw] && lomask[x+rw]) || (!limask[x-1] && lomask[x-1])) {
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
/* Test the TOP row of pixels in buffer, except corners */
- for (x = t-1; x>=(t-rw)+2; x--) {
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel to the right, or to the left, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
/* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw-2; x; x--) {
+ for (x = rw - 2; x; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel to the right, or to the left, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
/* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t-(rw<<1)+1; x>=rw; x-=rw) {
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or above, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
/* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t-rw; x>rw; x-=rw) {
+ for (x = t - rw; x > rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or above, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
- rsize[0]=isz; // fill in our return sizes for edges + fill
- rsize[1]=osz;
- rsize[2]=gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
static void do_adjacentBleedBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
{
int x;
- unsigned int isz=0; // inner edge size
- unsigned int osz=0; // outer edge size
- unsigned int gsz=0; // gradient fill area size
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
/* Test the four corners */
/* upper left corner */
- x=t-rw+1;
+ x = t - rw + 1;
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or to the right, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x+1]) { // test if outer mask is empty underneath or to the right
+ if (!lomask[x - rw] || !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* upper right corner */
- x=t;
+ x = t;
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or to the left, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x-1] && lomask[x-1])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x-1]) { // test if outer mask is empty underneath or to the left
+ if (!lomask[x - rw] || !lomask[x - 1]) { // test if outer mask is empty underneath or to the left
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* lower left corner */
- x=0;
+ x = 0;
// test if inner mask is filled
if (limask[x]) {
// test if pixel above, or to the right, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x+rw] && lomask[x+rw]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x+rw] || !lomask[x+1]) { // test if outer mask is empty above or to the right
+ if (!lomask[x + rw] || !lomask[x + 1]) { // test if outer mask is empty above or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* lower right corner */
- x=rw-1;
+ x = rw - 1;
// test if inner mask is filled
if (limask[x]) {
// test if pixel above, or to the left, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x+rw] && lomask[x+rw]) || (!limask[x-1] && lomask[x-1])) {
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x+rw] || !lomask[x-1]) { // test if outer mask is empty above or to the left
+ if (!lomask[x + rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* Test the TOP row of pixels in buffer, except corners */
- for (x = t-1; x>=(t-rw)+2; x--) {
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel to the left, or to the right, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
/* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw-2; x; x--) {
+ for (x = rw - 2; x; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel to the left, or to the right, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
/* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t-(rw<<1)+1; x>=rw; x-=rw) {
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or above, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
/* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t-rw; x>rw; x-=rw) {
+ for (x = t - rw; x > rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if pixel underneath, or above, are empty in the inner mask,
// but filled in the outer mask
- if ((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
- rsize[0]=isz; // fill in our return sizes for edges + fill
- rsize[1]=osz;
- rsize[2]=gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
static void do_allKeepBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
{
int x;
- unsigned int isz=0; // inner edge size
- unsigned int osz=0; // outer edge size
- unsigned int gsz=0; // gradient fill area size
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
/* Test the four corners */
/* upper left corner */
- x=t-rw+1;
+ x = t - rw + 1;
// test if inner mask is filled
if (limask[x]) {
// test if the inner mask is empty underneath or to the right
- if (!limask[x-rw] || !limask[x+1]) {
+ if (!limask[x - rw] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
/* upper right corner */
- x=t;
+ x = t;
// test if inner mask is filled
if (limask[x]) {
// test if the inner mask is empty underneath or to the left
- if (!limask[x-rw] || !limask[x-1]) {
+ if (!limask[x - rw] || !limask[x - 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
/* lower left corner */
- x=0;
+ x = 0;
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty above or to the right
- if (!limask[x+rw] || !limask[x+1]) {
+ if (!limask[x + rw] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
/* lower right corner */
- x=rw-1;
+ x = rw - 1;
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty above or to the left
- if (!limask[x+rw] || !limask[x-1]) {
+ if (!limask[x + rw] || !limask[x - 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
/* Test the TOP row of pixels in buffer, except corners */
- for (x = t-1; x>=(t-rw)+2; x--) {
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty to the left or to the right
- if (!limask[x-1] || !limask[x+1]) {
+ if (!limask[x - 1] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
/* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw-2; x; x--) {
+ for (x = rw - 2; x; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty to the left or to the right
- if (!limask[x-1] || !limask[x+1]) {
+ if (!limask[x - 1] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
/* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t-(rw<<1)+1; x>=rw; x-=rw) {
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty underneath or above
- if (!limask[x-rw] || !limask[x+rw]) {
+ if (!limask[x - rw] || !limask[x + rw]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
/* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t-rw; x>rw; x-=rw) {
+ for (x = t - rw; x > rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty underneath or above
- if (!limask[x-rw] || !limask[x+rw]) {
+ if (!limask[x - rw] || !limask[x + rw]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
}
- rsize[0]=isz; // fill in our return sizes for edges + fill
- rsize[1]=osz;
- rsize[2]=gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
static void do_allBleedBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
{
int x;
- unsigned int isz=0; // inner edge size
- unsigned int osz=0; // outer edge size
- unsigned int gsz=0; // gradient fill area size
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
/* Test the four corners */
/* upper left corner */
- x=t-rw+1;
+ x = t - rw + 1;
// test if inner mask is filled
if (limask[x]) {
// test if the inner mask is empty underneath or to the right
- if (!limask[x-rw] || !limask[x+1]) {
+ if (!limask[x - rw] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x+1]) { // test if outer mask is empty underneath or to the right
+ if (!lomask[x - rw] || !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* upper right corner */
- x=t;
+ x = t;
// test if inner mask is filled
if (limask[x]) {
// test if the inner mask is empty underneath or to the left
- if (!limask[x-rw] || !limask[x-1]) {
+ if (!limask[x - rw] || !limask[x - 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x-1]) { // test if outer mask is empty above or to the left
+ if (!lomask[x - rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* lower left corner */
- x=0;
+ x = 0;
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty above or to the right
- if (!limask[x+rw] || !limask[x+1]) {
+ if (!limask[x + rw] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x+rw] || !lomask[x+1]) { // test if outer mask is empty underneath or to the right
+ if (!lomask[x + rw] || !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* lower right corner */
- x=rw-1;
+ x = rw - 1;
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty above or to the left
- if (!limask[x+rw] || !limask[x-1]) {
+ if (!limask[x + rw] || !limask[x - 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x+rw] || !lomask[x-1]) { // test if outer mask is empty underneath or to the left
+ if (!lomask[x + rw] || !lomask[x - 1]) { // test if outer mask is empty underneath or to the left
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
/* Test the TOP row of pixels in buffer, except corners */
- for (x = t-1; x>=(t-rw)+2; x--) {
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty to the left or to the right
- if (!limask[x-1] || !limask[x+1]) {
+ if (!limask[x - 1] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
/* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw-2; x; x--) {
+ for (x = rw - 2; x; x--) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty to the left or to the right
- if (!limask[x-1] || !limask[x+1]) {
+ if (!limask[x - 1] || !limask[x + 1]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
/* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t-(rw<<1)+1; x>=rw; x-=rw) {
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty underneath or above
- if (!limask[x-rw] || !limask[x+rw]) {
+ if (!limask[x - rw] || !limask[x + rw]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
/* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t-rw; x>rw; x-=rw) {
+ for (x = t - rw; x > rw; x -= rw) {
// test if inner mask is filled
if (limask[x]) {
// test if inner mask is empty underneath or above
- if (!limask[x-rw] || !limask[x+rw]) {
+ if (!limask[x - rw] || !limask[x + rw]) {
isz++; // increment inner edge size
- lres[x]=4; // flag pixel as inner edge
+ lres[x] = 4; // flag pixel as inner edge
}
else {
- res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
}
}
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
osz++; // increment outer edge size
- lres[x]=3; // flag pixel as outer edge
+ lres[x] = 3; // flag pixel as outer edge
}
else {
gsz++; // increment the gradient pixel count
- lres[x]=2; // flag pixel as gradient
+ lres[x] = 2; // flag pixel as gradient
}
}
}
- rsize[0]=isz; // fill in our return sizes for edges + fill
- rsize[1]=osz;
- rsize[2]=gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz)
@@ -770,43 +771,43 @@ static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *l
int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
/* Test all rows between the FIRST and LAST rows, excluding left and right edges */
- for (x = (t-rw)+1, dx=x-(rw-2); dx>rw; x-=rw,dx-=rw) {
- a=x-2;
- pix_prevRow=a+rw;
- pix_nextRow=a-rw;
- pix_prevCol=a+1;
- pix_nextCol=a-1;
- while (a>dx-2) {
+ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) {
+ a = x - 2;
+ pix_prevRow = a + rw;
+ pix_nextRow = a - rw;
+ pix_prevCol = a + 1;
+ pix_nextCol = a - 1;
+ while (a > dx - 2) {
if (!limask[a]) { // if the inner mask is empty
if (lomask[a]) { // if the outer mask is full
/*
- Next we test all 4 directions around the current pixel: next/prev/up/down
- The test ensures that the outer mask is empty and that the inner mask
- is also empty. If both conditions are true for any one of the 4 adjacent pixels
- then the current pixel is counted as being a true outer edge pixel.
- */
+ Next we test all 4 directions around the current pixel: next/prev/up/down
+ The test ensures that the outer mask is empty and that the inner mask
+ is also empty. If both conditions are true for any one of the 4 adjacent pixels
+ then the current pixel is counted as being a true outer edge pixel.
+ */
if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
(!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
(!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
(!lomask[pix_prevRow] && !limask[pix_prevRow]))
{
- in_osz++; // increment the outer boundary pixel count
- lres[a]=3; // flag pixel as part of outer edge
+ in_osz++; // increment the outer boundary pixel count
+ lres[a] = 3; // flag pixel as part of outer edge
}
- else { // it's not a boundary pixel, but it is a gradient pixel
- in_gsz++; // increment the gradient pixel count
- lres[a]=2; // flag pixel as gradient
+ else { // it's not a boundary pixel, but it is a gradient pixel
+ in_gsz++; // increment the gradient pixel count
+ lres[a] = 2; // flag pixel as gradient
}
}
}
else {
if (!limask[pix_nextCol] || !limask[pix_prevCol] || !limask[pix_nextRow] || !limask[pix_prevRow]) {
- in_isz++; // increment the inner boundary pixel count
- lres[a]=4; // flag pixel as part of inner edge
+ in_isz++; // increment the inner boundary pixel count
+ lres[a] = 4; // flag pixel as part of inner edge
}
else {
- res[a]=1.0f; // pixel is part of inner mask, but not at an edge
+ res[a] = 1.0f; // pixel is part of inner mask, but not at an edge
}
}
a--;
@@ -817,9 +818,9 @@ static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *l
}
}
- rsize[0]=in_isz; // fill in our return sizes for edges + fill
- rsize[1]=in_osz;
- rsize[2]=in_gsz;
+ rsize[0] = in_isz; // fill in our return sizes for edges + fill
+ rsize[1] = in_osz;
+ rsize[2] = in_gsz;
}
static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz)
@@ -832,32 +833,32 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned i
int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
/* Test all rows between the FIRST and LAST rows, excluding left and right edges */
- for (x = (t-rw)+1, dx=x-(rw-2); dx>rw; x-=rw,dx-=rw) {
- a=x-2;
- pix_prevRow=a+rw;
- pix_nextRow=a-rw;
- pix_prevCol=a+1;
- pix_nextCol=a-1;
- while (a>dx-2) {
- if (!limask[a]) { // if the inner mask is empty
- if (lomask[a]) { // if the outer mask is full
+ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) {
+ a = x - 2;
+ pix_prevRow = a + rw;
+ pix_nextRow = a - rw;
+ pix_prevCol = a + 1;
+ pix_nextCol = a - 1;
+ while (a > dx - 2) {
+ if (!limask[a]) { // if the inner mask is empty
+ if (lomask[a]) { // if the outer mask is full
/*
- Next we test all 4 directions around the current pixel: next/prev/up/down
- The test ensures that the outer mask is empty and that the inner mask
- is also empty. If both conditions are true for any one of the 4 adjacent pixels
- then the current pixel is counted as being a true outer edge pixel.
- */
+ Next we test all 4 directions around the current pixel: next/prev/up/down
+ The test ensures that the outer mask is empty and that the inner mask
+ is also empty. If both conditions are true for any one of the 4 adjacent pixels
+ then the current pixel is counted as being a true outer edge pixel.
+ */
if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
(!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
(!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
(!lomask[pix_prevRow] && !limask[pix_prevRow]))
{
- in_osz++; // increment the outer boundary pixel count
- lres[a]=3; // flag pixel as part of outer edge
+ in_osz++; // increment the outer boundary pixel count
+ lres[a] = 3; // flag pixel as part of outer edge
}
- else { // it's not a boundary pixel, but it is a gradient pixel
- in_gsz++; // increment the gradient pixel count
- lres[a]=2; // flag pixel as gradient
+ else { // it's not a boundary pixel, but it is a gradient pixel
+ in_gsz++; // increment the gradient pixel count
+ lres[a] = 2; // flag pixel as gradient
}
}
@@ -868,24 +869,24 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned i
(!limask[pix_nextRow] && lomask[pix_nextRow]) ||
(!limask[pix_prevRow] && lomask[pix_prevRow]))
{
- in_isz++; // increment the inner boundary pixel count
- lres[a]=4; // flag pixel as part of inner edge
+ in_isz++; // increment the inner boundary pixel count
+ lres[a] = 4; // flag pixel as part of inner edge
}
else {
- res[a]=1.0f; // pixel is part of inner mask, but not at an edge
+ res[a] = 1.0f; // pixel is part of inner mask, but not at an edge
}
}
a--;
- pix_prevRow--; // advance all four "surrounding" pixel pointers
+ pix_prevRow--; // advance all four "surrounding" pixel pointers
pix_nextRow--;
pix_prevCol--;
pix_nextCol--;
}
}
- rsize[0]=in_isz; // fill in our return sizes for edges + fill
- rsize[1]=in_osz;
- rsize[2]=in_gsz;
+ rsize[0] = in_isz; // fill in our return sizes for edges + fill
+ rsize[1] = in_osz;
+ rsize[2] = in_gsz;
}
static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, unsigned int *lres, float *res, unsigned short *gbuf, unsigned int *innerEdgeOffset, unsigned int *outerEdgeOffset, unsigned int isz, unsigned int gsz)
@@ -897,102 +898,102 @@ static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, unsigne
unsigned int rsl; // long used for finding fast 1.0/sqrt
unsigned int gradientFillOffset;
- unsigned int innerAccum=0; // for looping inner edge pixel indexes, represents current position from offset
- unsigned int outerAccum=0; // for looping outer edge pixel indexes, represents current position from offset
- unsigned int gradientAccum=0; // for looping gradient pixel indexes, represents current position from offset
+ unsigned int innerAccum = 0; // for looping inner edge pixel indexes, represents current position from offset
+ unsigned int outerAccum = 0; // for looping outer edge pixel indexes, represents current position from offset
+ unsigned int gradientAccum = 0; // for looping gradient pixel indexes, represents current position from offset
/*
- Here we compute the size of buffer needed to hold (row,col) coordinates
- for each pixel previously determined to be either gradient, inner edge,
- or outer edge.
-
- Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even
- though gbuf[] is declared as unsigned short* (2 bytes) because we don't
- store the pixel indexes, we only store x,y location of pixel in buffer.
-
- This does make the assumption that x and y can fit in 16 unsigned bits
- so if Blender starts doing renders greater than 65536 in either direction
- this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes
- per flagged pixel.
-
- In general, the buffer on-screen:
-
- Example: 9 by 9 pixel block
-
- . = pixel non-white in both outer and inner mask
- o = pixel white in outer, but not inner mask, adjacent to "." pixel
- g = pixel white in outer, but not inner mask, not adjacent to "." pixel
- i = pixel white in inner mask, adjacent to "g" or "." pixel
- F = pixel white in inner mask, only adjacent to other pixels white in the inner mask
-
-
- ......... <----- pixel #80
- ..oooo...
- .oggggo..
- .oggiggo.
- .ogiFigo.
- .oggiggo.
- .oggggo..
- ..oooo...
- pixel #00 -----> .........
-
- gsz = 18 (18 "g" pixels above)
- isz = 4 (4 "i" pixels above)
- osz = 18 (18 "o" pixels above)
-
-
- The memory in gbuf[] after filling will look like this:
-
- gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels)
- / / /
- / / /
- |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y)
- +--------------------------------> <----------------> <------------------------> <----------------+
- |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes
- +--------------------------------> <----------------> <------------------------> <----------------+
- |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel
- / / /
- / / /
- / / /
- +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+
-
-
- Ultimately we do need the pixel's memory buffer index to set the output
- pixel color, but it's faster to reconstruct the memory buffer location
- each iteration of the final gradient calculation than it is to deconstruct
- a memory location into x,y pairs each round.
-*/
-
-
- gradientFillOffset=0; // since there are likely "more" of these, put it first. :)
- *innerEdgeOffset=gradientFillOffset+gsz; // set start of inner edge indexes
- *outerEdgeOffset=(*innerEdgeOffset)+isz; // set start of outer edge indexes
+ Here we compute the size of buffer needed to hold (row,col) coordinates
+ for each pixel previously determined to be either gradient, inner edge,
+ or outer edge.
+
+ Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even
+ though gbuf[] is declared as unsigned short* (2 bytes) because we don't
+ store the pixel indexes, we only store x,y location of pixel in buffer.
+
+ This does make the assumption that x and y can fit in 16 unsigned bits
+ so if Blender starts doing renders greater than 65536 in either direction
+ this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes
+ per flagged pixel.
+
+ In general, the buffer on-screen:
+
+ Example: 9 by 9 pixel block
+
+ . = pixel non-white in both outer and inner mask
+ o = pixel white in outer, but not inner mask, adjacent to "." pixel
+ g = pixel white in outer, but not inner mask, not adjacent to "." pixel
+ i = pixel white in inner mask, adjacent to "g" or "." pixel
+ F = pixel white in inner mask, only adjacent to other pixels white in the inner mask
+
+
+ ......... <----- pixel #80
+ ..oooo...
+ .oggggo..
+ .oggiggo.
+ .ogiFigo.
+ .oggiggo.
+ .oggggo..
+ ..oooo...
+ pixel #00 -----> .........
+
+ gsz = 18 (18 "g" pixels above)
+ isz = 4 (4 "i" pixels above)
+ osz = 18 (18 "o" pixels above)
+
+
+ The memory in gbuf[] after filling will look like this:
+
+ gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels)
+ / / /
+ / / /
+ |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y)
+ +--------------------------------> <----------------> <------------------------> <----------------+
+ |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes
+ +--------------------------------> <----------------> <------------------------> <----------------+
+ |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel
+ / / /
+ / / /
+ / / /
+ +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+
+
+
+ Ultimately we do need the pixel's memory buffer index to set the output
+ pixel color, but it's faster to reconstruct the memory buffer location
+ each iteration of the final gradient calculation than it is to deconstruct
+ a memory location into x,y pairs each round.
+ */
+
+
+ gradientFillOffset = 0; // since there are likely "more" of these, put it first. :)
+ *innerEdgeOffset = gradientFillOffset + gsz; // set start of inner edge indexes
+ *outerEdgeOffset = (*innerEdgeOffset) + isz; // set start of outer edge indexes
/* set the accumulators to correct positions */ // set up some accumulator variables for loops
gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective
innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each
outerAccum = *outerEdgeOffset; // section fills up it's allocated space in gbuf
//uses dmin=row, rsl=col
- for (x=0,dmin=0; x<t; x+=rw,dmin++) {
- for (rsl=0; rsl<rw; rsl++) {
- a=x+rsl;
- if (lres[a]==2) { // it is a gradient pixel flagged by 2
- ud=gradientAccum<<1; // double the index to reach correct unsigned short location
- gbuf[ud]=dmin; // insert pixel's row into gradient pixel location buffer
- gbuf[ud+1]=rsl; // insert pixel's column into gradient pixel location buffer
- gradientAccum++; // increment gradient index buffer pointer
+ for (x = 0, dmin = 0; x < t; x += rw, dmin++) {
+ for (rsl = 0; rsl < rw; rsl++) {
+ a = x + rsl;
+ if (lres[a] == 2) { // it is a gradient pixel flagged by 2
+ ud = gradientAccum << 1; // double the index to reach correct unsigned short location
+ gbuf[ud] = dmin; // insert pixel's row into gradient pixel location buffer
+ gbuf[ud + 1] = rsl; // insert pixel's column into gradient pixel location buffer
+ gradientAccum++; // increment gradient index buffer pointer
}
- else if (lres[a]==3) { // it is an outer edge pixel flagged by 3
- ud=outerAccum<<1; // double the index to reach correct unsigned short location
- gbuf[ud]=dmin; // insert pixel's row into outer edge pixel location buffer
- gbuf[ud+1]=rsl; // insert pixel's column into outer edge pixel location buffer
- outerAccum++; // increment outer edge index buffer pointer
- res[a]=0.0f; // set output pixel intensity now since it won't change later
+ else if (lres[a] == 3) { // it is an outer edge pixel flagged by 3
+ ud = outerAccum << 1; // double the index to reach correct unsigned short location
+ gbuf[ud] = dmin; // insert pixel's row into outer edge pixel location buffer
+ gbuf[ud + 1] = rsl; // insert pixel's column into outer edge pixel location buffer
+ outerAccum++; // increment outer edge index buffer pointer
+ res[a] = 0.0f; // set output pixel intensity now since it won't change later
}
- else if (lres[a]==4) { // it is an inner edge pixel flagged by 4
- ud=innerAccum<<1; // double int index to reach correct unsigned short location
- gbuf[ud]=dmin; // insert pixel's row into inner edge pixel location buffer
- gbuf[ud+1]=rsl; // insert pixel's column into inner edge pixel location buffer
- innerAccum++; // increment inner edge index buffer pointer
- res[a]=1.0f; // set output pixel intensity now since it won't change later
+ else if (lres[a] == 4) { // it is an inner edge pixel flagged by 4
+ ud = innerAccum << 1; // double int index to reach correct unsigned short location
+ gbuf[ud] = dmin; // insert pixel's row into inner edge pixel location buffer
+ gbuf[ud + 1] = rsl; // insert pixel's column into inner edge pixel location buffer
+ innerAccum++; // increment inner edge index buffer pointer
+ res[a] = 1.0f; // set output pixel intensity now since it won't change later
}
}
}
@@ -1018,111 +1019,111 @@ static void do_fillGradientBuffer(unsigned int rw, float *res, unsigned short *g
int dy; // dy = Y-delta (used for distance proportion calculation)
/*
- The general algorithm used to color each gradient pixel is:
-
- 1.) Loop through all gradient pixels.
- A.) For each gradient pixel:
- a.) Loop though all outside edge pixels, looking for closest one
- to the gradient pixel we are in.
- b.) Loop through all inside edge pixels, looking for closest one
- to the gradient pixel we are in.
- c.) Find proportion of distance from gradient pixel to inside edge
- pixel compared to sum of distance to inside edge and distance to
- outside edge.
-
- In an image where:
- . = blank (black) pixels, not covered by inner mask or outer mask
- + = desired gradient pixels, covered only by outer mask
- * = white full mask pixels, covered by at least inner mask
-
- ...............................
- ...............+++++++++++.....
- ...+O++++++..++++++++++++++....
- ..+++\++++++++++++++++++++.....
- .+++++G+++++++++*******+++.....
- .+++++|+++++++*********+++.....
- .++***I****************+++.....
- .++*******************+++......
- .+++*****************+++.......
- ..+++***************+++........
- ....+++**********+++...........
- ......++++++++++++.............
- ...............................
-
- O = outside edge pixel
- \
- G = gradient pixel
- |
- I = inside edge pixel
-
- __
- *note that IO does not need to be a straight line, in fact
- many cases can arise where straight lines do not work
- correctly.
-
- __ __ __
- d.) Pixel color is assigned as |GO| / ( |GI| + |GO| )
-
- The implementation does not compute distance, but the reciprocal of the
- distance. This is done to avoid having to compute a square root, as a
- reciprocal square root can be computed faster. Therefore, the code computes
- pixel color as |GI| / (|GI| + |GO|). Since these are reciprocals, GI serves the
- purpose of GO for the proportion calculation.
-
- For the purposes of the minimun distance comparisons, we only check
- the sums-of-squares against eachother, since they are in the same
- mathematical sort-order as if we did go ahead and take square roots
-
- Loop through all gradient pixels.
- */
-
- for (x = gsz-1; x>=0; x--) {
- gradientFillOffset=x<<1;
- t=gbuf[gradientFillOffset]; // calculate column of pixel indexed by gbuf[x]
- fsz=gbuf[gradientFillOffset+1]; // calculate row of pixel indexed by gbuf[x]
- dmin=0xffffffff; // reset min distance to edge pixel
- for (a=outerEdgeOffset+osz-1; a>=outerEdgeOffset; a--) { // loop through all outer edge buffer pixels
- ud=a<<1;
- dy=t-gbuf[ud]; // set dx to gradient pixel column - outer edge pixel row
- dx=fsz-gbuf[ud+1]; // set dy to gradient pixel row - outer edge pixel column
- ud=dx*dx+dy*dy; // compute sum of squares
- if (ud<dmin) { // if our new sum of squares is less than the current minimum
- dmin=ud; // set a new minimum equal to the new lower value
+ * The general algorithm used to color each gradient pixel is:
+ *
+ * 1.) Loop through all gradient pixels.
+ * A.) For each gradient pixel:
+ * a.) Loop though all outside edge pixels, looking for closest one
+ * to the gradient pixel we are in.
+ * b.) Loop through all inside edge pixels, looking for closest one
+ * to the gradient pixel we are in.
+ * c.) Find proportion of distance from gradient pixel to inside edge
+ * pixel compared to sum of distance to inside edge and distance to
+ * outside edge.
+ *
+ * In an image where:
+ * . = blank (black) pixels, not covered by inner mask or outer mask
+ * + = desired gradient pixels, covered only by outer mask
+ * * = white full mask pixels, covered by at least inner mask
+ *
+ * ...............................
+ * ...............+++++++++++.....
+ * ...+O++++++..++++++++++++++....
+ * ..+++\++++++++++++++++++++.....
+ * .+++++G+++++++++*******+++.....
+ * .+++++|+++++++*********+++.....
+ * .++***I****************+++.....
+ * .++*******************+++......
+ * .+++*****************+++.......
+ * ..+++***************+++........
+ * ....+++**********+++...........
+ * ......++++++++++++.............
+ * ...............................
+ *
+ * O = outside edge pixel
+ * \
+ * G = gradient pixel
+ * |
+ * I = inside edge pixel
+ *
+ * __
+ * *note that IO does not need to be a straight line, in fact
+ * many cases can arise where straight lines do not work
+ * correctly.
+ *
+ * __ __ __
+ * d.) Pixel color is assigned as |GO| / ( |GI| + |GO| )
+ *
+ * The implementation does not compute distance, but the reciprocal of the
+ * distance. This is done to avoid having to compute a square root, as a
+ * reciprocal square root can be computed faster. Therefore, the code computes
+ * pixel color as |GI| / (|GI| + |GO|). Since these are reciprocals, GI serves the
+ * purpose of GO for the proportion calculation.
+ *
+ * For the purposes of the minimun distance comparisons, we only check
+ * the sums-of-squares against eachother, since they are in the same
+ * mathematical sort-order as if we did go ahead and take square roots
+ *
+ * Loop through all gradient pixels.
+ */
+
+ for (x = gsz - 1; x >= 0; x--) {
+ gradientFillOffset = x << 1;
+ t = gbuf[gradientFillOffset]; // calculate column of pixel indexed by gbuf[x]
+ fsz = gbuf[gradientFillOffset + 1]; // calculate row of pixel indexed by gbuf[x]
+ dmin = 0xffffffff; // reset min distance to edge pixel
+ for (a = outerEdgeOffset + osz - 1; a >= outerEdgeOffset; a--) { // loop through all outer edge buffer pixels
+ ud = a << 1;
+ dy = t - gbuf[ud]; // set dx to gradient pixel column - outer edge pixel row
+ dx = fsz - gbuf[ud + 1]; // set dy to gradient pixel row - outer edge pixel column
+ ud = dx * dx + dy * dy; // compute sum of squares
+ if (ud < dmin) { // if our new sum of squares is less than the current minimum
+ dmin = ud; // set a new minimum equal to the new lower value
}
}
- odist=(float)(dmin); // cast outer min to a float
- rsf=odist*0.5f; //
- rsl=*(unsigned int*)&odist; // use some peculiar properties of the way bits are stored
- rsl=0x5f3759df-(rsl>>1); // in floats vs. unsigned ints to compute an approximate
- odist=*(float*)&rsl; // reciprocal square root
- odist=odist*(rsopf-(rsf*odist*odist)); // -- ** this line can be iterated for more accuracy ** --
- dmin=0xffffffff; // reset min distance to edge pixel
- for (a = innerEdgeOffset+isz-1; a>=innerEdgeOffset; a--) { // loop through all inside edge pixels
- ud=a<<1;
- dy=t-gbuf[ud]; // compute delta in Y from gradient pixel to inside edge pixel
- dx=fsz-gbuf[ud+1]; // compute delta in X from gradient pixel to inside edge pixel
- ud=dx*dx+dy*dy; // compute sum of squares
- if (ud<dmin) { // if our new sum of squares is less than the current minimum we've found
- dmin=ud; // set a new minimum equal to the new lower value
+ odist = (float)(dmin); // cast outer min to a float
+ rsf = odist * 0.5f; //
+ rsl = *(unsigned int *)&odist; // use some peculiar properties of the way bits are stored
+ rsl = 0x5f3759df - (rsl >> 1); // in floats vs. unsigned ints to compute an approximate
+ odist = *(float *)&rsl; // reciprocal square root
+ odist = odist * (rsopf - (rsf * odist * odist)); // -- ** this line can be iterated for more accuracy ** --
+ dmin = 0xffffffff; // reset min distance to edge pixel
+ for (a = innerEdgeOffset + isz - 1; a >= innerEdgeOffset; a--) { // loop through all inside edge pixels
+ ud = a << 1;
+ dy = t - gbuf[ud]; // compute delta in Y from gradient pixel to inside edge pixel
+ dx = fsz - gbuf[ud + 1]; // compute delta in X from gradient pixel to inside edge pixel
+ ud = dx * dx + dy * dy; // compute sum of squares
+ if (ud < dmin) { // if our new sum of squares is less than the current minimum we've found
+ dmin = ud; // set a new minimum equal to the new lower value
}
}
- idist=(float)(dmin); // cast inner min to a float
- rsf=idist*0.5f; //
- rsl=*(unsigned int*)&idist; //
- rsl=0x5f3759df-(rsl>>1); // see notes above
- idist=*(float*)&rsl; //
- idist=idist*(rsopf-(rsf*idist*idist)); //
+ idist = (float)(dmin); // cast inner min to a float
+ rsf = idist * 0.5f; //
+ rsl = *(unsigned int *)&idist; //
+ rsl = 0x5f3759df - (rsl >> 1); // see notes above
+ idist = *(float *)&rsl; //
+ idist = idist * (rsopf - (rsf * idist * idist)); //
/*
- Note once again that since we are using reciprocals of distance values our
- proportion is already the correct intensity, and does not need to be
- subracted from 1.0 like it would have if we used real distances.
- */
+ * Note once again that since we are using reciprocals of distance values our
+ * proportion is already the correct intensity, and does not need to be
+ * subracted from 1.0 like it would have if we used real distances.
+ */
/*
- Here we reconstruct the pixel's memory location in the CompBuf by
- Pixel Index = Pixel Column + ( Pixel Row * Row Width )
- */
- res[gbuf[gradientFillOffset+1]+(gbuf[gradientFillOffset]*rw)]=(idist/(idist+odist)); //set intensity
+ * Here we reconstruct the pixel's memory location in the CompBuf by
+ * Pixel Index = Pixel Column + ( Pixel Row * Row Width )
+ */
+ res[gbuf[gradientFillOffset + 1] + (gbuf[gradientFillOffset] * rw)] = (idist / (idist + odist)); //set intensity
}
}
@@ -1139,92 +1140,92 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float
int t; // t = total number of pixels in buffer - 1 (used for loop starts)
int fsz; // size of the frame
- unsigned int isz=0; // size (in pixels) of inside edge pixel index buffer
- unsigned int osz=0; // size (in pixels) of outside edge pixel index buffer
- unsigned int gsz=0; // size (in pixels) of gradient pixel index buffer
- unsigned int rsize[3]; // size storage to pass to helper functions
- unsigned int innerEdgeOffset=0; // offset into final buffer where inner edge pixel indexes start
- unsigned int outerEdgeOffset=0; // offset into final buffer where outer edge pixel indexes start
+ unsigned int isz = 0; // size (in pixels) of inside edge pixel index buffer
+ unsigned int osz = 0; // size (in pixels) of outside edge pixel index buffer
+ unsigned int gsz = 0; // size (in pixels) of gradient pixel index buffer
+ unsigned int rsize[3]; // size storage to pass to helper functions
+ unsigned int innerEdgeOffset = 0; // offset into final buffer where inner edge pixel indexes start
+ unsigned int outerEdgeOffset = 0; // offset into final buffer where outer edge pixel indexes start
unsigned short *gbuf; // gradient/inner/outer pixel location index buffer
if (true) { // if both input sockets have some data coming in...
- t=(this->getWidth()*this->getHeight())-1; // determine size of the frame
+ t = (this->getWidth() * this->getHeight()) - 1; // determine size of the frame
- lres = (unsigned int*)res; // unsigned int pointer to output buffer (for bit level ops)
- limask=(unsigned int*)imask; // unsigned int pointer to input mask (for bit level ops)
- lomask=(unsigned int*)omask; // unsigned int pointer to output mask (for bit level ops)
+ lres = (unsigned int *)res; // unsigned int pointer to output buffer (for bit level ops)
+ limask = (unsigned int *)imask; // unsigned int pointer to input mask (for bit level ops)
+ lomask = (unsigned int *)omask; // unsigned int pointer to output mask (for bit level ops)
rw = this->getWidth(); // width of a row of pixels
/*
- The whole buffer is broken up into 4 parts. The four CORNERS, the FIRST and LAST rows, the
- LEFT and RIGHT edges (excluding the corner pixels), and all OTHER rows.
- This allows for quick computation of outer edge pixels where
- a screen edge pixel is marked to be gradient.
-
- The pixel type (gradient vs inner-edge vs outer-edge) tests change
- depending on the user selected "Inner Edge Mode" and the user selected
- "Buffer Edge Mode" on the node's GUI. There are 4 sets of basically the
- same algorithm:
-
- 1.) Inner Edge -> Adjacent Only
- Buffer Edge -> Keep Inside
-
- 2.) Inner Edge -> Adjacent Only
- Buffer Edge -> Bleed Out
-
- 3.) Inner Edge -> All
- Buffer Edge -> Keep Inside
-
- 4.) Inner Edge -> All
- Buffer Edge -> Bleed Out
-
- Each version has slightly different criteria for detecting an edge pixel.
+ * The whole buffer is broken up into 4 parts. The four CORNERS, the FIRST and LAST rows, the
+ * LEFT and RIGHT edges (excluding the corner pixels), and all OTHER rows.
+ * This allows for quick computation of outer edge pixels where
+ * a screen edge pixel is marked to be gradient.
+ *
+ * The pixel type (gradient vs inner-edge vs outer-edge) tests change
+ * depending on the user selected "Inner Edge Mode" and the user selected
+ * "Buffer Edge Mode" on the node's GUI. There are 4 sets of basically the
+ * same algorithm:
+ *
+ * 1.) Inner Edge -> Adjacent Only
+ * Buffer Edge -> Keep Inside
+ *
+ * 2.) Inner Edge -> Adjacent Only
+ * Buffer Edge -> Bleed Out
+ *
+ * 3.) Inner Edge -> All
+ * Buffer Edge -> Keep Inside
+ *
+ * 4.) Inner Edge -> All
+ * Buffer Edge -> Bleed Out
+ *
+ * Each version has slightly different criteria for detecting an edge pixel.
*/
- if (this->adjecentOnly) { // if "adjacent only" inner edge mode is turned on
- if (this->keepInside) { // if "keep inside" buffer edge mode is turned on
- do_adjacentKeepBorders(t,rw,limask,lomask,lres,res,rsize);
+ if (this->adjecentOnly) { // if "adjacent only" inner edge mode is turned on
+ if (this->keepInside) { // if "keep inside" buffer edge mode is turned on
+ do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize);
}
- else { // "bleed out" buffer edge mode is turned on
- do_adjacentBleedBorders(t,rw,limask,lomask,lres,res,rsize);
+ else { // "bleed out" buffer edge mode is turned on
+ do_adjacentBleedBorders(t, rw, limask, lomask, lres, res, rsize);
}
- isz=rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass
- osz=rsize[1];
- gsz=rsize[2];
+ isz = rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass
+ osz = rsize[1];
+ gsz = rsize[2];
// detect edges in all non-border pixels in the buffer
- do_adjacentEdgeDetection(t,rw,limask,lomask,lres,res,rsize,isz,osz,gsz);
+ do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz);
}
- else { // "all" inner edge mode is turned on
- if (this->keepInside) { // if "keep inside" buffer edge mode is turned on
- do_allKeepBorders(t,rw,limask,lomask,lres,res,rsize);
+ else { // "all" inner edge mode is turned on
+ if (this->keepInside) { // if "keep inside" buffer edge mode is turned on
+ do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize);
}
- else { // "bleed out" buffer edge mode is turned on
- do_allBleedBorders(t,rw,limask,lomask,lres,res,rsize);
+ else { // "bleed out" buffer edge mode is turned on
+ do_allBleedBorders(t, rw, limask, lomask, lres, res, rsize);
}
- isz=rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass
- osz=rsize[1];
- gsz=rsize[2];
+ isz = rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass
+ osz = rsize[1];
+ gsz = rsize[2];
// detect edges in all non-border pixels in the buffer
- do_allEdgeDetection(t,rw,limask,lomask,lres,res,rsize,isz,osz,gsz);
+ do_allEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz);
}
- isz=rsize[0]; // set edge and gradient buffer sizes once again...
- osz=rsize[1]; // the sizes in rsize[] may have been modified
- gsz=rsize[2]; // by the do_*EdgeDetection() function.
+ isz = rsize[0]; // set edge and gradient buffer sizes once again...
+ osz = rsize[1]; // the sizes in rsize[] may have been modified
+ gsz = rsize[2]; // by the do_*EdgeDetection() function.
- fsz=gsz+isz+osz; // calculate size of pixel index buffer needed
- gbuf = new unsigned short[fsz*2]; // allocate edge/gradient pixel index buffer
+ fsz = gsz + isz + osz; // calculate size of pixel index buffer needed
+ gbuf = (unsigned short *)MEM_callocN(sizeof (unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer
- do_createEdgeLocationBuffer(t,rw,lres,res,gbuf,&innerEdgeOffset,&outerEdgeOffset,isz,gsz);
- do_fillGradientBuffer(rw,res,gbuf,isz,osz,gsz,innerEdgeOffset,outerEdgeOffset);
+ do_createEdgeLocationBuffer(t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz);
+ do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset);
- delete gbuf; // free the gradient index buffer
+ MEM_freeN(gbuf); // free the gradient index buffer
}
}
-DoubleEdgeMaskOperation::DoubleEdgeMaskOperation(): NodeOperation()
+DoubleEdgeMaskOperation::DoubleEdgeMaskOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
@@ -1263,11 +1264,11 @@ void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect, MemoryBuffer **mem
{
if (this->cachedInstance) return this->cachedInstance;
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (this->cachedInstance == NULL) {
- MemoryBuffer *innerMask = (MemoryBuffer*)inputInnerMask->initializeTileData(rect, memoryBuffers);
- MemoryBuffer *outerMask = (MemoryBuffer*)inputOuterMask->initializeTileData(rect, memoryBuffers);
- float *data = new float[this->getWidth()*this->getHeight()];
+ MemoryBuffer *innerMask = (MemoryBuffer *)inputInnerMask->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *outerMask = (MemoryBuffer *)inputOuterMask->initializeTileData(rect, memoryBuffers);
+ float *data = new float[this->getWidth() * this->getHeight()];
float *imask = innerMask->convertToValueBuffer();
float *omask = outerMask->convertToValueBuffer();
doDoubleEdgeMask(imask, omask, data);
@@ -1275,17 +1276,17 @@ void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect, MemoryBuffer **mem
delete omask;
this->cachedInstance = data;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return this->cachedInstance;
}
void DoubleEdgeMaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- float *buffer = (float*) data;
- int index = (y*this->getWidth() + x);
+ float *buffer = (float *) data;
+ int index = (y * this->getWidth() + x);
color[0] = buffer[index];
- color[1] = buffer[index+1];
- color[2] = buffer[index+2];
- color[3] = buffer[index+3];
+ color[1] = buffer[index + 1];
+ color[2] = buffer[index + 2];
+ color[3] = buffer[index + 3];
}
void DoubleEdgeMaskOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
index 85c4fd9e5b7..a18d59ae5a2 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
@@ -28,10 +28,10 @@
class DoubleEdgeMaskOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOuterMask;
- SocketReader * inputInnerMask;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOuterMask;
+ SocketReader *inputInnerMask;
bool adjecentOnly;
bool keepInside;
float *cachedInstance;
@@ -40,25 +40,25 @@ public:
void doDoubleEdgeMask(float *inner, float *outer, float *res);
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void setAdjecentOnly(bool adjecentOnly) {this->adjecentOnly = adjecentOnly;}
- void setKeepInside(bool keepInside) {this->keepInside = keepInside;}
+ void setAdjecentOnly(bool adjecentOnly) { this->adjecentOnly = adjecentOnly; }
+ void setKeepInside(bool keepInside) { this->keepInside = keepInside; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
index 650c57dd8dc..0beacd02738 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -24,7 +24,7 @@
#include "BLI_math.h"
#include "DNA_node_types.h"
-EllipseMaskOperation::EllipseMaskOperation(): NodeOperation()
+EllipseMaskOperation::EllipseMaskOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
@@ -41,7 +41,7 @@ void EllipseMaskOperation::initExecution()
const double rad = DEG2RAD((double)this->data->rotation);
this->cosine = cos(rad);
this->sine = sin(rad);
- this->aspectRatio = ((float)this->getWidth())/this->getHeight();
+ this->aspectRatio = ((float)this->getWidth()) / this->getHeight();
}
void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -49,32 +49,32 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam
float inputMask[4];
float inputValue[4];
- float rx = x/this->getWidth();
- float ry = y/this->getHeight();
+ float rx = x / this->getWidth();
+ float ry = y / this->getHeight();
- const float dy = (ry - this->data->y)/this->aspectRatio;
+ const float dy = (ry - this->data->y) / this->aspectRatio;
const float dx = rx - this->data->x;
- rx = this->data->x+(this->cosine*dx + this->sine*dy);
- ry = this->data->y+(-this->sine*dx + this->cosine*dy);
+ rx = this->data->x + (this->cosine * dx + this->sine * dy);
+ ry = this->data->y + (-this->sine * dx + this->cosine * dy);
this->inputMask->read(inputMask, x, y, sampler, inputBuffers);
this->inputValue->read(inputValue, x, y, sampler, inputBuffers);
- const float halfHeight = (this->data->height)/2.0f;
- const float halfWidth = this->data->width/2.0f;
- float sx = rx-this->data->x;
+ const float halfHeight = (this->data->height) / 2.0f;
+ const float halfWidth = this->data->width / 2.0f;
+ float sx = rx - this->data->x;
sx *= sx;
const float tx = halfWidth * halfWidth;
- float sy = ry-this->data->y;
+ float sy = ry - this->data->y;
sy *= sy;
const float ty = halfHeight * halfHeight;
- bool inside = ((sx/tx)+(sy/ty))<1.0f;
+ bool inside = ((sx / tx) + (sy / ty)) < 1.0f;
switch (this->maskType) {
case CMP_NODE_MASKTYPE_ADD:
if (inside) {
- color[0] = max(inputMask[0],inputValue[0]);
+ color[0] = max(inputMask[0], inputValue[0]);
}
else {
color[0] = inputMask[0];
@@ -82,7 +82,7 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam
break;
case CMP_NODE_MASKTYPE_SUBTRACT:
if (inside) {
- color[0] = inputMask[0]-inputValue[0];
+ color[0] = inputMask[0] - inputValue[0];
CLAMP(color[0], 0, 1);
}
else {
@@ -91,24 +91,24 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam
break;
case CMP_NODE_MASKTYPE_MULTIPLY:
if (inside) {
- color[0] = inputMask[0]*inputValue[0];
+ color[0] = inputMask[0] * inputValue[0];
}
else {
color[0] = 0;
}
break;
case CMP_NODE_MASKTYPE_NOT:
- if (inside) {
- if (inputMask[0]>0.0f) {
- color[0] = 0;
+ if (inside) {
+ if (inputMask[0] > 0.0f) {
+ color[0] = 0;
+ }
+ else {
+ color[0] = inputValue[0];
+ }
}
else {
- color[0] = inputValue[0];
+ color[0] = inputMask[0];
}
- }
- else {
- color[0] = inputMask[0];
- }
break;
}
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
index bff94941190..61d724c2f15 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
@@ -28,10 +28,10 @@
class EllipseMaskOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputMask;
- SocketReader * inputValue;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputMask;
+ SocketReader *inputValue;
float sine;
float cosine;
@@ -43,23 +43,23 @@ public:
EllipseMaskOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setData(NodeEllipseMask *data) {this->data = data;}
-
- void setMaskType(int maskType) {this->maskType = maskType;}
+ void setData(NodeEllipseMask *data) { this->data = data; }
+
+ void setMaskType(int maskType) { this->maskType = maskType; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index ad58631f2c1..7830eef829c 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -24,14 +24,14 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-FastGaussianBlurOperation::FastGaussianBlurOperation(): BlurBaseOperation()
+FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation()
{
this->iirgaus = NULL;
}
-void FastGaussianBlurOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
+void FastGaussianBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- MemoryBuffer *newData = (MemoryBuffer*)data;
+ MemoryBuffer *newData = (MemoryBuffer *)data;
newData->read(color, x, y);
}
@@ -44,7 +44,7 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
@@ -79,33 +79,33 @@ void FastGaussianBlurOperation::deinitExecution()
void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
- BLI_mutex_lock(this->getMutex());
+ lockMutex();
if (!iirgaus) {
- MemoryBuffer *newBuf = (MemoryBuffer*)this->inputProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *newBuf = (MemoryBuffer *)this->inputProgram->initializeTileData(rect, memoryBuffers);
MemoryBuffer *copy = newBuf->duplicate();
updateSize(memoryBuffers);
int c;
- sx = data->sizex * this->size/2.0f;
- sy = data->sizey * this->size/2.0f;
+ sx = data->sizex * this->size / 2.0f;
+ sy = data->sizey * this->size / 2.0f;
if ((sx == sy) && (sx > 0.f)) {
- for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
IIR_gauss(copy, sx, c, 3);
}
else {
if (sx > 0.f) {
- for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
IIR_gauss(copy, sx, c, 1);
}
if (sy > 0.f) {
- for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
IIR_gauss(copy, sy, c, 2);
}
}
this->iirgaus = copy;
}
- BLI_mutex_unlock(this->getMutex());
+ unlockMutex();
return iirgaus;
}
@@ -130,17 +130,17 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch
// see "Recursive Gabor Filtering" by Young/VanVliet
// all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
if (sigma >= 3.556f)
- q = 0.9804f*(sigma - 3.556f) + 2.5091f;
+ q = 0.9804f * (sigma - 3.556f) + 2.5091f;
else // sigma >= 0.5
- q = (0.0561f*sigma + 0.5784f)*sigma - 0.2568f;
- q2 = q*q;
- sc = (1.1668 + q)*(3.203729649 + (2.21566 + q)*q);
+ q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
+ q2 = q * q;
+ sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q);
// no gabor filtering here, so no complex multiplies, just the regular coefs.
// all negated here, so as not to have to recalc Triggs/Sdika matrix
- cf[1] = q*(5.788961737 + (6.76492 + 3.0*q)*q)/ sc;
- cf[2] = -q2*(3.38246 + 3.0*q)/sc;
+ cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc;
+ cf[2] = -q2 * (3.38246 + 3.0 * q) / sc;
// 0 & 3 unchanged
- cf[3] = q2*q/sc;
+ cf[3] = q2 * q / sc;
cf[0] = 1.0 - cf[1] - cf[2] - cf[3];
// Triggs/Sdika border corrections,
@@ -150,59 +150,61 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch
// but neither seem to be quite the same, result seems to be ok so far anyway.
// Extra scale factor here to not have to do it in filter,
// though maybe this had something to with the precision errors
- sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3]));
- tsM[0] = sc*(-cf[3]*cf[1] + 1.0 - cf[3]*cf[3] - cf[2]);
- tsM[1] = sc*((cf[3] + cf[1])*(cf[2] + cf[3]*cf[1]));
- tsM[2] = sc*(cf[3]*(cf[1] + cf[3]*cf[2]));
- tsM[3] = sc*(cf[1] + cf[3]*cf[2]);
- tsM[4] = sc*(-(cf[2] - 1.0)*(cf[2] + cf[3]*cf[1]));
- tsM[5] = sc*(-(cf[3]*cf[1] + cf[3]*cf[3] + cf[2] - 1.0)*cf[3]);
- tsM[6] = sc*(cf[3]*cf[1] + cf[2] + cf[1]*cf[1] - cf[2]*cf[2]);
- tsM[7] = sc*(cf[1]*cf[2] + cf[3]*cf[2]*cf[2] - cf[1]*cf[3]*cf[3] - cf[3]*cf[3]*cf[3] - cf[3]*cf[2] + cf[3]);
- tsM[8] = sc*(cf[3]*(cf[1] + cf[3]*cf[2]));
+ sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) * (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3]));
+ tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]);
+ tsM[1] = sc * ((cf[3] + cf[1]) * (cf[2] + cf[3] * cf[1]));
+ tsM[2] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
+ tsM[3] = sc * (cf[1] + cf[3] * cf[2]);
+ tsM[4] = sc * (-(cf[2] - 1.0) * (cf[2] + cf[3] * cf[1]));
+ tsM[5] = sc * (-(cf[3] * cf[1] + cf[3] * cf[3] + cf[2] - 1.0) * cf[3]);
+ tsM[6] = sc * (cf[3] * cf[1] + cf[2] + cf[1] * cf[1] - cf[2] * cf[2]);
+ tsM[7] = sc * (cf[1] * cf[2] + cf[3] * cf[2] * cf[2] - cf[1] * cf[3] * cf[3] - cf[3] * cf[3] * cf[3] - cf[3] * cf[2] + cf[3]);
+ tsM[8] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
-#define YVV(L) \
-{ \
-W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0]; \
-W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0]; \
-W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0]; \
-for (i=3; i<L; i++) \
-W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3]; \
-tsu[0] = W[L-1] - X[L-1]; \
-tsu[1] = W[L-2] - X[L-1]; \
-tsu[2] = W[L-3] - X[L-1]; \
-tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1]; \
-tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1]; \
-tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1]; \
-Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2]; \
-Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1]; \
-Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0]; \
-for (i=L-4; i>=0; i--) \
-Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3]; \
-}
+#define YVV(L) \
+{ \
+ W[0] = cf[0] * X[0] + cf[1] * X[0] + cf[2] * X[0] + cf[3] * X[0]; \
+ W[1] = cf[0] * X[1] + cf[1] * W[0] + cf[2] * X[0] + cf[3] * X[0]; \
+ W[2] = cf[0] * X[2] + cf[1] * W[1] + cf[2] * W[0] + cf[3] * X[0]; \
+ for (i = 3; i < L; i++) { \
+ W[i] = cf[0] * X[i] + cf[1] * W[i - 1] + cf[2] * W[i - 2] + cf[3] * W[i - 3]; \
+ } \
+ tsu[0] = W[L - 1] - X[L - 1]; \
+ tsu[1] = W[L - 2] - X[L - 1]; \
+ tsu[2] = W[L - 3] - X[L - 1]; \
+ tsv[0] = tsM[0] * tsu[0] + tsM[1] * tsu[1] + tsM[2] * tsu[2] + X[L - 1]; \
+ tsv[1] = tsM[3] * tsu[0] + tsM[4] * tsu[1] + tsM[5] * tsu[2] + X[L - 1]; \
+ tsv[2] = tsM[6] * tsu[0] + tsM[7] * tsu[1] + tsM[8] * tsu[2] + X[L - 1]; \
+ Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \
+ Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \
+ Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \
+ for (i = L - 4; i >= 0; i--) { \
+ Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \
+ } \
+} (void)0
// intermediate buffers
sz = MAX2(src->getWidth(), src->getHeight());
- X = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss X buf");
- Y = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss Y buf");
- W = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss W buf");
- if (xy & 1) { // H
- for (y=0; y<src->getHeight(); ++y) {
- const int yx = y*src->getWidth();
- for (x=0; x<src->getWidth(); ++x)
- X[x] = buffer[(x + yx)*COM_NUMBER_OF_CHANNELS + chan];
+ X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
+ Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
+ W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
+ if (xy & 1) { // H
+ for (y = 0; y < src->getHeight(); ++y) {
+ const int yx = y * src->getWidth();
+ for (x = 0; x < src->getWidth(); ++x)
+ X[x] = buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan];
YVV(src->getWidth());
- for (x=0; x<src->getWidth(); ++x)
- buffer[(x + yx)*COM_NUMBER_OF_CHANNELS + chan] = Y[x];
+ for (x = 0; x < src->getWidth(); ++x)
+ buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan] = Y[x];
}
}
- if (xy & 2) { // V
- for (x=0; x<src->getWidth(); ++x) {
- for (y=0; y<src->getHeight(); ++y)
- X[y] = buffer[(x + y*src->getWidth())*COM_NUMBER_OF_CHANNELS + chan];
+ if (xy & 2) { // V
+ for (x = 0; x < src->getWidth(); ++x) {
+ for (y = 0; y < src->getHeight(); ++y)
+ X[y] = buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan];
YVV(src->getHeight());
- for (y=0; y<src->getHeight(); ++y)
- buffer[(x + y*src->getWidth())*COM_NUMBER_OF_CHANNELS + chan] = Y[y];
+ for (y = 0; y < src->getHeight(); ++y)
+ buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan] = Y[y];
}
}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
index 1f71fe7f9ed..f92e3dc68a5 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -26,15 +26,15 @@
#include "COM_BlurBaseOperation.h"
#include "DNA_node_types.h"
-class FastGaussianBlurOperation: public BlurBaseOperation {
+class FastGaussianBlurOperation : public BlurBaseOperation {
private:
float sx;
float sy;
- MemoryBuffer* iirgaus;
+ MemoryBuffer *iirgaus;
public:
FastGaussianBlurOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp
index 38018ffc3f7..5023473f4aa 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.cpp
+++ b/source/blender/compositor/operations/COM_FlipOperation.cpp
@@ -42,10 +42,10 @@ void FlipOperation::deinitExecution()
}
-void FlipOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void FlipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
- float nx = this->flipX?this->getWidth()-1-x:x;
- float ny = this->flipY?this->getHeight()-1-y:y;
+ float nx = this->flipX ? this->getWidth() - 1 - x : x;
+ float ny = this->flipY ? this->getHeight() - 1 - y : y;
this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
}
@@ -55,16 +55,16 @@ bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper
rcti newInput;
if (this->flipX) {
- newInput.xmax = (this->getWidth()- 1 - input->xmin)+1;
- newInput.xmin = (this->getWidth()- 1 - input->xmax)-1;
+ newInput.xmax = (this->getWidth() - 1 - input->xmin) + 1;
+ newInput.xmin = (this->getWidth() - 1 - input->xmax) - 1;
}
else {
newInput.xmin = input->xmin;
newInput.xmax = input->xmax;
}
if (this->flipY) {
- newInput.ymax = (this->getHeight()- 1 - input->ymin)+1;
- newInput.ymin = (this->getHeight()- 1 - input->ymax)-1;
+ newInput.ymax = (this->getHeight() - 1 - input->ymin) + 1;
+ newInput.ymin = (this->getHeight() - 1 - input->ymax) - 1;
}
else {
newInput.ymin = input->ymin;
diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h
index 9774cfd7bcd..f83fa6ac3a8 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.h
+++ b/source/blender/compositor/operations/COM_FlipOperation.h
@@ -25,7 +25,7 @@
#include "COM_NodeOperation.h"
-class FlipOperation: public NodeOperation {
+class FlipOperation : public NodeOperation {
private:
SocketReader *inputOperation;
bool flipX;
@@ -33,12 +33,12 @@ private:
public:
FlipOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setFlipX(bool flipX) {this->flipX = flipX;}
- void setFlipY(bool flipY) {this->flipY = flipY;}
+ void setFlipX(bool flipX) { this->flipX = flipX; }
+ void setFlipY(bool flipY) { this->flipY = flipY; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp b/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
deleted file mode 100644
index 05a758aca7f..00000000000
--- a/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_FogGlowImageOperation.h"
-#include "BLI_math.h"
-
-FogGlowImageOperation::FogGlowImageOperation(): NodeOperation()
-{
- this->addOutputSocket(COM_DT_COLOR);
-}
-void FogGlowImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
-{
- const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
-
- float u, v, w, d, r;
-
- v = 2.f*(y / (float)512) - 1.f;
- u = 2.f*(x / (float)512) - 1.f;
- r = (u*u + v*v)*256;
- d = -sqrtf(sqrtf(sqrtf(r)));
- w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
- color[0] = expf(d*cs_r) * w;
- color[1] = expf(d*cs_g) * w;
- color[2] = expf(d*cs_b) * w;
- color[3] = 1.0f;
-}
-
-void FogGlowImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
-{
- resolution[0] = 512;
- resolution[1] = 512;
-}
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
index a4fb20402a4..3e90b643604 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_GammaCorrectOperation.h"
#include "BLI_math.h"
-GammaCorrectOperation::GammaCorrectOperation(): NodeOperation()
+GammaCorrectOperation::GammaCorrectOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -45,9 +45,9 @@ void GammaCorrectOperation::executePixel(float *color, float x, float y, PixelSa
}
/* check for negative to avoid nan's */
- color[0] = inputColor[0]>0.0f?inputColor[0]*inputColor[0] :0.0f;
- color[1] = inputColor[1]>0.0f?inputColor[1]*inputColor[1] :0.0f;
- color[2] = inputColor[2]>0.0f?inputColor[2]*inputColor[2] :0.0f;
+ color[0] = inputColor[0] > 0.0f ? inputColor[0] * inputColor[0] : 0.0f;
+ color[1] = inputColor[1] > 0.0f ? inputColor[1] * inputColor[1] : 0.0f;
+ color[2] = inputColor[2] > 0.0f ? inputColor[2] * inputColor[2] : 0.0f;
inputColor[0] *= inputColor[3];
inputColor[1] *= inputColor[3];
@@ -64,7 +64,7 @@ void GammaCorrectOperation::deinitExecution()
this->inputProgram = NULL;
}
-GammaUncorrectOperation::GammaUncorrectOperation(): NodeOperation()
+GammaUncorrectOperation::GammaUncorrectOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -86,9 +86,9 @@ void GammaUncorrectOperation::executePixel(float *color, float x, float y, Pixel
inputColor[2] /= inputColor[3];
}
- color[0] = inputColor[0]>0.0f?sqrtf(inputColor[0]) :0.0f;
- color[1] = inputColor[1]>0.0f?sqrtf(inputColor[1]) :0.0f;
- color[2] = inputColor[2]>0.0f?sqrtf(inputColor[2]) :0.0f;
+ color[0] = inputColor[0] > 0.0f ? sqrtf(inputColor[0]) : 0.0f;
+ color[1] = inputColor[1] > 0.0f ? sqrtf(inputColor[1]) : 0.0f;
+ color[2] = inputColor[2] > 0.0f ? sqrtf(inputColor[2]) : 0.0f;
inputColor[0] *= inputColor[3];
inputColor[1] *= inputColor[3];
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
index 6132f04edba..4bf03eac0a1 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
@@ -28,52 +28,52 @@
class GammaCorrectOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
public:
GammaCorrectOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
class GammaUncorrectOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
public:
GammaUncorrectOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp
index 989ffd5dfba..2c3e78840ee 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_GammaOperation.h"
#include "BLI_math.h"
-GammaOperation::GammaOperation(): NodeOperation()
+GammaOperation::GammaOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h
index 2f3d8cdf9f7..8c007d27843 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.h
+++ b/source/blender/compositor/operations/COM_GammaOperation.h
@@ -28,27 +28,27 @@
class GammaOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
SocketReader *inputGammaProgram;
public:
GammaOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index e522d334d8b..b38ed28cd6a 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-GaussianBokehBlurOperation::GaussianBokehBlurOperation(): BlurBaseOperation()
+GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation()
{
this->gausstab = NULL;
}
@@ -65,42 +65,42 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
if (!sizeavailable) {
updateSize(memoryBuffers);
}
- radxf = size*(float)this->data->sizex;
- if (radxf>width/2.0f)
- radxf = width/2.0f;
- else if (radxf<1.0f)
+ radxf = size * (float)this->data->sizex;
+ if (radxf > width / 2.0f)
+ radxf = width / 2.0f;
+ else if (radxf < 1.0f)
radxf = 1.0f;
/* vertical */
- radyf = size*(float)this->data->sizey;
- if (radyf>height/2.0f)
- radyf = height/2.0f;
- else if (radyf<1.0f)
+ radyf = size * (float)this->data->sizey;
+ if (radyf > height / 2.0f)
+ radyf = height / 2.0f;
+ else if (radyf < 1.0f)
radyf = 1.0f;
radx = ceil(radxf);
rady = ceil(radyf);
- n = (2*radx+1)*(2*rady+1);
+ n = (2 * radx + 1) * (2 * rady + 1);
/* create a full filter image */
ddgauss = new float[n];
dgauss = ddgauss;
val = 0.0f;
- for (j=-rady; j<=rady; j++) {
- for (i=-radx; i<=radx; i++, dgauss++) {
+ for (j = -rady; j <= rady; j++) {
+ for (i = -radx; i <= radx; i++, dgauss++) {
float fj = (float)j / radyf;
float fi = (float)i / radxf;
float dist = sqrt(fj * fj + fi * fi);
*dgauss = RE_filter_value(this->data->filtertype, dist);
- val+= *dgauss;
+ val += *dgauss;
}
}
- if (val!=0.0f) {
- val = 1.0f/val;
- for (j = n - 1; j>=0; j--)
- ddgauss[j]*= val;
+ if (val != 0.0f) {
+ val = 1.0f / val;
+ for (j = n - 1; j >= 0; j--)
+ ddgauss[j] *= val;
}
else ddgauss[4] = 1.0f;
@@ -116,7 +116,7 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
tempColor[2] = 0;
tempColor[3] = 0;
float overallmultiplyer = 0;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
@@ -131,33 +131,28 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
- int index = 0;
+ int index;
int step = QualityStepHelper::getStep();
int offsetadd = QualityStepHelper::getOffsetAdd();
- for (int ny = miny ; ny < maxy ; ny +=step) {
- int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
- for (int nx = minx ; nx < maxx ; nx +=step) {
- float multiplyer = gausstab[index];
- tempColor[0] += multiplyer * buffer[bufferindex];
- tempColor[1] += multiplyer * buffer[bufferindex+1];
- tempColor[2] += multiplyer * buffer[bufferindex+2];
- tempColor[3] += multiplyer * buffer[bufferindex+3];
+ for (int ny = miny; ny < maxy; ny += step) {
+ index = ((ny - y) + this->rady) * (this->radx * 2 + 1) + (minx - x + this->radx);
+ int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
+ for (int nx = minx; nx < maxx; nx += step) {
+ const float multiplyer = gausstab[index];
+ madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
overallmultiplyer += multiplyer;
index += step;
- bufferindex +=offsetadd;
+ bufferindex += offsetadd;
}
}
- float divider = 1.0f / overallmultiplyer;
- color[0] = tempColor[0] * divider;
- color[1] = tempColor[1] * divider;
- color[2] = tempColor[2] * divider;
- color[3] = tempColor[3] * divider;
+
+ mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
}
void GaussianBokehBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete this->gausstab;
+ delete [] this->gausstab;
this->gausstab = NULL;
}
@@ -169,7 +164,7 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, R
sizeInput.ymin = 0;
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
index 78c6437eac6..616a6539ad4 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
@@ -37,13 +37,13 @@ public:
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index 2eb51b4577f..09a2a70ead3 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-GaussianXBlurOperation::GaussianXBlurOperation(): BlurBaseOperation()
+GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation()
{
this->gausstab = NULL;
this->rad = 0;
@@ -48,8 +48,8 @@ void GaussianXBlurOperation::initExecution()
BlurBaseOperation::initExecution();
if (this->sizeavailable) {
- float rad = size*this->data->sizex;
- if (rad<1)
+ float rad = size * this->data->sizex;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -61,8 +61,8 @@ void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
{
if (this->gausstab == NULL) {
updateSize(memoryBuffers);
- float rad = size*this->data->sizex;
- if (rad<1)
+ float rad = size * this->data->sizex;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -78,7 +78,7 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
tempColor[2] = 0;
tempColor[3] = 0;
float overallmultiplyer = 0.0f;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
@@ -93,30 +93,24 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
- int index = 0;
+ int index;
int step = getStep();
int offsetadd = getOffsetAdd();
- int bufferindex = ((minx - bufferstartx)*4)+((miny-bufferstarty)*4*bufferwidth);
- for (int nx = minx ; nx < maxx ; nx +=step) {
- float multiplyer = gausstab[index++];
- tempColor[0] += multiplyer * buffer[bufferindex];
- tempColor[1] += multiplyer * buffer[bufferindex+1];
- tempColor[2] += multiplyer * buffer[bufferindex+2];
- tempColor[3] += multiplyer * buffer[bufferindex+3];
+ int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth);
+ for (int nx = minx; nx < maxx; nx += step) {
+ index = (nx - x) + this->rad;
+ const float multiplyer = gausstab[index];
+ madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
overallmultiplyer += multiplyer;
- bufferindex +=offsetadd;
+ bufferindex += offsetadd;
}
- float divider = 1.0f / overallmultiplyer;
- color[0] = tempColor[0] * divider;
- color[1] = tempColor[1] * divider;
- color[2] = tempColor[2] * divider;
- color[3] = tempColor[3] * divider;
+ mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
}
void GaussianXBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete this->gausstab;
+ delete [] this->gausstab;
this->gausstab = NULL;
}
@@ -129,7 +123,7 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
index a957b8c12af..10a8a538391 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
@@ -34,18 +34,18 @@ public:
GaussianXBlurOperation();
/**
- *@brief the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * @brief the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- *@brief initialize the execution
- */
+ * @brief initialize the execution
+ */
void initExecution();
/**
- *@brief Deinitialize the execution
- */
+ * @brief Deinitialize the execution
+ */
void deinitExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 28e8e548530..ace817194f3 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-GaussianYBlurOperation::GaussianYBlurOperation(): BlurBaseOperation()
+GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation()
{
this->gausstab = NULL;
this->rad = 0;
@@ -45,8 +45,8 @@ void *GaussianYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memo
void GaussianYBlurOperation::initExecution()
{
if (this->sizeavailable) {
- float rad = size*this->data->sizey;
- if (rad<1)
+ float rad = size * this->data->sizey;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -58,8 +58,8 @@ void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
{
if (this->gausstab == NULL) {
updateSize(memoryBuffers);
- float rad = size*this->data->sizey;
- if (rad<1)
+ float rad = size * this->data->sizey;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -75,7 +75,7 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
tempColor[2] = 0;
tempColor[3] = 0;
float overallmultiplyer = 0;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
@@ -91,27 +91,21 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
maxx = min(maxx, inputBuffer->getRect()->xmax);
int step = getStep();
- int index = 0;
- for (int ny = miny ; ny < maxy ; ny +=step) {
- int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
- float multiplyer = gausstab[index++];
- tempColor[0] += multiplyer * buffer[bufferindex];
- tempColor[1] += multiplyer * buffer[bufferindex+1];
- tempColor[2] += multiplyer * buffer[bufferindex+2];
- tempColor[3] += multiplyer * buffer[bufferindex+3];
+ int index;
+ for (int ny = miny; ny < maxy; ny += step) {
+ index = (ny - y) + this->rad;
+ int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
+ const float multiplyer = gausstab[index];
+ madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
overallmultiplyer += multiplyer;
}
- float divider = 1.0f / overallmultiplyer;
- color[0] = tempColor[0] * divider;
- color[1] = tempColor[1] * divider;
- color[2] = tempColor[2] * divider;
- color[3] = tempColor[3] * divider;
+ mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
}
void GaussianYBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete this->gausstab;
+ delete [] this->gausstab;
this->gausstab = NULL;
}
@@ -124,7 +118,7 @@ bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
index f33d38de14e..e8d362e4c32 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
@@ -34,18 +34,18 @@ public:
GaussianYBlurOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- *@brief initialize the execution
- */
+ * @brief initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
index fdfd19a10ae..90bdd705a7c 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -23,56 +23,41 @@
#include "COM_GlareBaseOperation.h"
#include "BLI_math.h"
-GlareBaseOperation::GlareBaseOperation(): NodeOperation()
+GlareBaseOperation::GlareBaseOperation() : SingleThreadedNodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->settings = NULL;
- this->cachedInstance = NULL;
- setComplex(true);
}
void GlareBaseOperation::initExecution()
{
- initMutex();
+ SingleThreadedNodeOperation::initExecution();
this->inputProgram = getInputSocketReader(0);
- this->cachedInstance = NULL;
-}
-
-void GlareBaseOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)\
-{
- float *buffer = (float*) data;
- int index = (y*this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
- color[0] = buffer[index];
- color[1] = buffer[index+1];
- color[2] = buffer[index+2];
- color[3] = buffer[index+3];
}
void GlareBaseOperation::deinitExecution()
{
- deinitMutex();
this->inputProgram = NULL;
- if (this->cachedInstance) {
- delete cachedInstance;
- this->cachedInstance = NULL;
- }
+ SingleThreadedNodeOperation::deinitExecution();
}
-void *GlareBaseOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+
+MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2, MemoryBuffer **memoryBuffers)
{
- BLI_mutex_lock(getMutex());
- if (this->cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer*)inputProgram->initializeTileData(rect, memoryBuffers);
- float *data = new float[this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS];
- this->generateGlare(data, tile, this->settings);
- this->cachedInstance = data;
- }
- BLI_mutex_unlock(getMutex());
- return this->cachedInstance;
+ MemoryBuffer *tile = (MemoryBuffer *)inputProgram->initializeTileData(rect2, memoryBuffers);
+ rcti rect;
+ rect.xmin = 0;
+ rect.ymin = 0;
+ rect.xmax = getWidth();
+ rect.ymax = getHeight();
+ MemoryBuffer *result = new MemoryBuffer(NULL, &rect);
+ float *data = result->getBuffer();
+ this->generateGlare(data, tile, this->settings);
+ return result;
}
bool GlareBaseOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- if (this->cachedInstance != NULL) {
+ if (isCached()) {
return false;
}
else {
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h
index 2fa8afc9c4c..ac67ac055e9 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.h
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h
@@ -15,86 +15,60 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_GlareBaseOperation_h
#define _COM_GlareBaseOperation_h
-#include "COM_NodeOperation.h"
+
+#include "COM_SingleThreadedNodeOperation.h"
#include "DNA_node_types.h"
/* utility functions used by glare, tonemap and lens distortion */
/* soms macros for color handling */
typedef float fRGB[4];
-/* clear color */
-#define fRGB_clear(c) { c[0]=c[1]=c[2]=0.f; } (void)0
-/* copy c2 to c1 */
-#define fRGB_copy(c1, c2) { c1[0]=c2[0]; c1[1]=c2[1]; c1[2]=c2[2]; c1[3]=c2[3]; } (void)0
-/* add c2 to c1 */
-#define fRGB_add(c1, c2) { c1[0]+=c2[0]; c1[1]+=c2[1]; c1[2]+=c2[2]; } (void)0
-/* subtract c2 from c1 */
-#define fRGB_sub(c1, c2) { c1[0]-=c2[0]; c1[1]-=c2[1]; c1[2]-=c2[2]; } (void)0
-/* multiply c by float value s */
-#define fRGB_mult(c, s) { c[0]*=s; c[1]*=s; c[2]*=s; } (void)0
-/* multiply c2 by s and add to c1 */
-#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s; c1[1]+=c2[1]*s; c1[2]+=c2[2]*s; } (void)0
-/* multiply c2 by color c1 */
-#define fRGB_colormult(c, cs) { c[0]*=cs[0]; c[1]*=cs[1]; c[2]*=cs[2]; } (void)0
-/* multiply c2 by color c3 and add to c1 */
-#define fRGB_colormadd(c1, c2, c3) { c1[0]+=c2[0]*c3[0]; c1[1]+=c2[1]*c3[1]; c1[2]+=c2[2]*c3[2]; } (void)0
+
+/* TODO - replace with BLI_math_vector */
/* multiply c2 by color rgb, rgb as separate arguments */
-#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r); c[1]*=(g); c[2]*=(b); } (void)0
-/* swap colors c1 & c2 */
-#define fRGB_swap(c1, c2) { float _t=c1[0]; c1[0]=c2[0]; c2[0]=_t;\
- _t=c1[1]; c1[1]=c2[1]; c2[1]=_t;\
- _t=c1[2]; c1[2]=c2[2]; c2[2]=_t;\
- _t=c1[3]; c1[3]=c2[3]; c3[3]=_t;\
- } (void)0
+#define fRGB_rgbmult(c, r, g, b) { c[0] *= (r); c[1] *= (g); c[2] *= (b); } (void)0
-class GlareBaseOperation : public NodeOperation {
+class GlareBaseOperation : public SingleThreadedNodeOperation {
private:
/**
- * @brief Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
-
- /**
- * @brief settings of the glare node.
- */
- NodeGlare * settings;
-
- float *cachedInstance;
+ * @brief Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
-public:
-
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
-
+ * @brief settings of the glare node.
+ */
+ NodeGlare *settings;
+public:
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
-
+
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
-
- void setGlareSettings(NodeGlare * settings) {this->settings = settings;}
+ void setGlareSettings(NodeGlare *settings) {
+ this->settings = settings;
+ }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
protected:
GlareBaseOperation();
-
+
virtual void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) = 0;
-
-
+
+ MemoryBuffer *createMemoryBuffer(rcti *rect, MemoryBuffer **memoryBuffers);
+
};
#endif
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
new file mode 100644
index 00000000000..694aa26bcde
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
@@ -0,0 +1,405 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GlareFogGlowOperation.h"
+#include "MEM_guardedalloc.h"
+
+/*
+ * 2D Fast Hartley Transform, used for convolution
+ */
+
+typedef float fREAL;
+
+// returns next highest power of 2 of x, as well it's log2 in L2
+static unsigned int nextPow2(unsigned int x, unsigned int *L2)
+{
+ unsigned int pw, x_notpow2 = x & (x - 1);
+ *L2 = 0;
+ while (x >>= 1) ++(*L2);
+ pw = 1 << (*L2);
+ if (x_notpow2) { (*L2)++; pw <<= 1; }
+ return pw;
+}
+
+//------------------------------------------------------------------------------
+
+// from FXT library by Joerg Arndt, faster in order bitreversal
+// use: r = revbin_upd(r, h) where h = N>>1
+static unsigned int revbin_upd(unsigned int r, unsigned int h)
+{
+ while (!((r ^= h) & h)) h >>= 1;
+ return r;
+}
+//------------------------------------------------------------------------------
+static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
+{
+ double tt, fc, dc, fs, ds, a = M_PI;
+ fREAL t1, t2;
+ int n2, bd, bl, istep, k, len = 1 << M, n = 1;
+
+ int i, j = 0;
+ unsigned int Nh = len >> 1;
+ for (i = 1; i < (len - 1); ++i) {
+ j = revbin_upd(j, Nh);
+ if (j > i) {
+ t1 = data[i];
+ data[i] = data[j];
+ data[j] = t1;
+ }
+ }
+
+ do {
+ fREAL *data_n = &data[n];
+
+ istep = n << 1;
+ for (k = 0; k < len; k += istep) {
+ t1 = data_n[k];
+ data_n[k] = data[k] - t1;
+ data[k] += t1;
+ }
+
+ n2 = n >> 1;
+ if (n > 2) {
+ fc = dc = cos(a);
+ fs = ds = sqrt(1.0 - fc * fc); //sin(a);
+ bd = n - 2;
+ for (bl = 1; bl < n2; bl++) {
+ fREAL *data_nbd = &data_n[bd];
+ fREAL *data_bd = &data[bd];
+ for (k = bl; k < len; k += istep) {
+ t1 = fc * data_n[k] + fs * data_nbd[k];
+ t2 = fs * data_n[k] - fc * data_nbd[k];
+ data_n[k] = data[k] - t1;
+ data_nbd[k] = data_bd[k] - t2;
+ data[k] += t1;
+ data_bd[k] += t2;
+ }
+ tt = fc * dc - fs * ds;
+ fs = fs * dc + fc * ds;
+ fc = tt;
+ bd -= 2;
+ }
+ }
+
+ if (n > 1) {
+ for (k = n2; k < len; k += istep) {
+ t1 = data_n[k];
+ data_n[k] = data[k] - t1;
+ data[k] += t1;
+ }
+ }
+
+ n = istep;
+ a *= 0.5;
+ } while (n < len);
+
+ if (inverse) {
+ fREAL sc = (fREAL)1 / (fREAL)len;
+ for (k = 0; k < len; ++k)
+ data[k] *= sc;
+ }
+}
+//------------------------------------------------------------------------------
+/* 2D Fast Hartley Transform, Mx/My -> log2 of width/height,
+ nzp -> the row where zero pad data starts,
+ inverse -> see above */
+static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My,
+ unsigned int nzp, unsigned int inverse)
+{
+ unsigned int i, j, Nx, Ny, maxy;
+ fREAL t;
+
+ Nx = 1 << Mx;
+ Ny = 1 << My;
+
+ // rows (forward transform skips 0 pad data)
+ maxy = inverse ? Ny : nzp;
+ for (j = 0; j < maxy; ++j)
+ FHT(&data[Nx * j], Mx, inverse);
+
+ // transpose data
+ if (Nx == Ny) { // square
+ for (j = 0; j < Ny; ++j)
+ for (i = j + 1; i < Nx; ++i) {
+ unsigned int op = i + (j << Mx), np = j + (i << My);
+ t = data[op], data[op] = data[np], data[np] = t;
+ }
+ }
+ else { // rectangular
+ unsigned int k, Nym = Ny - 1, stm = 1 << (Mx + My);
+ for (i = 0; stm > 0; i++) {
+ #define PRED(k) (((k & Nym) << Mx) + (k >> My))
+ for (j = PRED(i); j > i; j = PRED(j)) ;
+ if (j < i) continue;
+ for (k = i, j = PRED(i); j != i; k = j, j = PRED(j), stm--) {
+ t = data[j], data[j] = data[k], data[k] = t;
+ }
+ #undef PRED
+ stm--;
+ }
+ }
+ // swap Mx/My & Nx/Ny
+ i = Nx, Nx = Ny, Ny = i;
+ i = Mx, Mx = My, My = i;
+
+ // now columns == transposed rows
+ for (j = 0; j < Ny; ++j)
+ FHT(&data[Nx * j], Mx, inverse);
+
+ // finalize
+ for (j = 0; j <= (Ny >> 1); j++) {
+ unsigned int jm = (Ny - j) & (Ny - 1);
+ unsigned int ji = j << Mx;
+ unsigned int jmi = jm << Mx;
+ for (i = 0; i <= (Nx >> 1); i++) {
+ unsigned int im = (Nx - i) & (Nx - 1);
+ fREAL A = data[ji + i];
+ fREAL B = data[jmi + i];
+ fREAL C = data[ji + im];
+ fREAL D = data[jmi + im];
+ fREAL E = (fREAL)0.5 * ((A + D) - (B + C));
+ data[ji + i] = A - E;
+ data[jmi + i] = B + E;
+ data[ji + im] = C + E;
+ data[jmi + im] = D - E;
+ }
+ }
+
+}
+
+//------------------------------------------------------------------------------
+
+/* 2D convolution calc, d1 *= d2, M/N - > log2 of width/height */
+static void fht_convolve(fREAL *d1, fREAL *d2, unsigned int M, unsigned int N)
+{
+ fREAL a, b;
+ unsigned int i, j, k, L, mj, mL;
+ unsigned int m = 1 << M, n = 1 << N;
+ unsigned int m2 = 1 << (M - 1), n2 = 1 << (N - 1);
+ unsigned int mn2 = m << (N - 1);
+
+ d1[0] *= d2[0];
+ d1[mn2] *= d2[mn2];
+ d1[m2] *= d2[m2];
+ d1[m2 + mn2] *= d2[m2 + mn2];
+ for (i = 1; i < m2; i++) {
+ k = m - i;
+ a = d1[i] * d2[i] - d1[k] * d2[k];
+ b = d1[k] * d2[i] + d1[i] * d2[k];
+ d1[i] = (b + a) * (fREAL)0.5;
+ d1[k] = (b - a) * (fREAL)0.5;
+ a = d1[i + mn2] * d2[i + mn2] - d1[k + mn2] * d2[k + mn2];
+ b = d1[k + mn2] * d2[i + mn2] + d1[i + mn2] * d2[k + mn2];
+ d1[i + mn2] = (b + a) * (fREAL)0.5;
+ d1[k + mn2] = (b - a) * (fREAL)0.5;
+ }
+ for (j = 1; j < n2; j++) {
+ L = n - j;
+ mj = j << M;
+ mL = L << M;
+ a = d1[mj] * d2[mj] - d1[mL] * d2[mL];
+ b = d1[mL] * d2[mj] + d1[mj] * d2[mL];
+ d1[mj] = (b + a) * (fREAL)0.5;
+ d1[mL] = (b - a) * (fREAL)0.5;
+ a = d1[m2 + mj] * d2[m2 + mj] - d1[m2 + mL] * d2[m2 + mL];
+ b = d1[m2 + mL] * d2[m2 + mj] + d1[m2 + mj] * d2[m2 + mL];
+ d1[m2 + mj] = (b + a) * (fREAL)0.5;
+ d1[m2 + mL] = (b - a) * (fREAL)0.5;
+ }
+ for (i = 1; i < m2; i++) {
+ k = m - i;
+ for (j = 1; j < n2; j++) {
+ L = n - j;
+ mj = j << M;
+ mL = L << M;
+ a = d1[i + mj] * d2[i + mj] - d1[k + mL] * d2[k + mL];
+ b = d1[k + mL] * d2[i + mj] + d1[i + mj] * d2[k + mL];
+ d1[i + mj] = (b + a) * (fREAL)0.5;
+ d1[k + mL] = (b - a) * (fREAL)0.5;
+ a = d1[i + mL] * d2[i + mL] - d1[k + mj] * d2[k + mj];
+ b = d1[k + mj] * d2[i + mL] + d1[i + mL] * d2[k + mj];
+ d1[i + mL] = (b + a) * (fREAL)0.5;
+ d1[k + mj] = (b - a) * (fREAL)0.5;
+ }
+ }
+}
+//------------------------------------------------------------------------------
+
+void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
+{
+ fREAL *data1, *data2, *fp;
+ unsigned int w2, h2, hw, hh, log2_w, log2_h;
+ fRGB wt, *colp;
+ int x, y, ch;
+ int xbl, ybl, nxb, nyb, xbsz, ybsz;
+ int in2done = FALSE;
+ const unsigned int kernelWidth = in2->getWidth();
+ const unsigned int kernelHeight = in2->getHeight();
+ const unsigned int imageWidth = in1->getWidth();
+ const unsigned int imageHeight = in1->getHeight();
+ float *kernelBuffer = in2->getBuffer();
+ float *imageBuffer = in1->getBuffer();
+
+ MemoryBuffer *rdst = new MemoryBuffer(NULL, in1->getRect());
+
+ // convolution result width & height
+ w2 = 2 * kernelWidth - 1;
+ h2 = 2 * kernelHeight - 1;
+ // FFT pow2 required size & log2
+ w2 = nextPow2(w2, &log2_w);
+ h2 = nextPow2(h2, &log2_h);
+
+ // alloc space
+ data1 = (fREAL *)MEM_callocN(3 * w2 * h2 * sizeof(fREAL), "convolve_fast FHT data1");
+ data2 = (fREAL *)MEM_callocN(w2 * h2 * sizeof(fREAL), "convolve_fast FHT data2");
+
+ // normalize convolutor
+ wt[0] = wt[1] = wt[2] = 0.f;
+ for (y = 0; y < kernelHeight; y++) {
+ colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUMBER_OF_CHANNELS];
+ for (x = 0; x < kernelWidth; x++)
+ add_v3_v3(wt, colp[x]);
+ }
+ if (wt[0] != 0.f) wt[0] = 1.f / wt[0];
+ if (wt[1] != 0.f) wt[1] = 1.f / wt[1];
+ if (wt[2] != 0.f) wt[2] = 1.f / wt[2];
+ for (y = 0; y < kernelHeight; y++) {
+ colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUMBER_OF_CHANNELS];
+ for (x = 0; x < kernelWidth; x++)
+ mul_v3_v3(colp[x], wt);
+ }
+
+ // copy image data, unpacking interleaved RGBA into separate channels
+ // only need to calc data1 once
+
+ // block add-overlap
+ hw = kernelWidth >> 1;
+ hh = kernelHeight >> 1;
+ xbsz = (w2 + 1) - kernelWidth;
+ ybsz = (h2 + 1) - kernelHeight;
+ nxb = imageWidth / xbsz;
+ if (imageWidth % xbsz) nxb++;
+ nyb = imageHeight / ybsz;
+ if (imageHeight % ybsz) nyb++;
+ for (ybl = 0; ybl < nyb; ybl++) {
+ for (xbl = 0; xbl < nxb; xbl++) {
+
+ // each channel one by one
+ for (ch = 0; ch < 3; ch++) {
+ fREAL *data1ch = &data1[ch * w2 * h2];
+
+ // only need to calc fht data from in2 once, can re-use for every block
+ if (!in2done) {
+ // in2, channel ch -> data1
+ for (y = 0; y < kernelHeight; y++) {
+ fp = &data1ch[y * w2];
+ colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUMBER_OF_CHANNELS];
+ for (x = 0; x < kernelWidth; x++)
+ fp[x] = colp[x][ch];
+ }
+ }
+
+ // in1, channel ch -> data2
+ memset(data2, 0, w2 * h2 * sizeof(fREAL));
+ for (y = 0; y < ybsz; y++) {
+ int yy = ybl * ybsz + y;
+ if (yy >= imageHeight) continue;
+ fp = &data2[y * w2];
+ colp = (fRGB *)&imageBuffer[yy * imageWidth * COM_NUMBER_OF_CHANNELS];
+ for (x = 0; x < xbsz; x++) {
+ int xx = xbl * xbsz + x;
+ if (xx >= imageWidth) continue;
+ fp[x] = colp[xx][ch];
+ }
+ }
+
+ // forward FHT
+ // zero pad data start is different for each == height+1
+ if (!in2done) FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0);
+ FHT2D(data2, log2_w, log2_h, kernelHeight + 1, 0);
+
+ // FHT2D transposed data, row/col now swapped
+ // convolve & inverse FHT
+ fht_convolve(data2, data1ch, log2_h, log2_w);
+ FHT2D(data2, log2_h, log2_w, 0, 1);
+ // data again transposed, so in order again
+
+ // overlap-add result
+ for (y = 0; y < (int)h2; y++) {
+ const int yy = ybl * ybsz + y - hh;
+ if ((yy < 0) || (yy >= imageHeight)) continue;
+ fp = &data2[y * w2];
+ colp = (fRGB *)&rdst->getBuffer()[yy * imageWidth * COM_NUMBER_OF_CHANNELS];
+ for (x = 0; x < (int)w2; x++) {
+ const int xx = xbl * xbsz + x - hw;
+ if ((xx < 0) || (xx >= imageWidth)) continue;
+ colp[xx][ch] += fp[x];
+ }
+ }
+
+ }
+ in2done = TRUE;
+ }
+ }
+
+ MEM_freeN(data2);
+ MEM_freeN(data1);
+ memcpy(dst, rdst->getBuffer(), sizeof(float) * imageWidth * imageHeight * COM_NUMBER_OF_CHANNELS);
+ delete(rdst);
+}
+
+void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
+{
+ int x, y;
+ float scale, u, v, r, w, d;
+ fRGB fcol;
+ MemoryBuffer *ckrn;
+ unsigned int sz = 1 << settings->size;
+ const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
+
+ // temp. src image
+ // make the convolution kernel
+ rcti kernelRect;
+ BLI_init_rcti(&kernelRect, 0, sz, 0, sz);
+ ckrn = new MemoryBuffer(NULL, &kernelRect);
+
+ scale = 0.25f * sqrtf((float)(sz * sz));
+
+ for (y = 0; y < sz; ++y) {
+ v = 2.f * (y / (float)sz) - 1.0f;
+ for (x = 0; x < sz; ++x) {
+ u = 2.f * (x / (float)sz) - 1.0f;
+ r = (u * u + v * v) * scale;
+ d = -sqrtf(sqrtf(sqrtf(r))) * 9.0f;
+ fcol[0] = expf(d * cs_r), fcol[1] = expf(d * cs_g), fcol[2] = expf(d * cs_b);
+ // linear window good enough here, visual result counts, not scientific analysis
+ //w = (1.f-fabs(u))*(1.f-fabs(v));
+ // actually, Hanning window is ok, cos^2 for some reason is slower
+ w = (0.5f + 0.5f * cos((double)u * M_PI)) * (0.5f + 0.5f * cos((double)v * M_PI));
+ mul_v3_fl(fcol, w);
+ ckrn->writePixel(x, y, fcol);
+ }
+ }
+
+ convolve(data, inputTile, ckrn);
+ delete ckrn;
+}
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
new file mode 100644
index 00000000000..5737a6a1ff0
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GlareFogGlowOperation_h
+#define _COM_GlareFogGlowOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+#include "COM_GlareBaseOperation.h"
+
+class GlareFogGlowOperation : public GlareBaseOperation {
+public:
+ GlareFogGlowOperation() : GlareBaseOperation() {
+ }
+protected:
+ void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
index c5b1d6caa89..39fffd6ac64 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -27,16 +27,20 @@
static float smoothMask(float x, float y)
{
float t;
- x = 2.f*x - 1.f, y = 2.f*y - 1.f;
- if ((t = 1.f - sqrtf(x*x + y*y)) <= 0.f) return 0.f;
- return t;
+ x = 2.0f * x - 1.0f;
+ y = 2.0f * y - 1.0f;
+ if ((t = 1.0f - sqrtf(x * x + y * y)) > 0.0f) {
+ return t;
+ }
+ else {
+ return 0.0f;
+ }
}
-
void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
{
const int qt = 1 << settings->quality;
- const float s1 = 4.f/(float)qt, s2 = 2.f*s1;
+ const float s1 = 4.f / (float)qt, s2 = 2.f * s1;
int x, y, n, p, np;
fRGB c, tc, cm[64];
float sc, isc, u, v, sm, s, t, ofs, scalef[64];
@@ -45,69 +49,78 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
MemoryBuffer *gbuf = inputTile->duplicate();
MemoryBuffer *tbuf1 = inputTile->duplicate();
+ bool breaked = false;
+
FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
- FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
- FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
-
+ if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
+ if (isBreaked()) breaked = true;
+ if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
+
MemoryBuffer *tbuf2 = tbuf1->duplicate();
-
- FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
- FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
- FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
-
+
+ if (isBreaked()) breaked = true;
+ if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
+ if (isBreaked()) breaked = true;
+ if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
+ if (isBreaked()) breaked = true;
+ if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
+
if (settings->iter & 1) ofs = 0.5f; else ofs = 0.f;
- for (x=0; x<(settings->iter*4); x++) {
+ for (x = 0; x < (settings->iter * 4); x++) {
y = x & 3;
cm[x][0] = cm[x][1] = cm[x][2] = 1;
- if (y==1) fRGB_rgbmult(cm[x], 1.f, cmo, cmo);
- if (y==2) fRGB_rgbmult(cm[x], cmo, cmo, 1.f);
- if (y==3) fRGB_rgbmult(cm[x], cmo, 1.f, cmo);
- scalef[x] = 2.1f*(1.f-(x+ofs)/(float)(settings->iter*4));
- if (x & 1) scalef[x] = -0.99f/scalef[x];
+ if (y == 1) fRGB_rgbmult(cm[x], 1.f, cmo, cmo);
+ if (y == 2) fRGB_rgbmult(cm[x], cmo, cmo, 1.f);
+ if (y == 3) fRGB_rgbmult(cm[x], cmo, 1.f, cmo);
+ scalef[x] = 2.1f * (1.f - (x + ofs) / (float)(settings->iter * 4));
+ if (x & 1) scalef[x] = -0.99f / scalef[x];
}
sc = 2.13;
isc = -0.97;
- for (y=0; y<gbuf->getHeight(); y++) {
- v = (float)(y+0.5f) / (float)gbuf->getHeight();
- for (x=0; x<gbuf->getWidth(); x++) {
- u = (float)(x+0.5f) / (float)gbuf->getWidth();
- s = (u-0.5f)*sc + 0.5f, t = (v-0.5f)*sc + 0.5f;
- tbuf1->read(c, s*gbuf->getWidth(), t*gbuf->getHeight());
+ for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
+ v = (float)(y + 0.5f) / (float)gbuf->getHeight();
+ for (x = 0; x < gbuf->getWidth(); x++) {
+ u = (float)(x + 0.5f) / (float)gbuf->getWidth();
+ s = (u - 0.5f) * sc + 0.5f, t = (v - 0.5f) * sc + 0.5f;
+ tbuf1->read(c, s * gbuf->getWidth(), t * gbuf->getHeight());
sm = smoothMask(s, t);
- fRGB_mult(c, sm);
- s = (u-0.5f)*isc + 0.5f, t = (v-0.5f)*isc + 0.5f;
- tbuf2->read(tc, s*gbuf->getWidth()-0.5f, t*gbuf->getHeight()-0.5f);
+ mul_v3_fl(c, sm);
+ s = (u - 0.5f) * isc + 0.5f, t = (v - 0.5f) * isc + 0.5f;
+ tbuf2->read(tc, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
sm = smoothMask(s, t);
- fRGB_madd(c, tc, sm);
-
+ madd_v3_v3fl(c, tc, sm);
+
gbuf->writePixel(x, y, c);
}
+ if (isBreaked()) breaked = true;
+
}
- memset(tbuf1->getBuffer(), 0, tbuf1->getWidth()*tbuf1->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
- for (n=1; n<settings->iter; n++) {
- for (y=0; y<gbuf->getHeight(); y++) {
- v = (float)(y+0.5f) / (float)gbuf->getHeight();
- for (x=0; x<gbuf->getWidth(); x++) {
- u = (float)(x+0.5f) / (float)gbuf->getWidth();
+ memset(tbuf1->getBuffer(), 0, tbuf1->getWidth() * tbuf1->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
+ for (n = 1; n < settings->iter && (!breaked); n++) {
+ for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
+ v = (float)(y + 0.5f) / (float)gbuf->getHeight();
+ for (x = 0; x < gbuf->getWidth(); x++) {
+ u = (float)(x + 0.5f) / (float)gbuf->getWidth();
tc[0] = tc[1] = tc[2] = 0.f;
- for (p=0;p<4;p++) {
- np = (n<<2) + p;
- s = (u-0.5f)*scalef[np] + 0.5f;
- t = (v-0.5f)*scalef[np] + 0.5f;
- gbuf->read(c, s*gbuf->getWidth() - 0.5f, t*gbuf->getHeight() - 0.5f);
- fRGB_colormult(c, cm[np]);
- sm = smoothMask(s, t)*0.25f;
- fRGB_madd(tc, c, sm);
+ for (p = 0; p < 4; p++) {
+ np = (n << 2) + p;
+ s = (u - 0.5f) * scalef[np] + 0.5f;
+ t = (v - 0.5f) * scalef[np] + 0.5f;
+ gbuf->read(c, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
+ mul_v3_v3(c, cm[np]);
+ sm = smoothMask(s, t) * 0.25f;
+ madd_v3_v3fl(tc, c, sm);
}
- tbuf1->writePixel(x, y, tc);
+ tbuf1->addPixel(x, y, tc);
}
+ if (isBreaked()) breaked = true;
}
- memcpy(gbuf->getBuffer(), tbuf1->getBuffer(), tbuf1->getWidth()*tbuf1->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+ memcpy(gbuf->getBuffer(), tbuf1->getBuffer(), tbuf1->getWidth() * tbuf1->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
}
- memcpy(data, gbuf->getBuffer(), gbuf->getWidth()*gbuf->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
-
+ memcpy(data, gbuf->getBuffer(), gbuf->getWidth() * gbuf->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
+
delete gbuf;
delete tbuf1;
delete tbuf2;
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.h b/source/blender/compositor/operations/COM_GlareGhostOperation.h
index 48b5e8986a9..2ee85cc4543 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.h
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -28,7 +28,8 @@
class GlareGhostOperation : public GlareBaseOperation {
public:
- GlareGhostOperation() : GlareBaseOperation() {}
+ GlareGhostOperation() : GlareBaseOperation() {
+ }
protected:
void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
index 602e18521ee..957ac5af748 100644
--- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -25,87 +25,77 @@
void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
{
int i, x, y, ym, yp, xm, xp;
- float c[4] = {0,0,0,0}, tc[4] = {0,0,0,0};
- const float f1 = 1.f - settings->fade, f2 = (1.f - f1)*0.5f;
-
+ float c[4] = {0, 0, 0, 0}, tc[4] = {0, 0, 0, 0};
+ const float f1 = 1.0f - settings->fade;
+ const float f2 = (1.0f - f1) * 0.5f;
MemoryBuffer *tbuf1 = inputTile->duplicate();
MemoryBuffer *tbuf2 = inputTile->duplicate();
- for (i=0; i<settings->iter; i++) {
+ bool breaked = false;
+ for (i = 0; i < settings->iter && (!breaked); i++) {
// // (x || x-1, y-1) to (x || x+1, y+1)
// // F
- for (y=0; y<this->getHeight(); y++) {
+ for (y = 0; y < this->getHeight() && (!breaked); y++) {
ym = y - i;
yp = y + i;
- for (x=0; x<this->getWidth(); x++) {
+ for (x = 0; x < this->getWidth(); x++) {
xm = x - i;
xp = x + i;
tbuf1->read(c, x, y);
- c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ mul_v3_fl(c, f1);
tbuf1->read(tc, (settings->angle ? xm : x), ym);
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
tbuf1->read(tc, (settings->angle ? xp : x), yp);
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
c[3] = 1.0f;
tbuf1->writePixel(x, y, c);
tbuf2->read(c, x, y);
- c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ mul_v3_fl(c, f1);
tbuf2->read(tc, xm, (settings->angle ? yp : y));
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
tbuf2->read(tc, xp, (settings->angle ? ym : y));
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
c[3] = 1.0f;
tbuf2->writePixel(x, y, c);
-
+ }
+ if (isBreaked()) {
+ breaked = true;
}
}
// // B
- for (y=tbuf1->getHeight()-1; y>=0; y--) {
+ for (y = tbuf1->getHeight() - 1 && (!breaked); y >= 0; y--) {
ym = y - i;
yp = y + i;
- for (x=tbuf1->getWidth()-1; x>=0; x--) {
+ for (x = tbuf1->getWidth() - 1; x >= 0; x--) {
xm = x - i;
xp = x + i;
tbuf1->read(c, x, y);
- c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ mul_v3_fl(c, f1);
tbuf1->read(tc, (settings->angle ? xm : x), ym);
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
tbuf1->read(tc, (settings->angle ? xp : x), yp);
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
c[3] = 1.0f;
tbuf1->writePixel(x, y, c);
tbuf2->read(c, x, y);
- c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ mul_v3_fl(c, f1);
tbuf2->read(tc, xm, (settings->angle ? yp : y));
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
tbuf2->read(tc, xp, (settings->angle ? ym : y));
- c[0]+=tc[0]*f2;
- c[1]+=tc[1]*f2;
- c[2]+=tc[2]*f2;
+ madd_v3_v3fl(c, tc, f2);
c[3] = 1.0f;
tbuf2->writePixel(x, y, c);
}
+ if (isBreaked()) {
+ breaked = true;
+ }
}
}
- for (i = 0 ; i < this->getWidth()*this->getHeight()*4 ; i++) {
+ for (i = 0; i < this->getWidth() * this->getHeight() * 4; i++) {
data[i] = tbuf1->getBuffer()[i] + tbuf2->getBuffer()[i];
}
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
index 22040da9bc5..a12d1191a1a 100644
--- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -28,7 +28,8 @@
class GlareSimpleStarOperation : public GlareBaseOperation {
public:
- GlareSimpleStarOperation() : GlareBaseOperation() {}
+ GlareSimpleStarOperation() : GlareBaseOperation() {
+ }
protected:
void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
index 42b6a2b5e50..9125783c222 100644
--- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -26,70 +26,73 @@
void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
{
int x, y, n;
- unsigned int nump=0;
+ unsigned int nump = 0;
float c1[4], c2[4], c3[4], c4[4];
- float a, ang = DEG2RADF(360.0f)/(float)settings->angle;
-
- int size = inputTile->getWidth()*inputTile->getHeight();
- int size4 = size*4;
+ float a, ang = DEG2RADF(360.0f) / (float)settings->angle;
+
+ int size = inputTile->getWidth() * inputTile->getHeight();
+ int size4 = size * 4;
+
+ bool breaked = false;
-
MemoryBuffer *tsrc = inputTile->duplicate();
MemoryBuffer *tdst = new MemoryBuffer(NULL, inputTile->getRect());
tdst->clear();
- memset(data, 0, size4*sizeof(float));
-
- for (a=0.f; a<DEG2RADF(360.0f); a+=ang) {
+ memset(data, 0, size4 * sizeof(float));
+
+ for (a = 0.f; a < DEG2RADF(360.0f) && (!breaked); a += ang) {
const float an = a + settings->angle_ofs;
const float vx = cos((double)an), vy = sin((double)an);
- for (n=0; n<settings->iter; ++n) {
+ for (n = 0; n < settings->iter && (!breaked); ++n) {
const float p4 = pow(4.0, (double)n);
- const float vxp = vx*p4, vyp = vy*p4;
+ const float vxp = vx * p4, vyp = vy * p4;
const float wt = pow((double)settings->fade, (double)p4);
- const float cmo = 1.f - (float)pow((double)settings->colmod, (double)n+1); // colormodulation amount relative to current pass
+ const float cmo = 1.f - (float)pow((double)settings->colmod, (double)n + 1); // colormodulation amount relative to current pass
float *tdstcol = tdst->getBuffer();
- for (y=0; y<tsrc->getHeight(); ++y) {
- for (x=0; x<tsrc->getWidth(); ++x, tdstcol+=4) {
+ for (y = 0; y < tsrc->getHeight() && (!breaked); ++y) {
+ for (x = 0; x < tsrc->getWidth(); ++x, tdstcol += 4) {
// first pass no offset, always same for every pass, exact copy,
// otherwise results in uneven brightness, only need once
- if (n==0) tsrc->read(c1, x, y); else c1[0]=c1[1]=c1[2]=0;
+ if (n == 0) tsrc->read(c1, x, y); else c1[0] = c1[1] = c1[2] = 0;
tsrc->readCubic(c2, x + vxp, y + vyp);
- tsrc->readCubic(c3, x + vxp*2.f, y + vyp*2.f);
- tsrc->readCubic(c4, x + vxp*3.f, y + vyp*3.f);
+ tsrc->readCubic(c3, x + vxp * 2.f, y + vyp * 2.f);
+ tsrc->readCubic(c4, x + vxp * 3.f, y + vyp * 3.f);
// modulate color to look vaguely similar to a color spectrum
c2[1] *= cmo;
c2[2] *= cmo;
c3[0] *= cmo;
c3[1] *= cmo;
-
+
c4[0] *= cmo;
c4[2] *= cmo;
- tdstcol[0] = 0.5f*(tdstcol[0] + c1[0] + wt*(c2[0] + wt*(c3[0] + wt*c4[0])));
- tdstcol[1] = 0.5f*(tdstcol[1] + c1[1] + wt*(c2[1] + wt*(c3[1] + wt*c4[1])));
- tdstcol[2] = 0.5f*(tdstcol[2] + c1[2] + wt*(c2[2] + wt*(c3[2] + wt*c4[2])));
+ tdstcol[0] = 0.5f * (tdstcol[0] + c1[0] + wt * (c2[0] + wt * (c3[0] + wt * c4[0])));
+ tdstcol[1] = 0.5f * (tdstcol[1] + c1[1] + wt * (c2[1] + wt * (c3[1] + wt * c4[1])));
+ tdstcol[2] = 0.5f * (tdstcol[2] + c1[2] + wt * (c2[2] + wt * (c3[2] + wt * c4[2])));
tdstcol[3] = 1.0f;
}
+ if (isBreaked()) {
+ breaked = true;
+ }
}
- memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float)*size4);
+ memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float) * size4);
}
-// addImage(sbuf, tsrc, 1.f/(float)(6 - ndg->iter)); // add result to data @todo
float *sourcebuffer = tsrc->getBuffer();
- float factor = 1.f/(float)(6 - settings->iter);
- for (int i = 0 ; i < size4; i ++) {
+ float factor = 1.f / (float)(6 - settings->iter);
+ for (int i = 0; i < size4; i++) {
data[i] += sourcebuffer[i] * factor;
}
- for (int i = 0 ; i < size; i ++) {
- data[i*4+3] = 1.0f;
+ for (int i = 0; i < size; i++) {
+ data[i * 4 + 3] = 1.0f;
}
-
+
tdst->clear();
- memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float)*size4);
+ memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float) * size4);
nump++;
}
-
+
delete tsrc;
delete tdst;
}
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.h b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
index 07155a4713a..6520a05b44f 100644
--- a/source/blender/compositor/operations/COM_GlareStreaksOperation.h
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -28,7 +28,8 @@
class GlareStreaksOperation : public GlareBaseOperation {
public:
- GlareStreaksOperation() : GlareBaseOperation() {}
+ GlareStreaksOperation() : GlareBaseOperation() {
+ }
protected:
void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
index e8def72b7da..f9b2ec2b32d 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
@@ -15,20 +15,28 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_GlareThresholdOperation.h"
#include "BLI_math.h"
-GlareThresholdOperation::GlareThresholdOperation(): NodeOperation()
+GlareThresholdOperation::GlareThresholdOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_FIT);
this->addOutputSocket(COM_DT_COLOR);
this->inputProgram = NULL;
}
+
+void GlareThresholdOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ resolution[0] = resolution[0] / (1 << settings->quality);
+ resolution[1] = resolution[1] / (1 << settings->quality);
+}
+
void GlareThresholdOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
@@ -36,14 +44,18 @@ void GlareThresholdOperation::initExecution()
void GlareThresholdOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
+ const float threshold = settings->threshold;
+
this->inputProgram->read(color, x, y, sampler, inputBuffers);
- if ((0.212671f*color[0] + 0.71516f*color[1] + 0.072169f*color[2]) >= threshold) {
+ if (rgb_to_luma_y(color) >= threshold) {
color[0] -= threshold, color[1] -= threshold, color[2] -= threshold;
- color[0] = MAX2(color[0], 0.f);
- color[1] = MAX2(color[1], 0.f);
- color[2] = MAX2(color[2], 0.f);
+ color[0] = MAX2(color[0], 0.0f);
+ color[1] = MAX2(color[1], 0.0f);
+ color[2] = MAX2(color[2], 0.0f);
+ }
+ else {
+ zero_v3(color);
}
- else color[0] = color[1] = color[2] = 0.f;
}
void GlareThresholdOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
index 3dfa2f44339..70692565e27 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -28,30 +28,36 @@
class GlareThresholdOperation : public NodeOperation {
private:
/**
- * @brief Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
-
- float threshold;
+ * @brief Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
+ /**
+ * @brief settings of the glare node.
+ */
+ NodeGlare *settings;
public:
GlareThresholdOperation();
-
+
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
-
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
+
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
-
+
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
+
+ void setGlareSettings(NodeGlare *settings) {
+ this->settings = settings;
+ }
- void setThreshold(float threshold) {this->threshold = threshold;}
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
index 2afcc2e5cc7..b8e46e2d0be 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
@@ -32,7 +32,7 @@ extern "C" {
}
#endif
-HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation(): CurveBaseOperation()
+HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation() : CurveBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -53,7 +53,7 @@ void HueSaturationValueCorrectOperation::executePixel(float *output, float x, fl
/* adjust hue, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(this->curveMapping, 0, hsv[0]);
- hsv[0] += f-0.5f;
+ hsv[0] += f - 0.5f;
/* adjust saturation, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(this->curveMapping, 1, hsv[0]);
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
index 860bb71a0f1..5ede0491773 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
@@ -28,25 +28,25 @@
class HueSaturationValueCorrectOperation : public CurveBaseOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
public:
HueSaturationValueCorrectOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *Vector, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *Vector, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
index 834ca4fc5ed..d02367088d7 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_IDMaskOperation.h"
-IDMaskOperation::IDMaskOperation(): NodeOperation()
+IDMaskOperation::IDMaskOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -38,7 +38,7 @@ void IDMaskOperation::executePixel(float *color, float x, float y, PixelSampler
float inputValue[4];
this->inputProgram->read(inputValue, x, y, sampler, inputBuffers);
- const float a = (inputValue[0] == this->objectIndex)?1.0f:0.0f;
+ const float a = (inputValue[0] == this->objectIndex) ? 1.0f : 0.0f;
color[0] = a;
}
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
index 9f897c53d18..229e1b2dd82 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.h
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -28,8 +28,8 @@
class IDMaskOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
+ * Cached reference to the inputProgram
+ */
SocketReader *inputProgram;
float objectIndex;
@@ -37,21 +37,21 @@ public:
IDMaskOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setObjectIndex(float objectIndex) {this->objectIndex = objectIndex;}
+ void setObjectIndex(float objectIndex) { this->objectIndex = objectIndex; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index 04cd91d3c3a..9dbe8419daa 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -36,7 +36,7 @@ extern "C" {
#include "IMB_imbuf_types.h"
}
-BaseImageOperation::BaseImageOperation(): NodeOperation()
+BaseImageOperation::BaseImageOperation() : NodeOperation()
{
this->image = NULL;
this->buffer = NULL;
@@ -48,15 +48,15 @@ BaseImageOperation::BaseImageOperation(): NodeOperation()
this->depthBuffer = NULL;
this->numberOfChannels = 0;
}
-ImageOperation::ImageOperation(): BaseImageOperation()
+ImageOperation::ImageOperation() : BaseImageOperation()
{
this->addOutputSocket(COM_DT_COLOR);
}
-ImageAlphaOperation::ImageAlphaOperation(): BaseImageOperation()
+ImageAlphaOperation::ImageAlphaOperation() : BaseImageOperation()
{
this->addOutputSocket(COM_DT_VALUE);
}
-ImageDepthOperation::ImageDepthOperation(): BaseImageOperation()
+ImageDepthOperation::ImageDepthOperation() : BaseImageOperation()
{
this->addOutputSocket(COM_DT_VALUE);
}
@@ -66,12 +66,12 @@ ImBuf *BaseImageOperation::getImBuf()
ImBuf *ibuf;
ibuf = BKE_image_get_ibuf(this->image, this->imageUser);
- if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
- return NULL;
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
+ return NULL;
}
if (ibuf->rect_float == NULL) {
- IMB_float_from_rect(ibuf);
+ IMB_float_from_rect(ibuf);
}
return ibuf;
}
@@ -108,7 +108,7 @@ void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned
}
}
-void ImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])\
+void ImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
if (this->imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
color[0] = 0.0f;
@@ -118,15 +118,15 @@ void ImageOperation::executePixel(float *color, float x, float y, PixelSampler s
}
else {
switch (sampler) {
- case COM_PS_NEAREST:
- neareast_interpolation_color(this->buffer, NULL, color, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(this->buffer, NULL, color, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(this->buffer, NULL, color, x, y);
- break;
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
}
}
}
@@ -141,15 +141,15 @@ void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSamp
else {
tempcolor[3] = 1.0f;
switch (sampler) {
- case COM_PS_NEAREST:
- neareast_interpolation_color(this->buffer, NULL, tempcolor, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(this->buffer, NULL, tempcolor, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(this->buffer, NULL, tempcolor, x, y);
- break;
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->buffer, NULL, tempcolor, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->buffer, NULL, tempcolor, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->buffer, NULL, tempcolor, x, y);
+ break;
}
color[0] = tempcolor[3];
}
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index 0bd112304a8..a4645c9d504 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -36,8 +36,8 @@ extern "C" {
}
/**
- * @brief Base class for all image operations
- */
+ * @brief Base class for all image operations
+ */
class BaseImageOperation : public NodeOperation {
protected:
ImBuf *buffer;
@@ -52,8 +52,8 @@ protected:
BaseImageOperation();
/**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
virtual ImBuf *getImBuf();
@@ -62,33 +62,33 @@ public:
void initExecution();
void deinitExecution();
- void setImage(Image *image) {this->image = image;}
- void setImageUser(ImageUser *imageuser) {this->imageUser = imageuser;}
-
- void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+ void setImage(Image *image) { this->image = image; }
+ void setImageUser(ImageUser *imageuser) { this->imageUser = imageuser; }
+
+ void setFramenumber(int framenumber) { this->framenumber = framenumber; }
};
-class ImageOperation: public BaseImageOperation {
+class ImageOperation : public BaseImageOperation {
public:
/**
- * Constructor
- */
+ * Constructor
+ */
ImageOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class ImageAlphaOperation: public BaseImageOperation {
+class ImageAlphaOperation : public BaseImageOperation {
public:
/**
- * Constructor
- */
+ * Constructor
+ */
ImageAlphaOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class ImageDepthOperation: public BaseImageOperation {
+class ImageDepthOperation : public BaseImageOperation {
public:
/**
- * Constructor
- */
+ * Constructor
+ */
ImageDepthOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
index 982fe1a5450..6142959a12e 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_InvertOperation.h"
-InvertOperation::InvertOperation(): NodeOperation()
+InvertOperation::InvertOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -50,18 +50,16 @@ void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sa
const float invertedValue = 1.0f - value;
if (color) {
- out[0] = (1.0f - inputColor[0])*value + inputColor[0]*invertedValue;
- out[1] = (1.0f - inputColor[1])*value + inputColor[1]*invertedValue;
- out[2] = (1.0f - inputColor[2])*value + inputColor[2]*invertedValue;
+ out[0] = (1.0f - inputColor[0]) * value + inputColor[0] * invertedValue;
+ out[1] = (1.0f - inputColor[1]) * value + inputColor[1] * invertedValue;
+ out[2] = (1.0f - inputColor[2]) * value + inputColor[2] * invertedValue;
}
else {
- out[0] = inputColor[0];
- out[1] = inputColor[1];
- out[2] = inputColor[2];
+ copy_v3_v3(out, inputColor);
}
if (alpha)
- out[3] = (1.0f - inputColor[3])*value + inputColor[3]*invertedValue;
+ out[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue;
else
out[3] = inputColor[3];
diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h
index 27a995238c7..48432aecdd0 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.h
+++ b/source/blender/compositor/operations/COM_InvertOperation.h
@@ -28,10 +28,10 @@
class InvertOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputValueProgram;
- SocketReader * inputColorProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputValueProgram;
+ SocketReader *inputColorProgram;
bool alpha;
bool color;
@@ -40,21 +40,21 @@ public:
InvertOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setColor(bool color) {this->color = color;}
- void setAlpha(bool alpha) {this->alpha = alpha;}
+ void setColor(bool color) { this->color = color; }
+ void setAlpha(bool alpha) { this->alpha = alpha; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
new file mode 100644
index 00000000000..9c7a33c1327
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingBlurOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+KeyingBlurOperation::KeyingBlurOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+
+ this->size = 0.0f;
+
+ this->setComplex(true);
+}
+
+void *KeyingBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+ void *buffer = getInputOperation(0)->initializeTileData(rect, memoryBuffers);
+
+ return buffer;
+}
+
+void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+
+ int bufferWidth = inputBuffer->getWidth();
+ int bufferHeight = inputBuffer->getHeight();
+
+ int i, j, count = 0;
+
+ float average = 0.0f;
+
+ for (i = -this->size + 1; i < this->size; i++) {
+ for (j = -this->size + 1; j < this->size; j++) {
+ int cx = x + j, cy = y + i;
+
+ if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) {
+ int bufferIndex = (cy * bufferWidth + cx) * 4;
+
+ average += buffer[bufferIndex];
+ count++;
+ }
+ }
+ }
+
+ average /= (float) count;
+
+ color[0] = average;
+}
+
+bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newInput;
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
new file mode 100644
index 00000000000..2848f260cbd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#ifndef _COM_KeyingBlurOperation_h
+#define _COM_KeyingBlurOperation_h
+
+#include "COM_NodeOperation.h"
+
+/**
+ * Class with implementation of bluring for keying node
+ */
+class KeyingBlurOperation : public NodeOperation {
+protected:
+ int size;
+
+public:
+ KeyingBlurOperation();
+
+ void setSize(float value) {this->size = value;}
+
+ void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
new file mode 100644
index 00000000000..2c9949f2b4b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingClipOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+KeyingClipOperation::KeyingClipOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+
+ this->kernelRadius = 3;
+ this->kernelTolerance = 0.1f;
+
+ this->clipBlack = 0.0f;
+ this->clipWhite = 1.0f;
+
+ this->isEdgeMatte = false;
+
+ this->setComplex(true);
+}
+
+void *KeyingClipOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+ void *buffer = getInputOperation(0)->initializeTileData(rect, memoryBuffers);
+
+ return buffer;
+}
+
+void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+ const int delta = this->kernelRadius;
+ const float tolerance = this->kernelTolerance;
+
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+
+ int bufferWidth = inputBuffer->getWidth();
+ int bufferHeight = inputBuffer->getHeight();
+
+ int i, j, count = 0, totalCount = 0;
+
+ float value = buffer[(y * bufferWidth + x) * 4];
+
+ bool ok = false;
+
+ for (i = -delta + 1; i < delta; i++) {
+ for (j = -delta + 1; j < delta; j++) {
+ int cx = x + j, cy = y + i;
+
+ if (i == 0 && j == 0)
+ continue;
+
+ if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) {
+ int bufferIndex = (cy * bufferWidth + cx) * 4;
+ float currentValue = buffer[bufferIndex];
+
+ if (fabsf(currentValue - value) < tolerance) {
+ count++;
+ }
+
+ totalCount++;
+ }
+ }
+ }
+
+ ok = count >= (float) totalCount * 0.9f;
+
+ if (this->isEdgeMatte) {
+ if (ok)
+ color[0] = 0.0f;
+ else
+ color[0] = 1.0f;
+ }
+ else {
+ color[0] = value;
+
+ if (ok) {
+ if (color[0] < this->clipBlack)
+ color[0] = 0.0f;
+ else if (color[0] >= this->clipWhite)
+ color[0] = 1.0f;
+ else
+ color[0] = (color[0] - this->clipBlack) / (this->clipWhite - this->clipBlack);
+ }
+ }
+}
+
+bool KeyingClipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newInput;
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h
new file mode 100644
index 00000000000..9c7b23b0160
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#ifndef _COM_KeyingClipOperation_h
+#define _COM_KeyingClipOperation_h
+
+#include "COM_NodeOperation.h"
+
+/**
+ * Class with implementation of black/white clipping for keying node
+ */
+class KeyingClipOperation : public NodeOperation {
+protected:
+ float clipBlack;
+ float clipWhite;
+
+ int kernelRadius;
+ float kernelTolerance;
+
+ bool isEdgeMatte;
+public:
+ KeyingClipOperation();
+
+ void setClipBlack(float value) {this->clipBlack = value;}
+ void setClipWhite(float value) {this->clipWhite = value;}
+
+ void setKernelRadius(int value) {this->kernelRadius = value;}
+ void setKernelTolerance(float value) {this->kernelTolerance = value;}
+
+ void setIsEdgeMatte(bool value) {this->isEdgeMatte = value;}
+
+ void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
new file mode 100644
index 00000000000..04523384653
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingDespillOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+static int get_pixel_primary_channel(float *pixel)
+{
+ float max_value = MAX3(pixel[0], pixel[1], pixel[2]);
+
+ if (max_value == pixel[0])
+ return 0;
+ else if (max_value == pixel[1])
+ return 1;
+
+ return 2;
+}
+
+KeyingDespillOperation::KeyingDespillOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->despillFactor = 0.5f;
+
+ this->pixelReader = NULL;
+ this->screenReader = NULL;
+}
+
+void KeyingDespillOperation::initExecution()
+{
+ this->pixelReader = this->getInputSocketReader(0);
+ this->screenReader = this->getInputSocketReader(1);
+}
+
+void KeyingDespillOperation::deinitExecution()
+{
+ this->pixelReader = NULL;
+ this->screenReader = NULL;
+}
+
+void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+{
+ float pixelColor[4];
+ float screenColor[4];
+
+ this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers);
+ this->screenReader->read(screenColor, x, y, sampler, inputBuffers);
+
+ int screen_primary_channel = get_pixel_primary_channel(screenColor);
+ float average_value, amount;
+
+ average_value = (pixelColor[0] + pixelColor[1] + pixelColor[2] - pixelColor[screen_primary_channel]) / 2.0f;
+ amount = pixelColor[screen_primary_channel] - average_value;
+
+ color[0] = pixelColor[0];
+ color[1] = pixelColor[1];
+ color[2] = pixelColor[2];
+ color[3] = pixelColor[3];
+
+ if (this->despillFactor * amount > 0) {
+ color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->despillFactor * amount;
+ }
+}
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
new file mode 100644
index 00000000000..92a1415a1f0
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#ifndef _COM_KeyingDespillOperation_h
+#define _COM_KeyingDespillOperation_h
+
+#include "COM_NodeOperation.h"
+
+/**
+ * Class with implementation of keying despill node
+ */
+class KeyingDespillOperation : public NodeOperation {
+protected:
+ SocketReader *pixelReader;
+ SocketReader *screenReader;
+ float despillFactor;
+
+public:
+ KeyingDespillOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ void setDespillFactor(float value) {this->despillFactor = value;}
+
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp
new file mode 100644
index 00000000000..0a450cc3bf8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+static int get_pixel_primary_channel(float pixelColor[4])
+{
+ float max_value = MAX3(pixelColor[0], pixelColor[1], pixelColor[2]);
+
+ if (max_value == pixelColor[0])
+ return 0;
+ else if (max_value == pixelColor[1])
+ return 1;
+
+ return 2;
+}
+
+static float get_pixel_saturation(float pixelColor[4], float screen_balance, int primary_channel)
+{
+ int other_1 = (primary_channel + 1) % 3;
+ int other_2 = (primary_channel + 2) % 3;
+
+ float min = MIN2(pixelColor[other_1], pixelColor[other_2]);
+ float max = MAX2(pixelColor[other_1], pixelColor[other_2]);
+ float val = screen_balance * min + (1.0f - screen_balance) * max;
+
+ return (pixelColor[primary_channel] - val) * fabsf(1.0f - val);
+}
+
+KeyingOperation::KeyingOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+
+ this->screenBalance = 0.5f;
+
+ this->pixelReader = NULL;
+ this->screenReader = NULL;
+ this->garbageReader = NULL;
+ this->coreReader = NULL;
+}
+
+void KeyingOperation::initExecution()
+{
+ this->pixelReader = this->getInputSocketReader(0);
+ this->screenReader = this->getInputSocketReader(1);
+ this->garbageReader = this->getInputSocketReader(2);
+ this->coreReader = this->getInputSocketReader(3);
+}
+
+void KeyingOperation::deinitExecution()
+{
+ this->pixelReader = NULL;
+ this->screenReader = NULL;
+ this->garbageReader = NULL;
+ this->coreReader = NULL;
+}
+
+void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+{
+ float pixelColor[4];
+ float screenColor[4];
+ float garbageValue[4];
+ float coreValue[4];
+
+ this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers);
+ this->screenReader->read(screenColor, x, y, sampler, inputBuffers);
+ this->garbageReader->read(garbageValue, x, y, sampler, inputBuffers);
+ this->coreReader->read(coreValue, x, y, sampler, inputBuffers);
+
+ int primary_channel = get_pixel_primary_channel(screenColor);
+
+ float saturation = get_pixel_saturation(pixelColor, this->screenBalance, primary_channel);
+ float screen_saturation = get_pixel_saturation(screenColor, this->screenBalance, primary_channel);
+
+ if (saturation < 0) {
+ color[0] = 1.0f;
+ }
+ else if (saturation >= screen_saturation) {
+ color[0] = 0.0f;
+ }
+ else {
+ float distance = 1.0f - saturation / screen_saturation;
+
+ color[0] = distance;
+ }
+
+ color[0] *= (1.0f - garbageValue[0]);
+
+ color[0] = MAX2(color[0], coreValue[0]);
+}
+
+bool KeyingOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newInput;
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h
new file mode 100644
index 00000000000..8d0e7851ee5
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+
+#ifndef _COM_KeyingOperation_h
+#define _COM_KeyingOperation_h
+
+#include <string.h>
+
+#include "COM_NodeOperation.h"
+
+#include "BLI_listbase.h"
+
+/**
+ * Class with implementation of keying node
+ */
+class KeyingOperation : public NodeOperation {
+protected:
+ SocketReader *pixelReader;
+ SocketReader *screenReader;
+ SocketReader *garbageReader;
+ SocketReader *coreReader;
+
+ float screenBalance;
+
+public:
+ KeyingOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ void setScreenBalance(float value) {this->screenBalance = value;}
+
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
new file mode 100644
index 00000000000..b728f6c5cca
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingScreenOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_math_color.h"
+
+#include "DNA_scene_types.h"
+
+extern "C" {
+ #include "BKE_movieclip.h"
+ #include "BKE_tracking.h"
+
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+KeyingScreenOperation::KeyingScreenOperation() : NodeOperation()
+{
+ this->addOutputSocket(COM_DT_COLOR);
+ this->movieClip = NULL;
+ this->framenumber = 0;
+ this->trackingObject[0] = 0;
+ setComplex(true);
+}
+
+void KeyingScreenOperation::initExecution()
+{
+ initMutex();
+ this->cachedTriangulation = NULL;
+}
+
+void KeyingScreenOperation::deinitExecution()
+{
+ if (this->cachedTriangulation) {
+ TriangulationData *triangulation = cachedTriangulation;
+
+ if (triangulation->triangulated_points)
+ MEM_freeN(triangulation->triangulated_points);
+
+ if (triangulation->triangles)
+ MEM_freeN(triangulation->triangles);
+
+ MEM_freeN(this->cachedTriangulation);
+
+ this->cachedTriangulation = NULL;
+ }
+}
+
+KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTriangulation()
+{
+ MovieClipUser user = {0};
+ TriangulationData *triangulation;
+ MovieTracking *tracking = &movieClip->tracking;
+ MovieTrackingTrack *track;
+ VoronoiSite *sites;
+ ImBuf *ibuf;
+ ListBase *tracksbase;
+ ListBase edges = {NULL, NULL};
+ int sites_total;
+ int i;
+ int width = this->getWidth();
+ int height = this->getHeight();
+
+ if (this->trackingObject[0]) {
+ MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->trackingObject);
+
+ if (!object)
+ return NULL;
+
+ tracksbase = BKE_tracking_object_get_tracks(tracking, object);
+ }
+ else
+ tracksbase = BKE_tracking_get_active_tracks(tracking);
+
+ sites_total = BLI_countlist(tracksbase);
+
+ if (!sites_total)
+ return NULL;
+
+ BKE_movieclip_user_set_frame(&user, framenumber);
+ ibuf = BKE_movieclip_get_ibuf(movieClip, &user);
+
+ if (!ibuf)
+ return NULL;
+
+ triangulation = (TriangulationData *) MEM_callocN(sizeof(TriangulationData), "keying screen triangulation data");
+
+ sites = (VoronoiSite *) MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites");
+ track = (MovieTrackingTrack *) tracksbase->first;
+ i = 0;
+ while (track) {
+ VoronoiSite *site = &sites[i];
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenumber);
+ ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
+ int j;
+
+ zero_v3(site->color);
+ for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
+ if (pattern_ibuf->rect_float) {
+ add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
+ }
+ else {
+ unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
+
+ site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
+ site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
+ site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ }
+ }
+
+ mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
+ IMB_freeImBuf(pattern_ibuf);
+
+ site->co[0] = marker->pos[0] * width;
+ site->co[1] = marker->pos[1] * height;
+
+ track = track->next;
+ i++;
+ }
+
+ IMB_freeImBuf(ibuf);
+
+ BLI_voronoi_compute(sites, sites_total, width, height, &edges);
+
+ BLI_voronoi_triangulate(sites, sites_total, &edges, width, height,
+ &triangulation->triangulated_points, &triangulation->triangulated_points_total,
+ &triangulation->triangles, &triangulation->triangles_total);
+
+ MEM_freeN(sites);
+ BLI_freelistN(&edges);
+
+ return triangulation;
+}
+
+void *KeyingScreenOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+ if (this->movieClip == NULL)
+ return NULL;
+
+ if (this->cachedTriangulation)
+ return this->cachedTriangulation;
+
+ lockMutex();
+ if (this->cachedTriangulation == NULL) {
+ this->cachedTriangulation = buildVoronoiTriangulation();
+ }
+ unlockMutex();
+
+ return this->cachedTriangulation;
+}
+
+void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
+ resolution[0] = 0;
+ resolution[1] = 0;
+
+ if (this->movieClip) {
+ MovieClipUser user = {0};
+ int width, height;
+
+ BKE_movieclip_user_set_frame(&user, framenumber);
+ BKE_movieclip_get_size(this->movieClip, &user, &width, &height);
+
+ resolution[0] = width;
+ resolution[1] = height;
+ }
+}
+
+void KeyingScreenOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 1.0f;
+
+ if (this->movieClip && data) {
+ TriangulationData *triangulation = (TriangulationData *) data;
+ int i;
+ for (i = 0; i < triangulation->triangles_total; i++) {
+ int *triangle = triangulation->triangles[i];
+ VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]],
+ *b = &triangulation->triangulated_points[triangle[1]],
+ *c = &triangulation->triangulated_points[triangle[2]];
+ float co[2] = {(float) x, (float) y}, w[3];
+
+ if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) {
+ if (barycentric_inside_triangle_v2(w)) {
+ color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2];
+ color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2];
+ color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2];
+ }
+ }
+ }
+ }
+}
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.h b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
new file mode 100644
index 00000000000..9d3f44f6be2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+
+#ifndef _COM_KeyingScreenOperation_h
+#define _COM_KeyingScreenOperation_h
+
+#include <string.h>
+
+#include "COM_NodeOperation.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_movieclip_types.h"
+
+#include "BLI_listbase.h"
+
+extern "C" {
+ #include "BLI_voronoi.h"
+}
+
+/**
+ * Class with implementation of green screen gradient rasterization
+ */
+class KeyingScreenOperation : public NodeOperation {
+protected:
+ typedef struct TriangulationData {
+ VoronoiTriangulationPoint *triangulated_points;
+ int (*triangles)[3];
+ int triangulated_points_total, triangles_total;
+ } TriangulationData;
+
+ MovieClip *movieClip;
+ int framenumber;
+ TriangulationData *cachedTriangulation;
+ char trackingObject[64];
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ TriangulationData *buildVoronoiTriangulation();
+
+ public:
+ KeyingScreenOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ void setMovieClip(MovieClip *clip) {this->movieClip = clip;}
+ void setTrackingObject(char *object) {strncpy(this->trackingObject, object, sizeof(this->trackingObject));}
+ void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+
+ void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
index f206bf4df8e..6e8aa9461e6 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_LuminanceMatteOperation.h"
#include "BLI_math.h"
-LuminanceMatteOperation::LuminanceMatteOperation(): NodeOperation()
+LuminanceMatteOperation::LuminanceMatteOperation() : NodeOperation()
{
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
@@ -44,26 +44,26 @@ void LuminanceMatteOperation::executePixel(float *outputValue, float x, float y,
{
float inColor[4];
- const float high=this->settings->t1;
- const float low=this->settings->t2;
+ const float high = this->settings->t1;
+ const float low = this->settings->t2;
float alpha;
this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers);
/* one line thread-friend algorithm:
- outputValue[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low))))
- */
+ * outputValue[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low))))
+ */
/* test range*/
if (inColor[0] > high) {
- alpha=1.f;
+ alpha = 1.f;
}
else if (inColor[0] < low) {
- alpha=0.f;
+ alpha = 0.f;
}
- else {/*blend */
- alpha=(inColor[0]-low)/(high-low);
+ else { /*blend */
+ alpha = (inColor[0] - low) / (high - low);
}
@@ -72,12 +72,12 @@ void LuminanceMatteOperation::executePixel(float *outputValue, float x, float y,
*/
/* don't make something that was more transparent less transparent */
- if (alpha<inColor[3]) {
- outputValue[0]=alpha;
+ if (alpha < inColor[3]) {
+ outputValue[0] = alpha;
}
else {
- /* leave now it was before */
- outputValue[0]=inColor[3];
+ /* leave now it was before */
+ outputValue[0] = inColor[3];
}
}
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
index 1c2cd2dca51..f44e32396a3 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
@@ -25,27 +25,27 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class LuminanceMatteOperation : public NodeOperation {
private:
NodeChroma *settings;
SocketReader *inputImageProgram;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
LuminanceMatteOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) {this->settings = nodeChroma;}
+ void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index 035f5584065..b29dcfab194 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_MapUVOperation.h"
#include "BLI_math.h"
-MapUVOperation::MapUVOperation(): NodeOperation()
+MapUVOperation::MapUVOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VECTOR);
@@ -44,7 +44,7 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s
{
float inputUV[4];
float uv_a[4], uv_b[4];
- float u,v;
+ float u, v;
float dx, dy;
float uv_l, uv_r;
@@ -52,48 +52,45 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s
this->inputUVProgram->read(inputUV, x, y, sampler, inputBuffers);
if (inputUV[2] == 0.f) {
- color[0] = 0.f;
- color[1] = 0.f;
- color[2] = 0.f;
- color[3] = 0.f;
- return;
+ zero_v4(color);
+ return;
}
/* adaptive sampling, red (U) channel */
- this->inputUVProgram->read(uv_a, x-1, y, COM_PS_NEAREST, inputBuffers);
- this->inputUVProgram->read(uv_b, x+1, y, COM_PS_NEAREST, inputBuffers);
- uv_l = uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
- uv_r = uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
+ this->inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST, inputBuffers);
+ uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f;
dx = 0.5f * (uv_l + uv_r);
/* adaptive sampling, green (V) channel */
- this->inputUVProgram->read(uv_a, x, y-1, COM_PS_NEAREST, inputBuffers);
- this->inputUVProgram->read(uv_b, x, y+1, COM_PS_NEAREST, inputBuffers);
- uv_u = uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
- uv_d = uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+ this->inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST, inputBuffers);
+ uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d = uv_b[2] != 0.f ? fabsf(inputUV[1] - uv_b[1]) : 0.f;
dy = 0.5f * (uv_u + uv_d);
/* more adaptive sampling, red and green (UV) channels */
- this->inputUVProgram->read(uv_a, x-1, y-1, COM_PS_NEAREST, inputBuffers);
- this->inputUVProgram->read(uv_b, x-1, y+1, COM_PS_NEAREST, inputBuffers);
- uv_l = uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
- uv_r = uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
- uv_u = uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
- uv_d = uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
-
- dx+= 0.25f * (uv_l + uv_r);
- dy+= 0.25f * (uv_u + uv_d);
-
- this->inputUVProgram->read(uv_a, x+1, y-1, COM_PS_NEAREST, inputBuffers);
- this->inputUVProgram->read(uv_b, x+1, y+1, COM_PS_NEAREST, inputBuffers);
- uv_l = uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
- uv_r = uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
- uv_u = uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
- uv_d = uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
-
- dx+= 0.25f * (uv_l + uv_r);
- dy+= 0.25f * (uv_u + uv_d);
+ this->inputUVProgram->read(uv_a, x - 1, y - 1, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x - 1, y + 1, COM_PS_NEAREST, inputBuffers);
+ uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f;
+ uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d = uv_b[2] != 0.f ? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+
+ dx += 0.25f * (uv_l + uv_r);
+ dy += 0.25f * (uv_u + uv_d);
+
+ this->inputUVProgram->read(uv_a, x + 1, y - 1, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x + 1, y + 1, COM_PS_NEAREST, inputBuffers);
+ uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f;
+ uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d = uv_b[2] != 0.f ? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+
+ dx += 0.25f * (uv_l + uv_r);
+ dy += 0.25f * (uv_u + uv_d);
/* UV to alpha threshold */
const float threshold = this->alpha * 0.05f;
@@ -114,10 +111,7 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s
/* "premul" */
if (alpha < 1.0f) {
- color[0]*= alpha;
- color[1]*= alpha;
- color[2]*= alpha;
- color[3]*= alpha;
+ mul_v4_fl(color, alpha);
}
}
@@ -131,7 +125,7 @@ bool MapUVOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe
{
rcti colorInput;
rcti uvInput;
- NodeOperation *operation=NULL;
+ NodeOperation *operation = NULL;
/* the uv buffer only needs a 3x3 buffer. The image needs whole buffer */
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h
index 4d7bc814dc2..22e3531e838 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.h
+++ b/source/blender/compositor/operations/COM_MapUVOperation.h
@@ -38,14 +38,14 @@ public:
MapUVOperation();
/**
- * we need a 3x3 differential filter for UV Input and full buffer for the image
- */
+ * we need a 3x3 differential filter for UV Input and full buffer for the image
+ */
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
/**
* the inner loop of this program
*/
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
index bf6d29c0456..6d7804dd6e3 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_MapValueOperation.h"
-MapValueOperation::MapValueOperation(): NodeOperation()
+MapValueOperation::MapValueOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -39,12 +39,12 @@ void MapValueOperation::executePixel(float *outputValue, float x, float y, Pixel
float src[4];
inputOperation->read(src, x, y, sampler, inputBuffers);
TexMapping *texmap = this->settings;
- float value = (src[0] + texmap->loc[0])*texmap->size[0];
+ float value = (src[0] + texmap->loc[0]) * texmap->size[0];
if (texmap->flag & TEXMAP_CLIP_MIN)
- if (value<texmap->min[0])
+ if (value < texmap->min[0])
value = texmap->min[0];
if (texmap->flag & TEXMAP_CLIP_MAX)
- if (value>texmap->max[0])
+ if (value > texmap->max[0])
value = texmap->max[0];
outputValue[0] = value;
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h
index ac320256fe4..5fae74e0a6a 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.h
+++ b/source/blender/compositor/operations/COM_MapValueOperation.h
@@ -26,41 +26,41 @@
#include "DNA_texture_types.h"
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MapValueOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputOperation;
- TexMapping * settings;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputOperation;
+ TexMapping *settings;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MapValueOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
/**
- * @brief set the TexMapping settings
- */
- void setSettings(TexMapping *settings) {this->settings = settings;}
+ * @brief set the TexMapping settings
+ */
+ void setSettings(TexMapping *settings) { this->settings = settings; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index a7c1de323f1..0493bdee12c 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -32,12 +32,12 @@
extern "C" {
#include "BKE_mask.h"
+ #include "../../../../intern/raskter/raskter.h"
}
-MaskOperation::MaskOperation(): NodeOperation()
+MaskOperation::MaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
this->mask = NULL;
this->maskWidth = 0;
this->maskHeight = 0;
@@ -68,19 +68,21 @@ void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers
if (!this->mask)
return NULL;
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (this->rasterizedMask == NULL) {
int width = this->getWidth();
int height = this->getHeight();
float *buffer;
buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask");
- BKE_mask_rasterize(mask, width, height, buffer, TRUE, TRUE);
+ BKE_mask_rasterize(mask, width, height, buffer, TRUE, this->smooth);
+ if (this->smooth) {
+ PLX_antialias_buffer(buffer, width, height);
+ }
this->rasterizedMask = buffer;
}
- BLI_mutex_unlock(getMutex());
-
+ unlockMutex();
return this->rasterizedMask;
}
@@ -105,20 +107,12 @@ void MaskOperation::determineResolution(unsigned int resolution[], unsigned int
void MaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
if (!data) {
- color[0] = 0;
- color[1] = 0;
- color[2] = 0;
- color[3] = 1.0f;
+ color[0] = 0.0f;
}
else {
- float *buffer = (float*) data;
+ float *buffer = (float *) data;
int index = (y * this->getWidth() + x);
color[0] = buffer[index];
- color[1] = buffer[index];
- color[2] = buffer[index];
- color[3] = 1.0f;
}
}
-
-
diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h
index 9f2c7f53f56..8507cb994c0 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.h
+++ b/source/blender/compositor/operations/COM_MaskOperation.h
@@ -32,19 +32,20 @@
#include "IMB_imbuf_types.h"
/**
- * Class with implementation of mask rasterization
- */
+ * Class with implementation of mask rasterization
+ */
class MaskOperation : public NodeOperation {
protected:
Mask *mask;
int maskWidth;
int maskHeight;
int framenumber;
+ bool smooth;
float *rasterizedMask;
/**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
public:
@@ -55,10 +56,11 @@ public:
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
- void setMask(Mask *mask) {this->mask = mask;}
- void setMaskWidth(int width) {this->maskWidth = width;}
- void setMaskHeight(int height) {this->maskHeight = height;}
- void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+ void setMask(Mask *mask) { this->mask = mask; }
+ void setMaskWidth(int width) { this->maskWidth = width; }
+ void setMaskHeight(int height) { this->maskHeight = height; }
+ void setFramenumber(int framenumber) { this->framenumber = framenumber; }
+ void setSmooth(bool smooth) { this->smooth = smooth; }
void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
};
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index b943ec88fde..5e9fb70b206 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -25,7 +25,7 @@ extern "C" {
#include "BLI_math.h"
}
-MathBaseOperation::MathBaseOperation(): NodeOperation()
+MathBaseOperation::MathBaseOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
@@ -50,14 +50,15 @@ void MathBaseOperation::deinitExecution()
void MathBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
InputSocket *socket;
- unsigned int tempPreferredResolution[] = {0,0};
+ unsigned int tempPreferredResolution[] = {0, 0};
unsigned int tempResolution[2];
socket = this->getInputSocket(0);
socket->determineResolution(tempResolution, tempPreferredResolution);
if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
this->setResolutionInputSocketIndex(0);
- } else {
+ }
+ else {
this->setResolutionInputSocketIndex(1);
}
NodeOperation::determineResolution(resolution, preferredResolution);
@@ -104,7 +105,7 @@ void MathDivideOperation::executePixel(float *outputValue, float x, float y, Pix
inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
- if (inputValue2[0]==0) /* We don't want to divide by zero. */
+ if (inputValue2[0] == 0) /* We don't want to divide by zero. */
outputValue[0] = 0.0;
else
outputValue[0] = inputValue1[0] / inputValue2[0];
@@ -151,7 +152,7 @@ void MathArcSineOperation::executePixel(float *outputValue, float x, float y, Pi
inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
- if (inputValue1[0] <= 1 && inputValue1[0] >= -1 )
+ if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
outputValue[0] = asin(inputValue1[0]);
else
outputValue[0] = 0.0;
@@ -165,7 +166,7 @@ void MathArcCosineOperation::executePixel(float *outputValue, float x, float y,
inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
- if (inputValue1[0] <= 1 && inputValue1[0] >= -1 )
+ if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
outputValue[0] = acos(inputValue1[0]);
else
outputValue[0] = 0.0;
@@ -260,7 +261,7 @@ void MathLessThanOperation::executePixel(float *outputValue, float x, float y, P
inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
- outputValue[0] = inputValue1[0]<inputValue2[0]?1.0f:0.0f;
+ outputValue[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f;
}
void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -271,7 +272,7 @@ void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y
inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
- outputValue[0] = inputValue1[0]>inputValue2[0]?1.0f:0.0f;
+ outputValue[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
}
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index 64e8c4af88f..12dc5fa36c7 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -26,129 +26,129 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MathBaseOperation : public NodeOperation {
protected:
/**
- * Prefetched reference to the inputProgram
- */
- SocketReader * inputValue1Operation;
- SocketReader * inputValue2Operation;
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader *inputValue1Operation;
+ SocketReader *inputValue2Operation;
protected:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MathBaseOperation();
public:
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) = 0;
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]) = 0;
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
/**
- * Determine resolution
- */
+ * Determine resolution
+ */
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
};
-class MathAddOperation: public MathBaseOperation {
+class MathAddOperation : public MathBaseOperation {
public:
MathAddOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathSubtractOperation: public MathBaseOperation {
+class MathSubtractOperation : public MathBaseOperation {
public:
MathSubtractOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathMultiplyOperation: public MathBaseOperation {
+class MathMultiplyOperation : public MathBaseOperation {
public:
MathMultiplyOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathDivideOperation: public MathBaseOperation {
+class MathDivideOperation : public MathBaseOperation {
public:
MathDivideOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathSineOperation: public MathBaseOperation {
+class MathSineOperation : public MathBaseOperation {
public:
MathSineOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathCosineOperation: public MathBaseOperation {
+class MathCosineOperation : public MathBaseOperation {
public:
MathCosineOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathTangentOperation: public MathBaseOperation {
+class MathTangentOperation : public MathBaseOperation {
public:
MathTangentOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathArcSineOperation: public MathBaseOperation {
+class MathArcSineOperation : public MathBaseOperation {
public:
MathArcSineOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathArcCosineOperation: public MathBaseOperation {
+class MathArcCosineOperation : public MathBaseOperation {
public:
MathArcCosineOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathArcTangentOperation: public MathBaseOperation {
+class MathArcTangentOperation : public MathBaseOperation {
public:
MathArcTangentOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathPowerOperation: public MathBaseOperation {
+class MathPowerOperation : public MathBaseOperation {
public:
MathPowerOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathLogarithmOperation: public MathBaseOperation {
+class MathLogarithmOperation : public MathBaseOperation {
public:
MathLogarithmOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathMinimumOperation: public MathBaseOperation {
+class MathMinimumOperation : public MathBaseOperation {
public:
MathMinimumOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathMaximumOperation: public MathBaseOperation {
+class MathMaximumOperation : public MathBaseOperation {
public:
MathMaximumOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathRoundOperation: public MathBaseOperation {
+class MathRoundOperation : public MathBaseOperation {
public:
MathRoundOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathLessThanOperation: public MathBaseOperation {
+class MathLessThanOperation : public MathBaseOperation {
public:
MathLessThanOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MathGreaterThanOperation: public MathBaseOperation {
+class MathGreaterThanOperation : public MathBaseOperation {
public:
MathGreaterThanOperation() : MathBaseOperation() {}
- void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixAddOperation.cpp b/source/blender/compositor/operations/COM_MixAddOperation.cpp
index a4f601ae9e6..bd9538a5600 100644
--- a/source/blender/compositor/operations/COM_MixAddOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixAddOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixAddOperation.h"
-MixAddOperation::MixAddOperation(): MixBaseOperation()
+MixAddOperation::MixAddOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixAddOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -41,9 +42,9 @@ void MixAddOperation::executePixel(float *outputValue, float x, float y, PixelSa
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}
- outputValue[0] = inputColor1[0]+value*inputColor2[0];
- outputValue[1] = inputColor1[1]+value*inputColor2[1];
- outputValue[2] = inputColor1[2]+value*inputColor2[2];
+ outputValue[0] = inputColor1[0] + value * inputColor2[0];
+ outputValue[1] = inputColor1[1] + value * inputColor2[1];
+ outputValue[2] = inputColor1[2] + value * inputColor2[2];
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixAddOperation.h b/source/blender/compositor/operations/COM_MixAddOperation.h
index 99a6af67d7d..7b03802cf7e 100644
--- a/source/blender/compositor/operations/COM_MixAddOperation.h
+++ b/source/blender/compositor/operations/COM_MixAddOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixAddOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixAddOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.cpp b/source/blender/compositor/operations/COM_MixBaseOperation.cpp
index 49ae67a06f7..0efab2942b0 100644
--- a/source/blender/compositor/operations/COM_MixBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixBaseOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_MixBaseOperation.h"
-MixBaseOperation::MixBaseOperation(): NodeOperation()
+MixBaseOperation::MixBaseOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -55,9 +55,9 @@ void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelS
value *= inputColor2[3];
}
float valuem = 1.0f - value;
- outputColor[0] = valuem*(inputColor1[0])+value*(inputColor2[0]);
- outputColor[1] = valuem*(inputColor1[1])+value*(inputColor2[1]);
- outputColor[2] = valuem*(inputColor1[2])+value*(inputColor2[2]);
+ outputColor[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]);
+ outputColor[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]);
+ outputColor[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]);
outputColor[3] = inputColor1[3];
}
@@ -71,7 +71,7 @@ void MixBaseOperation::deinitExecution()
void MixBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
InputSocket *socket;
- unsigned int tempPreferredResolution[] = {0,0};
+ unsigned int tempPreferredResolution[] = {0, 0};
unsigned int tempResolution[2];
socket = this->getInputSocket(1);
diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h
index b9bb94d58d8..3637cc9eacf 100644
--- a/source/blender/compositor/operations/COM_MixBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MixBaseOperation.h
@@ -26,42 +26,42 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixBaseOperation : public NodeOperation {
protected:
/**
- * Prefetched reference to the inputProgram
- */
+ * Prefetched reference to the inputProgram
+ */
SocketReader *inputValueOperation;
SocketReader *inputColor1Operation;
SocketReader *inputColor2Operation;
bool valueAlphaMultiply;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixBaseOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- void setUseValueAlphaMultiply(const bool value) {this->valueAlphaMultiply = value;}
- bool useValueAlphaMultiply() {return this->valueAlphaMultiply;}
+ void setUseValueAlphaMultiply(const bool value) { this->valueAlphaMultiply = value; }
+ bool useValueAlphaMultiply() { return this->valueAlphaMultiply; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.cpp b/source/blender/compositor/operations/COM_MixBlendOperation.cpp
index 579f15bcc27..f010d23ce60 100644
--- a/source/blender/compositor/operations/COM_MixBlendOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixBlendOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixBlendOperation.h"
-MixBlendOperation::MixBlendOperation(): MixBaseOperation()
+MixBlendOperation::MixBlendOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixBlendOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -42,8 +43,8 @@ void MixBlendOperation::executePixel(float *outputValue, float x, float y, Pixel
value *= inputColor2[3];
}
float valuem = 1.0f - value;
- outputValue[0] = valuem*(inputColor1[0])+value*(inputColor2[0]);
- outputValue[1] = valuem*(inputColor1[1])+value*(inputColor2[1]);
- outputValue[2] = valuem*(inputColor1[2])+value*(inputColor2[2]);
+ outputValue[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]);
+ outputValue[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]);
+ outputValue[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]);
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.h b/source/blender/compositor/operations/COM_MixBlendOperation.h
index da3342c0e4a..b906134f5cb 100644
--- a/source/blender/compositor/operations/COM_MixBlendOperation.h
+++ b/source/blender/compositor/operations/COM_MixBlendOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixBlendOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixBlendOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.cpp b/source/blender/compositor/operations/COM_MixBurnOperation.cpp
index 7cad107c5e9..e94834148e8 100644
--- a/source/blender/compositor/operations/COM_MixBurnOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixBurnOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixBurnOperation.h"
-MixBurnOperation::MixBurnOperation(): MixBaseOperation()
+MixBurnOperation::MixBurnOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -42,7 +43,7 @@ void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelS
}
float valuem = 1.0f - value;
- tmp = valuem + value*inputColor2[0];
+ tmp = valuem + value * inputColor2[0];
if (tmp <= 0.0f)
outputValue[0] = 0.0f;
else {
@@ -55,7 +56,7 @@ void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelS
outputValue[0] = tmp;
}
- tmp = valuem + value*inputColor2[1];
+ tmp = valuem + value * inputColor2[1];
if (tmp <= 0.0f)
outputValue[1] = 0.0f;
else {
@@ -68,7 +69,7 @@ void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelS
outputValue[1] = tmp;
}
- tmp = valuem + value*inputColor2[2];
+ tmp = valuem + value * inputColor2[2];
if (tmp <= 0.0f)
outputValue[2] = 0.0f;
else {
diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.h b/source/blender/compositor/operations/COM_MixBurnOperation.h
index ff7de119605..af09772edde 100644
--- a/source/blender/compositor/operations/COM_MixBurnOperation.h
+++ b/source/blender/compositor/operations/COM_MixBurnOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixBurnOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixBurnOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixColorOperation.cpp b/source/blender/compositor/operations/COM_MixColorOperation.cpp
index e14b10b305e..f3e893bc18f 100644
--- a/source/blender/compositor/operations/COM_MixColorOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixColorOperation.cpp
@@ -26,8 +26,9 @@ extern "C" {
#include "BLI_math.h"
}
-MixColorOperation::MixColorOperation(): MixBaseOperation()
+MixColorOperation::MixColorOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -45,16 +46,16 @@ void MixColorOperation::executePixel(float *outputValue, float x, float y, Pixel
}
float valuem = 1.0f - value;
- float colH,colS,colV;
+ float colH, colS, colV;
rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- if (colS!=0.0f) {
- float rH,rS,rV;
- float tmpr,tmpg,tmpb;
+ if (colS != 0.0f) {
+ float rH, rS, rV;
+ float tmpr, tmpg, tmpb;
rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
- hsv_to_rgb(colH , colS, rV, &tmpr, &tmpg, &tmpb);
- outputValue[0] = valuem*(inputColor1[0]) + value*tmpr;
- outputValue[1] = valuem*(inputColor1[1]) + value*tmpg;
- outputValue[2] = valuem*(inputColor1[2]) + value*tmpb;
+ hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb);
+ outputValue[0] = valuem * (inputColor1[0]) + value * tmpr;
+ outputValue[1] = valuem * (inputColor1[1]) + value * tmpg;
+ outputValue[2] = valuem * (inputColor1[2]) + value * tmpb;
}
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixColorOperation.h b/source/blender/compositor/operations/COM_MixColorOperation.h
index 1a98e847ccd..9b0d93f934d 100644
--- a/source/blender/compositor/operations/COM_MixColorOperation.h
+++ b/source/blender/compositor/operations/COM_MixColorOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixColorOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixColorOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp
index 666db9d8f32..a36c663ddda 100644
--- a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixDarkenOperation.h"
-MixDarkenOperation::MixDarkenOperation(): MixBaseOperation()
+MixDarkenOperation::MixDarkenOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixDarkenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -41,13 +42,13 @@ void MixDarkenOperation::executePixel(float *outputValue, float x, float y, Pixe
}
float valuem = 1.0f - value;
float tmp;
- tmp=inputColor2[0]+((1.0f-inputColor2[0])*valuem);
+ tmp = inputColor2[0] + ((1.0f - inputColor2[0]) * valuem);
if (tmp < inputColor1[0]) outputValue[0] = tmp;
else outputValue[0] = inputColor1[0];
- tmp=inputColor2[1]+((1.0f-inputColor2[1])*valuem);
+ tmp = inputColor2[1] + ((1.0f - inputColor2[1]) * valuem);
if (tmp < inputColor1[1]) outputValue[1] = tmp;
else outputValue[1] = inputColor1[1];
- tmp=inputColor2[2]+((1.0f-inputColor2[2])*valuem);
+ tmp = inputColor2[2] + ((1.0f - inputColor2[2]) * valuem);
if (tmp < inputColor1[2]) outputValue[2] = tmp;
else outputValue[2] = inputColor1[2];
diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.h b/source/blender/compositor/operations/COM_MixDarkenOperation.h
index b1792d4930e..69fb4450458 100644
--- a/source/blender/compositor/operations/COM_MixDarkenOperation.h
+++ b/source/blender/compositor/operations/COM_MixDarkenOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixDarkenOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixDarkenOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp
index 497bb9c2bb5..69886753480 100644
--- a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp
@@ -23,8 +23,9 @@
#include "COM_MixDifferenceOperation.h"
#include "BLI_math.h"
-MixDifferenceOperation::MixDifferenceOperation(): MixBaseOperation()
+MixDifferenceOperation::MixDifferenceOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixDifferenceOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -41,9 +42,9 @@ void MixDifferenceOperation::executePixel(float *outputValue, float x, float y,
value *= inputColor2[3];
}
float valuem = 1.0f - value;
- outputValue[0] = valuem*inputColor1[0] + value*fabsf(inputColor1[0]-inputColor2[0]);
- outputValue[1] = valuem*inputColor1[1] + value*fabsf(inputColor1[1]-inputColor2[1]);
- outputValue[2] = valuem*inputColor1[2] + value*fabsf(inputColor1[2]-inputColor2[2]);
+ outputValue[0] = valuem * inputColor1[0] + value *fabsf(inputColor1[0] - inputColor2[0]);
+ outputValue[1] = valuem * inputColor1[1] + value *fabsf(inputColor1[1] - inputColor2[1]);
+ outputValue[2] = valuem * inputColor1[2] + value *fabsf(inputColor1[2] - inputColor2[2]);
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.h b/source/blender/compositor/operations/COM_MixDifferenceOperation.h
index 554d7b2f1fe..c71b22214cc 100644
--- a/source/blender/compositor/operations/COM_MixDifferenceOperation.h
+++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixDifferenceOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixDifferenceOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.cpp b/source/blender/compositor/operations/COM_MixDivideOperation.cpp
index c522fcf225a..8b6586c5336 100644
--- a/source/blender/compositor/operations/COM_MixDivideOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixDivideOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixDivideOperation.h"
-MixDivideOperation::MixDivideOperation(): MixBaseOperation()
+MixDivideOperation::MixDivideOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixDivideOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -42,15 +43,15 @@ void MixDivideOperation::executePixel(float *outputValue, float x, float y, Pixe
float valuem = 1.0f - value;
if (inputColor2[0] != 0.0f)
- outputValue[0] = valuem*(inputColor1[0]) + value*(inputColor1[0])/inputColor2[0];
+ outputValue[0] = valuem * (inputColor1[0]) + value * (inputColor1[0]) / inputColor2[0];
else
outputValue[0] = 0.0f;
if (inputColor2[1] != 0.0f)
- outputValue[1] = valuem*(inputColor1[1]) + value*(inputColor1[1])/inputColor2[1];
+ outputValue[1] = valuem * (inputColor1[1]) + value * (inputColor1[1]) / inputColor2[1];
else
outputValue[1] = 0.0f;
if (inputColor2[2] != 0.0f)
- outputValue[2] = valuem*(inputColor1[2]) + value*(inputColor1[2])/inputColor2[2];
+ outputValue[2] = valuem * (inputColor1[2]) + value * (inputColor1[2]) / inputColor2[2];
else
outputValue[2] = 0.0f;
diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.h b/source/blender/compositor/operations/COM_MixDivideOperation.h
index e9c4cf81cd3..375e7129e8b 100644
--- a/source/blender/compositor/operations/COM_MixDivideOperation.h
+++ b/source/blender/compositor/operations/COM_MixDivideOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixDivideOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixDivideOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp
index 10c04ba376b..971ddd5b736 100644
--- a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixDodgeOperation.h"
-MixDodgeOperation::MixDodgeOperation(): MixBaseOperation()
+MixDodgeOperation::MixDodgeOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixDodgeOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -42,7 +43,7 @@ void MixDodgeOperation::executePixel(float *outputValue, float x, float y, Pixel
}
if (inputColor1[0] != 0.0f) {
- tmp = 1.0f - value*inputColor2[0];
+ tmp = 1.0f - value * inputColor2[0];
if (tmp <= 0.0f)
outputValue[0] = 1.0f;
else {
@@ -57,7 +58,7 @@ void MixDodgeOperation::executePixel(float *outputValue, float x, float y, Pixel
outputValue[0] = 0.0f;
if (inputColor1[1] != 0.0f) {
- tmp = 1.0f - value*inputColor2[1];
+ tmp = 1.0f - value * inputColor2[1];
if (tmp <= 0.0f)
outputValue[1] = 1.0f;
else {
@@ -72,7 +73,7 @@ void MixDodgeOperation::executePixel(float *outputValue, float x, float y, Pixel
outputValue[1] = 0.0f;
if (inputColor1[2] != 0.0f) {
- tmp = 1.0f - value*inputColor2[2];
+ tmp = 1.0f - value * inputColor2[2];
if (tmp <= 0.0f)
outputValue[2] = 1.0f;
else {
diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.h b/source/blender/compositor/operations/COM_MixDodgeOperation.h
index 6baa73e8f6f..a4adf6fde47 100644
--- a/source/blender/compositor/operations/COM_MixDodgeOperation.h
+++ b/source/blender/compositor/operations/COM_MixDodgeOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixDodgeOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixDodgeOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.cpp b/source/blender/compositor/operations/COM_MixGlareOperation.cpp
new file mode 100644
index 00000000000..bfb0efe692f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixGlareOperation.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Glareer Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixGlareOperation.h"
+
+MixGlareOperation::MixGlareOperation() : MixBaseOperation()
+{
+ /* pass */
+}
+
+void MixGlareOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+{
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+ float value;
+
+ inputValueOperation->read(inputValue, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers);
+ inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers);
+ value = inputValue[0];
+ float mf = 2.f - 2.f * fabsf(value - 0.5f);
+
+ outputValue[0] = mf * ((inputColor1[0]) + value * (inputColor2[0] - inputColor1[0]));
+ outputValue[1] = mf * ((inputColor1[1]) + value * (inputColor2[1] - inputColor1[1]));
+ outputValue[2] = mf * ((inputColor1[2]) + value * (inputColor2[2] - inputColor1[2]));
+ outputValue[3] = inputColor1[3];
+}
diff --git a/source/blender/compositor/operations/COM_FogGlowImageOperation.h b/source/blender/compositor/operations/COM_MixGlareOperation.h
index d0fc107638e..1a025eb3edd 100644
--- a/source/blender/compositor/operations/COM_FogGlowImageOperation.h
+++ b/source/blender/compositor/operations/COM_MixGlareOperation.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Blender Foundation.
+ * Copyright 2011, Glareer Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -20,20 +20,26 @@
* Monique Dewanchand
*/
-#ifndef _COM_FogGlowOperation_h
-#define _COM_FogGlowOperation_h
-#include "COM_NodeOperation.h"
-#include "DNA_lamp_types.h"
+#ifndef _COM_MixGlareOperation_h
+#define _COM_MixGlareOperation_h
+#include "COM_MixBaseOperation.h"
-class FogGlowImageOperation : public NodeOperation {
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixGlareOperation : public MixBaseOperation {
public:
- FogGlowImageOperation();
-
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * Default constructor
+ */
+ MixGlareOperation();
- void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
+
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixHueOperation.cpp b/source/blender/compositor/operations/COM_MixHueOperation.cpp
index de376f3500c..05d02805ebc 100644
--- a/source/blender/compositor/operations/COM_MixHueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixHueOperation.cpp
@@ -26,8 +26,9 @@ extern "C" {
#include "BLI_math.h"
}
-MixHueOperation::MixHueOperation(): MixBaseOperation()
+MixHueOperation::MixHueOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixHueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -45,16 +46,16 @@ void MixHueOperation::executePixel(float *outputValue, float x, float y, PixelSa
}
float valuem = 1.0f - value;
- float colH,colS,colV;
+ float colH, colS, colV;
rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- if (colS!=0.0f) {
- float rH,rS,rV;
- float tmpr,tmpg,tmpb;
+ if (colS != 0.0f) {
+ float rH, rS, rV;
+ float tmpr, tmpg, tmpb;
rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
- hsv_to_rgb(colH , rS, rV, &tmpr, &tmpg, &tmpb);
- outputValue[0] = valuem*(inputColor1[0]) + value*tmpr;
- outputValue[1] = valuem*(inputColor1[1]) + value*tmpg;
- outputValue[2] = valuem*(inputColor1[2]) + value*tmpb;
+ hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb);
+ outputValue[0] = valuem * (inputColor1[0]) + value * tmpr;
+ outputValue[1] = valuem * (inputColor1[1]) + value * tmpg;
+ outputValue[2] = valuem * (inputColor1[2]) + value * tmpb;
}
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixHueOperation.h b/source/blender/compositor/operations/COM_MixHueOperation.h
index d3d1717f448..56310e253c0 100644
--- a/source/blender/compositor/operations/COM_MixHueOperation.h
+++ b/source/blender/compositor/operations/COM_MixHueOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixHueOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixHueOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.cpp b/source/blender/compositor/operations/COM_MixLightenOperation.cpp
index bc3e5090bd8..6e1af7a3c44 100644
--- a/source/blender/compositor/operations/COM_MixLightenOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixLightenOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixLightenOperation.h"
-MixLightenOperation::MixLightenOperation(): MixBaseOperation()
+MixLightenOperation::MixLightenOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixLightenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -40,13 +41,13 @@ void MixLightenOperation::executePixel(float *outputValue, float x, float y, Pix
value *= inputColor2[3];
}
float tmp;
- tmp=value * inputColor2[0];
+ tmp = value * inputColor2[0];
if (tmp > inputColor1[0]) outputValue[0] = tmp;
else outputValue[0] = inputColor1[0];
- tmp=value * inputColor2[1];
+ tmp = value * inputColor2[1];
if (tmp > inputColor1[1]) outputValue[1] = tmp;
else outputValue[1] = inputColor1[1];
- tmp=value * inputColor2[2];
+ tmp = value * inputColor2[2];
if (tmp > inputColor1[2]) outputValue[2] = tmp;
else outputValue[2] = inputColor1[2];
outputValue[3] = inputColor1[3];
diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.h b/source/blender/compositor/operations/COM_MixLightenOperation.h
index 73ac3e6e165..bb251a44653 100644
--- a/source/blender/compositor/operations/COM_MixLightenOperation.h
+++ b/source/blender/compositor/operations/COM_MixLightenOperation.h
@@ -26,19 +26,19 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixLightenOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixLightenOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp
index b68064f0e47..bf1c181b566 100644
--- a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixLinearLightOperation.h"
-MixLinearLightOperation::MixLinearLightOperation(): MixBaseOperation()
+MixLinearLightOperation::MixLinearLightOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixLinearLightOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -40,17 +41,17 @@ void MixLinearLightOperation::executePixel(float *outputValue, float x, float y,
value *= inputColor2[3];
}
if (inputColor2[0] > 0.5f)
- outputValue[0] = inputColor1[0] + value*(2.0f*(inputColor2[0]-0.5f));
+ outputValue[0] = inputColor1[0] + value * (2.0f * (inputColor2[0] - 0.5f));
else
- outputValue[0] = inputColor1[0] + value*(2.0f*(inputColor2[0]) - 1.0f);
+ outputValue[0] = inputColor1[0] + value * (2.0f * (inputColor2[0]) - 1.0f);
if (inputColor2[1] > 0.5f)
- outputValue[1] = inputColor1[1] + value*(2.0f*(inputColor2[1]-0.5f));
+ outputValue[1] = inputColor1[1] + value * (2.0f * (inputColor2[1] - 0.5f));
else
- outputValue[1] = inputColor1[1] + value*(2.0f*(inputColor2[1]) - 1.0f);
+ outputValue[1] = inputColor1[1] + value * (2.0f * (inputColor2[1]) - 1.0f);
if (inputColor2[2] > 0.5f)
- outputValue[2] = inputColor1[2] + value*(2.0f*(inputColor2[2]-0.5f));
+ outputValue[2] = inputColor1[2] + value * (2.0f * (inputColor2[2] - 0.5f));
else
- outputValue[2] = inputColor1[2] + value*(2.0f*(inputColor2[2]) - 1.0f);
+ outputValue[2] = inputColor1[2] + value * (2.0f * (inputColor2[2]) - 1.0f);
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.h b/source/blender/compositor/operations/COM_MixLinearLightOperation.h
index 7e26b25e5c0..39d5b6495d1 100644
--- a/source/blender/compositor/operations/COM_MixLinearLightOperation.h
+++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixLinearLightOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixLinearLightOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp
index fdf8c1ca51b..62018ed5698 100644
--- a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixMultiplyOperation.h"
-MixMultiplyOperation::MixMultiplyOperation(): MixBaseOperation()
+MixMultiplyOperation::MixMultiplyOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixMultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -41,9 +42,9 @@ void MixMultiplyOperation::executePixel(float *outputValue, float x, float y, Pi
value *= inputColor2[3];
}
float valuem = 1.0f - value;
- outputValue[0] = inputColor1[0] *(valuem+value*inputColor2[0]);
- outputValue[1] = inputColor1[1] *(valuem+value*inputColor2[1]);
- outputValue[2] = inputColor1[2] *(valuem+value*inputColor2[2]);
+ outputValue[0] = inputColor1[0] * (valuem + value * inputColor2[0]);
+ outputValue[1] = inputColor1[1] * (valuem + value * inputColor2[1]);
+ outputValue[2] = inputColor1[2] * (valuem + value * inputColor2[2]);
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.h b/source/blender/compositor/operations/COM_MixMultiplyOperation.h
index 5d4468e7271..2c12854bfa6 100644
--- a/source/blender/compositor/operations/COM_MixMultiplyOperation.h
+++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixMultiplyOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixMultiplyOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp
index 0025daeb3f5..a269045c598 100644
--- a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixOverlayOperation.h"
-MixOverlayOperation::MixOverlayOperation(): MixBaseOperation()
+MixOverlayOperation::MixOverlayOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixOverlayOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -43,22 +44,22 @@ void MixOverlayOperation::executePixel(float *outputValue, float x, float y, Pix
float valuem = 1.0f - value;
if (inputColor1[0] < 0.5f) {
- outputValue[0] = inputColor1[0] * (valuem + 2.0f*value*inputColor2[0]);
+ outputValue[0] = inputColor1[0] * (valuem + 2.0f * value * inputColor2[0]);
}
else {
- outputValue[0] = 1.0f - (valuem + 2.0f*value*(1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
+ outputValue[0] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
}
if (inputColor1[1] < 0.5f) {
- outputValue[1] = inputColor1[1] * (valuem + 2.0f*value*inputColor2[1]);
+ outputValue[1] = inputColor1[1] * (valuem + 2.0f * value * inputColor2[1]);
}
else {
- outputValue[1] = 1.0f - (valuem + 2.0f*value*(1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
+ outputValue[1] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
}
if (inputColor1[2] < 0.5f) {
- outputValue[2] = inputColor1[2] * (valuem + 2.0f*value*inputColor2[2]);
+ outputValue[2] = inputColor1[2] * (valuem + 2.0f * value * inputColor2[2]);
}
else {
- outputValue[2] = 1.0f - (valuem + 2.0f*value*(1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
+ outputValue[2] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
}
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.h b/source/blender/compositor/operations/COM_MixOverlayOperation.h
index dd1d16a53d3..48d1d10a697 100644
--- a/source/blender/compositor/operations/COM_MixOverlayOperation.h
+++ b/source/blender/compositor/operations/COM_MixOverlayOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixOverlayOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixOverlayOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp
index f6f6ec73c6e..863a17a7f80 100644
--- a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp
@@ -26,8 +26,9 @@ extern "C" {
#include "BLI_math.h"
}
-MixSaturationOperation::MixSaturationOperation(): MixBaseOperation()
+MixSaturationOperation::MixSaturationOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixSaturationOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -45,12 +46,12 @@ void MixSaturationOperation::executePixel(float *outputValue, float x, float y,
}
float valuem = 1.0f - value;
- float rH,rS,rV;
+ float rH, rS, rV;
rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
- if (rS!=0.0f) {
- float colH,colS,colV;
+ if (rS != 0.0f) {
+ float colH, colS, colV;
rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- hsv_to_rgb(rH , (valuem*rS+value*colS), rV, &outputValue[0], &outputValue[1], &outputValue[2]);
+ hsv_to_rgb(rH, (valuem * rS + value * colS), rV, &outputValue[0], &outputValue[1], &outputValue[2]);
}
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.h b/source/blender/compositor/operations/COM_MixSaturationOperation.h
index 7e746c02e09..ccb95e2f00f 100644
--- a/source/blender/compositor/operations/COM_MixSaturationOperation.h
+++ b/source/blender/compositor/operations/COM_MixSaturationOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixSaturationOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixSaturationOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.cpp b/source/blender/compositor/operations/COM_MixScreenOperation.cpp
index a1a98bd82a2..6fb7befeba4 100644
--- a/source/blender/compositor/operations/COM_MixScreenOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixScreenOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixScreenOperation.h"
-MixScreenOperation::MixScreenOperation(): MixBaseOperation()
+MixScreenOperation::MixScreenOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixScreenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -42,9 +43,9 @@ void MixScreenOperation::executePixel(float *outputValue, float x, float y, Pixe
}
float valuem = 1.0f - value;
- outputValue[0] = 1.0f - (valuem + value*(1.0f-inputColor2[0])) *(1.0f-inputColor1[0]);
- outputValue[1] = 1.0f - (valuem + value*(1.0f-inputColor2[1])) *(1.0f-inputColor1[1]);
- outputValue[2] = 1.0f - (valuem + value*(1.0f-inputColor2[2])) *(1.0f-inputColor1[2]);
+ outputValue[0] = 1.0f - (valuem + value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
+ outputValue[1] = 1.0f - (valuem + value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
+ outputValue[2] = 1.0f - (valuem + value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.h b/source/blender/compositor/operations/COM_MixScreenOperation.h
index 6522907f295..6b9fa302325 100644
--- a/source/blender/compositor/operations/COM_MixScreenOperation.h
+++ b/source/blender/compositor/operations/COM_MixScreenOperation.h
@@ -26,19 +26,19 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixScreenOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixScreenOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp
index ea6a3ddd498..9f7d0823473 100644
--- a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp
@@ -22,12 +22,13 @@
#include "COM_MixSoftLightOperation.h"
-MixSoftLightOperation::MixSoftLightOperation(): MixBaseOperation()
+MixSoftLightOperation::MixSoftLightOperation() : MixBaseOperation()
{
+ /* pass */
}
-void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])\
-{
+void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) \
+ {
float inputColor1[4];
float inputColor2[4];
float value;
@@ -47,9 +48,9 @@ void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, P
scg = 1.0f - (1.0f - inputColor2[1]) * (1.0f - inputColor1[1]);
scb = 1.0f - (1.0f - inputColor2[2]) * (1.0f - inputColor1[2]);
- outputValue[0] = valuem*(inputColor1[0]) + value*(((1.0f - inputColor1[0]) * inputColor2[0] * (inputColor1[0])) + (inputColor1[0] * scr));
- outputValue[1] = valuem*(inputColor1[1]) + value*(((1.0f - inputColor1[1]) * inputColor2[1] * (inputColor1[1])) + (inputColor1[1] * scg));
- outputValue[2] = valuem*(inputColor1[2]) + value*(((1.0f - inputColor1[2]) * inputColor2[2] * (inputColor1[2])) + (inputColor1[2] * scb));
+ outputValue[0] = valuem * (inputColor1[0]) + value * (((1.0f - inputColor1[0]) * inputColor2[0] * (inputColor1[0])) + (inputColor1[0] * scr));
+ outputValue[1] = valuem * (inputColor1[1]) + value * (((1.0f - inputColor1[1]) * inputColor2[1] * (inputColor1[1])) + (inputColor1[1] * scg));
+ outputValue[2] = valuem * (inputColor1[2]) + value * (((1.0f - inputColor1[2]) * inputColor2[2] * (inputColor1[2])) + (inputColor1[2] * scb));
outputValue[3] = inputColor1[3];
-}
+ }
diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.h b/source/blender/compositor/operations/COM_MixSoftLightOperation.h
index fcbd8dab8b8..4189066de2c 100644
--- a/source/blender/compositor/operations/COM_MixSoftLightOperation.h
+++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixSoftLightOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixSoftLightOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp
index 57320dcd611..80086053872 100644
--- a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp
@@ -22,8 +22,9 @@
#include "COM_MixSubtractOperation.h"
-MixSubtractOperation::MixSubtractOperation(): MixBaseOperation()
+MixSubtractOperation::MixSubtractOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixSubtractOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -39,9 +40,9 @@ void MixSubtractOperation::executePixel(float *outputValue, float x, float y, Pi
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}
- outputValue[0] = inputColor1[0]-value*(inputColor2[0]);
- outputValue[1] = inputColor1[1]-value*(inputColor2[1]);
- outputValue[2] = inputColor1[2]-value*(inputColor2[2]);
+ outputValue[0] = inputColor1[0] - value * (inputColor2[0]);
+ outputValue[1] = inputColor1[1] - value * (inputColor2[1]);
+ outputValue[2] = inputColor1[2] - value * (inputColor2[2]);
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.h b/source/blender/compositor/operations/COM_MixSubtractOperation.h
index 441857a8aca..b820fb1e5e1 100644
--- a/source/blender/compositor/operations/COM_MixSubtractOperation.h
+++ b/source/blender/compositor/operations/COM_MixSubtractOperation.h
@@ -26,20 +26,20 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixSubtractOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixSubtractOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixValueOperation.cpp b/source/blender/compositor/operations/COM_MixValueOperation.cpp
index 8c43bb6af8c..cd79c54318d 100644
--- a/source/blender/compositor/operations/COM_MixValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixValueOperation.cpp
@@ -26,8 +26,9 @@ extern "C" {
#include "BLI_math.h"
}
-MixValueOperation::MixValueOperation(): MixBaseOperation()
+MixValueOperation::MixValueOperation() : MixBaseOperation()
{
+ /* pass */
}
void MixValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -45,10 +46,10 @@ void MixValueOperation::executePixel(float *outputValue, float x, float y, Pixel
}
float valuem = 1.0f - value;
- float rH,rS,rV;
- float colH,colS,colV;
+ float rH, rS, rV;
+ float colH, colS, colV;
rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- hsv_to_rgb(rH , rS, (valuem*rV+value*colV), &outputValue[0], &outputValue[1], &outputValue[2]);
+ hsv_to_rgb(rH, rS, (valuem * rV + value * colV), &outputValue[0], &outputValue[1], &outputValue[2]);
outputValue[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_MixValueOperation.h b/source/blender/compositor/operations/COM_MixValueOperation.h
index 89461b3ba40..d12a2d2b3d6 100644
--- a/source/blender/compositor/operations/COM_MixValueOperation.h
+++ b/source/blender/compositor/operations/COM_MixValueOperation.h
@@ -26,19 +26,19 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MixValueOperation : public MixBaseOperation {
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MixValueOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
index a81288be3f7..662212567de 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
@@ -23,8 +23,9 @@
#include "COM_MovieClipAttributeOperation.h"
extern "C" {
#include "BKE_tracking.h"
+ #include "BKE_movieclip.h"
}
-MovieClipAttributeOperation::MovieClipAttributeOperation(): NodeOperation()
+MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_VALUE);
this->valueSet = false;
@@ -41,21 +42,22 @@ void MovieClipAttributeOperation::executePixel(float *outputValue, float x, floa
scale = 1.0f;
angle = 0.0f;
if (clip) {
- BKE_tracking_stabilization_data(&clip->tracking, framenumber, getWidth(), getHeight(), loc, &scale, &angle);
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenumber);
+ BKE_tracking_stabilization_data_get(&clip->tracking, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle);
}
switch (this->attribute) {
- case MCA_SCALE:
- this->value = scale;
- break;
- case MCA_ANGLE:
- this->value = angle;
- break;
- case MCA_X:
- this->value = loc[0];
- break;
- case MCA_Y:
- this->value = loc[1];
- break;
+ case MCA_SCALE:
+ this->value = scale;
+ break;
+ case MCA_ANGLE:
+ this->value = angle;
+ break;
+ case MCA_X:
+ this->value = loc[0];
+ break;
+ case MCA_Y:
+ this->value = loc[1];
+ break;
}
valueSet = true;
}
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
index aca2ec2eff7..b6e89fa345c 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -32,30 +32,30 @@ typedef enum MovieClipAttribute {
MCA_ANGLE
} MovieClipAttribute;
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class MovieClipAttributeOperation : public NodeOperation {
private:
- MovieClip * clip;
+ MovieClip *clip;
float value;
bool valueSet;
int framenumber;
MovieClipAttribute attribute;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
MovieClipAttributeOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- void setMovieClip(MovieClip *clip) {this->clip = clip;}
- void setFramenumber(int framenumber) {this->framenumber = framenumber;}
- void setAttribute(MovieClipAttribute attribute) {this->attribute = attribute;}
+ void setMovieClip(MovieClip *clip) { this->clip = clip; }
+ void setFramenumber(int framenumber) { this->framenumber = framenumber; }
+ void setAttribute(MovieClipAttribute attribute) { this->attribute = attribute; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index 6019ab879be..b8bda12c626 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -31,7 +31,7 @@ extern "C" {
}
#include "BKE_image.h"
-MovieClipOperation::MovieClipOperation(): NodeOperation()
+MovieClipOperation::MovieClipOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_COLOR);
this->movieClip = NULL;
@@ -51,9 +51,9 @@ void MovieClipOperation::initExecution()
ibuf = BKE_movieclip_get_ibuf(this->movieClip, this->movieClipUser);
if (ibuf) {
this->movieClipBuffer = ibuf;
- if (ibuf->rect_float == NULL || ibuf->userflags&IB_RECT_INVALID) {
+ if (ibuf->rect_float == NULL || ibuf->userflags & IB_RECT_INVALID) {
IMB_float_from_rect(ibuf);
- ibuf->userflags&= ~IB_RECT_INVALID;
+ ibuf->userflags &= ~IB_RECT_INVALID;
}
}
}
@@ -93,15 +93,15 @@ void MovieClipOperation::executePixel(float *color, float x, float y, PixelSampl
}
else {
switch (sampler) {
- case COM_PS_NEAREST:
- neareast_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
- break;
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
+ break;
}
}
}
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h
index f52a9973fc5..454c442a167 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.h
@@ -31,10 +31,10 @@
#include "IMB_imbuf_types.h"
/**
- * Base class for all renderlayeroperations
- *
- * @todo: rename to operation.
- */
+ * Base class for all renderlayeroperations
+ *
+ * @todo: rename to operation.
+ */
class MovieClipOperation : public NodeOperation {
protected:
MovieClip *movieClip;
@@ -45,8 +45,8 @@ protected:
int framenumber;
/**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
public:
@@ -54,11 +54,11 @@ public:
void initExecution();
void deinitExecution();
- void setMovieClip(MovieClip *image) {this->movieClip = image;}
- void setMovieClipUser(MovieClipUser *imageuser) {this->movieClipUser = imageuser;}
-
- void setFramenumber(int framenumber) {this->framenumber = framenumber;}
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void setMovieClip(MovieClip *image) { this->movieClip = image; }
+ void setMovieClipUser(MovieClipUser *imageuser) { this->movieClipUser = imageuser; }
+
+ void setFramenumber(int framenumber) { this->framenumber = framenumber; }
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
index ebea9e8b4a2..5320f901747 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
@@ -29,7 +29,7 @@ extern "C" {
}
-vector<DistortionCache*> s_cache;
+vector<DistortionCache *> s_cache;
MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperation()
@@ -52,8 +52,8 @@ void MovieDistortionOperation::initExecution()
BKE_movieclip_user_set_frame(&clipUser, this->framenumber);
BKE_movieclip_get_size(this->movieClip, &clipUser, &calibration_width, &calibration_height);
- for (int i = 0 ; i < s_cache.size() ; i ++) {
- DistortionCache *c = (DistortionCache*)s_cache[i];
+ for (unsigned int i = 0; i < s_cache.size(); i++) {
+ DistortionCache *c = (DistortionCache *)s_cache[i];
if (c->isCacheFor(this->movieClip, this->width, this->height,
calibration_width, calibration_height, this->distortion))
{
@@ -78,7 +78,7 @@ void MovieDistortionOperation::deinitExecution()
}
-void MovieDistortionOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void MovieDistortionOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
if (this->cache != NULL) {
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
index 5792248464a..c2ce04a78e1 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -57,28 +57,28 @@ public:
this->calibration_width = calibration_width;
this->calibration_height = calibration_height;
this->inverted = inverted;
- this->bufferCalculated = new int[this->width*this->height];
- this->buffer = new float[this->width*this->height*2];
- for (int i = 0 ; i < this->width*this->height ; i ++) {
+ this->bufferCalculated = new int[this->width * this->height];
+ this->buffer = new float[this->width * this->height * 2];
+ for (int i = 0; i < this->width * this->height; i++) {
this->bufferCalculated[i] = 0;
}
}
bool isCacheFor(MovieClip *movieclip, int width, int height, int calibration_width, int claibration_height, bool inverted) {
return this->k1 == movieclip->tracking.camera.k1 &&
- this->k2 == movieclip->tracking.camera.k2 &&
- this->k3 == movieclip->tracking.camera.k3 &&
- this->principal_x == movieclip->tracking.camera.principal[0] &&
- this->principal_y == movieclip->tracking.camera.principal[1] &&
- this->pixel_aspect == movieclip->tracking.camera.pixel_aspect &&
- this->inverted == inverted &&
- this->width == width &&
- this->height == height &&
- this->calibration_width == calibration_width &&
- this->calibration_height == calibration_height;
+ this->k2 == movieclip->tracking.camera.k2 &&
+ this->k3 == movieclip->tracking.camera.k3 &&
+ this->principal_x == movieclip->tracking.camera.principal[0] &&
+ this->principal_y == movieclip->tracking.camera.principal[1] &&
+ this->pixel_aspect == movieclip->tracking.camera.pixel_aspect &&
+ this->inverted == inverted &&
+ this->width == width &&
+ this->height == height &&
+ this->calibration_width == calibration_width &&
+ this->calibration_height == calibration_height;
}
- void getUV(MovieTracking *trackingData, int x, int y, float *u, float*v) {
- if (x<0 || x >= this->width || y <0 || y >= this->height) {
+ void getUV(MovieTracking *trackingData, int x, int y, float *u, float *v) {
+ if (x < 0 || x >= this->width || y < 0 || y >= this->height) {
*u = x;
*v = y;
}
@@ -88,8 +88,8 @@ public:
if (!bufferCalculated[offset]) {
//float overscan = 0.0f;
- float w = (float)this->width/* / (1 + overscan) */;
- float h = (float)this->height/* / (1 + overscan) */;
+ float w = (float)this->width /* / (1 + overscan) */;
+ float h = (float)this->height /* / (1 + overscan) */;
float aspx = (float)w / this->calibration_width;
float aspy = (float)h / this->calibration_height;
float in[2];
@@ -99,28 +99,28 @@ public:
in[1] = (y /* - 0.5 * overscan * h */) / aspy / this->pixel_aspect;
if (inverted) {
- BKE_tracking_invert_intrinsics(trackingData, in, out);
+ BKE_tracking_undistort_v2(trackingData, in, out);
}
else {
- BKE_tracking_apply_intrinsics(trackingData, in, out);
+ BKE_tracking_distort_v2(trackingData, in, out);
}
buffer[offset2] = out[0] * aspx /* + 0.5 * overscan * w */;
- buffer[offset2+1] = (out[1] * aspy /* + 0.5 * overscan * h */) * this->pixel_aspect;
+ buffer[offset2 + 1] = (out[1] * aspy /* + 0.5 * overscan * h */) * this->pixel_aspect;
bufferCalculated[offset] = 1;
}
*u = buffer[offset2];
- *v = buffer[offset2+1];
+ *v = buffer[offset2 + 1];
}
}
};
-class MovieDistortionOperation: public NodeOperation {
+class MovieDistortionOperation : public NodeOperation {
private:
DistortionCache *cache;
SocketReader *inputOperation;
- MovieClip * movieClip;
+ MovieClip *movieClip;
protected:
bool distortion;
@@ -129,13 +129,13 @@ protected:
public:
MovieDistortionOperation(bool distortion);
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setMovieClip(MovieClip *clip) {this->movieClip = clip;}
- void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+ void setMovieClip(MovieClip *clip) { this->movieClip = clip; }
+ void setFramenumber(int framenumber) { this->framenumber = framenumber; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index f95dd12a81a..1bd21f6e712 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "IMB_imbuf_types.h"
}
-MultilayerBaseOperation::MultilayerBaseOperation(int pass): BaseImageOperation()
+MultilayerBaseOperation::MultilayerBaseOperation(int pass) : BaseImageOperation()
{
this->passId = pass;
}
@@ -47,7 +47,7 @@ void MultilayerColorOperation::executePixel(float *color, float x, float y, Pixe
{
int yi = y;
int xi = x;
- if (this->imageBuffer == NULL || xi < 0 || yi < 0 || xi >= this->getWidth() || yi >= this->getHeight() ) {
+ if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
color[0] = 0.0f;
color[1] = 0.0f;
color[2] = 0.0f;
@@ -56,22 +56,22 @@ void MultilayerColorOperation::executePixel(float *color, float x, float y, Pixe
else {
if (this->numberOfChannels == 4) {
switch (sampler) {
- case COM_PS_NEAREST:
- neareast_interpolation_color(this->buffer, NULL, color, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(this->buffer, NULL, color, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(this->buffer, NULL, color, x, y);
- break;
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
}
}
else {
- int offset = (yi*this->getWidth()+xi)*3;
+ int offset = (yi * this->getWidth() + xi) * 3;
color[0] = this->imageBuffer[offset];
- color[1] = this->imageBuffer[offset+1];
- color[2] = this->imageBuffer[offset+2];
+ color[1] = this->imageBuffer[offset + 1];
+ color[2] = this->imageBuffer[offset + 2];
}
}
}
@@ -80,11 +80,11 @@ void MultilayerValueOperation::executePixel(float *color, float x, float y, Pixe
{
int yi = y;
int xi = x;
- if (this->imageBuffer == NULL || xi < 0 || yi < 0 || xi >= this->getWidth() || yi >= this->getHeight() ) {
+ if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
color[0] = 0.0f;
}
else {
- float result = this->imageBuffer[yi*this->getWidth()+xi];
+ float result = this->imageBuffer[yi * this->getWidth() + xi];
color[0] = result;
}
}
@@ -93,13 +93,13 @@ void MultilayerVectorOperation::executePixel(float *color, float x, float y, Pix
{
int yi = y;
int xi = x;
- if (this->imageBuffer == NULL || xi < 0 || yi < 0 || xi >= this->getWidth() || yi >= this->getHeight() ) {
+ if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
color[0] = 0.0f;
}
else {
- int offset = (yi*this->getWidth()+xi)*3;
+ int offset = (yi * this->getWidth() + xi) * 3;
color[0] = this->imageBuffer[offset];
- color[1] = this->imageBuffer[offset+1];
- color[2] = this->imageBuffer[offset+2];
+ color[1] = this->imageBuffer[offset + 1];
+ color[2] = this->imageBuffer[offset + 2];
}
}
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
index 809253e532a..c33e65fc55b 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -27,7 +27,7 @@
#include "COM_ImageOperation.h"
-class MultilayerBaseOperation: public BaseImageOperation {
+class MultilayerBaseOperation : public BaseImageOperation {
private:
int passId;
RenderLayer *renderlayer;
@@ -35,34 +35,34 @@ protected:
ImBuf *getImBuf();
public:
/**
- * Constructor
- */
+ * Constructor
+ */
MultilayerBaseOperation(int pass);
- void setRenderLayer(RenderLayer *renderlayer) {this->renderlayer = renderlayer;}
+ void setRenderLayer(RenderLayer *renderlayer) { this->renderlayer = renderlayer; }
};
-class MultilayerColorOperation: public MultilayerBaseOperation {
+class MultilayerColorOperation : public MultilayerBaseOperation {
public:
- MultilayerColorOperation(int pass): MultilayerBaseOperation(pass) {
+ MultilayerColorOperation(int pass) : MultilayerBaseOperation(pass) {
this->addOutputSocket(COM_DT_COLOR);
}
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MultilayerValueOperation: public MultilayerBaseOperation {
+class MultilayerValueOperation : public MultilayerBaseOperation {
public:
- MultilayerValueOperation(int pass): MultilayerBaseOperation(pass) {
+ MultilayerValueOperation(int pass) : MultilayerBaseOperation(pass) {
this->addOutputSocket(COM_DT_VALUE);
}
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class MultilayerVectorOperation: public MultilayerBaseOperation {
+class MultilayerVectorOperation : public MultilayerBaseOperation {
public:
- MultilayerVectorOperation(int pass): MultilayerBaseOperation(pass) {
+ MultilayerVectorOperation(int pass) : MultilayerBaseOperation(pass) {
this->addOutputSocket(COM_DT_VECTOR);
}
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
index d144739f845..6d12141a455 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
@@ -21,7 +21,7 @@
#include "COM_NormalizeOperation.h"
-NormalizeOperation::NormalizeOperation(): NodeOperation()
+NormalizeOperation::NormalizeOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -35,7 +35,7 @@ void NormalizeOperation::initExecution()
NodeOperation::initMutex();
}
-void NormalizeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data)
+void NormalizeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
/* using generic two floats struct to store x: min y: mult */
NodeTwoFloats *minmult = (NodeTwoFloats *)data;
@@ -76,10 +76,9 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe
void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
- BLI_mutex_lock(getMutex());
-
+ lockMutex();
if (this->cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers);
/* using generic two floats struct to store x: min y: mult */
NodeTwoFloats *minmult = new NodeTwoFloats();
@@ -87,28 +86,29 @@ void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu
int p = tile->getWidth() * tile->getHeight();
float *bc = buffer;
- float minv = 1.0f+BLENDER_ZMAX;
- float maxv = -1.0f-BLENDER_ZMAX;
+ float minv = 1.0f + BLENDER_ZMAX;
+ float maxv = -1.0f - BLENDER_ZMAX;
float value;
while (p--) {
- value=bc[0];
+ value = bc[0];
maxv = max(value, maxv);
minv = min(value, minv);
- bc+=4;
+ bc += 4;
}
minmult->x = minv;
/* The rare case of flat buffer would cause a divide by 0 */
- minmult->y = ((maxv!=minv)? 1.0f/(maxv-minv):0.f);
+ minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.f);
this->cachedInstance = minmult;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return this->cachedInstance;
}
void NormalizeOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data)
{
+ /* pass */
}
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.h b/source/blender/compositor/operations/COM_NormalizeOperation.h
index 765b8847384..de1c4d67bba 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.h
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.h
@@ -25,41 +25,41 @@
#include "DNA_node_types.h"
/**
- * @brief base class of normalize, implementing the simple normalize
- * @ingroup operation
- */
+ * @brief base class of normalize, implementing the simple normalize
+ * @ingroup operation
+ */
class NormalizeOperation : public NodeOperation {
protected:
/**
- * @brief Cached reference to the reader
- */
- SocketReader * imageReader;
+ * @brief Cached reference to the reader
+ */
+ SocketReader *imageReader;
/**
- * @brief temporarily cache of the execution storage
- * it stores x->min and y->mult
- */
- NodeTwoFloats * cachedInstance;
+ * @brief temporarily cache of the execution storage
+ * it stores x->min and y->mult
+ */
+ NodeTwoFloats *cachedInstance;
public:
NormalizeOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl
index aeccfcab8b5..0f8e543de7f 100644
--- a/source/blender/compositor/operations/COM_OpenCLKernels.cl
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl
@@ -6,8 +6,8 @@ const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS
__constant const int2 zero = {0,0};
// KERNEL --- BOKEH BLUR ---
-__kernel void bokehBlurKernel(__global __read_only image2d_t boundingBox, __global __read_only image2d_t inputImage,
- __global __read_only image2d_t bokehImage, __global __write_only image2d_t output,
+__kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only image2d_t inputImage,
+ __read_only image2d_t bokehImage, __write_only image2d_t output,
int2 offsetInput, int2 offsetOutput, int radius, int step, int2 dimension, int2 offset)
{
int2 coords = {get_global_id(0), get_global_id(1)};
@@ -50,3 +50,65 @@ __kernel void bokehBlurKernel(__global __read_only image2d_t boundingBox, __glob
write_imagef(output, coords, color);
}
+
+// KERNEL --- DILATE ---
+__kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image2d_t output,
+ int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,
+ int2 offset)
+{
+ int2 coords = {get_global_id(0), get_global_id(1)};
+ coords += offset;
+ const int2 realCoordinate = coords + offsetOutput;
+
+ const int2 minXY = max(realCoordinate - scope, zero);
+ const int2 maxXY = min(realCoordinate + scope, dimension);
+
+ float value = 0.0f;
+ int nx, ny;
+ int2 inputXy;
+
+ for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny ++, inputXy.y++) {
+ const float deltaY = (realCoordinate.y - ny);
+ for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx ++, inputXy.x++) {
+ const float deltaX = (realCoordinate.x - nx);
+ const float measuredDistance = deltaX*deltaX+deltaY*deltaY;
+ if (measuredDistance <= distanceSquared) {
+ value = max(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
+ }
+ }
+ }
+
+ float4 color = {value,0.0f,0.0f,0.0f};
+ write_imagef(output, coords, color);
+}
+
+// KERNEL --- DILATE ---
+__kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2d_t output,
+ int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,
+ int2 offset)
+{
+ int2 coords = {get_global_id(0), get_global_id(1)};
+ coords += offset;
+ const int2 realCoordinate = coords + offsetOutput;
+
+ const int2 minXY = max(realCoordinate - scope, zero);
+ const int2 maxXY = min(realCoordinate + scope, dimension);
+
+ float value = 1.0f;
+ int nx, ny;
+ int2 inputXy;
+
+ for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny ++, inputXy.y++) {
+ for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx ++, inputXy.x++) {
+ const float deltaX = (realCoordinate.x - nx);
+ const float deltaY = (realCoordinate.y - ny);
+ const float measuredDistance = deltaX*deltaX+deltaY*deltaY;
+ if (measuredDistance <= distanceSquared) {
+ value = min(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
+ }
+ }
+ }
+
+ float4 color = {value,0.0f,0.0f,0.0f};
+ write_imagef(output, coords, color);
+}
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h
index 3cf33c75272..ef8668f6f21 100644
--- a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h
@@ -8,8 +8,8 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope
"__constant const int2 zero = {0,0};\n" \
"\n" \
"// KERNEL --- BOKEH BLUR ---\n" \
-"__kernel void bokehBlurKernel(__global __read_only image2d_t boundingBox, __global __read_only image2d_t inputImage,\n" \
-" __global __read_only image2d_t bokehImage, __global __write_only image2d_t output,\n" \
+"__kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only image2d_t inputImage,\n" \
+" __read_only image2d_t bokehImage, __write_only image2d_t output,\n" \
" int2 offsetInput, int2 offsetOutput, int radius, int step, int2 dimension, int2 offset)\n" \
"{\n" \
" int2 coords = {get_global_id(0), get_global_id(1)};\n" \
@@ -26,8 +26,8 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope
" if (tempBoundingBox > 0.0f) {\n" \
" const int2 bokehImageDim = get_image_dim(bokehImage);\n" \
" const int2 bokehImageCenter = bokehImageDim/2;\n" \
-" const int2 minXY = max(realCoordinate - radius, zero);;\n" \
-" const int2 maxXY = min(realCoordinate + radius, dimension);;\n" \
+" const int2 minXY = max(realCoordinate - radius, zero);\n" \
+" const int2 maxXY = min(realCoordinate + radius, dimension);\n" \
" int nx, ny;\n" \
"\n" \
" float2 uv;\n" \
@@ -52,4 +52,66 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope
"\n" \
" write_imagef(output, coords, color);\n" \
"}\n" \
+"\n" \
+"// KERNEL --- DILATE ---\n" \
+"__kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image2d_t output,\n" \
+" int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,\n" \
+" int2 offset)\n" \
+"{\n" \
+" int2 coords = {get_global_id(0), get_global_id(1)};\n" \
+" coords += offset;\n" \
+" const int2 realCoordinate = coords + offsetOutput;\n" \
+"\n" \
+" const int2 minXY = max(realCoordinate - scope, zero);\n" \
+" const int2 maxXY = min(realCoordinate + scope, dimension);\n" \
+"\n" \
+" float value = 0.0f;\n" \
+" int nx, ny;\n" \
+" int2 inputXy;\n" \
+"\n" \
+" for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny ++, inputXy.y++) {\n" \
+" for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx ++, inputXy.x++) {\n" \
+" const float deltaX = (realCoordinate.x - nx);\n" \
+" const float deltaY = (realCoordinate.y - ny);\n" \
+" const float measuredDistance = deltaX*deltaX+deltaY*deltaY;\n" \
+" if (measuredDistance <= distanceSquared) {\n" \
+" value = max(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);\n" \
+" }\n" \
+" }\n" \
+" }\n" \
+"\n" \
+" float4 color = {value,0.0f,0.0f,0.0f};\n" \
+" write_imagef(output, coords, color);\n" \
+"}\n" \
+"\n" \
+"// KERNEL --- DILATE ---\n" \
+"__kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2d_t output,\n" \
+" int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,\n" \
+" int2 offset)\n" \
+"{\n" \
+" int2 coords = {get_global_id(0), get_global_id(1)};\n" \
+" coords += offset;\n" \
+" const int2 realCoordinate = coords + offsetOutput;\n" \
+"\n" \
+" const int2 minXY = max(realCoordinate - scope, zero);\n" \
+" const int2 maxXY = min(realCoordinate + scope, dimension);\n" \
+"\n" \
+" float value = 1.0f;\n" \
+" int nx, ny;\n" \
+" int2 inputXy;\n" \
+"\n" \
+" for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny ++, inputXy.y++) {\n" \
+" for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx ++, inputXy.x++) {\n" \
+" const float deltaX = (realCoordinate.x - nx);\n" \
+" const float deltaY = (realCoordinate.y - ny);\n" \
+" const float measuredDistance = deltaX*deltaX+deltaY*deltaY;\n" \
+" if (measuredDistance <= distanceSquared) {\n" \
+" value = min(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);\n" \
+" }\n" \
+" }\n" \
+" }\n" \
+"\n" \
+" float4 color = {value,0.0f,0.0f,0.0f};\n" \
+" write_imagef(output, coords, color);\n" \
+"}\n" \
"\0";
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index 8d39e987bd4..e71178a811d 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -41,10 +41,10 @@ extern "C" {
static int get_datatype_size(DataType datatype)
{
switch (datatype) {
- case COM_DT_VALUE: return 1;
- case COM_DT_VECTOR: return 3;
- case COM_DT_COLOR: return 4;
- default: return 0;
+ case COM_DT_VALUE: return 1;
+ case COM_DT_VECTOR: return 3;
+ case COM_DT_COLOR: return 4;
+ default: return 0;
}
}
@@ -53,13 +53,13 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data
// When initializing the tree during initial load the width and height can be zero.
if (width != 0 && height != 0) {
int size = get_datatype_size(datatype);
- return (float *)MEM_callocN(width*height*size*sizeof(float), "OutputFile buffer");
+ return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer");
}
else
return NULL;
}
-static void write_buffer_rect(rcti *rect, MemoryBuffer** memoryBuffers, const bNodeTree *tree,
+static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bNodeTree *tree,
SocketReader *reader, float *buffer, unsigned int width, DataType datatype)
{
float color[4];
@@ -70,29 +70,29 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer** memoryBuffers, const bN
int y1 = rect->ymin;
int x2 = rect->xmax;
int y2 = rect->ymax;
- int offset = (y1*width + x1 ) * size;
+ int offset = (y1 * width + x1) * size;
int x;
int y;
bool breaked = false;
- for (y = y1 ; y < y2 && (!breaked); y++) {
- for (x = x1 ; x < x2 && (!breaked) ; x++) {
+ for (y = y1; y < y2 && (!breaked); y++) {
+ for (x = x1; x < x2 && (!breaked); x++) {
reader->read(color, x, y, COM_PS_NEAREST, memoryBuffers);
- for (i=0; i < size; ++i)
- buffer[offset+i] = color[i];
+ for (i = 0; i < size; ++i)
+ buffer[offset + i] = color[i];
offset += size;
if (tree->test_break && tree->test_break(tree->tbh))
breaked = true;
}
- offset += (width-(x2-x1)) * size;
+ offset += (width - (x2 - x1)) * size;
}
}
OutputSingleLayerOperation::OutputSingleLayerOperation(
- const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path)
+ const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path)
{
this->scene = scene;
this->tree = tree;
@@ -113,7 +113,7 @@ void OutputSingleLayerOperation::initExecution()
this->outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->datatype);
}
-void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers)
+void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers)
{
write_buffer_rect(rect, memoryBuffers, this->tree, imageInput, this->outputBuffer, this->getWidth(), this->datatype);
}
@@ -123,7 +123,7 @@ void OutputSingleLayerOperation::deinitExecution()
if (this->getWidth() * this->getHeight() != 0) {
int size = get_datatype_size(this->datatype);
- ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), size*8, 0);
+ ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), size * 8, 0);
Main *bmain = G.main; /* TODO, have this passed along */
char filename[FILE_MAX];
@@ -160,7 +160,7 @@ OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype)
}
OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(
- const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec)
+ const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec)
{
this->scene = scene;
this->tree = tree;
@@ -177,15 +177,15 @@ void OutputOpenExrMultiLayerOperation::add_layer(const char *name, DataType data
void OutputOpenExrMultiLayerOperation::initExecution()
{
- for (int i=0; i < layers.size(); ++i) {
+ for (unsigned int i = 0; i < layers.size(); ++i) {
layers[i].imageInput = getInputSocketReader(i);
layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), layers[i].datatype);
}
}
-void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers)
+void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers)
{
- for (int i=0; i < layers.size(); ++i) {
+ for (unsigned int i = 0; i < layers.size(); ++i) {
write_buffer_rect(rect, memoryBuffers, this->tree, layers[i].imageInput, layers[i].outputBuffer, this->getWidth(), layers[i].datatype);
}
}
@@ -203,39 +203,39 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
(this->scene->r.scemode & R_EXTENSION), true);
BLI_make_existing_file(filename);
- for (int i=0; i < layers.size(); ++i) {
+ for (unsigned int i = 0; i < layers.size(); ++i) {
char channelname[EXR_TOT_MAXNAME];
- BLI_strncpy(channelname, layers[i].name, sizeof(channelname)-2);
+ BLI_strncpy(channelname, layers[i].name, sizeof(channelname) - 2);
char *channelname_ext = channelname + strlen(channelname);
float *buf = layers[i].outputBuffer;
/* create channels */
switch (layers[i].datatype) {
- case COM_DT_VALUE:
- strcpy(channelname_ext, ".V");
- IMB_exr_add_channel(exrhandle, 0, channelname, 1, width, buf);
- break;
- case COM_DT_VECTOR:
- strcpy(channelname_ext, ".X");
- IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3*width, buf);
- strcpy(channelname_ext, ".Y");
- IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3*width, buf+1);
- strcpy(channelname_ext, ".Z");
- IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3*width, buf+2);
- break;
- case COM_DT_COLOR:
- strcpy(channelname_ext, ".R");
- IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf);
- strcpy(channelname_ext, ".G");
- IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf+1);
- strcpy(channelname_ext, ".B");
- IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf+2);
- strcpy(channelname_ext, ".A");
- IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf+3);
- break;
- default:
- break;
+ case COM_DT_VALUE:
+ strcpy(channelname_ext, ".V");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 1, width, buf);
+ break;
+ case COM_DT_VECTOR:
+ strcpy(channelname_ext, ".X");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3 * width, buf);
+ strcpy(channelname_ext, ".Y");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3 * width, buf + 1);
+ strcpy(channelname_ext, ".Z");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3 * width, buf + 2);
+ break;
+ case COM_DT_COLOR:
+ strcpy(channelname_ext, ".R");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4 * width, buf);
+ strcpy(channelname_ext, ".G");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4 * width, buf + 1);
+ strcpy(channelname_ext, ".B");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4 * width, buf + 2);
+ strcpy(channelname_ext, ".A");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4 * width, buf + 3);
+ break;
+ default:
+ break;
}
}
@@ -251,7 +251,7 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
}
IMB_exr_close(exrhandle);
- for (int i=0; i < layers.size(); ++i) {
+ for (unsigned int i = 0; i < layers.size(); ++i) {
if (layers[i].outputBuffer) {
MEM_freeN(layers[i].outputBuffer);
layers[i].outputBuffer = NULL;
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index 9b9fb023467..cfc5f7e41f2 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -45,18 +45,18 @@ private:
public:
OutputSingleLayerOperation(const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path);
- void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
- bool isOutputOperation(bool rendering) const {return true;}
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
+ bool isOutputOperation(bool rendering) const { return true; }
void initExecution();
void deinitExecution();
- const CompositorPriority getRenderPriority() const {return COM_PRIORITY_LOW;}
+ const CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
};
/* extra info for OpenEXR layers */
struct OutputOpenExrLayer {
OutputOpenExrLayer(const char *name, DataType datatype);
- char name[EXR_TOT_MAXNAME-2];
+ char name[EXR_TOT_MAXNAME - 2];
float *outputBuffer;
DataType datatype;
SocketReader *imageInput;
@@ -79,11 +79,11 @@ public:
void add_layer(const char *name, DataType datatype);
- void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
- bool isOutputOperation(bool rendering) const {return true;}
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
+ bool isOutputOperation(bool rendering) const { return true; }
void initExecution();
void deinitExecution();
- const CompositorPriority getRenderPriority() const {return COM_PRIORITY_LOW;}
+ const CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index 4975f13a285..54a95af33b9 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -52,7 +52,7 @@ void PreviewOperation::initExecution()
{
this->input = getInputSocketReader(0);
if (!this->node->preview) {
- this->node->preview = (bNodePreview*)MEM_callocN(sizeof(bNodePreview), "node preview");
+ this->node->preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview");
}
else {
if (this->getWidth() == (unsigned int)this->node->preview->xsize && this->getHeight() == (unsigned int)this->node->preview->ysize) {
@@ -61,9 +61,9 @@ void PreviewOperation::initExecution()
}
if (this->outputBuffer == NULL) {
- this->outputBuffer = (unsigned char*)MEM_callocN(sizeof(unsigned char)*4*getWidth()*getHeight(), "PreviewOperation");
+ this->outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation");
if (this->node->preview->rect) {
- MEM_freeN(this->node->preview->rect);
+ MEM_freeN(this->node->preview->rect);
}
this->node->preview->xsize = getWidth();
this->node->preview->ysize = getHeight();
@@ -81,11 +81,11 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, Memory
{
int offset;
float color[4];
- for (int y = rect->ymin ; y < rect->ymax ; y++) {
- offset = (y * getWidth() + rect->xmin)*4;
- for (int x = rect->xmin ; x < rect->xmax ; x++) {
- float rx = floor(x/divider);
- float ry = floor(y/divider);
+ for (int y = rect->ymin; y < rect->ymax; y++) {
+ offset = (y * getWidth() + rect->xmin) * 4;
+ for (int x = rect->xmin; x < rect->xmax; x++) {
+ float rx = floor(x / divider);
+ float ry = floor(y / divider);
color[0] = 0.0f;
color[1] = 0.0f;
@@ -93,8 +93,8 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, Memory
color[3] = 1.0f;
input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers);
linearrgb_to_srgb_v4(color, color);
- F4TOCHAR4(color, outputBuffer+offset);
- offset +=4;
+ F4TOCHAR4(color, outputBuffer + offset);
+ offset += 4;
}
}
}
@@ -102,10 +102,10 @@ bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferO
{
rcti newInput;
- newInput.xmin = input->xmin/divider;
- newInput.xmax = input->xmax/divider;
- newInput.ymin = input->ymin/divider;
- newInput.ymax = input->ymax/divider;
+ newInput.xmin = input->xmin / divider;
+ newInput.xmax = input->xmax / divider;
+ newInput.ymin = input->ymin / divider;
+ newInput.ymax = input->ymax / divider;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
@@ -116,10 +116,10 @@ void PreviewOperation::determineResolution(unsigned int resolution[], unsigned i
int height = resolution[1];
this->divider = 0.0f;
if (width > height) {
- divider = COM_PREVIEW_SIZE / (width-1);
+ divider = COM_PREVIEW_SIZE / (width - 1);
}
else {
- divider = COM_PREVIEW_SIZE / (height-1);
+ divider = COM_PREVIEW_SIZE / (height - 1);
}
width = width * divider;
height = height * divider;
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index 3d1cd38a5ea..f9ce0c644a1 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -31,24 +31,24 @@ protected:
unsigned char *outputBuffer;
/**
- * @brief holds reference to the SDNA bNode, where this nodes will render the preview image for
- */
+ * @brief holds reference to the SDNA bNode, where this nodes will render the preview image for
+ */
bNode *node;
- const bNodeTree *tree;
SocketReader *input;
float divider;
public:
PreviewOperation();
- bool isOutputOperation(bool rendering) const {return true;}
+ bool isOutputOperation(bool rendering) const { return true; }
void initExecution();
void deinitExecution();
const CompositorPriority getRenderPriority() const;
void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- void setbNode(bNode *node) { this->node = node;}
- void setbNodeTree(const bNodeTree *tree) { this->tree = tree;}
+ void setbNode(bNode *node) { this->node = node; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ bool isPreviewOperation() { return true; }
+
};
#endif
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index 7695e0f63c2..77f2a06b29b 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -24,7 +24,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-ProjectorLensDistortionOperation::ProjectorLensDistortionOperation(): NodeOperation()
+ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -34,7 +34,7 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation(): NodeOperat
void ProjectorLensDistortionOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
- kr = 0.25f*MAX2(MIN2(this->dispersion, 1.f), 0.f);
+ kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
kr2 = kr * 20;
}
@@ -49,14 +49,14 @@ void ProjectorLensDistortionOperation::executePixel(float *color, int x, int y,
float inputValue[4];
const float height = this->getHeight();
const float width = this->getWidth();
- const float v = (y + 0.5f)/height;
- const float u = (x + 0.5f)/width;
- MemoryBuffer * inputBuffer = (MemoryBuffer*)data;
- inputBuffer->readCubic(inputValue, (u*width + kr2) - 0.5f, v*height - 0.5f);
+ const float v = (y + 0.5f) / height;
+ const float u = (x + 0.5f) / width;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ inputBuffer->readCubic(inputValue, (u * width + kr2) - 0.5f, v * height - 0.5f);
color[0] = inputValue[0];
inputBuffer->read(inputValue, x, y);
color[1] = inputValue[1];
- inputBuffer->readCubic(inputValue, (u*width - kr2) - 0.5f, v*height - 0.5f);
+ inputBuffer->readCubic(inputValue, (u * width - kr2) - 0.5f, v * height - 0.5f);
color[2] = inputValue[2];
color[3] = 1.0f;
}
@@ -71,7 +71,7 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *in
rcti newInput;
newInput.ymax = input->ymax;
newInput.ymin = input->ymin;
- newInput.xmin = input->xmin-kr2-2;
- newInput.xmax = input->xmax+kr2+2;
+ newInput.xmin = input->xmin - kr2 - 2;
+ newInput.xmax = input->xmax + kr2 + 2;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
index c8788e100c8..2e188617ab5 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
@@ -28,11 +28,11 @@
class ProjectorLensDistortionOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
- NodeLensDist * data;
+ NodeLensDist *data;
float dispersion;
float kr, kr2;
@@ -40,23 +40,23 @@ public:
ProjectorLensDistortionOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setData(NodeLensDist *data) {this->data = data;}
- void setDispertion(float dispersion) {this->dispersion = dispersion;}
+ void setData(NodeLensDist *data) { this->data = data; }
+ void setDispertion(float dispersion) { this->dispersion = dispersion; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.cpp b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
index f2d700292a4..18b3b106138 100644
--- a/source/blender/compositor/operations/COM_QualityStepHelper.cpp
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
@@ -32,40 +32,40 @@ QualityStepHelper::QualityStepHelper()
void QualityStepHelper::initExecution(QualityHelper helper)
{
switch (helper) {
- case COM_QH_INCREASE:
- switch (this->quality) {
- case COM_QUALITY_HIGH:
- default:
- this->step = 1;
- this->offsetadd = 4;
+ case COM_QH_INCREASE:
+ switch (this->quality) {
+ case COM_QUALITY_HIGH:
+ default:
+ this->step = 1;
+ this->offsetadd = 4;
+ break;
+ case COM_QUALITY_MEDIUM:
+ this->step = 2;
+ this->offsetadd = 8;
+ break;
+ case COM_QUALITY_LOW:
+ this->step = 3;
+ this->offsetadd = 12;
+ break;
+ }
break;
- case COM_QUALITY_MEDIUM:
- this->step = 2;
- this->offsetadd = 8;
+ case COM_QH_MULTIPLY:
+ switch (this->quality) {
+ case COM_QUALITY_HIGH:
+ default:
+ this->step = 1;
+ this->offsetadd = 4;
+ break;
+ case COM_QUALITY_MEDIUM:
+ this->step = 2;
+ this->offsetadd = 8;
+ break;
+ case COM_QUALITY_LOW:
+ this->step = 4;
+ this->offsetadd = 16;
+ break;
+ }
break;
- case COM_QUALITY_LOW:
- this->step = 3;
- this->offsetadd = 12;
- break;
- }
- break;
- case COM_QH_MULTIPLY:
- switch (this->quality) {
- case COM_QUALITY_HIGH:
- default:
- this->step = 1;
- this->offsetadd = 4;
- break;
- case COM_QUALITY_MEDIUM:
- this->step = 2;
- this->offsetadd = 8;
- break;
- case COM_QUALITY_LOW:
- this->step = 4;
- this->offsetadd = 16;
- break;
- }
- break;
}
}
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.h b/source/blender/compositor/operations/COM_QualityStepHelper.h
index 80b25684c5e..aef80e22e38 100644
--- a/source/blender/compositor/operations/COM_QualityStepHelper.h
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.h
@@ -37,17 +37,17 @@ private:
protected:
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution(QualityHelper helper);
- inline int getStep() const {return this->step;}
- inline int getOffsetAdd() const {return this->offsetadd;}
+ inline int getStep() const { return this->step; }
+ inline int getOffsetAdd() const { return this->offsetadd; }
public:
QualityStepHelper();
- void setQuality(CompositorQuality quality) {this->quality = quality;}
+ void setQuality(CompositorQuality quality) { this->quality = quality; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
index d7f95c10cfb..fa1f0280207 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
@@ -24,7 +24,7 @@
#include "COM_WriteBufferOperation.h"
#include "COM_defines.h"
-ReadBufferOperation::ReadBufferOperation():NodeOperation()
+ReadBufferOperation::ReadBufferOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_COLOR);
this->offset = 0;
@@ -38,7 +38,7 @@ void *ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB
void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
if (this->memoryProxy != NULL) {
- WriteBufferOperation * operation = memoryProxy->getWriteBufferOperation();
+ WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation();
operation->determineResolution(resolution, preferredResolution);
operation->setResolution(resolution);
@@ -67,11 +67,19 @@ void ReadBufferOperation::executePixel(float *color, float x, float y, float dx,
}
}
-bool ReadBufferOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output)
+bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- if (this==readOperation) {
+ if (this == readOperation) {
BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax);
return true;
}
return false;
}
+
+void ReadBufferOperation::readResolutionFromWriteBuffer() {
+ if (this->memoryProxy != NULL) {
+ WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation();
+ this->setWidth(operation->getWidth());
+ this->setHeight(operation->getHeight());
+ }
+}
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
index d58d131264b..576aa194bc5 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.h
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -26,26 +26,26 @@
#include "COM_NodeOperation.h"
#include "COM_MemoryProxy.h"
-class ReadBufferOperation: public NodeOperation {
+class ReadBufferOperation : public NodeOperation {
private:
MemoryProxy *memoryProxy;
unsigned int offset;
public:
ReadBufferOperation();
- int isBufferOperation() {return true;}
- void setMemoryProxy(MemoryProxy *memoryProxy) {this->memoryProxy = memoryProxy;}
- MemoryProxy *getMemoryProxy() {return this->memoryProxy;}
+ int isBufferOperation() { return true; }
+ void setMemoryProxy(MemoryProxy *memoryProxy) { this->memoryProxy = memoryProxy; }
+ MemoryProxy *getMemoryProxy() { return this->memoryProxy; }
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
- void executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]);
- const bool isReadBufferOperation() const {return true;}
- void setOffset(unsigned int offset) {this->offset = offset;}
- unsigned int getOffset() {return this->offset;}
- bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output);
- MemoryBuffer *getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return memoryBuffers[offset];}
-
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
+ void executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer * inputBuffers[]);
+ const bool isReadBufferOperation() const { return true; }
+ void setOffset(unsigned int offset) { this->offset = offset; }
+ unsigned int getOffset() { return this->offset; }
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[offset]; }
+ void readResolutionFromWriteBuffer();
};
#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp
index dad082cf0ca..bb165c2fe1c 100644
--- a/source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersAOOperation.h"
-RenderLayersAOOperation::RenderLayersAOOperation() :RenderLayersBaseProg(SCE_PASS_AO, 3)
+RenderLayersAOOperation::RenderLayersAOOperation() : RenderLayersBaseProg(SCE_PASS_AO, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp
index ccb7dd91c04..35f787cb59f 100644
--- a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersAlphaProg.h"
-RenderLayersAlphaProg::RenderLayersAlphaProg() :RenderLayersBaseProg(SCE_PASS_COMBINED, 4)
+RenderLayersAlphaProg::RenderLayersAlphaProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4)
{
this->addOutputSocket(COM_DT_VALUE);
}
@@ -31,7 +31,7 @@ void RenderLayersAlphaProg::executePixel(float *output, float x, float y, PixelS
{
int ix = x;
int iy = y;
- float * inputBuffer = this->getInputBuffer();
+ float *inputBuffer = this->getInputBuffer();
if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) {
output[0] = 0.0f;
@@ -40,8 +40,8 @@ void RenderLayersAlphaProg::executePixel(float *output, float x, float y, PixelS
output[3] = 0.0f;
}
else {
- unsigned int offset = (iy*this->getWidth()+ix) * 4;
- output[0] = inputBuffer[offset+3];
+ unsigned int offset = (iy * this->getWidth() + ix) * 4;
+ output[0] = inputBuffer[offset + 3];
output[1] = 0.0f;
output[2] = 0.0f;
output[3] = 0.0f;
diff --git a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h
index da808f49fdf..846e337c572 100644
--- a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h
@@ -28,7 +28,7 @@
class RenderLayersAlphaProg : public RenderLayersBaseProg {
public:
RenderLayersAlphaProg();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
index 35c8753ded6..f27af3c25f5 100644
--- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
@@ -31,7 +31,7 @@ extern "C" {
#include "RE_render_ext.h"
}
-RenderLayersBaseProg::RenderLayersBaseProg(int renderpass, int elementsize): NodeOperation()
+RenderLayersBaseProg::RenderLayersBaseProg(int renderpass, int elementsize) : NodeOperation()
{
this->renderpass = renderpass;
this->setScene(NULL);
@@ -42,15 +42,15 @@ RenderLayersBaseProg::RenderLayersBaseProg(int renderpass, int elementsize): Nod
void RenderLayersBaseProg::initExecution()
{
- Scene * scene = this->getScene();
- Render *re = (scene)? RE_GetRender(scene->id.name): NULL;
+ Scene *scene = this->getScene();
+ Render *re = (scene) ? RE_GetRender(scene->id.name) : NULL;
RenderResult *rr = NULL;
if (re)
rr = RE_AcquireResultRead(re);
if (rr) {
- SceneRenderLayer *srl = (SceneRenderLayer*)BLI_findlink(&scene->r.layers, getLayerId());
+ SceneRenderLayer *srl = (SceneRenderLayer *)BLI_findlink(&scene->r.layers, getLayerId());
if (srl) {
RenderLayer *rl = RE_GetRenderLayer(rr, srl->name);
@@ -81,7 +81,7 @@ void RenderLayersBaseProg::executePixel(float *output, float x, float y, PixelSa
output[3] = 0.0f;
}
else {
- unsigned int offset = (iy*this->getWidth()+ix) * elementsize;
+ unsigned int offset = (iy * this->getWidth() + ix) * elementsize;
if (elementsize == 1) {
output[0] = inputBuffer[offset];
output[1] = 0.0f;
@@ -90,15 +90,15 @@ void RenderLayersBaseProg::executePixel(float *output, float x, float y, PixelSa
}
else if (elementsize == 3) {
output[0] = inputBuffer[offset];
- output[1] = inputBuffer[offset+1];
- output[2] = inputBuffer[offset+2];
+ output[1] = inputBuffer[offset + 1];
+ output[2] = inputBuffer[offset + 2];
output[3] = 1.0f;
}
else {
output[0] = inputBuffer[offset];
- output[1] = inputBuffer[offset+1];
- output[2] = inputBuffer[offset+2];
- output[3] = inputBuffer[offset+3];
+ output[1] = inputBuffer[offset + 1];
+ output[2] = inputBuffer[offset + 2];
+ output[3] = inputBuffer[offset + 3];
}
}
}
@@ -121,12 +121,12 @@ void RenderLayersBaseProg::determineResolution(unsigned int resolution[], unsign
rr = RE_AcquireResultRead(re);
if (rr) {
- SceneRenderLayer *srl = (SceneRenderLayer*)BLI_findlink(&sce->r.layers, getLayerId());
+ SceneRenderLayer *srl = (SceneRenderLayer *)BLI_findlink(&sce->r.layers, getLayerId());
if (srl) {
RenderLayer *rl = RE_GetRenderLayer(rr, srl->name);
if (rl && rl->rectf) {
- resolution[0]=rl->rectx;
- resolution[1]=rl->recty;
+ resolution[0] = rl->rectx;
+ resolution[1] = rl->recty;
}
}
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
index 64e2496621f..ce2b8f767b6 100644
--- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
@@ -36,64 +36,63 @@ extern "C" {
}
/**
- * Base class for all renderlayeroperations
- *
- * @todo: rename to operation.
- */
+ * Base class for all renderlayeroperations
+ *
+ * @todo: rename to operation.
+ */
class RenderLayersBaseProg : public NodeOperation {
private:
/**
- * Reference to the scene object.
- */
+ * Reference to the scene object.
+ */
Scene *scene;
/**
- * layerId of the layer where this operation needs to get its data from
- */
+ * layerId of the layer where this operation needs to get its data from
+ */
short layerId;
/**
- * cached instance to the float buffer inside the layer
- */
+ * cached instance to the float buffer inside the layer
+ */
float *inputBuffer;
/**
- * renderpass where this operation needs to get its data from
- */
+ * renderpass where this operation needs to get its data from
+ */
int renderpass;
int elementsize;
protected:
/**
- * Constructor
- */
+ * Constructor
+ */
RenderLayersBaseProg(int renderpass, int elementsize);
/**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
/**
- * retrieve the reference to the float buffer of the renderer.
- */
- inline float *getInputBuffer() {return this->inputBuffer;}
+ * retrieve the reference to the float buffer of the renderer.
+ */
+ inline float *getInputBuffer() { return this->inputBuffer; }
public:
/**
- * setter for the scene field. Will be called from
- * @see RenderLayerNode to set the actual scene where
- * the data will be retrieved from.
- */
- void setScene(Scene *scene) {this->scene = scene;}
- Scene *getScene() {return this->scene;}
- void setLayerId(short layerId) {this->layerId = layerId;}
- short getLayerId() {return this->layerId;}
+ * setter for the scene field. Will be called from
+ * @see RenderLayerNode to set the actual scene where
+ * the data will be retrieved from.
+ */
+ void setScene(Scene *scene) { this->scene = scene; }
+ Scene *getScene() { return this->scene; }
+ void setLayerId(short layerId) { this->layerId = layerId; }
+ short getLayerId() { return this->layerId; }
void initExecution();
void deinitExecution();
void executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
-
};
#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp
index aee68afe55d..3083c37c2bb 100644
--- a/source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersColorOperation.h"
-RenderLayersColorOperation::RenderLayersColorOperation() :RenderLayersBaseProg(SCE_PASS_RGBA, 4)
+RenderLayersColorOperation::RenderLayersColorOperation() : RenderLayersBaseProg(SCE_PASS_RGBA, 4)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp
index fc1df884181..b056896994e 100644
--- a/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersCyclesOperation.h"
-RenderLayersCyclesOperation::RenderLayersCyclesOperation(int pass) :RenderLayersBaseProg(pass, 3)
+RenderLayersCyclesOperation::RenderLayersCyclesOperation(int pass) : RenderLayersBaseProg(pass, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp b/source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp
index 985b1c1bee8..ae5fc3b2254 100644
--- a/source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersDepthProg.h"
-RenderLayersDepthProg::RenderLayersDepthProg() :RenderLayersBaseProg(SCE_PASS_Z, 1)
+RenderLayersDepthProg::RenderLayersDepthProg() : RenderLayersBaseProg(SCE_PASS_Z, 1)
{
this->addOutputSocket(COM_DT_VALUE);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp
index ad73490b92d..6baa25e5600 100644
--- a/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersDiffuseOperation.h"
-RenderLayersDiffuseOperation::RenderLayersDiffuseOperation() :RenderLayersBaseProg(SCE_PASS_DIFFUSE, 3)
+RenderLayersDiffuseOperation::RenderLayersDiffuseOperation() : RenderLayersBaseProg(SCE_PASS_DIFFUSE, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp
index 7537e2d10fc..1b03a4e169f 100644
--- a/source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersEmitOperation.h"
-RenderLayersEmitOperation::RenderLayersEmitOperation() :RenderLayersBaseProg(SCE_PASS_EMIT, 3)
+RenderLayersEmitOperation::RenderLayersEmitOperation() : RenderLayersBaseProg(SCE_PASS_EMIT, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp
index 0ace9a7c58f..f4d6dc7353b 100644
--- a/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersEnvironmentOperation.h"
-RenderLayersEnvironmentOperation::RenderLayersEnvironmentOperation() :RenderLayersBaseProg(SCE_PASS_ENVIRONMENT, 3)
+RenderLayersEnvironmentOperation::RenderLayersEnvironmentOperation() : RenderLayersBaseProg(SCE_PASS_ENVIRONMENT, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp
index 264e2f0fd79..14c3d652c42 100644
--- a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersImageProg.h"
-RenderLayersColourProg::RenderLayersColourProg() :RenderLayersBaseProg(SCE_PASS_COMBINED, 4)
+RenderLayersColourProg::RenderLayersColourProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp
index 645f9768eb2..4258cb94a26 100644
--- a/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersIndirectOperation.h"
-RenderLayersIndirectOperation::RenderLayersIndirectOperation() :RenderLayersBaseProg(SCE_PASS_INDIRECT, 3)
+RenderLayersIndirectOperation::RenderLayersIndirectOperation() : RenderLayersBaseProg(SCE_PASS_INDIRECT, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp
index e5cef7753f2..aab7e0089e4 100644
--- a/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersMaterialIndexOperation.h"
-RenderLayersMaterialIndexOperation::RenderLayersMaterialIndexOperation() :RenderLayersBaseProg(SCE_PASS_INDEXMA, 1)
+RenderLayersMaterialIndexOperation::RenderLayersMaterialIndexOperation() : RenderLayersBaseProg(SCE_PASS_INDEXMA, 1)
{
this->addOutputSocket(COM_DT_VALUE);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp
index fae6c73f747..c64ddc6e9d8 100644
--- a/source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersMistOperation.h"
-RenderLayersMistOperation::RenderLayersMistOperation() :RenderLayersBaseProg(SCE_PASS_MIST, 1)
+RenderLayersMistOperation::RenderLayersMistOperation() : RenderLayersBaseProg(SCE_PASS_MIST, 1)
{
this->addOutputSocket(COM_DT_VALUE);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp
index 67ea4d68204..9d8e7d6272c 100644
--- a/source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersNormalOperation.h"
-RenderLayersNormalOperation::RenderLayersNormalOperation() :RenderLayersBaseProg(SCE_PASS_NORMAL, 3)
+RenderLayersNormalOperation::RenderLayersNormalOperation() : RenderLayersBaseProg(SCE_PASS_NORMAL, 3)
{
this->addOutputSocket(COM_DT_VECTOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp
index 821ff447112..430ea698263 100644
--- a/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersObjectIndexOperation.h"
-RenderLayersObjectIndexOperation::RenderLayersObjectIndexOperation() :RenderLayersBaseProg(SCE_PASS_INDEXOB, 1)
+RenderLayersObjectIndexOperation::RenderLayersObjectIndexOperation() : RenderLayersBaseProg(SCE_PASS_INDEXOB, 1)
{
this->addOutputSocket(COM_DT_VALUE);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp
index e53144d3501..1fbd599235b 100644
--- a/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersReflectionOperation.h"
-RenderLayersReflectionOperation::RenderLayersReflectionOperation() :RenderLayersBaseProg(SCE_PASS_REFLECT, 3)
+RenderLayersReflectionOperation::RenderLayersReflectionOperation() : RenderLayersBaseProg(SCE_PASS_REFLECT, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp
index 6e333175220..2ec9be46059 100644
--- a/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersRefractionOperation.h"
-RenderLayersRefractionOperation::RenderLayersRefractionOperation() :RenderLayersBaseProg(SCE_PASS_REFRACT, 3)
+RenderLayersRefractionOperation::RenderLayersRefractionOperation() : RenderLayersBaseProg(SCE_PASS_REFRACT, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp
index ce492d54a79..7582e010e2c 100644
--- a/source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersShadowOperation.h"
-RenderLayersShadowOperation::RenderLayersShadowOperation() :RenderLayersBaseProg(SCE_PASS_SHADOW, 3)
+RenderLayersShadowOperation::RenderLayersShadowOperation() : RenderLayersBaseProg(SCE_PASS_SHADOW, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp
index 7b7d223680c..60c1636dcda 100644
--- a/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersSpecularOperation.h"
-RenderLayersSpecularOperation::RenderLayersSpecularOperation() :RenderLayersBaseProg(SCE_PASS_SPEC, 3)
+RenderLayersSpecularOperation::RenderLayersSpecularOperation() : RenderLayersBaseProg(SCE_PASS_SPEC, 3)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp
index 213d044a9bd..5a0662d13eb 100644
--- a/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersSpeedOperation.h"
-RenderLayersSpeedOperation::RenderLayersSpeedOperation() :RenderLayersBaseProg(SCE_PASS_VECTOR, 4)
+RenderLayersSpeedOperation::RenderLayersSpeedOperation() : RenderLayersBaseProg(SCE_PASS_VECTOR, 4)
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp
index e3917d7796b..b966f98632c 100644
--- a/source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_RenderLayersUVOperation.h"
-RenderLayersUVOperation::RenderLayersUVOperation() :RenderLayersBaseProg(SCE_PASS_UV, 3)
+RenderLayersUVOperation::RenderLayersUVOperation() : RenderLayersBaseProg(SCE_PASS_UV, 3)
{
this->addOutputSocket(COM_DT_VECTOR);
}
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
index af2633f0e53..ac06048faf3 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cpp
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -32,24 +32,14 @@ RotateOperation::RotateOperation() : NodeOperation()
this->imageSocket = NULL;
this->degreeSocket = NULL;
this->doDegree2RadConversion = false;
+ this->isDegreeSet = false;
}
void RotateOperation::initExecution()
{
this->imageSocket = this->getInputSocketReader(0);
this->degreeSocket = this->getInputSocketReader(1);
- this->centerX = this->getWidth()/2.0;
- this->centerY = this->getHeight()/2.0;
- float degree[4];
- this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL);
- double rad;
- if (this->doDegree2RadConversion) {
- rad = DEG2RAD((double)degree[0]);
- }
- else {
- rad = degree[0];
- }
- this->cosine = cos(rad);
- this->sine = sin(rad);
+ this->centerX = this->getWidth() / 2.0;
+ this->centerY = this->getHeight() / 2.0;
}
void RotateOperation::deinitExecution()
@@ -58,18 +48,38 @@ void RotateOperation::deinitExecution()
this->degreeSocket = NULL;
}
+inline void RotateOperation::ensureDegree() {
+ if (!isDegreeSet) {
+ float degree[4];
+ this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL);
+ double rad;
+ if (this->doDegree2RadConversion) {
+ rad = DEG2RAD((double)degree[0]);
+ }
+ else {
+ rad = degree[0];
+ }
+ this->cosine = cos(rad);
+ this->sine = sin(rad);
+
+ isDegreeSet = true;
+ }
+}
+
-void RotateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void RotateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
+ ensureDegree();
const float dy = y - this->centerY;
const float dx = x - this->centerX;
- const float nx = this->centerX+(this->cosine*dx + this->sine*dy);
- const float ny = this->centerY+(-this->sine*dx + this->cosine*dy);
+ const float nx = this->centerX + (this->cosine * dx + this->sine * dy);
+ const float ny = this->centerY + (-this->sine * dx + this->cosine * dy);
this->imageSocket->read(color, nx, ny, sampler, inputBuffers);
}
bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
+ ensureDegree();
rcti newInput;
const float dxmin = input->xmin - this->centerX;
@@ -77,23 +87,23 @@ bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOp
const float dxmax = input->xmax - this->centerX;
const float dymax = input->ymax - this->centerY;
- const float x1 = this->centerX+(this->cosine*dxmin + this->sine*dymin);
- const float x2 = this->centerX+(this->cosine*dxmax + this->sine*dymin);
- const float x3 = this->centerX+(this->cosine*dxmin + this->sine*dymax);
- const float x4 = this->centerX+(this->cosine*dxmax + this->sine*dymax);
- const float y1 = this->centerY+(-this->sine*dxmin + this->cosine*dymin);
- const float y2 = this->centerY+(-this->sine*dxmax + this->cosine*dymin);
- const float y3 = this->centerY+(-this->sine*dxmin + this->cosine*dymax);
- const float y4 = this->centerY+(-this->sine*dxmax + this->cosine*dymax);
+ const float x1 = this->centerX + (this->cosine * dxmin + this->sine * dymin);
+ const float x2 = this->centerX + (this->cosine * dxmax + this->sine * dymin);
+ const float x3 = this->centerX + (this->cosine * dxmin + this->sine * dymax);
+ const float x4 = this->centerX + (this->cosine * dxmax + this->sine * dymax);
+ const float y1 = this->centerY + (-this->sine * dxmin + this->cosine * dymin);
+ const float y2 = this->centerY + (-this->sine * dxmax + this->cosine * dymin);
+ const float y3 = this->centerY + (-this->sine * dxmin + this->cosine * dymax);
+ const float y4 = this->centerY + (-this->sine * dxmax + this->cosine * dymax);
const float minx = min(x1, min(x2, min(x3, x4)));
const float maxx = max(x1, max(x2, max(x3, x4)));
const float miny = min(y1, min(y2, min(y3, y4)));
const float maxy = max(y1, max(y2, max(y3, y4)));
- newInput.xmax = ceil(maxx)+1;
- newInput.xmin = floor(minx)-1;
- newInput.ymax = ceil(maxy)+1;
- newInput.ymin = floor(miny)-1;
+ newInput.xmax = ceil(maxx) + 1;
+ newInput.xmin = floor(minx) - 1;
+ newInput.ymax = ceil(maxy) + 1;
+ newInput.ymin = floor(miny) - 1;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h
index 9965d1021da..bf7355da80e 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.h
+++ b/source/blender/compositor/operations/COM_RotateOperation.h
@@ -25,7 +25,7 @@
#include "COM_NodeOperation.h"
-class RotateOperation: public NodeOperation {
+class RotateOperation : public NodeOperation {
private:
SocketReader *imageSocket;
SocketReader *degreeSocket;
@@ -34,13 +34,16 @@ private:
float cosine;
float sine;
bool doDegree2RadConversion;
+ bool isDegreeSet;
public:
RotateOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setDoDegree2RadConversion(bool abool) {this->doDegree2RadConversion = abool;}
+ void setDoDegree2RadConversion(bool abool) { this->doDegree2RadConversion = abool; }
+
+ void ensureDegree();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index ca2095c3170..2e23df73b67 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -15,13 +15,17 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ScaleOperation.h"
+#define USE_FORCE_BICUBIC
+/* XXX - ignore input and use default from old compositor,
+ * could become an option like the transform node - campbell */
+
ScaleOperation::ScaleOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
@@ -38,8 +42,8 @@ void ScaleOperation::initExecution()
this->inputOperation = this->getInputSocketReader(0);
this->inputXOperation = this->getInputSocketReader(1);
this->inputYOperation = this->getInputSocketReader(2);
- this->centerX = this->getWidth()/2.0;
- this->centerY = this->getHeight()/2.0;
+ this->centerX = this->getWidth() / 2.0;
+ this->centerY = this->getHeight() / 2.0;
}
void ScaleOperation::deinitExecution()
@@ -50,8 +54,12 @@ void ScaleOperation::deinitExecution()
}
-void ScaleOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void ScaleOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
+#ifdef USE_FORCE_BICUBIC
+ sampler = COM_PS_BICUBIC;
+#endif
+
float scaleX[4];
float scaleY[4];
@@ -61,8 +69,8 @@ void ScaleOperation::executePixel(float *color,float x, float y, PixelSampler sa
const float scx = scaleX[0];
const float scy = scaleY[0];
- float nx = this->centerX+ (x - this->centerX) / scx;
- float ny = this->centerY+ (y - this->centerY) / scy;
+ float nx = this->centerX + (x - this->centerX) / scx;
+ float ny = this->centerY + (y - this->centerY) / scy;
this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
}
@@ -71,18 +79,18 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe
rcti newInput;
float scaleX[4];
float scaleY[4];
-
+
this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL);
this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL);
-
+
const float scx = scaleX[0];
const float scy = scaleY[0];
-
- newInput.xmax = this->centerX+ (input->xmax - this->centerX) / scx;
- newInput.xmin = this->centerX+ (input->xmin - this->centerX) / scx;
- newInput.ymax = this->centerY+ (input->ymax - this->centerY) / scy;
- newInput.ymin = this->centerY+ (input->ymin - this->centerY) / scy;
-
+
+ newInput.xmax = this->centerX + (input->xmax - this->centerX) / scx;
+ newInput.xmin = this->centerX + (input->xmin - this->centerX) / scx;
+ newInput.ymax = this->centerY + (input->ymax - this->centerY) / scy;
+ newInput.ymin = this->centerY + (input->ymin - this->centerY) / scy;
+
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
@@ -92,7 +100,7 @@ ScaleAbsoluteOperation::ScaleAbsoluteOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
this->inputOperation = NULL;
@@ -104,8 +112,8 @@ void ScaleAbsoluteOperation::initExecution()
this->inputOperation = this->getInputSocketReader(0);
this->inputXOperation = this->getInputSocketReader(1);
this->inputYOperation = this->getInputSocketReader(2);
- this->centerX = this->getWidth()/2.0;
- this->centerY = this->getHeight()/2.0;
+ this->centerX = this->getWidth() / 2.0;
+ this->centerY = this->getHeight() / 2.0;
}
void ScaleAbsoluteOperation::deinitExecution()
@@ -116,8 +124,12 @@ void ScaleAbsoluteOperation::deinitExecution()
}
-void ScaleAbsoluteOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
+#ifdef USE_FORCE_BICUBIC
+ sampler = COM_PS_BICUBIC;
+#endif
+
float scaleX[4];
float scaleY[4];
@@ -126,14 +138,16 @@ void ScaleAbsoluteOperation::executePixel(float *color,float x, float y, PixelSa
const float scx = scaleX[0]; // target absolute scale
const float scy = scaleY[0]; // target absolute scale
+
const float width = this->getWidth();
const float height = this->getHeight();
//div
- float relativeXScale = scx/width;
- float relativeYScale = scy/height;
+ float relativeXScale = scx / width;
+ float relativeYScale = scy / height;
+
+ float nx = this->centerX + (x - this->centerX) / relativeXScale;
+ float ny = this->centerY + (y - this->centerY) / relativeYScale;
- float nx = this->centerX+ (x - this->centerX) / relativeXScale;
- float ny = this->centerY+ (y - this->centerY) / relativeYScale;
this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
}
@@ -151,13 +165,13 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB
const float width = this->getWidth();
const float height = this->getHeight();
//div
- float relateveXScale = scx/width;
- float relateveYScale = scy/height;
+ float relateveXScale = scx / width;
+ float relateveYScale = scy / height;
- newInput.xmax = this->centerX+ (input->xmax - this->centerX) / relateveXScale;
- newInput.xmin = this->centerX+ (input->xmin - this->centerX) / relateveXScale;
- newInput.ymax = this->centerY+ (input->ymax - this->centerY) / relateveYScale;
- newInput.ymin = this->centerY+ (input->ymin - this->centerY) / relateveYScale;
+ newInput.xmax = this->centerX + (input->xmax - this->centerX) / relateveXScale;
+ newInput.xmin = this->centerX + (input->xmin - this->centerX) / relateveXScale;
+ newInput.ymax = this->centerY + (input->ymax - this->centerY) / relateveYScale;
+ newInput.ymin = this->centerY + (input->ymin - this->centerY) / relateveYScale;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
@@ -176,6 +190,52 @@ void ScaleFixedSizeOperation::initExecution()
this->inputOperation = this->getInputSocketReader(0);
this->relX = inputOperation->getWidth() / (float)this->newWidth;
this->relY = inputOperation->getHeight() / (float)this->newHeight;
+
+
+ /* *** all the options below are for a fairly special case - camera framing *** */
+ if (this->offsetX != 0.0f || this->offsetY != 0.0f) {
+ this->is_offset = true;
+
+ if (this->newWidth > this->newHeight) {
+ this->offsetX *= this->newWidth;
+ this->offsetY *= this->newWidth;
+ }
+ else {
+ this->offsetX *= this->newHeight;
+ this->offsetY *= this->newHeight;
+ }
+ }
+
+ if (this->is_aspect) {
+ /* apply aspect from clip */
+ const float w_src = inputOperation->getWidth();
+ const float h_src = inputOperation->getHeight();
+
+ /* destination aspect is already applied from the camera frame */
+ const float w_dst = this->newWidth;
+ const float h_dst = this->newHeight;
+
+ const float asp_src = w_src / h_src;
+ const float asp_dst = w_dst / h_dst;
+
+ if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
+ if ((asp_src > asp_dst) == (this->is_crop == true)) {
+ /* fit X */
+ const float div = asp_src / asp_dst;
+ this->relX /= div;
+ this->offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
+ }
+ else {
+ /* fit Y */
+ const float div = asp_dst / asp_src;
+ this->relY /= div;
+ this->offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
+ }
+
+ this->is_offset = true;
+ }
+ }
+ /* *** end framing options *** */
}
void ScaleFixedSizeOperation::deinitExecution()
@@ -184,19 +244,30 @@ void ScaleFixedSizeOperation::deinitExecution()
}
-void ScaleFixedSizeOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void ScaleFixedSizeOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
- this->inputOperation->read(color, x*relX, y*relY, sampler, inputBuffers);
+#ifdef USE_FORCE_BICUBIC
+ sampler = COM_PS_BICUBIC;
+#endif
+
+ if (this->is_offset) {
+ float nx = ((x - this->offsetX) * relX);
+ float ny = ((y - this->offsetY) * relY);
+ this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
+ }
+ else {
+ this->inputOperation->read(color, x * relX, y * relY, sampler, inputBuffers);
+ }
}
bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
-
- newInput.xmax = input->xmax *relX;
- newInput.xmin = input->xmin *relX;
- newInput.ymax = input->ymax *relY;
- newInput.ymin = input->ymin *relY;
+
+ newInput.xmax = input->xmax * relX;
+ newInput.xmin = input->xmin * relX;
+ newInput.ymax = input->ymax * relY;
+ newInput.ymin = input->ymin * relY;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index 3e075249fa1..7089f6c10a4 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -25,7 +25,7 @@
#include "COM_NodeOperation.h"
-class ScaleOperation: public NodeOperation {
+class ScaleOperation : public NodeOperation {
private:
SocketReader *inputOperation;
SocketReader *inputXOperation;
@@ -35,43 +35,56 @@ private:
public:
ScaleOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
};
-class ScaleAbsoluteOperation: public NodeOperation {
+class ScaleAbsoluteOperation : public NodeOperation {
SocketReader *inputOperation;
SocketReader *inputXOperation;
SocketReader *inputYOperation;
float centerX;
float centerY;
+
public:
ScaleAbsoluteOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
};
-class ScaleFixedSizeOperation: public NodeOperation {
+class ScaleFixedSizeOperation : public NodeOperation {
SocketReader *inputOperation;
int newWidth;
int newHeight;
float relX;
float relY;
+
+ /* center is only used for aspect correction */
+ float offsetX;
+ float offsetY;
+ bool is_aspect;
+ bool is_crop;
+ /* set from other properties on initialization,
+ * check if we need to apply offset */
+ bool is_offset;
public:
ScaleFixedSizeOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setNewWidth(int width) {this->newWidth = width;}
- void setNewHeight(int height) {this->newHeight = height;}
+ void setNewWidth(int width) { this->newWidth = width; }
+ void setNewHeight(int height) { this->newHeight = height; }
+ void setIsAspect(bool is_aspect) { this->is_aspect = is_aspect; }
+ void setIsCrop(bool is_crop) { this->is_crop = is_crop; }
+ void setOffset(float x, float y) { this->offsetX = x; this->offsetY = y; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index 4442fd9075e..3299434a02e 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "BLI_rand.h"
}
-ScreenLensDistortionOperation::ScreenLensDistortionOperation(): NodeOperation()
+ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -39,19 +39,19 @@ void ScreenLensDistortionOperation::initExecution()
this->inputProgram = this->getInputSocketReader(0);
kg = MAX2(MIN2(this->distortion, 1.f), -0.999f);
// smaller dispersion range for somewhat more control
- const float d = 0.25f*MAX2(MIN2(this->dispersion, 1.f), 0.f);
- kr = MAX2(MIN2((kg+d), 1.f), -0.999f);
- kb = MAX2(MIN2((kg-d), 1.f), -0.999f);
+ const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
+ kr = MAX2(MIN2((kg + d), 1.f), -0.999f);
+ kb = MAX2(MIN2((kg - d), 1.f), -0.999f);
maxk = MAX3(kr, kg, kb);
- sc = (this->data->fit && (maxk > 0.f)) ? (1.f/(1.f + 2.f*maxk)) : (1.f/(1.f + maxk));
- drg = 4.f*(kg - kr);
- dgb = 4.f*(kb - kg);
+ sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk));
+ drg = 4.f * (kg - kr);
+ dgb = 4.f * (kb - kg);
- kr4 = kr*4;
- kg4 = kg*4.f;
- kb4 *= kb*4.f;
- cx = 0.5f*(float)getWidth();
- cy = 0.5f*(float)getHeight();
+ kr4 = kr * 4;
+ kg4 = kg * 4.f;
+ kb4 *= kb * 4.f;
+ cx = 0.5f * (float)getWidth();
+ cy = 0.5f * (float)getHeight();
}
@@ -65,28 +65,28 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int
{
const float height = this->getHeight();
const float width = this->getWidth();
- MemoryBuffer *buffer = (MemoryBuffer*)data;
+ MemoryBuffer *buffer = (MemoryBuffer *)data;
int dr = 0, dg = 0, db = 0;
float d, t, ln[6] = {0, 0, 0, 0, 0, 0};
float tc[4] = {0, 0, 0, 0};
- const float v = sc*((y + 0.5f) - cy)/cy;
- const float u = sc*((x + 0.5f) - cx)/cx;
+ const float v = sc * ((y + 0.5f) - cy) / cy;
+ const float u = sc * ((x + 0.5f) - cx) / cx;
int sta = 0, mid = 0, end = 0;
- if ((t = 1.f - kr4*(u*u + v*v)) >= 0.f) {
- d = 1.f/(1.f + sqrtf(t));
- ln[0] = (u*d + 0.5f)*width - 0.5f, ln[1] = (v*d + 0.5f)*height - 0.5f;
+ if ((t = 1.f - kr4 * (u * u + v * v)) >= 0.f) {
+ d = 1.f / (1.f + sqrtf(t));
+ ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f;
sta = 1;
}
- if ((t = 1.f - kg4*(u*u + v*v)) >= 0.f) {
- d = 1.f/(1.f + sqrtf(t));
- ln[2] = (u*d + 0.5f)*width - 0.5f, ln[3] = (v*d + 0.5f)*height - 0.5f;
+ if ((t = 1.f - kg4 * (u * u + v * v)) >= 0.f) {
+ d = 1.f / (1.f + sqrtf(t));
+ ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f;
mid = 1;
}
- if ((t = 1.f - kb4*(u*u + v*v)) >= 0.f) {
- d = 1.f/(1.f + sqrtf(t));
- ln[4] = (u*d + 0.5f)*width - 0.5f, ln[5] = (v*d + 0.5f)*height - 0.5f;
+ if ((t = 1.f - kb4 * (u * u + v * v)) >= 0.f) {
+ d = 1.f / (1.f + sqrtf(t));
+ ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f;
end = 1;
}
@@ -97,43 +97,43 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int
{
// RG
const int dx = ln[2] - ln[0], dy = ln[3] - ln[1];
- const float dsf = sqrtf((float)dx*dx + dy*dy) + 1.f;
+ const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f;
const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
- const float sd = 1.f/(float)ds;
+ const float sd = 1.f / (float)ds;
- for (z=0; z<ds; ++z) {
- const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd;
- t = 1.f - (kr4 + tz*drg)*(u*u + v*v);
+ for (z = 0; z < ds; ++z) {
+ const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd;
+ t = 1.f - (kr4 + tz * drg) * (u * u + v * v);
d = 1.f / (1.f + sqrtf(t));
- const float nx = (u*d + 0.5f)*getWidth() - 0.5f;
- const float ny = (v*d + 0.5f)*getHeight() - 0.5f;
+ const float nx = (u * d + 0.5f) * getWidth() - 0.5f;
+ const float ny = (v * d + 0.5f) * getHeight() - 0.5f;
buffer->readCubic(color, nx, ny);
- tc[0] += (1.f-tz)*color[0], tc[1] += tz*color[1];
+ tc[0] += (1.f - tz) * color[0], tc[1] += tz * color[1];
dr++, dg++;
}
}
{
// GB
const int dx = ln[4] - ln[2], dy = ln[5] - ln[3];
- const float dsf = sqrtf((float)dx*dx + dy*dy) + 1.f;
+ const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f;
const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
- const float sd = 1.f/(float)ds;
+ const float sd = 1.f / (float)ds;
- for (z=0; z<ds; ++z) {
- const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd;
- t = 1.f - (kg4 + tz*dgb)*(u*u + v*v);
+ for (z = 0; z < ds; ++z) {
+ const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd;
+ t = 1.f - (kg4 + tz * dgb) * (u * u + v * v);
d = 1.f / (1.f + sqrtf(t));
- const float nx = (u*d + 0.5f)*getWidth() - 0.5f;
- const float ny = (v*d + 0.5f)*getHeight() - 0.5f;
+ const float nx = (u * d + 0.5f) * getWidth() - 0.5f;
+ const float ny = (v * d + 0.5f) * getHeight() - 0.5f;
buffer->readCubic(color, nx, ny);
- tc[1] += (1.f-tz)*color[1], tc[2] += tz*color[2];
+ tc[1] += (1.f - tz) * color[1], tc[2] += tz * color[2];
dg++, db++;
}
}
- if (dr) outputColor[0] = 2.f*tc[0] / (float)dr;
- if (dg) outputColor[1] = 2.f*tc[1] / (float)dg;
- if (db) outputColor[2] = 2.f*tc[2] / (float)db;
+ if (dr) outputColor[0] = 2.f * tc[0] / (float)dr;
+ if (dg) outputColor[1] = 2.f * tc[1] / (float)dg;
+ if (db) outputColor[2] = 2.f * tc[2] / (float)db;
/* set alpha */
outputColor[3] = 1.0f;
@@ -153,12 +153,12 @@ void ScreenLensDistortionOperation::deinitExecution()
void ScreenLensDistortionOperation::determineUV(float result[2], float x, float y) const
{
- const float v = sc*((y + 0.5f) - cy)/cy;
- const float u = sc*((x + 0.5f) - cx)/cx;
- const float t = ABS(MIN3(kr, kg, kb)*4);
- float d = 1.f/(1.f + sqrtf(t));
- result[0] = (u*d + 0.5f)*getWidth() - 0.5f;
- result[1] = (v*d + 0.5f)*getHeight() - 0.5f;
+ const float v = sc * ((y + 0.5f) - cy) / cy;
+ const float u = sc * ((x + 0.5f) - cx) / cx;
+ const float t = ABS(MIN3(kr, kg, kb) * 4);
+ float d = 1.f / (1.f + sqrtf(t));
+ result[0] = (u * d + 0.5f) * getWidth() - 0.5f;
+ result[1] = (v * d + 0.5f) * getHeight() - 0.5f;
}
bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
index d2db55ea214..34656f38a09 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
@@ -28,11 +28,11 @@
class ScreenLensDistortionOperation : public NodeOperation {
private:
/**
- * Cached reference to the inputProgram
- */
+ * Cached reference to the inputProgram
+ */
SocketReader *inputProgram;
- NodeLensDist * data;
+ NodeLensDist *data;
float dispersion;
float distortion;
@@ -46,24 +46,24 @@ public:
ScreenLensDistortionOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setData(NodeLensDist *data) {this->data = data;}
- void setDispertion(float dispersion) {this->dispersion = dispersion;}
- void setDistortion(float distortion) {this->distortion = distortion;}
+ void setData(NodeLensDist *data) { this->data = data; }
+ void setDispertion(float dispersion) { this->dispersion = dispersion; }
+ void setDistortion(float distortion) { this->distortion = distortion; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp
index 680e1648ebd..caa1387da2a 100644
--- a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp
+++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp
@@ -39,7 +39,7 @@ void SeparateChannelOperation::deinitExecution()
}
-void SeparateChannelOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void SeparateChannelOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
float input[4];
this->inputOperation->read(input, x, y, sampler, inputBuffers);
diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.h b/source/blender/compositor/operations/COM_SeparateChannelOperation.h
index 3c1eed4bdd9..b1a38fd8294 100644
--- a/source/blender/compositor/operations/COM_SeparateChannelOperation.h
+++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.h
@@ -25,18 +25,18 @@
#include "COM_NodeOperation.h"
-class SeparateChannelOperation: public NodeOperation {
+class SeparateChannelOperation : public NodeOperation {
private:
SocketReader *inputOperation;
int channel;
public:
SeparateChannelOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- void setChannel(int channel) {this->channel = channel;}
+ void setChannel(int channel) { this->channel = channel; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
index 0aefb075b64..5924108ed86 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_SetAlphaOperation.h"
-SetAlphaOperation::SetAlphaOperation(): NodeOperation()
+SetAlphaOperation::SetAlphaOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h
index 3d9caabf880..231b41f1697 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.h
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h
@@ -26,9 +26,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class SetAlphaOperation : public NodeOperation {
private:
SocketReader *inputColor;
@@ -36,14 +36,14 @@ private:
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
SetAlphaOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp
index 50ff2a87a72..5307d7abc24 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_SetColorOperation.h"
-SetColorOperation::SetColorOperation(): NodeOperation()
+SetColorOperation::SetColorOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h
index dad3cfd7fc9..9d28f1757db 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.h
+++ b/source/blender/compositor/operations/COM_SetColorOperation.h
@@ -26,9 +26,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class SetColorOperation : public NodeOperation {
private:
float channel1;
@@ -38,8 +38,8 @@ private:
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
SetColorOperation();
const float getChannel1() {return this->channel1;}
@@ -53,12 +53,12 @@ public:
void setChannels(float value[4]) {this->channel1 = value[0];this->channel2 = value[1];this->channel3 = value[2];this->channel4 = value[3];}
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- const bool isSetOperation() const {return true;}
+ const bool isSetOperation() const { return true; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
index 8974554e700..dfe7fe91bf8 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_SetSamplerOperation.h"
-SetSamplerOperation::SetSamplerOperation(): NodeOperation()
+SetSamplerOperation::SetSamplerOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h
index 49bbae7e4ff..5dba0b3703f 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.h
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h
@@ -26,25 +26,25 @@
/**
- * this program converts an input colour to an output Sampler.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output Sampler.
+ * it assumes we are in sRGB colour space.
+ */
class SetSamplerOperation : public NodeOperation {
private:
PixelSampler sampler;
SocketReader *reader;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
SetSamplerOperation();
- void setSampler(PixelSampler sampler) {this->sampler = sampler;}
+ void setSampler(PixelSampler sampler) { this->sampler = sampler; }
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp
index abd4acafea6..483fcc97a1f 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp
@@ -22,7 +22,7 @@
#include "COM_SetValueOperation.h"
-SetValueOperation::SetValueOperation(): NodeOperation()
+SetValueOperation::SetValueOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_VALUE);
}
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h
index 25810cd7ee5..2f4a6ec0dc8 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.h
+++ b/source/blender/compositor/operations/COM_SetValueOperation.h
@@ -26,29 +26,29 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class SetValueOperation : public NodeOperation {
private:
float value;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
SetValueOperation();
- const float getValue() {return this->value;}
- void setValue(float value) {this->value = value;}
+ const float getValue() { return this->value; }
+ void setValue(float value) { this->value = value; }
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- const bool isSetOperation() const {return true;}
+ const bool isSetOperation() const { return true; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
index 70477de0514..3d15a184c4e 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_SetVectorOperation.h"
#include "COM_defines.h"
-SetVectorOperation::SetVectorOperation(): NodeOperation()
+SetVectorOperation::SetVectorOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_VECTOR);
}
@@ -38,12 +38,6 @@ void SetVectorOperation::executePixel(float *outputValue, float x, float y, Pixe
void SetVectorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
- if (preferredResolution[0] == 0 ||preferredResolution[1]==0) {
- resolution[0] = COM_DEFAULT_RESOLUTION_WIDTH;
- resolution[1] = COM_DEFAULT_RESOLUTION_HEIGHT;
- }
- else {
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
- }
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
}
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
index 9b5dd3ce674..49088027762 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.h
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -26,9 +26,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class SetVectorOperation : public NodeOperation {
private:
float x;
@@ -38,26 +38,26 @@ private:
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
SetVectorOperation();
- const float getX() {return this->x;}
- void setX(float value) {this->x = value;}
- const float getY() {return this->y;}
- void setY(float value) {this->y = value;}
- const float getZ() {return this->z;}
- void setZ(float value) {this->z = value;}
- const float getW() {return this->w;}
- void setW(float value) {this->w = value;}
+ const float getX() { return this->x; }
+ void setX(float value) { this->x = value; }
+ const float getY() { return this->y; }
+ void setY(float value) { this->y = value; }
+ const float getZ() { return this->z; }
+ void setZ(float value) { this->z = value; }
+ const float getW() { return this->w; }
+ void setW(float value) { this->w = value; }
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
- const bool isSetOperation() const {return true;}
+ const bool isSetOperation() const { return true; }
void setVector(float vector[3]) {
setX(vector[0]);
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
index 6ed877523d1..55c4b68ee57 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -22,10 +22,10 @@
#include "COM_SocketProxyOperation.h"
-SocketProxyOperation::SocketProxyOperation() : NodeOperation()
+SocketProxyOperation::SocketProxyOperation(DataType type) : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR/*|COM_DT_VECTOR|COM_DT_VALUE*/);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(type);
+ this->addOutputSocket(type);
this->inputOperation = NULL;
}
@@ -39,7 +39,9 @@ void SocketProxyOperation::deinitExecution()
this->inputOperation = NULL;
}
-void SocketProxyOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void SocketProxyOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
- this->inputOperation->read(color, x, y, sampler, inputBuffers);
+ if (this->inputOperation) {
+ this->inputOperation->read(color, x, y, sampler, inputBuffers);
+ }
}
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index a86134c1ea9..5dc8f3d6f8f 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.h
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -25,12 +25,12 @@
#include "COM_NodeOperation.h"
-class SocketProxyOperation: public NodeOperation {
+class SocketProxyOperation : public NodeOperation {
private:
SocketReader *inputOperation;
public:
- SocketProxyOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ SocketProxyOperation(DataType type);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
index 4601bebb49f..2735f182406 100644
--- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
@@ -60,7 +60,7 @@ void SplitViewerOperation::deinitExecution()
}
-void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers)
+void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers)
{
float *buffer = this->outputBuffer;
unsigned char *bufferDisplay = this->outputBufferDisplay;
@@ -70,15 +70,15 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
int y1 = rect->ymin;
int x2 = rect->xmax;
int y2 = rect->ymax;
- int offset = (y1*this->getWidth() + x1 ) * 4;
+ int offset = (y1 * this->getWidth() + x1) * 4;
int x;
int y;
- int perc = xSplit?this->splitPercentage*getWidth()/100.0f:this->splitPercentage*getHeight()/100.0f;
- for (y = y1 ; y < y2 ; y++) {
- for (x = x1 ; x < x2 ; x++) {
+ int perc = xSplit ? this->splitPercentage *getWidth() / 100.0f : this->splitPercentage *getHeight() / 100.0f;
+ for (y = y1; y < y2; y++) {
+ for (x = x1; x < x2; x++) {
bool image1;
float srgb[4];
- image1 = xSplit?x>perc:y>perc;
+ image1 = xSplit ? x > perc : y > perc;
if (image1) {
image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers);
}
@@ -88,21 +88,21 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
/// @todo: linear conversion only when scene color management is selected, also check predivide.
if (this->doColorManagement) {
if (this->doColorPredivide) {
- linearrgb_to_srgb_predivide_v4(srgb, buffer+offset);
+ linearrgb_to_srgb_predivide_v4(srgb, buffer + offset);
}
else {
- linearrgb_to_srgb_v4(srgb, buffer+offset);
+ linearrgb_to_srgb_v4(srgb, buffer + offset);
}
}
else {
- copy_v4_v4(srgb, buffer+offset);
+ copy_v4_v4(srgb, buffer + offset);
}
- F4TOCHAR4(srgb, bufferDisplay+offset);
+ rgba_float_to_uchar(bufferDisplay + offset, srgb);
- offset +=4;
+ offset += 4;
}
- offset += (this->getWidth()-(x2-x1))*4;
+ offset += (this->getWidth() - (x2 - x1)) * 4;
}
updateImage(rect);
}
diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.h b/source/blender/compositor/operations/COM_SplitViewerOperation.h
index 2c3163f0b0a..aba63ff190b 100644
--- a/source/blender/compositor/operations/COM_SplitViewerOperation.h
+++ b/source/blender/compositor/operations/COM_SplitViewerOperation.h
@@ -35,10 +35,10 @@ private:
bool xSplit;
public:
SplitViewerOperation();
- void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
void initExecution();
void deinitExecution();
- void setSplitPercentage(float splitPercentage) {this->splitPercentage = splitPercentage;}
- void setXSplit(bool xsplit) {this->xSplit = xsplit;}
+ void setSplitPercentage(float splitPercentage) { this->splitPercentage = splitPercentage; }
+ void setXSplit(bool xsplit) { this->xSplit = xsplit; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index 0d85f71c691..072528f3fc6 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -25,10 +25,10 @@
#include "BLI_listbase.h"
#include "DNA_scene_types.h"
-TextureBaseOperation::TextureBaseOperation(): NodeOperation()
+TextureBaseOperation::TextureBaseOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VECTOR);//offset
- this->addInputSocket(COM_DT_VECTOR);//size
+ this->addInputSocket(COM_DT_VECTOR); //offset
+ this->addInputSocket(COM_DT_VECTOR); //size
this->texture = NULL;
this->inputSize = NULL;
this->inputOffset = NULL;
@@ -57,8 +57,8 @@ void TextureBaseOperation::deinitExecution()
void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
if (preferredResolution[0] == 0 || preferredResolution[1] == 0) {
- int width = this->scene->r.xsch*this->scene->r.size/100;
- int height = this->scene->r.ysch*this->scene->r.size/100;
+ int width = this->scene->r.xsch * this->scene->r.size / 100;
+ int height = this->scene->r.ysch * this->scene->r.size / 100;
resolution[0] = width;
resolution[1] = height;
}
@@ -79,22 +79,22 @@ void TextureAlphaOperation::executePixel(float *color, float x, float y, PixelSa
void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
- TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
+ TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
float textureSize[4];
float textureOffset[4];
float vec[3];
int retval;
- const float cx = this->getWidth()/2;
- const float cy = this->getHeight()/2;
- const float u = (cx-x)/this->getWidth()*2;
- const float v = (cy-y)/this->getHeight()*2;
+ const float cx = this->getWidth() / 2;
+ const float cy = this->getHeight() / 2;
+ const float u = (cx - x) / this->getWidth() * 2;
+ const float v = (cy - y) / this->getHeight() * 2;
this->inputSize->read(textureSize, x, y, sampler, inputBuffers);
this->inputOffset->read(textureOffset, x, y, sampler, inputBuffers);
- vec[0] = textureSize[0]*(u + textureOffset[0]);
- vec[1] = textureSize[1]*(v + textureOffset[1]);
- vec[2] = textureSize[2]*textureOffset[2];
+ vec[0] = textureSize[0] * (u + textureOffset[0]);
+ vec[1] = textureSize[1] * (v + textureOffset[1]);
+ vec[2] = textureSize[2] * textureOffset[2];
retval = multitex_ext(this->texture, vec, NULL, NULL, 0, &texres);
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index de42b144730..e862a1f1910 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -36,10 +36,10 @@ extern "C" {
}
/**
- * Base class for all renderlayeroperations
- *
- * @todo: rename to operation.
- */
+ * Base class for all renderlayeroperations
+ *
+ * @todo: rename to operation.
+ */
class TextureBaseOperation : public NodeOperation {
private:
Tex *texture;
@@ -50,33 +50,33 @@ private:
protected:
/**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
/**
- * Constructor
- */
+ * Constructor
+ */
TextureBaseOperation();
public:
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
- void setTexture(Tex *texture) {this->texture = texture;}
+ void setTexture(Tex *texture) { this->texture = texture; }
void initExecution();
void deinitExecution();
- void setScene(const Scene *scene) {this->scene = scene;}
+ void setScene(const Scene *scene) { this->scene = scene; }
};
-class TextureOperation:public TextureBaseOperation {
+class TextureOperation : public TextureBaseOperation {
public:
TextureOperation();
};
-class TextureAlphaOperation:public TextureBaseOperation {
+class TextureAlphaOperation : public TextureBaseOperation {
public:
TextureAlphaOperation();
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
index d8089bdf3ea..7b978e0f87c 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cpp
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -26,7 +26,7 @@
-TonemapOperation::TonemapOperation(): NodeOperation()
+TonemapOperation::TonemapOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
@@ -41,15 +41,13 @@ void TonemapOperation::initExecution()
NodeOperation::initMutex();
}
-void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data)
+void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- AvgLogLum * avg = (AvgLogLum*)data;
+ AvgLogLum *avg = (AvgLogLum *)data;
float output[4];
this->imageReader->read(output, x, y, inputBuffers, NULL);
- output[0] *= avg->al;
- output[1] *= avg->al;
- output[2] *= avg->al;
+ mul_v3_fl(output, avg->al);
float dr = output[0] + this->data->offset;
float dg = output[1] + this->data->offset;
float db = output[2] + this->data->offset;
@@ -63,10 +61,7 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in
output[2] = powf(MAX2(output[2], 0.0f), igm);
}
- color[0] = output[0];
- color[1] = output[1];
- color[2] = output[2];
- color[3] = output[3];
+ copy_v4_v4(color, output);
}
void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
@@ -80,7 +75,7 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem
float output[4];
this->imageReader->read(output, x, y, inputBuffers, NULL);
- const float L = 0.212671f * output[0] + 0.71516f * output[1] + 0.072169f * output[2];
+ const float L = rgb_to_luma_y(output);
float I_l = output[0] + ic * (L - output[0]);
float I_g = avg->cav[0] + ic * (avg->lav - avg->cav[0]);
float I_a = I_l + ia * (I_g - I_l);
@@ -94,10 +89,7 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem
I_a = I_l + ia * (I_g - I_l);
output[2] /= (output[2] + powf(f * I_a, m));
- color[0] = output[0];
- color[1] = output[1];
- color[2] = output[2];
- color[3] = output[3];
+ copy_v4_v4(color, output);
}
void TonemapOperation::deinitExecution()
@@ -126,12 +118,12 @@ bool TonemapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferO
void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (this->cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers);
AvgLogLum *data = new AvgLogLum();
- float * buffer = tile->getBuffer();
+ float *buffer = tile->getBuffer();
float lsum = 0.0f;
int p = tile->getWidth() * tile->getHeight();
@@ -139,33 +131,30 @@ void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuff
float avl, maxl = -1e10f, minl = 1e10f;
const float sc = 1.0f / p;
float Lav = 0.f;
- float cav[4] = {0.0f,0.0f,0.0f,0.0f};
+ float cav[4] = {0.0f, 0.0f, 0.0f, 0.0f};
while (p--) {
- float L = 0.212671f * bc[0] + 0.71516f * bc[1] + 0.072169f * bc[2];
+ float L = rgb_to_luma_y(bc);
Lav += L;
- cav[0] += bc[0];
- cav[1] += bc[1];
- cav[2] += bc[2];
+ add_v3_v3(cav, bc);
lsum += logf(MAX2(L, 0.0f) + 1e-5f);
maxl = (L > maxl) ? L : maxl;
minl = (L < minl) ? L : minl;
- bc+=4;
+ bc += 4;
}
data->lav = Lav * sc;
- data->cav[0] = cav[0]*sc;
- data->cav[1] = cav[1]*sc;
- data->cav[2] = cav[2]*sc;
+ mul_v3_v3fl(data->cav, cav, sc);
maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5); avl = lsum * sc;
data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f;
float al = exp((double)avl);
data->al = (al == 0.f) ? 0.f : (this->data->key / al);
- data->igm = (this->data->gamma==0.f) ? 1 : (1.f / this->data->gamma);
+ data->igm = (this->data->gamma == 0.f) ? 1 : (1.f / this->data->gamma);
this->cachedInstance = data;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return this->cachedInstance;
}
void TonemapOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data)
{
+ /* pass */
}
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h
index e7ea4f039f2..005f0862443 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.h
+++ b/source/blender/compositor/operations/COM_TonemapOperation.h
@@ -26,9 +26,9 @@
#include "DNA_node_types.h"
/**
- * @brief temporarily storage during execution of Tonemap
- * @ingroup operation
- */
+ * @brief temporarily storage during execution of Tonemap
+ * @ingroup operation
+ */
typedef struct AvgLogLum {
float al;
float auto_key;
@@ -38,48 +38,48 @@ typedef struct AvgLogLum {
} AvgLogLum;
/**
- * @brief base class of tonemap, implementing the simple tonemap
- * @ingroup operation
- */
+ * @brief base class of tonemap, implementing the simple tonemap
+ * @ingroup operation
+ */
class TonemapOperation : public NodeOperation {
protected:
/**
- * @brief Cached reference to the reader
- */
- SocketReader * imageReader;
+ * @brief Cached reference to the reader
+ */
+ SocketReader *imageReader;
/**
- * @brief settings of the Tonemap
- */
- NodeTonemap * data;
+ * @brief settings of the Tonemap
+ */
+ NodeTonemap *data;
/**
- * @brief temporarily cache of the execution storage
- */
- AvgLogLum * cachedInstance;
+ * @brief temporarily cache of the execution storage
+ */
+ AvgLogLum *cachedInstance;
public:
TonemapOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
- void setData(NodeTonemap *data) {this->data = data;}
+ void setData(NodeTonemap *data) { this->data = data; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
@@ -87,17 +87,17 @@ public:
};
/**
- * @brief class of tonemap, implementing the photoreceptor tonemap
- * most parts have already been done in TonemapOperation
- * @ingroup operation
- */
+ * @brief class of tonemap, implementing the photoreceptor tonemap
+ * most parts have already been done in TonemapOperation
+ * @ingroup operation
+ */
class PhotoreceptorTonemapOperation : public TonemapOperation {
public:
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
};
#endif
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp
index 6d2fdfc11d0..c41e2c7f156 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.cpp
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp
@@ -32,6 +32,7 @@ TranslateOperation::TranslateOperation() : NodeOperation()
this->inputOperation = NULL;
this->inputXOperation = NULL;
this->inputYOperation = NULL;
+ this->isDeltaSet = false;
}
void TranslateOperation::initExecution()
{
@@ -39,11 +40,6 @@ void TranslateOperation::initExecution()
this->inputXOperation = this->getInputSocketReader(1);
this->inputYOperation = this->getInputSocketReader(2);
- float tempDelta[4];
- this->inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL);
- this->deltaX = tempDelta[0];
- this->inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL);
- this->deltaY = tempDelta[0];
}
void TranslateOperation::deinitExecution()
@@ -54,13 +50,15 @@ void TranslateOperation::deinitExecution()
}
-void TranslateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void TranslateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
- this->inputOperation->read(color, x-this->getDeltaX(), y-this->getDeltaY(), sampler, inputBuffers);
+ ensureDelta();
+ this->inputOperation->read(color, x - this->getDeltaX(), y - this->getDeltaY(), sampler, inputBuffers);
}
bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
+ ensureDelta();
rcti newInput;
newInput.xmax = input->xmax - this->getDeltaX();
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h
index eab3391041e..bf3121bec11 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.h
+++ b/source/blender/compositor/operations/COM_TranslateOperation.h
@@ -25,23 +25,35 @@
#include "COM_NodeOperation.h"
-class TranslateOperation: public NodeOperation {
+class TranslateOperation : public NodeOperation {
private:
SocketReader *inputOperation;
- SocketReader*inputXOperation;
- SocketReader*inputYOperation;
+ SocketReader *inputXOperation;
+ SocketReader *inputYOperation;
float deltaX;
float deltaY;
+ bool isDeltaSet;
public:
TranslateOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
void initExecution();
void deinitExecution();
- float getDeltaX() {return this->deltaX;}
- float getDeltaY() {return this->deltaY;}
+ float getDeltaX() { return this->deltaX; }
+ float getDeltaY() { return this->deltaY; }
+
+ inline void ensureDelta() {
+ if (!isDeltaSet) {
+ float tempDelta[4];
+ this->inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL);
+ this->deltaX = tempDelta[0];
+ this->inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL);
+ this->deltaY = tempDelta[0];
+ this->isDeltaSet = true;
+ }
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 270fedc174b..7c9b0c75518 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -61,9 +61,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
tempColor[2] = 0;
tempColor[3] = 0;
float tempSize[4];
- float overallmultiplyerr = 0;
- float overallmultiplyerg = 0;
- float overallmultiplyerb = 0;
+ float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
int miny = y - maxBlur;
int maxy = y + maxBlur;
@@ -74,40 +72,37 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
tempColor[0] += readColor[0];
tempColor[1] += readColor[1];
tempColor[2] += readColor[2];
- overallmultiplyerr += 1;
- overallmultiplyerg += 1;
- overallmultiplyerb += 1;
+ tempColor[3] += readColor[3];
+ add_v4_v4(tempColor, readColor);
+ add_v3_fl(overallmultiplyer, 1.0f);
- for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) {
- for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) {
- if (nx >=0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
+ for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) {
+ for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) {
+ if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
float size = tempSize[0];
- size += this->threshold;
+// size += this->threshold;
float dx = nx - x;
float dy = ny - y;
if (nx == x && ny == y) {
/* pass */
}
else if (size >= fabsf(dx) && size >= fabsf(dy)) {
- float u = 256 + dx*256/size;
- float v = 256 + dy*256/size;
+ float u = 256 + dx * 256 / size;
+ float v = 256 + dy * 256 / size;
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
- tempColor[0] += bokeh[0] * readColor[0];
- tempColor[1] += bokeh[1] * readColor[1];
- tempColor[2] += bokeh[2]* readColor[2];
- overallmultiplyerr += bokeh[0];
- overallmultiplyerg += bokeh[1];
- overallmultiplyerb += bokeh[2];
+ madd_v4_v4v4(tempColor, bokeh, readColor);
+ add_v4_v4(overallmultiplyer, bokeh);
}
}
}
}
- color[0] = tempColor[0] * (1.0f / overallmultiplyerr);
- color[1] = tempColor[1] * (1.0f / overallmultiplyerg);
- color[2] = tempColor[2] * (1.0f / overallmultiplyerb);
- color[3] = 1.0f;
+
+ color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]);
+ color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]);
+ color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]);
+ color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]);
}
}
@@ -124,10 +119,10 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
rcti newInput;
rcti bokehInput;
- newInput.xmax = input->xmax + maxBlur+2;
- newInput.xmin = input->xmin - maxBlur+2;
- newInput.ymax = input->ymax + maxBlur-2;
- newInput.ymin = input->ymin - maxBlur-2;
+ newInput.xmax = input->xmax + maxBlur + 2;
+ newInput.xmin = input->xmin - maxBlur + 2;
+ newInput.ymax = input->ymax + maxBlur - 2;
+ newInput.ymin = input->ymin - maxBlur - 2;
bokehInput.xmax = 512;
bokehInput.xmin = 0;
bokehInput.ymax = 512;
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
index 9c2c4b4bf68..ede8f0333b4 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -37,25 +37,25 @@ public:
VariableSizeBokehBlurOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void setMaxBlur(int maxRadius) {this->maxBlur = maxRadius;}
-
- void setThreshold(float threshold) {this->threshold = threshold;}
+ void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; }
+
+ void setThreshold(float threshold) { this->threshold = threshold; }
};
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index e6305dc26a2..3efae2c4e3d 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -28,7 +28,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-VectorBlurOperation::VectorBlurOperation(): NodeOperation()
+VectorBlurOperation::VectorBlurOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE); // ZBUF
@@ -54,12 +54,12 @@ void VectorBlurOperation::initExecution()
void VectorBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- float *buffer = (float*) data;
- int index = (y*this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
+ float *buffer = (float *) data;
+ int index = (y * this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
color[0] = buffer[index];
- color[1] = buffer[index+1];
- color[2] = buffer[index+2];
- color[3] = buffer[index+3];
+ color[1] = buffer[index + 1];
+ color[2] = buffer[index + 2];
+ color[3] = buffer[index + 3];
}
void VectorBlurOperation::deinitExecution()
@@ -77,17 +77,17 @@ void *VectorBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB
{
if (this->cachedInstance) return this->cachedInstance;
- BLI_mutex_lock(getMutex());
+ lockMutex();
if (this->cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer*)inputImageProgram->initializeTileData(rect, memoryBuffers);
- MemoryBuffer *speed = (MemoryBuffer*)inputSpeedProgram->initializeTileData(rect, memoryBuffers);
- MemoryBuffer *z = (MemoryBuffer*)inputZProgram->initializeTileData(rect, memoryBuffers);
- float *data = new float[this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS];
- memcpy(data, tile->getBuffer(),this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+ MemoryBuffer *tile = (MemoryBuffer *)inputImageProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *speed = (MemoryBuffer *)inputSpeedProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *z = (MemoryBuffer *)inputZProgram->initializeTileData(rect, memoryBuffers);
+ float *data = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS];
+ memcpy(data, tile->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
this->generateVectorBlur(data, tile, speed, z);
this->cachedInstance = data;
}
- BLI_mutex_unlock(getMutex());
+ unlockMutex();
return this->cachedInstance;
}
@@ -110,7 +110,7 @@ void VectorBlurOperation::generateVectorBlur(float *data, MemoryBuffer *inputIma
{
float *zbuf = inputZ->convertToValueBuffer();
NodeBlurData blurdata;
- blurdata.samples = this->settings->samples/QualityStepHelper::getStep();
+ blurdata.samples = this->settings->samples / QualityStepHelper::getStep();
blurdata.maxspeed = this->settings->maxspeed;
blurdata.minspeed = this->settings->minspeed;
blurdata.curved = this->settings->curved;
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h
index 2c45628726d..30821cdd8b2 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h
@@ -29,16 +29,16 @@
class VectorBlurOperation : public NodeOperation, public QualityStepHelper {
private:
/**
- * @brief Cached reference to the inputProgram
- */
- SocketReader * inputImageProgram;
- SocketReader * inputSpeedProgram;
- SocketReader * inputZProgram;
+ * @brief Cached reference to the inputProgram
+ */
+ SocketReader *inputImageProgram;
+ SocketReader *inputSpeedProgram;
+ SocketReader *inputZProgram;
/**
- * @brief settings of the glare node.
- */
- NodeBlurData * settings;
+ * @brief settings of the glare node.
+ */
+ NodeBlurData *settings;
float *cachedInstance;
@@ -46,23 +46,23 @@ public:
VectorBlurOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
- void setVectorBlurSettings(NodeBlurData * settings) {this->settings = settings;}
+ void setVectorBlurSettings(NodeBlurData *settings) { this->settings = settings; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
protected:
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
index e9045b126e2..3173599ece6 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
@@ -30,7 +30,7 @@ extern "C" {
}
#endif
-VectorCurveOperation::VectorCurveOperation(): CurveBaseOperation()
+VectorCurveOperation::VectorCurveOperation() : CurveBaseOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_VECTOR);
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h
index 759e265220f..41faee7acf6 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h
@@ -28,25 +28,25 @@
class VectorCurveOperation : public CurveBaseOperation {
private:
/**
- * Cached reference to the inputProgram
- */
- SocketReader * inputProgram;
+ * Cached reference to the inputProgram
+ */
+ SocketReader *inputProgram;
public:
VectorCurveOperation();
/**
- * the inner loop of this program
- */
- void executePixel(float *Vector, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *Vector, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
/**
- * Initialize the execution
- */
+ * Initialize the execution
+ */
void initExecution();
/**
- * Deinitialize the execution
- */
+ * Deinitialize the execution
+ */
void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
index 809c688195f..a8aa84e84f9 100644
--- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
@@ -74,13 +74,13 @@ void ViewerBaseOperation::initImage()
/* now we combine the input with ibuf */
this->outputBuffer = ibuf->rect_float;
- this->outputBufferDisplay = (unsigned char*)ibuf->rect;
+ this->outputBufferDisplay = (unsigned char *)ibuf->rect;
BKE_image_release_ibuf(this->image, this->lock);
}
void ViewerBaseOperation:: updateImage(rcti *rect)
{
- WM_main_add_notifier(NC_WINDOW|ND_DRAW, NULL);
+ WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
}
void ViewerBaseOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
index 51fa8cecc0d..2aaa7d20966 100644
--- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
@@ -30,11 +30,10 @@ class ViewerBaseOperation : public NodeOperation {
protected:
float *outputBuffer;
unsigned char *outputBufferDisplay;
- Image * image;
- ImageUser * imageUser;
+ Image *image;
+ ImageUser *imageUser;
void *lock;
bool active;
- const bNodeTree *tree;
float centerX;
float centerY;
OrderOfChunks chunkOrder;
@@ -42,28 +41,27 @@ protected:
bool doColorPredivide;
public:
- bool isOutputOperation(bool rendering) const {return isActiveViewerOutput();}
+ bool isOutputOperation(bool rendering) const { return isActiveViewerOutput(); }
void initExecution();
void deinitExecution();
- void setImage(Image *image) {this->image = image;}
- void setImageUser(ImageUser *imageUser) {this->imageUser = imageUser;}
- const bool isActiveViewerOutput() const {return active;}
- void setActive(bool active) {this->active = active;}
- void setbNodeTree(const bNodeTree *tree) {this->tree = tree;}
- void setCenterX(float centerX) {this->centerX = centerX;}
- void setCenterY(float centerY) {this->centerY = centerY;}
- void setChunkOrder(OrderOfChunks tileOrder) {this->chunkOrder = tileOrder;}
+ void setImage(Image *image) { this->image = image; }
+ void setImageUser(ImageUser *imageUser) { this->imageUser = imageUser; }
+ const bool isActiveViewerOutput() const { return active; }
+ void setActive(bool active) { this->active = active; }
+ void setCenterX(float centerX) { this->centerX = centerX;}
+ void setCenterY(float centerY) { this->centerY = centerY;}
+ void setChunkOrder(OrderOfChunks tileOrder) { this->chunkOrder = tileOrder; }
float getCenterX() { return this->centerX; }
float getCenterY() { return this->centerY; }
OrderOfChunks getChunkOrder() { return this->chunkOrder; }
const CompositorPriority getRenderPriority() const;
- void setColorManagement(bool doColorManagement) {this->doColorManagement = doColorManagement;}
- void setColorPredivide(bool doColorPredivide) {this->doColorPredivide = doColorPredivide;}
- bool isViewerOperation() {return true;}
+ void setColorManagement(bool doColorManagement) { this->doColorManagement = doColorManagement; }
+ void setColorPredivide(bool doColorPredivide) { this->doColorPredivide = doColorPredivide; }
+ bool isViewerOperation() { return true; }
protected:
ViewerBaseOperation();
- void updateImage(rcti*rect);
+ void updateImage(rcti *rect);
private:
void initImage();
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index 22e6511fbe7..cf7bf3fdc9d 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -64,7 +64,7 @@ void ViewerOperation::deinitExecution()
}
-void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers)
+void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers)
{
float *buffer = this->outputBuffer;
unsigned char *bufferDisplay = this->outputBufferDisplay;
@@ -73,38 +73,38 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryB
const int y1 = rect->ymin;
const int x2 = rect->xmax;
const int y2 = rect->ymax;
- const int offsetadd = (this->getWidth()-(x2-x1))*4;
- int offset = (y1*this->getWidth() + x1 ) * 4;
+ const int offsetadd = (this->getWidth() - (x2 - x1)) * 4;
+ int offset = (y1 * this->getWidth() + x1) * 4;
float alpha[4], srgb[4];
int x;
int y;
bool breaked = false;
- for (y = y1 ; y < y2 && (!breaked) ; y++) {
- for (x = x1 ; x < x2; x++) {
+ for (y = y1; y < y2 && (!breaked); y++) {
+ for (x = x1; x < x2; x++) {
imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers);
if (alphaInput != NULL) {
alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers);
- buffer[offset+3] = alpha[0];
+ buffer[offset + 3] = alpha[0];
}
/// @todo: linear conversion only when scene color management is selected, also check predivide.
if (this->doColorManagement) {
if (this->doColorPredivide) {
- linearrgb_to_srgb_predivide_v4(srgb, buffer+offset);
+ linearrgb_to_srgb_predivide_v4(srgb, buffer + offset);
}
else {
- linearrgb_to_srgb_v4(srgb, buffer+offset);
+ linearrgb_to_srgb_v4(srgb, buffer + offset);
}
}
else {
- copy_v4_v4(srgb, buffer+offset);
+ copy_v4_v4(srgb, buffer + offset);
}
- F4TOCHAR4(srgb, bufferDisplay+offset);
+ rgba_float_to_uchar(bufferDisplay + offset, srgb);
- offset +=4;
+ offset += 4;
}
- if (tree->test_break && tree->test_break(tree->tbh)) {
+ if (isBreaked()) {
breaked = true;
}
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index 4ffae31c131..49ef5ad4bb7 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -34,7 +34,7 @@ private:
public:
ViewerOperation();
- void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
void initExecution();
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
index 222b879645c..e1018e0d037 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -24,13 +24,12 @@
#include "COM_defines.h"
#include <stdio.h>
-WriteBufferOperation::WriteBufferOperation() :NodeOperation()
+WriteBufferOperation::WriteBufferOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->memoryProxy = new MemoryProxy();
this->memoryProxy->setWriteBufferOperation(this);
this->memoryProxy->setExecutor(NULL);
- this->tree = NULL;
}
WriteBufferOperation::~WriteBufferOperation()
{
@@ -57,7 +56,7 @@ void WriteBufferOperation::deinitExecution()
this->memoryProxy->free();
}
-void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers)
+void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers)
{
//MemoryBuffer *memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber);
MemoryBuffer *memoryBuffer = this->memoryProxy->getBuffer();
@@ -71,14 +70,14 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
int x;
int y;
bool breaked = false;
- for (y = y1 ; y < y2 && (!breaked) ; y++) {
- int offset4 = (y*memoryBuffer->getWidth()+x1)*COM_NUMBER_OF_CHANNELS;
- for (x = x1 ; x < x2; x++) {
+ for (y = y1; y < y2 && (!breaked); y++) {
+ int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS;
+ for (x = x1; x < x2; x++) {
input->read(&(buffer[offset4]), x, y, memoryBuffers, data);
- offset4 +=COM_NUMBER_OF_CHANNELS;
+ offset4 += COM_NUMBER_OF_CHANNELS;
}
- if (tree->test_break && tree->test_break(tree->tbh)) {
+ if (isBreaked()) {
breaked = true;
}
@@ -97,13 +96,13 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
int x;
int y;
bool breaked = false;
- for (y = y1 ; y < y2 && (!breaked) ; y++) {
- int offset4 = (y*memoryBuffer->getWidth()+x1)*COM_NUMBER_OF_CHANNELS;
- for (x = x1 ; x < x2 ; x++) {
+ for (y = y1; y < y2 && (!breaked); y++) {
+ int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS;
+ for (x = x1; x < x2; x++) {
input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers);
- offset4 +=COM_NUMBER_OF_CHANNELS;
+ offset4 += COM_NUMBER_OF_CHANNELS;
}
- if (tree->test_break && tree->test_break(tree->tbh)) {
+ if (isBreaked()) {
breaked = true;
}
}
@@ -111,7 +110,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
memoryBuffer->setCreatedState();
}
-void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** inputMemoryBuffers, MemoryBuffer* outputBuffer)
+void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer)
{
float *outputFloatBuffer = outputBuffer->getBuffer();
cl_int error;
@@ -132,11 +131,11 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr
CL_FLOAT
};
- cl_mem clOutputBuffer = clCreateImage2D(context, CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ cl_mem clOutputBuffer = clCreateImage2D(context, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
// STEP 2
- list<cl_mem> * clMemToCleanUp = new list<cl_mem>();
+ list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
clMemToCleanUp->push_back(clOutputBuffer);
list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
@@ -144,34 +143,40 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr
// STEP 3
- size_t origin[3] = {0,0,0};
- size_t region[3] = {outputBufferWidth,outputBufferHeight,1};
+ size_t origin[3] = {0, 0, 0};
+ size_t region[3] = {outputBufferWidth, outputBufferHeight, 1};
// clFlush(queue);
// clFinish(queue);
error = clEnqueueBarrier(queue);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
error = clEnqueueReadImage(queue, clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
// STEP 4
- while (clMemToCleanUp->size()>0) {
+ while (clMemToCleanUp->size() > 0) {
cl_mem mem = clMemToCleanUp->front();
error = clReleaseMemObject(mem);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
clMemToCleanUp->pop_front();
}
- while (clKernelsToCleanUp->size()>0) {
+ while (clKernelsToCleanUp->size() > 0) {
cl_kernel kernel = clKernelsToCleanUp->front();
error = clReleaseKernel(kernel);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
clKernelsToCleanUp->pop_front();
}
delete clKernelsToCleanUp;
}
+
+void WriteBufferOperation::readResolutionFromInputSocket() {
+ NodeOperation *inputOperation = this->getInputOperation(0);
+ this->setWidth(inputOperation->getWidth());
+ this->setHeight(inputOperation->getHeight());
+}
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
index 6f2c49c49bd..321eed7240a 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.h
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -27,26 +27,25 @@
#include "COM_MemoryProxy.h"
#include "COM_SocketReader.h"
/**
- * @brief Operation to write to a tile
- * @ingroup Operation
- */
-class WriteBufferOperation: public NodeOperation {
+ * @brief Operation to write to a tile
+ * @ingroup Operation
+ */
+class WriteBufferOperation : public NodeOperation {
MemoryProxy *memoryProxy;
NodeOperation *input;
- const bNodeTree * tree;
public:
WriteBufferOperation();
~WriteBufferOperation();
- int isBufferOperation() {return true;}
- MemoryProxy *getMemoryProxy() {return this->memoryProxy;}
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
- const bool isWriteBufferOperation() const {return true;}
+ int isBufferOperation() { return true; }
+ MemoryProxy *getMemoryProxy() { return this->memoryProxy; }
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
+ const bool isWriteBufferOperation() const { return true; }
- void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
void initExecution();
void deinitExecution();
- void setbNodeTree(const bNodeTree *tree) {this->tree = tree;}
- void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** memoryBuffers, MemoryBuffer* outputBuffer);
+ void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer);
+ void readResolutionFromInputSocket();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 7f32bac2e64..eb02b150fa4 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_ZCombineOperation.h"
#include "BLI_utildefines.h"
-ZCombineOperation::ZCombineOperation(): NodeOperation()
+ZCombineOperation::ZCombineOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -53,7 +53,7 @@ void ZCombineOperation::executePixel(float *color, float x, float y, PixelSample
this->depth1Reader->read(depth1, x, y, sampler, inputBuffers);
this->depth2Reader->read(depth2, x, y, sampler, inputBuffers);
- if (depth1[0]<depth2[0]) {
+ if (depth1[0] < depth2[0]) {
this->image1Reader->read(color, x, y, sampler, inputBuffers);
}
else {
@@ -69,7 +69,7 @@ void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelS
this->depth1Reader->read(depth1, x, y, sampler, inputBuffers);
this->depth2Reader->read(depth2, x, y, sampler, inputBuffers);
- if (depth1[0]<depth2[0]) {
+ if (depth1[0] < depth2[0]) {
this->image1Reader->read(color1, x, y, sampler, inputBuffers);
this->image2Reader->read(color2, x, y, sampler, inputBuffers);
}
@@ -78,10 +78,10 @@ void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelS
this->image2Reader->read(color1, x, y, sampler, inputBuffers);
}
float fac = color1[3];
- float ifac = 1.0f-fac;
- color[0] = color1[0]+ifac*color2[0];
- color[1] = color1[1]+ifac*color2[1];
- color[2] = color1[2]+ifac*color2[2];
+ float ifac = 1.0f - fac;
+ color[0] = color1[0] + ifac * color2[0];
+ color[1] = color1[1] + ifac * color2[1];
+ color[2] = color1[2] + ifac * color2[2];
color[3] = MAX2(color1[3], color2[3]);
}
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h
index f9de916fce0..56ad950a3aa 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.h
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.h
@@ -26,9 +26,9 @@
/**
- * this program converts an input colour to an output value.
- * it assumes we are in sRGB colour space.
- */
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
class ZCombineOperation : public NodeOperation {
protected:
SocketReader *image1Reader;
@@ -37,21 +37,21 @@ protected:
SocketReader *depth2Reader;
public:
/**
- * Default constructor
- */
+ * Default constructor
+ */
ZCombineOperation();
void initExecution();
void deinitExecution();
/**
- * the inner loop of this program
- */
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ * the inner loop of this program
+ */
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
-class ZCombineAlphaOperation: public ZCombineOperation {
- void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+class ZCombineAlphaOperation : public ZCombineOperation {
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]);
};
#endif
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 14bee00a72a..a8f8d2974e5 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -184,10 +184,10 @@ void clean_fcurve(FCurve *fcu, float thresh)
int totCount, i;
/* check if any points */
- if ((fcu == NULL) || (fcu->totvert <= 1))
+ if ((fcu == NULL) || (fcu->bezt == NULL) || (fcu->totvert <= 1))
return;
- /* make a copy of the old BezTriples, and clear IPO curve */
+ /* make a copy of the old BezTriples, and clear F-Curve */
old_bezts = fcu->bezt;
totCount = fcu->totvert;
fcu->bezt = NULL;
@@ -286,7 +286,11 @@ void smooth_fcurve(FCurve *fcu)
{
BezTriple *bezt;
int i, x, totSel = 0;
-
+
+ if (fcu->bezt == NULL) {
+ return;
+ }
+
/* first loop through - count how many verts are selected */
bezt = fcu->bezt;
for (i = 0; i < fcu->totvert; i++, bezt++) {
@@ -408,13 +412,13 @@ void sample_fcurve(FCurve *fcu)
if (range) {
value_cache = MEM_callocN(sizeof(TempFrameValCache) * range, "IcuFrameValCache");
- /* sample values */
+ /* sample values */
for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
fp->frame = (float)(sfra + n);
fp->val = evaluate_fcurve(fcu, fp->frame);
}
- /* add keyframes with these, tagging as 'breakdowns' */
+ /* add keyframes with these, tagging as 'breakdowns' */
for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
nIndex = insert_vert_fcurve(fcu, fp->frame, fp->val, 1);
BEZKEYTYPE(fcu->bezt + nIndex) = BEZT_KEYTYPE_BREAKDOWN;
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 1823bbce3a1..fa555b0ddb8 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -37,10 +37,8 @@
#include "BLO_sys_types.h"
-#include "IMB_imbuf_types.h"
-
-#include "BLI_math.h"
#include "BLI_blenlib.h"
+#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_gpencil_types.h"
@@ -53,8 +51,6 @@
#include "BKE_global.h"
#include "BKE_gpencil.h"
-
-
#include "WM_api.h"
#include "BIF_gl.h"
@@ -64,7 +60,6 @@
#include "ED_sequencer.h"
#include "ED_view3d.h"
-
#include "gpencil_intern.h"
/* ************************************************** */
@@ -225,7 +220,7 @@ static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness
/* need to roll-back one point to ensure that there are no gaps in the stroke */
if (i != 0) glVertex3fv(&(pt - 1)->x);
-
+
/* now the point we want... */
glVertex3fv(&pt->x);
@@ -340,7 +335,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
mt[1] = m2[1] * pthick * 0.5f;
sc[0] = s0[0] - (m1[0] * pthick * 0.75f);
sc[1] = s0[1] - (m1[1] * pthick * 0.75f);
-
+
t0[0] = sc[0] - mt[0];
t0[1] = sc[1] - mt[1];
t1[0] = sc[0] + mt[0];
@@ -382,7 +377,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
mt[1] = mb[1] * pthick;
athick = len_v2(mt);
dfac = pthick - (athick * 2);
-
+
if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) {
mt[0] += (mb[0] * dfac);
mt[1] += (mb[1] * dfac);
@@ -429,7 +424,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
mt[1] = m2[1] * pthick * 0.5f;
sc[0] = s1[0] + (m1[0] * pthick * 0.75f);
sc[1] = s1[1] + (m1[1] * pthick * 0.75f);
-
+
t0[0] = sc[0] - mt[0];
t0[1] = sc[1] - mt[1];
t1[0] = sc[0] + mt[0];
@@ -669,7 +664,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
// ............................
/* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
-void draw_gpencil_2dimage(bContext *C /* , ImBuf *ibuf */)
+void draw_gpencil_2dimage(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@@ -699,35 +694,20 @@ void draw_gpencil_2dimage(bContext *C /* , ImBuf *ibuf */)
dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK;
}
break;
-#if 0 /* removed since 2.5x, needs to be added back */
case SPACE_SEQ: /* sequence */
{
- SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
- float zoom, zoomx, zoomy;
-
- /* check that we have grease-pencil stuff to draw */
- if (ELEM(NULL, sa, ibuf)) return;
-
- /* calculate accessory values */
- zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom));
- if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
- /* XXX sequencer zoom should store it? */
- zoomx = zoom; // * (G.scene->r.xasp / G.scene->r.yasp);
- zoomy = zoom;
- }
- else
- zoomx = zoomy = zoom;
-
- /* calculate transforms (Note: we use ibuf here, as we have it) */
- sizex = (int)(zoomx * ibuf->x);
- sizey = (int)(zoomy * ibuf->y);
- offsx = (int)( (ar->winx - sizex) / 2 + sseq->xof);
- offsy = (int)( (ar->winy - sizey) / 2 + sseq->yof);
+ /* just draw using standard scaling (settings here are currently ignored anyways) */
+ offsx = 0;
+ offsy = 0;
+ sizex = ar->winx;
+ sizey = ar->winy;
- dflag |= GP_DRAWDATA_ONLYI2D;
+ /* NOTE: I2D was used in 2.4x, but the old settings for that have been deprecated
+ * and everything moved to standard View2d
+ */
+ dflag |= GP_DRAWDATA_ONLYV2D;
}
break;
-#endif
default: /* for spacetype not yet handled */
offsx = 0;
offsy = 0;
@@ -746,7 +726,7 @@ void draw_gpencil_2dimage(bContext *C /* , ImBuf *ibuf */)
/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly
* Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes, second time with onlyv2d=0 for screen-aligned strokes
*/
-void draw_gpencil_view2d(bContext *C, short onlyv2d)
+void draw_gpencil_view2d(const bContext *C, short onlyv2d)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index b59f3756819..4c125ebe013 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -231,13 +231,30 @@ typedef enum eGP_Stroke_Ops {
STROKE_OPTS_V3D_ON,
} eGP_Stroke_Ops;
+static void draw_gpencil_space_specials(const bContext *C, uiLayout *layout)
+{
+ uiLayout *col, *row;
+ SpaceClip *sc = CTX_wm_space_clip(C);
+
+ col = uiLayoutColumn(layout, 0);
+
+ if (sc) {
+ bScreen *screen = CTX_wm_screen(C);
+ PointerRNA sc_ptr;
+
+ RNA_pointer_create(&screen->id, &RNA_SpaceClipEditor, sc, &sc_ptr);
+ row = uiLayoutRow(col, 1);
+ uiItemR(row, &sc_ptr, "grease_pencil_source", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ }
+}
+
/* Draw the contents for a grease-pencil panel*/
static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, PointerRNA *ctx_ptr)
{
PointerRNA gpd_ptr;
bGPDlayer *gpl;
uiLayout *col, *row;
- SpaceClip *sc= CTX_wm_space_clip(C);
+ SpaceClip *sc = CTX_wm_space_clip(C);
short v3d_stroke_opts = STROKE_OPTS_NORMAL;
const short is_v3d = CTX_wm_view3d(C) != NULL;
@@ -247,15 +264,6 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin
/* draw gpd settings first ------------------------------------- */
col = uiLayoutColumn(layout, 0);
- if (sc) {
- bScreen *screen = CTX_wm_screen(C);
- PointerRNA sc_ptr;
-
- RNA_pointer_create(&screen->id, &RNA_SpaceClipEditor, sc, &sc_ptr);
- row = uiLayoutRow(col, 1);
- uiItemR(row, &sc_ptr, "grease_pencil_source", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
- }
-
/* current Grease Pencil block */
/* TODO: show some info about who owns this? */
uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink");
@@ -315,6 +323,8 @@ void gpencil_panel_standard(const bContext *C, Panel *pa)
/* if (v3d->flag2 & V3D_DISPGP)... etc. */
+ draw_gpencil_space_specials(C, pa->layout);
+
/* get pointer to Grease Pencil Data */
gpd_ptr = gpencil_data_get_pointers((bContext *)C, &ptr);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 71cbabe9114..ed530bea4bd 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -78,8 +78,9 @@
/* Context Wrangling... */
/* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */
-bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
+bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr)
{
+ ID *screen_id = (ID *)CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
ScrArea *sa = CTX_wm_area(C);
@@ -122,9 +123,12 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
case SPACE_SEQ: /* Sequencer */
{
- //SpaceSeq *sseq= (SpaceSeq *)CTX_wm_space_data(C);
+ SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
- /* return the GP data for the active strips/image/etc. */
+ /* for now, Grease Pencil data is associated with the space (actually preview region only) */
+ // XXX our convention for everything else is to link to data though...
+ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr);
+ return &sseq->gpd;
}
break;
@@ -134,7 +138,7 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
/* for now, Grease Pencil data is associated with the space... */
// XXX our convention for everything else is to link to data though...
- if (ptr) RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_SpaceImageEditor, sima, ptr);
+ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr);
return &sima->gpd;
}
break;
@@ -143,10 +147,10 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
{
SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C);
MovieClip *clip = ED_space_clip(sc);
-
+
if (clip) {
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
- MovieTrackingTrack *track = BKE_tracking_active_track(&clip->tracking);
+ MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking);
if (!track)
return NULL;
@@ -177,7 +181,7 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
}
/* Get the active Grease Pencil datablock */
-bGPdata *gpencil_data_get_active(bContext *C)
+bGPdata *gpencil_data_get_active(const bContext *C)
{
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
return (gpd_ptr) ? *(gpd_ptr) : NULL;
@@ -214,7 +218,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op)
else {
/* decrement user count and add new datablock */
bGPdata *gpd = (*gpd_ptr);
-
+
id_us_min(&gpd->id);
*gpd_ptr = gpencil_data_addnew("GPencil");
}
@@ -479,7 +483,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect)
if (v3d) {
RegionView3D *rv3d = ar->regiondata;
-
+
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
Scene *scene = CTX_data_scene(C);
@@ -523,26 +527,26 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu
/* add points */
for (i = 0, bezt = nu->bezt; i < tot; i++, pt++, bezt++) {
float h1[3], h2[3];
-
+
if (i) interp_v3_v3v3(h1, p3d_cur, p3d_prev, 0.3);
else interp_v3_v3v3(h1, p3d_cur, p3d_next, -0.3);
-
+
if (i < tot - 1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3);
else interp_v3_v3v3(h2, p3d_cur, p3d_prev, -0.3);
-
+
copy_v3_v3(bezt->vec[0], h1);
copy_v3_v3(bezt->vec[1], p3d_cur);
copy_v3_v3(bezt->vec[2], h2);
-
+
/* set settings */
bezt->h1 = bezt->h2 = HD_FREE;
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
bezt->radius = bezt->weight = pt->pressure * gpl->thickness * 0.1f;
-
+
/* shift coord vects */
copy_v3_v3(p3d_prev, p3d_cur);
copy_v3_v3(p3d_cur, p3d_next);
-
+
if (i + 2 < tot) {
gp_strokepoint_convertcoords(C, gps, pt + 2, p3d_next, subrect);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 89d8ed9c465..6d90824668e 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -57,9 +57,12 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "RNA_access.h"
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+#include "RNA_access.h"
#include "RNA_define.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -79,15 +82,6 @@ typedef struct tGPsdata {
rctf *subrect; /* for using the camera rect within the 3d view */
rctf subrect_data;
-
-#if 0 // XXX review this 2d image stuff...
- ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */
- struct IBufViewSettings {
- int offsx, offsy; /* offsets */
- int sizex, sizey; /* dimensions to use as scale-factor */
- } im2d_settings; /* needed for GP_STROKE_2DIMAGE */
-#endif
-
PointerRNA ownerPtr; /* pointer to owner of gp-datablock */
bGPdata *gpd; /* gp-datablock layer comes from */
bGPDlayer *gpl; /* layer we're working on */
@@ -107,8 +101,10 @@ typedef struct tGPsdata {
float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space
* to region space */
-
- float custom_color[4]; /* custom color for (?) */
+
+ float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */
+
+ void *erasercursor; /* radial cursor data for drawing eraser */
} tGPsdata;
/* values for tGPsdata->status */
@@ -269,7 +265,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
int mval_prj[2];
float rvec[3], dvec[3];
float mval_f[2];
-
+
/* Current method just converts each point in screen-coordinates to
* 3D-coordinates using the 3D-cursor as reference. In general, this
* works OK, but it could of course be improved.
@@ -283,7 +279,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
/* method taken from editview.c - mouse_cursor() */
project_int_noclip(p->ar, rvec, mval_prj);
-
+
VECSUB2D(mval_f, mval_prj, mval);
ED_view3d_win_to_delta(p->ar, mval_f, dvec);
sub_v3_v3v3(out, rvec, dvec);
@@ -296,25 +292,6 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
mul_v3_m4v3(out, p->imat, out);
}
-#if 0
- /* 2d - on image 'canvas' (assume that p->v2d is set) */
- else if (gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) {
- int sizex, sizey, offsx, offsy;
-
- /* get stored settings
- * - assume that these have been set already (there are checks that set sane 'defaults' just in case)
- */
- sizex = p->im2d_settings.sizex;
- sizey = p->im2d_settings.sizey;
- offsx = p->im2d_settings.offsx;
- offsy = p->im2d_settings.offsy;
-
- /* calculate new points */
- out[0] = (float)(mval[0] - offsx) / (float)sizex;
- out[1] = (float)(mval[1] - offsy) / (float)sizey;
- }
-#endif
-
/* 2d - relative to screen (viewport area) */
else {
if (p->subrect == NULL) { /* normal 3D view */
@@ -393,11 +370,11 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure)
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* get pointer to destination point */
pt = (tGPspoint *)(gpd->sbuffer);
-
+
/* store settings */
copy_v2_v2_int(&pt->x, mval);
pt->pressure = pressure;
-
+
/* if there's stroke for this poly line session add (or replace last) point
* to stroke. This allows to draw lines more interactively (see new segment
* during mouse slide, i.e.)
@@ -405,36 +382,36 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure)
if (gp_stroke_added_check(p)) {
bGPDstroke *gps = p->gpf->strokes.last;
bGPDspoint *pts;
-
+
/* first time point is adding to temporary buffer -- need to allocate new point in stroke */
if (gpd->sbuffer_size == 0) {
gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1));
gps->totpoints++;
}
-
+
pts = &gps->points[gps->totpoints - 1];
-
+
/* special case for poly lines: normally, depth is needed only when creating new stroke from buffer,
* but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates
*/
if (gpencil_project_check(p)) {
View3D *v3d = p->sa->spacedata.first;
-
+
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0);
}
-
+
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL);
-
+
/* copy pressure */
pts->pressure = pt->pressure;
}
-
+
/* increment counters */
if (gpd->sbuffer_size == 0)
gpd->sbuffer_size++;
-
+
return GP_STROKEADD_NORMAL;
}
@@ -482,7 +459,7 @@ static void gp_stroke_smooth(tGPsdata *p)
/* second pass: apply smoothed coordinates */
for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) {
tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i);
-
+
copy_v2_v2_int(&pc->x, &spc->x);
}
@@ -639,10 +616,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* first point */
ptc = gpd->sbuffer;
-
+
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
-
+
/* copy pressure */
pt->pressure = ptc->pressure;
}
@@ -656,10 +633,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
int found_depth = 0;
depth_arr = MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points");
-
+
for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) {
copy_v2_v2_int(mval, &ptc->x);
-
+
if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) &&
(i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0)))
{
@@ -668,7 +645,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
else {
found_depth = TRUE;
}
-
+
copy_v2_v2_int(mval_prev, mval);
}
@@ -835,21 +812,6 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor
else if (gps->flag & GP_STROKE_2DSPACE) {
UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0);
}
-#if 0
- else if (gps->flag & GP_STROKE_2DIMAGE) {
- int offsx, offsy, sizex, sizey;
-
- /* get stored settings */
- sizex = p->im2d_settings.sizex;
- sizey = p->im2d_settings.sizey;
- offsx = p->im2d_settings.offsx;
- offsy = p->im2d_settings.offsy;
-
- /* calculate new points */
- x0 = (int)((gps->points->x * sizex) + offsx);
- y0 = (int)((gps->points->y * sizey) + offsy);
- }
-#endif
else {
if (p->subrect == NULL) { /* normal 3D view */
x0 = (int)(gps->points->x / 100 * p->ar->winx);
@@ -895,24 +857,6 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor
UI_view2d_view_to_region(p->v2d, pt2->x, pt2->y, &x1, &y1);
}
-#if 0
- else if (gps->flag & GP_STROKE_2DIMAGE) {
- int offsx, offsy, sizex, sizey;
-
- /* get stored settings */
- sizex = p->im2d_settings.sizex;
- sizey = p->im2d_settings.sizey;
- offsx = p->im2d_settings.offsx;
- offsy = p->im2d_settings.offsy;
-
- /* calculate new points */
- x0 = (int)((pt1->x * sizex) + offsx);
- y0 = (int)((pt1->y * sizey) + offsy);
-
- x1 = (int)((pt2->x * sizex) + offsx);
- y1 = (int)((pt2->y * sizey) + offsy);
- }
-#endif
else {
if (p->subrect == NULL) { /* normal 3D view */
x0 = (int)(pt1->x / 100 * p->ar->winx);
@@ -1029,16 +973,6 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable\n");
return 0;
}
-
-#if 0 // XXX will this sort of antiquated stuff be restored?
- /* check that gpencil data is allowed to be drawn */
- if ((v3d->flag2 & V3D_DISPGP) == 0) {
- p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
- printf("Error: In active view, Grease Pencil not shown\n");
- return 0;
- }
-#endif
}
break;
@@ -1050,19 +984,8 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
p->sa = curarea;
p->ar = ar;
p->v2d = &ar->v2d;
-
-#if 0 // XXX will this sort of antiquated stuff be restored?
- /* check that gpencil data is allowed to be drawn */
- if ((snode->flag & SNODE_DISPGP) == 0) {
- p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
- printf("Error: In active view, Grease Pencil not shown\n");
- return 0;
- }
-#endif
}
break;
-#if 0 // XXX these other spaces will come over time...
case SPACE_SEQ:
{
SpaceSeq *sseq = curarea->spacedata.first;
@@ -1079,15 +1002,8 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n");
return 0;
}
- if ((sseq->flag & SEQ_DRAW_GPENCIL) == 0) {
- p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
- printf("Error: In active view, Grease Pencil not shown\n");
- return 0;
- }
}
break;
-#endif
case SPACE_IMAGE:
{
//SpaceImage *sima= curarea->spacedata.first;
@@ -1096,48 +1012,36 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
p->sa = curarea;
p->ar = ar;
p->v2d = &ar->v2d;
- //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
-
-#if 0 // XXX disabled for now
- /* check that gpencil data is allowed to be drawn */
- if ((sima->flag & SI_DISPGP) == 0) {
- p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
- printf("Error: In active view, Grease Pencil not shown\n");
- return 0;
- }
-#endif
}
break;
case SPACE_CLIP:
{
SpaceClip *sc = curarea->spacedata.first;
-
+
/* set the current area */
p->sa = curarea;
p->ar = ar;
p->v2d = &ar->v2d;
- //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
-
+
invert_m4_m4(p->imat, sc->unistabmat);
-
+
/* custom color for new layer */
p->custom_color[0] = 1.0f;
p->custom_color[1] = 0.0f;
p->custom_color[2] = 0.5f;
p->custom_color[3] = 0.9f;
-
+
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
int framenr = sc->user.framenr;
- MovieTrackingTrack *track = BKE_tracking_active_track(&sc->clip->tracking);
- MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
-
+ MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
+
p->imat[3][0] -= marker->pos[0];
p->imat[3][1] -= marker->pos[1];
}
}
break;
-
+
/* unsupported views */
default:
{
@@ -1173,12 +1077,6 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
/* clear out buffer (stored in gp-data), in case something contaminated it */
gp_session_validatebuffer(p);
-#if 0
- /* set 'default' im2d_settings just in case something that uses this doesn't set it */
- p->im2d_settings.sizex = 1;
- p->im2d_settings.sizey = 1;
-#endif
-
return 1;
}
@@ -1224,7 +1122,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode)
p->gpl = gpencil_layer_getactive(p->gpd);
if (p->gpl == NULL) {
p->gpl = gpencil_layer_addnew(p->gpd);
-
+
if (p->custom_color[3])
copy_v3_v3(p->gpl->color, p->custom_color);
}
@@ -1260,7 +1158,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode)
if (p->sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = p->sa->spacedata.first;
RegionView3D *rv3d = p->ar->regiondata;
-
+
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, TRUE); /* no shift */
@@ -1290,41 +1188,13 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode)
p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
}
break;
-#if 0 // XXX other spacetypes to be restored in due course
+
case SPACE_SEQ:
{
- SpaceSeq *sseq = (SpaceSeq *)p->sa->spacedata.first;
- int rectx, recty;
- float zoom, zoomx, zoomy;
-
- /* set draw 2d-stroke flag */
- p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE;
-
- /* calculate zoom factor */
- zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom));
- if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
- zoomx = zoom * (p->scene->r.xasp / p->scene->r.yasp);
- zoomy = zoom;
- }
- else
- zoomx = zoomy = zoom;
-
- /* calculate rect size to use to calculate the size of the drawing area
- * - We use the size of the output image not the size of the ibuf being shown
- * as it is too messy getting the ibuf (and could be too slow). This should be
- * a reasonable for most cases anyway.
- */
- rectx = (p->scene->r.size * p->scene->r.xsch) / 100;
- recty = (p->scene->r.size * p->scene->r.ysch) / 100;
-
- /* set offset and scale values for opertations to use */
- p->im2d_settings.sizex = (int)(zoomx * rectx);
- p->im2d_settings.sizey = (int)(zoomy * recty);
- p->im2d_settings.offsx = (int)((p->sa->winx - p->im2d_settings.sizex) / 2 + sseq->xof);
- p->im2d_settings.offsy = (int)((p->sa->winy - p->im2d_settings.sizey) / 2 + sseq->yof);
+ p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
}
break;
-#endif
+
case SPACE_IMAGE:
{
SpaceImage *sima = (SpaceImage *)p->sa->spacedata.first;
@@ -1400,6 +1270,49 @@ static void gp_paint_cleanup(tGPsdata *p)
/* ------------------------------- */
+/* Helper callback for drawing the cursor itself */
+static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
+{
+ tGPsdata *p = (tGPsdata *)p_ptr;
+
+ if (p->paintmode == GP_PAINTMODE_ERASER) {
+ glPushMatrix();
+
+ glTranslatef((float)x, (float)y, 0.0f);
+
+ glColor4ub(255, 255, 255, 128);
+
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+
+ glutil_draw_lined_arc(0.0, M_PI * 2.0, p->radius, 40);
+
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+
+ glPopMatrix();
+ }
+}
+
+/* Turn brush cursor in 3D view on/off */
+static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short enable)
+{
+ if (p->erasercursor && !enable) {
+ /* clear cursor */
+ WM_paint_cursor_end(CTX_wm_manager(C), p->erasercursor);
+ p->erasercursor = NULL;
+ }
+ else if (enable) {
+ /* enable cursor */
+ p->erasercursor = WM_paint_cursor_activate(CTX_wm_manager(C),
+ NULL, // XXX
+ gpencil_draw_eraser, p);
+ }
+}
+
+/* ------------------------------- */
+
+
static void gpencil_draw_exit(bContext *C, wmOperator *op)
{
tGPsdata *p = op->customdata;
@@ -1414,8 +1327,12 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
if (p) {
/* check size of buffer before cleanup, to determine if anything happened here */
if (p->paintmode == GP_PAINTMODE_ERASER) {
- // TODO clear radial cursor thing
- // XXX draw_sel_circle(NULL, p.mvalo, 0, p.radius, 0);
+ /* turn off radial brush cursor */
+ gpencil_draw_toggle_eraser_cursor(C, p, FALSE);
+
+ /* if successful, store the new eraser size to be used again next time */
+ if (p->status == GP_STATUS_DONE)
+ U.gp_eraser = p->radius;
}
/* cleanup */
@@ -1466,6 +1383,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op)
return 1;
}
+
/* ------------------------------- */
/* update UI indicators of status, including cursor and header prints */
@@ -1560,8 +1478,9 @@ static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event)
float mousef[2];
int tablet = 0;
- /* convert from window-space to area-space mouse coordintes */
- // NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding...
+ /* convert from window-space to area-space mouse coordintes
+ * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding...
+ */
p->mval[0] = event->mval[0] + 1;
p->mval[1] = event->mval[1] + 1;
@@ -1710,7 +1629,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* if eraser is on, draw radial aid */
if (p->paintmode == GP_PAINTMODE_ERASER) {
- // TODO: this involves mucking around with radial control, so we leave this for now..
+ gpencil_draw_toggle_eraser_cursor(C, p, TRUE);
}
/* set cursor */
@@ -1743,13 +1662,13 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
-static int gpencil_area_exists(bContext *C, ScrArea *satest)
+static int gpencil_area_exists(bContext *C, ScrArea *sa_test)
{
bScreen *sc = CTX_wm_screen(C);
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa == satest)
+ if (sa == sa_test)
return 1;
}
@@ -1839,7 +1758,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
sketch |= GPENCIL_SKETCH_SESSIONS_ON(p->scene);
/* polyline drawing is also 'sketching' -- all knots should be added during one session */
sketch |= p->paintmode == GP_PAINTMODE_DRAW_POLY;
-
+
if (sketch) {
/* end stroke only, and then wait to resume painting soon */
//printf("\t\tGP - end stroke only\n");
@@ -1847,7 +1766,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
/* we've just entered idling state, so this event was processed (but no others yet) */
estate = OPERATOR_RUNNING_MODAL;
-
+
/* stroke could be smoothed, send notifier to refresh screen */
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL);
}
@@ -1860,7 +1779,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
else if (event->val == KM_PRESS) {
/* not painting, so start stroke (this should be mouse-button down) */
p = gpencil_stroke_begin(C, op);
-
+
if (p->status == GP_STATUS_ERROR) {
estate = OPERATOR_CANCELLED;
}
@@ -1889,8 +1808,37 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
estate = OPERATOR_RUNNING_MODAL;
}
}
+ /* eraser size */
+ else if ((p->paintmode == GP_PAINTMODE_ERASER) &&
+ ELEM4(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, PADPLUSKEY, PADMINUS))
+ {
+ /* just resize the brush (local version)
+ * TODO: fix the hardcoded size jumps (set to make a visible difference) and hardcoded keys
+ */
+ //printf("\t\tGP - resize eraser\n");
+ switch (event->type) {
+ case WHEELUPMOUSE: /* larger */
+ case PADPLUSKEY:
+ p->radius += 5;
+ break;
+
+ case WHEELDOWNMOUSE: /* smaller */
+ case PADMINUS:
+ p->radius -= 5;
+
+ if (p->radius < 0)
+ p->radius = 0;
+ break;
+ }
+
+ /* force refresh */
+ ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */
+
+ /* event handled, so just tag as running modal */
+ estate = OPERATOR_RUNNING_MODAL;
+ }
/* there shouldn't be any other events, but just in case there are, let's swallow them
- * (i.e. to prevent problems with with undo)
+ * (i.e. to prevent problems with undo)
*/
else {
/* swallow event to save ourselves trouble */
@@ -1916,7 +1864,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
case OPERATOR_CANCELLED:
gpencil_draw_exit(C, op);
break;
-
+
case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH:
/* event doesn't need to be handled */
//printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE);
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 1d42954a416..649266beec7 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -69,9 +69,9 @@ struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2]
void ED_clip_update_frame(const struct Main *mainp, int cfra);
int ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit);
-void ED_clip_point_undistorted_pos(SpaceClip * sc, float co[2], float nco[2]);
+void ED_clip_point_undistorted_pos(SpaceClip * sc, const float co[2], float r_co[2]);
void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr);
-void ED_clip_point_stable_pos__reverse(SpaceClip * sc, ARegion *ar, float co[2], float nco[2]);
+void ED_clip_point_stable_pos__reverse(SpaceClip * sc, ARegion *ar, const float co[2], float r_co[2]);
void ED_clip_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]);
int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc);
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 32eb63a26d5..1d461f797d6 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -64,8 +64,8 @@ typedef struct tGPspoint {
/* ----------- Grease Pencil Tools/Context ------------- */
-struct bGPdata **gpencil_data_get_pointers(struct bContext *C, struct PointerRNA *ptr);
-struct bGPdata *gpencil_data_get_active(struct bContext *C);
+struct bGPdata **gpencil_data_get_pointers(const struct bContext *C, struct PointerRNA *ptr);
+struct bGPdata *gpencil_data_get_active(const struct bContext *C);
struct bGPdata *gpencil_data_get_active_v3d(struct Scene *scene); /* for offscreen rendering */
/* ----------- Grease Pencil Operators ----------------- */
@@ -76,8 +76,8 @@ void ED_operatortypes_gpencil(void);
/* ------------ Grease-Pencil Drawing API ------------------ */
/* drawgpencil.c */
-void draw_gpencil_2dimage(struct bContext *C /* , struct ImBuf *ibuf */);
-void draw_gpencil_view2d(struct bContext *C, short onlyv2d);
+void draw_gpencil_2dimage(const struct bContext *C);
+void draw_gpencil_view2d(const struct bContext *C, short onlyv2d);
void draw_gpencil_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, short only3d);
void gpencil_panel_standard(const struct bContext *C, struct Panel *pa);
diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h
index c731245949e..cea567254de 100644
--- a/source/blender/editors/include/ED_sequencer.h
+++ b/source/blender/editors/include/ED_sequencer.h
@@ -27,8 +27,6 @@
#ifndef __ED_SEQUENCER_H__
#define __ED_SEQUENCER_H__
-#define SEQ_ZOOM_FAC(szoom) ((szoom) > 0.0f) ? (szoom) : ((szoom) == 0.0f) ? (1.0f) : (-1.0f / (szoom))
-
struct Scene;
struct Sequence;
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index f368e7cf4c7..3c802020747 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1542,15 +1542,16 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
}
else if ((scopes->track_search) &&
((!scopes->track_preview) ||
- (scopes->track_preview->x != width || scopes->track_preview->y != height)))
+ (scopes->track_preview->x != width || scopes->track_preview->y != height)))
{
ImBuf *tmpibuf;
if (scopes->track_preview)
IMB_freeImBuf(scopes->track_preview);
- tmpibuf = BKE_tracking_sample_pattern_imbuf(scopes->frame_width, scopes->frame_height,
- scopes->track_search, &scopes->undist_marker,
+ tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height,
+ scopes->track_search, scopes->track,
+ &scopes->undist_marker, scopes->use_track_mask,
width, height, scopes->track_pos);
if (tmpibuf->rect_float)
@@ -1582,6 +1583,12 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
if (width > 0 && height > 0) {
drawibuf = scopes->track_preview;
+ if (scopes->use_track_mask) {
+ glColor4f(0.0f, 0.0f, 0.0f, 0.3f);
+ uiSetRoundBox(15);
+ uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
+ }
+
glaDrawPixelsSafe(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y,
drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
@@ -1686,7 +1693,7 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE
int i;
float rad;
float a;
- float dalpha = alpha * 2.0f/255.0f, calpha;
+ float dalpha = alpha * 2.0f / 255.0f, calpha;
glEnable(GL_BLEND);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index a2adbd7a143..a8a7a55c653 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4201,9 +4201,9 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my);
}
else {
- if (scopes->marker) {
+ if (!scopes->track_locked) {
if (scopes->marker->framenr != scopes->framenr)
- scopes->marker = BKE_tracking_ensure_marker(scopes->track, scopes->framenr);
+ scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr);
scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->maxx - but->block->minx);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index dfd2d0cc4d0..1c3b642b63b 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -40,6 +40,7 @@
#include "BLI_blenlib.h"
#include "BLI_math_color.h"
+#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -69,22 +70,42 @@
/* ********************************************************** */
typedef struct Eyedropper {
+ short do_color_management;
+
PointerRNA ptr;
PropertyRNA *prop;
int index;
+
+ int accum_start; /* has mouse been presed */
+ float accum_col[3];
+ int accum_tot;
} Eyedropper;
static int eyedropper_init(bContext *C, wmOperator *op)
{
+ Scene *scene = CTX_data_scene(C);
+ const int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+
Eyedropper *eye;
op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index);
-
- return (eye->ptr.data && eye->prop && RNA_property_editable(&eye->ptr, eye->prop));
+
+ if ((eye->ptr.data == NULL) ||
+ (eye->prop == NULL) ||
+ (RNA_property_editable(&eye->ptr, eye->prop) == FALSE) ||
+ (RNA_property_array_length(&eye->ptr, eye->prop) < 3) ||
+ (RNA_property_type(eye->prop) != PROP_FLOAT))
+ {
+ return FALSE;
+ }
+
+ eye->do_color_management = (color_manage && RNA_property_subtype(eye->prop) == PROP_COLOR);
+
+ return TRUE;
}
-
+
static void eyedropper_exit(bContext *C, wmOperator *op)
{
WM_cursor_restore(CTX_wm_window(C));
@@ -100,29 +121,60 @@ static int eyedropper_cancel(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
-static void eyedropper_sample(bContext *C, Eyedropper *eye, int mx, int my)
+/* *** eyedropper_color_ helper functions *** */
+
+/* simply get the color from the screen */
+static void eyedropper_color_sample_fl(Eyedropper *UNUSED(eye), int mx, int my, float r_col[3])
{
- if (RNA_property_type(eye->prop) == PROP_FLOAT) {
- Scene *scene = CTX_data_scene(C);
- const int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
- float col[4];
-
- RNA_property_float_get_array(&eye->ptr, eye->prop, col);
-
- glReadBuffer(GL_FRONT);
- glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, col);
- glReadBuffer(GL_BACK);
-
- if (RNA_property_array_length(&eye->ptr, eye->prop) < 3) return;
+ glReadBuffer(GL_FRONT);
+ glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, r_col);
+ glReadBuffer(GL_BACK);
+}
- /* convert from screen (srgb) space to linear rgb space */
- if (color_manage && RNA_property_subtype(eye->prop) == PROP_COLOR)
- srgb_to_linearrgb_v3_v3(col, col);
-
- RNA_property_float_set_array(&eye->ptr, eye->prop, col);
-
- RNA_property_update(C, &eye->ptr, eye->prop);
+/* sets the sample color RGB, maintaining A */
+static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
+{
+ float col_conv[4];
+
+ /* to maintain alpha */
+ RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv);
+
+ /* convert from screen (srgb) space to linear rgb space */
+ if (eye->do_color_management) {
+ srgb_to_linearrgb_v3_v3(col_conv, col);
}
+ else {
+ copy_v3_v3(col_conv, col);
+ }
+
+ RNA_property_float_set_array(&eye->ptr, eye->prop, col_conv);
+
+ RNA_property_update(C, &eye->ptr, eye->prop);
+}
+
+/* set sample from accumulated values */
+static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye)
+{
+ float col[4];
+ mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot);
+ eyedropper_color_set(C, eye, col);
+}
+
+/* single point sample & set */
+static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my)
+{
+ float col[3];
+ eyedropper_color_sample_fl(eye, mx, my, col);
+ eyedropper_color_set(C, eye, col);
+}
+
+static void eyedropper_color_sample_accum(Eyedropper *eye, int mx, int my)
+{
+ float col[3];
+ eyedropper_color_sample_fl(eye, mx, my, col);
+ /* delay linear conversion */
+ add_v3_v3(eye->accum_col, col);
+ eye->accum_tot++;
}
/* main modal status check */
@@ -136,10 +188,35 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event)
return eyedropper_cancel(C, op);
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
- eyedropper_sample(C, eye, event->x, event->y);
+ if (eye->accum_tot == 0) {
+ eyedropper_color_sample(C, eye, event->x, event->y);
+ }
+ else {
+ eyedropper_color_set_accum(C, eye);
+ }
eyedropper_exit(C, op);
return OPERATOR_FINISHED;
}
+ else if (event->val == KM_PRESS) {
+ /* enable accum and make first sample */
+ eye->accum_start = TRUE;
+ eyedropper_color_sample_accum(eye, event->x, event->y);
+ }
+ break;
+ case MOUSEMOVE:
+ if (eye->accum_start) {
+ /* button is pressed so keep sampling */
+ eyedropper_color_sample_accum(eye, event->x, event->y);
+ eyedropper_color_set_accum(C, eye);
+ }
+ break;
+ case SPACEKEY:
+ if (event->val == KM_RELEASE) {
+ eye->accum_tot = 0;
+ zero_v3(eye->accum_col);
+ eyedropper_color_sample_accum(eye, event->x, event->y);
+ eyedropper_color_set_accum(C, eye);
+ }
break;
}
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index a0b83b5fef4..9773918e508 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -130,7 +130,13 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
return but;
}
-int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(PointerRNA *, PropertyRNA *), const char label_align)
+/**
+ * \a check_prop callback filters functions to avoid drawing certain properties,
+ * in cases where PROP_HIDDEN flag can't be used for a property.
+ */
+int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr,
+ int (*check_prop)(PointerRNA *, PropertyRNA *),
+ const char label_align)
{
uiLayout *split, *col;
int flag;
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index e1efb6d841b..678186f0e8c 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -233,11 +233,26 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline)
/* #define USE_XOR */
+static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char rgb[4], const short is_active)
+{
+ if (!is_active) {
+ r_rgb[0] = (unsigned char)((((int)(rgb[0])) + 128) / 2);
+ r_rgb[1] = (unsigned char)((((int)(rgb[1])) + 128) / 2);
+ r_rgb[2] = (unsigned char)((((int)(rgb[2])) + 128) / 2);
+ r_rgb[3] = rgb[3];
+ }
+ else {
+ *(unsigned int *)r_rgb = *(const unsigned int *)rgb;
+ }
+}
+
static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot_point,
- const short is_feather, const short is_smooth,
+ const short is_feather, const short is_smooth, const short is_active,
const unsigned char rgb_spline[4], const char draw_type)
{
const int draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GL_LINE_LOOP : GL_LINE_STRIP;
+ const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
+// const unsigned char rgb_white[4] = {0xff, 0xff, 0xff, 0xff};
unsigned char rgb_tmp[4];
glEnableClientState(GL_VERTEX_ARRAY);
@@ -247,12 +262,15 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
case MASK_DT_OUTLINE:
glLineWidth(3);
- cpack(0x0);
+
+ mask_color_active_tint(rgb_tmp, rgb_black, is_active);
+ glColor4ubv(rgb_tmp);
glDrawArrays(draw_method, 0, tot_point);
glLineWidth(1);
- glColor4ubv(rgb_spline);
+ mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
+ glColor4ubv(rgb_tmp);
glDrawArrays(draw_method, 0, tot_point);
break;
@@ -265,7 +283,8 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_OR);
#endif
- glColor4ubv(rgb_spline);
+ mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
+ glColor4ubv(rgb_tmp);
glLineStipple(3, 0xaaaa);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, points);
@@ -274,7 +293,8 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
#ifdef USE_XOR
glDisable(GL_COLOR_LOGIC_OP);
#endif
- glColor4ub(0, 0, 0, 255);
+ mask_color_active_tint(rgb_tmp, rgb_black, is_active);
+ glColor4ubv(rgb_tmp);
glLineStipple(3, 0x5555);
glDrawArrays(draw_method, 0, tot_point);
@@ -301,7 +321,9 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
+ mask_color_active_tint(rgb_tmp, rgb_tmp, is_active);
glColor4ubv(rgb_tmp);
+
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, points);
glDrawArrays(draw_method, 0, tot_point);
@@ -321,6 +343,7 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
const char draw_flag, const char draw_type,
+ const short is_active,
int width, int height)
{
unsigned char rgb_tmp[4];
@@ -350,14 +373,14 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
/* draw feather */
mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp);
mask_draw_curve_type(spline, feather_points, tot_feather_point,
- TRUE, is_smooth,
+ TRUE, is_smooth, is_active,
rgb_tmp, draw_type);
MEM_freeN(feather_points);
/* draw main curve */
mask_spline_color_get(masklay, spline, is_spline_sel, rgb_tmp);
mask_draw_curve_type(spline, diff_points, tot_diff_point,
- FALSE, is_smooth,
+ FALSE, is_smooth, is_active,
rgb_tmp, draw_type);
MEM_freeN(diff_points);
@@ -373,9 +396,11 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type
int width, int height)
{
MaskLayer *masklay;
+ int i;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ for (masklay = mask->masklayers.first, i = 0; masklay; masklay = masklay->next, i++) {
MaskSpline *spline;
+ const short is_active = (i == mask->masklay_act);
if (masklay->restrictflag & MASK_RESTRICT_VIEW) {
continue;
@@ -384,7 +409,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type
for (spline = masklay->splines.first; spline; spline = spline->next) {
/* draw curve itself first... */
- draw_spline_curve(masklay, spline, draw_flag, draw_type, width, height);
+ draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height);
// draw_spline_parents(masklay, spline);
@@ -398,7 +423,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type
void *back = spline->points_deform;
spline->points_deform = NULL;
- draw_spline_curve(masklay, spline, draw_flag, draw_type, width, height);
+ draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height);
// draw_spline_parents(masklay, spline);
draw_spline_points(masklay, spline);
spline->points_deform = back;
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 24f55f66bb8..52711c8da55 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -207,6 +207,7 @@ void ED_operatortypes_mask(void)
/* geometry */
WM_operatortype_append(MASK_OT_switch_direction);
+ WM_operatortype_append(MASK_OT_normals_make_consistent);
WM_operatortype_append(MASK_OT_delete);
/* select */
@@ -307,6 +308,7 @@ void ED_keymap_mask(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MASK_OT_cyclic_toggle", CKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MASK_OT_slide_point", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MASK_OT_handle_type_set", VKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "MASK_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0);
// WM_keymap_add_item(keymap, "MASK_OT_feather_weight_clear", SKEY, KM_PRESS, KM_ALT, 0);
/* ... matches curve editmode */
RNA_enum_set(WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", TFM_MASK_SHRINKFATTEN);
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index fc6089238a1..c34558d2a01 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -56,6 +56,7 @@ void MASK_OT_hide_view_clear(struct wmOperatorType *ot);
void MASK_OT_hide_view_set(struct wmOperatorType *ot);
void MASK_OT_feather_weight_clear(struct wmOperatorType *ot);
void MASK_OT_switch_direction(struct wmOperatorType *ot);
+void MASK_OT_normals_make_consistent(struct wmOperatorType *ot);
void MASK_OT_handle_type_set(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 67fd57ed50b..b770e5e9dba 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -758,11 +758,10 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event)
}
}
- free_slide_point_data(op->customdata);
-
WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask);
DAG_id_tag_update(&data->mask->id, 0);
+ free_slide_point_data(op->customdata); /* keep this last! */
return OPERATOR_FINISHED;
}
@@ -771,11 +770,10 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event)
case ESCKEY:
cancel_slide_point(op->customdata);
- free_slide_point_data(op->customdata);
-
WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask);
DAG_id_tag_update(&data->mask->id, 0);
+ free_slide_point_data(op->customdata); /* keep this last! */
return OPERATOR_CANCELLED;
}
@@ -959,6 +957,12 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
spline = next_spline;
}
+
+ /* not essential but confuses users when there are keys with no data!
+ * assume if they delete all data from the layer they also dont care about keys */
+ if (masklay->splines.first == NULL) {
+ BKE_mask_layer_free_shapes(masklay);
+ }
}
/* TODO: only update edited splines */
@@ -988,6 +992,7 @@ void MASK_OT_delete(wmOperatorType *ot)
/* *** switch direction *** */
static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
@@ -996,6 +1001,7 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
/* do actual selection */
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
MaskSpline *spline;
+ int change_layer = FALSE;
if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
@@ -1005,6 +1011,13 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
if (ED_mask_spline_select_check(spline)) {
BKE_mask_spline_direction_switch(masklay, spline);
change = TRUE;
+ change_layer = TRUE;
+ }
+ }
+
+ if (change_layer) {
+ if (IS_AUTOKEY_ON(scene)) {
+ ED_mask_layer_shape_auto_key(masklay, CFRA);
}
}
}
@@ -1037,6 +1050,73 @@ void MASK_OT_switch_direction(wmOperatorType *ot)
}
+/* *** recalc normals *** */
+static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ Mask *mask = CTX_data_edit_mask(C);
+ MaskLayer *masklay;
+ int i;
+
+ int change = FALSE;
+
+ /* do actual selection */
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ MaskSpline *spline;
+ int change_layer = FALSE;
+
+ if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ continue;
+ }
+
+ for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+
+ if (MASKPOINT_ISSEL_ANY(point)) {
+ BKE_mask_calc_handle_point_auto(spline, point, FALSE);
+ change = TRUE;
+ change_layer = TRUE;
+ }
+ }
+ }
+
+ if (change_layer) {
+ if (IS_AUTOKEY_ON(scene)) {
+ ED_mask_layer_shape_auto_key(masklay, CFRA);
+ }
+ }
+ }
+
+ if (change) {
+ /* TODO: only update this spline */
+ BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+
+ WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+/* named to match mesh recalc normals */
+void MASK_OT_normals_make_consistent(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Recalc Normals";
+ ot->description = "Re-calculate the direction of selected handles";
+ ot->idname = "MASK_OT_normals_make_consistent";
+
+ /* api callbacks */
+ ot->exec = mask_normals_make_consistent_exec;
+ ot->poll = ED_maskedit_mask_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
/******************** set handle type *********************/
static int set_handle_type_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c
index 77fe2a71225..7ba3c27e18d 100644
--- a/source/blender/editors/mask/mask_relationships.c
+++ b/source/blender/editors/mask/mask_relationships.c
@@ -113,8 +113,8 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
if ((NULL == (sc = CTX_wm_space_clip(C))) ||
(NULL == (clip = sc->clip)) ||
(NULL == (track = clip->tracking.act_track)) ||
- (NULL == (marker = BKE_tracking_get_marker(track, sc->user.framenr))) ||
- (NULL == (tracking = BKE_tracking_active_object(&clip->tracking))))
+ (NULL == (marker = BKE_tracking_marker_get(track, sc->user.framenr))) ||
+ (NULL == (tracking = BKE_tracking_object_get_active(&clip->tracking))))
{
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c
index c5f8494836b..2cb03104874 100644
--- a/source/blender/editors/mesh/editmesh_bvh.c
+++ b/source/blender/editors/mesh/editmesh_bvh.c
@@ -308,7 +308,7 @@ static void vertsearchcallback(void *userdata, int index, const float *UNUSED(co
}
}
-BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, float *co, float maxdist)
+BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist)
{
BVHTreeNearest hit;
@@ -370,7 +370,7 @@ int BMBVH_VertVisible(BMBVHTree *tree, BMEdge *e, RegionView3D *r3d)
}
#endif
-static BMFace *edge_ray_cast(BMBVHTree *tree, float *co, float *dir, float *hitout, BMEdge *e)
+static BMFace *edge_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], float *hitout, BMEdge *e)
{
BMFace *f = BMBVH_RayCast(tree, co, dir, hitout, NULL);
diff --git a/source/blender/editors/mesh/editmesh_bvh.h b/source/blender/editors/mesh/editmesh_bvh.h
index 6512f054c1b..53d1c36119e 100644
--- a/source/blender/editors/mesh/editmesh_bvh.h
+++ b/source/blender/editors/mesh/editmesh_bvh.h
@@ -57,8 +57,8 @@ int BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e,
struct ARegion *ar, struct View3D *v3d, struct Object *obedit);
/*find a vert closest to co in a sphere of radius maxdist*/
-struct BMVert *BMBVH_FindClosestVert(struct BMBVHTree *tree, float *co, float maxdist);
-
+struct BMVert *BMBVH_FindClosestVert(struct BMBVHTree *tree, const float co[3], const float maxdist);
+
/* BMBVH_NewBVH flag parameter */
enum {
BMBVH_USE_CAGE = 1, /* project geometry onto modifier cage */
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 185c804661d..15e3033b7eb 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -329,6 +329,8 @@ static void ringsel_finish(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, CTX_data_scene(C));
}
+ else
+ EDBM_selectmode_flush(lcd->em);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT | ND_DATA, lcd->ob->data);
DAG_id_tag_update(lcd->ob->data, 0);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 5988c9d8d5e..bf299ffaa61 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -676,6 +676,7 @@ static EnumPropertyItem prop_similar_types[] = {
{SIMVERT_NORMAL, "NORMAL", 0, "Normal", ""},
{SIMVERT_FACE, "FACE", 0, "Amount of Adjacent Faces", ""},
{SIMVERT_VGROUP, "VGROUP", 0, "Vertex Groups", ""},
+ {SIMVERT_EDGE, "EDGE", 0, "Amount of connecting edges", ""},
{SIMEDGE_LENGTH, "LENGTH", 0, "Length", ""},
{SIMEDGE_DIR, "DIR", 0, "Direction", ""},
@@ -1899,7 +1900,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *
}
BMW_end(&walker);
- BM_mesh_select_mode_flush(bm);
+ EDBM_selectmode_flush(em);
}
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 989f1a36f99..59a0475ebb5 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -690,7 +690,8 @@ static void mesh_octree_free_node(MocNode **bt)
/* temporal define, just to make nicer code below */
#define MOC_INDEX(vx, vy, vz) (((vx) * MOC_RES * MOC_RES) + (vy) * MOC_RES + (vz))
-static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, intptr_t index)
+static void mesh_octree_add_nodes(MocNode **basetable, const float co[3], const float offs[3],
+ const float div[3], intptr_t index)
{
float fx, fy, fz;
int vx, vy, vz;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 159f75b60e6..ba26b92f354 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -108,13 +108,14 @@
#include "object_intern.h"
/* this is an exact copy of the define in rna_lamp.c
- * kept here because of linking order */
+ * kept here because of linking order.
+ * Icons are only defined here */
EnumPropertyItem lamp_type_items[] = {
- {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"},
- {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"},
- {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"},
- {LA_HEMI, "HEMI", 0, "Hemi", "180 degree constant light source"},
- {LA_AREA, "AREA", 0, "Area", "Directional area light source"},
+ {LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source"},
+ {LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source"},
+ {LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source"},
+ {LA_HEMI, "HEMI", ICON_LAMP_HEMI, "Hemi", "180 degree constant light source"},
+ {LA_AREA, "AREA", ICON_LAMP_AREA, "Area", "Directional area light source"},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 7cc11fa0209..a38c69fba8a 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -418,15 +418,15 @@ static void test_constraints(Object *owner, bPoseChannel *pchan)
MovieTrackingObject *tracking_object;
if (data->object[0])
- tracking_object = BKE_tracking_named_object(tracking, data->object);
+ tracking_object = BKE_tracking_object_get_named(tracking, data->object);
else
- tracking_object = BKE_tracking_get_camera_object(tracking);
+ tracking_object = BKE_tracking_object_get_camera(tracking);
if (!tracking_object) {
curcon->flag |= CONSTRAINT_DISABLE;
}
else {
- if (!BKE_tracking_named_track(tracking, tracking_object, data->track))
+ if (!BKE_tracking_track_get_named(tracking, tracking_object, data->track))
curcon->flag |= CONSTRAINT_DISABLE;
}
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 3d7dd01bf30..5ad663b92d3 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1770,7 +1770,7 @@ static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_game_property_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Clear Game Property";
+ ot->name = "Clear Game Properties";
ot->idname = "OBJECT_OT_game_property_clear";
ot->description = "Remove all game properties from all selected objects";
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 66ad05aec7e..89dbe14f62a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -212,6 +212,11 @@ typedef struct StrokeCache {
float clip_tolerance[3];
float initial_mouse[2];
+ /* Pre-allocated temporary storage used during smoothing */
+ int num_threads;
+ float (**tmpgrid_co)[3], (**tmprow_co)[3];
+ float **tmpgrid_mask, **tmprow_mask;
+
/* Variants */
float radius;
float radius_squared;
@@ -919,7 +924,7 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod
/* Grab brush requires to test on original data (see r33888 and
* bug #25371) */
original = (paint_brush(&sd->paint)->sculpt_tool == SCULPT_TOOL_GRAB ?
- TRUE : ss->cache->original);
+ TRUE : ss->cache->original);
(void)sd; /* unused w/o openmp */
@@ -991,7 +996,7 @@ static void calc_sculpt_normal(Sculpt *sd, Object *ob,
case SCULPT_DISP_DIR_VIEW:
ED_view3d_global_to_vector(ss->cache->vc->rv3d,
ss->cache->vc->rv3d->twmat[3],
- an);
+ an);
break;
case SCULPT_DISP_DIR_X:
@@ -1117,21 +1122,21 @@ static void update_brush_local_mat(Sculpt *sd, Object *ob)
static int brush_needs_sculpt_normal(const Brush *brush)
{
return ((ELEM(brush->sculpt_tool,
- SCULPT_TOOL_GRAB,
- SCULPT_TOOL_SNAKE_HOOK) &&
- ((brush->normal_weight > 0) ||
- (brush->flag & BRUSH_FRONTFACE))) ||
-
- ELEM7(brush->sculpt_tool,
- SCULPT_TOOL_BLOB,
- SCULPT_TOOL_CREASE,
- SCULPT_TOOL_DRAW,
- SCULPT_TOOL_LAYER,
- SCULPT_TOOL_NUDGE,
- SCULPT_TOOL_ROTATE,
- SCULPT_TOOL_THUMB) ||
-
- (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA));
+ SCULPT_TOOL_GRAB,
+ SCULPT_TOOL_SNAKE_HOOK) &&
+ ((brush->normal_weight > 0) ||
+ (brush->flag & BRUSH_FRONTFACE))) ||
+
+ ELEM7(brush->sculpt_tool,
+ SCULPT_TOOL_BLOB,
+ SCULPT_TOOL_CREASE,
+ SCULPT_TOOL_DRAW,
+ SCULPT_TOOL_LAYER,
+ SCULPT_TOOL_NUDGE,
+ SCULPT_TOOL_ROTATE,
+ SCULPT_TOOL_THUMB) ||
+
+ (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA));
}
/* For the smooth brush, uses the neighboring vertices around vert to calculate
@@ -1257,6 +1262,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
float (*tmpgrid_co)[3], (*tmprow_co)[3];
float *tmpgrid_mask, *tmprow_mask;
int v1, v2, v3, v4;
+ int thread_num;
int *grid_indices, totgrid, gridsize, i, x, y;
sculpt_brush_test_init(ss, &test);
@@ -1267,17 +1273,15 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
NULL, &gridsize, &griddata, &gridadj);
BLI_pbvh_get_grid_key(ss->pbvh, &key);
- #pragma omp critical
- {
- if (smooth_mask) {
- tmpgrid_mask = MEM_mallocN(sizeof(float) * gridsize * gridsize, "tmpgrid_mask");
- tmprow_mask = MEM_mallocN(sizeof(float) * gridsize, "tmprow_mask");
- }
- else {
- tmpgrid_co = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid_co");
- tmprow_co = MEM_mallocN(sizeof(float) * 3 * gridsize, "tmprow_co");
- }
- }
+ thread_num = 0;
+#ifdef _OPENMP
+ if (sd->flags & SCULPT_USE_OPENMP)
+ thread_num = omp_get_thread_num();
+#endif
+ tmpgrid_co = ss->cache->tmpgrid_co[thread_num];
+ tmprow_co = ss->cache->tmprow_co[thread_num];
+ tmpgrid_mask = ss->cache->tmpgrid_mask[thread_num];
+ tmprow_mask = ss->cache->tmprow_mask[thread_num];
for (i = 0; i < totgrid; ++i) {
data = griddata[grid_indices[i]];
@@ -1393,18 +1397,6 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
}
}
}
-
- #pragma omp critical
- {
- if (smooth_mask) {
- MEM_freeN(tmpgrid_mask);
- MEM_freeN(tmprow_mask);
- }
- else {
- MEM_freeN(tmpgrid_co);
- MEM_freeN(tmprow_co);
- }
- }
}
static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode,
@@ -1432,14 +1424,14 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode,
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for (n = 0; n < totnode; n++) {
- switch(type) {
+ switch (type) {
case PBVH_GRIDS:
do_multires_smooth_brush(sd, ss, nodes[n], strength,
- smooth_mask);
+ smooth_mask);
break;
case PBVH_FACES:
do_mesh_smooth_brush(sd, ss, nodes[n], strength,
- smooth_mask);
+ smooth_mask);
break;
}
}
@@ -1532,7 +1524,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
/* offset vertex */
float fade = tex_strength(ss, brush, vd.co, test.dist,
ss->cache->sculpt_normal_symm, vd.no,
- vd.fno, *vd.mask);
+ vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], offset, fade);
@@ -1588,7 +1580,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
/* offset vertex */
const float fade = tex_strength(ss, brush, vd.co, test.dist,
ss->cache->sculpt_normal_symm,
- vd.no, vd.fno, *vd.mask);
+ vd.no, vd.fno, *vd.mask);
float val1[3];
float val2[3];
@@ -1726,7 +1718,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
ss->cache->sculpt_normal_symm,
- vd.no, vd.fno, *vd.mask);
+ vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -1775,7 +1767,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
ss->cache->sculpt_normal_symm,
- vd.no, vd.fno, *vd.mask);
+ vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -1823,7 +1815,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
ss->cache->sculpt_normal_symm,
- origno[vd.i], NULL, *vd.mask);
+ origno[vd.i], NULL, *vd.mask);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -1876,7 +1868,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
ss->cache->sculpt_normal_symm,
- origno[vd.i], NULL, *vd.mask);
+ origno[vd.i], NULL, *vd.mask);
mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]);
sub_v3_v3(proxy[vd.i], origco[vd.i]);
@@ -1929,7 +1921,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
ss->cache->sculpt_normal_symm,
- vd.no, vd.fno, *vd.mask);
+ vd.no, vd.fno, *vd.mask);
float *disp = &layer_disp[vd.i];
float val[3];
@@ -3233,6 +3225,69 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
}
}
+static void sculpt_omp_start(Sculpt *sd, SculptSession *ss)
+{
+ StrokeCache *cache = ss->cache;
+
+#ifdef _OPENMP
+ /* If using OpenMP then create a number of threads two times the
+ * number of processor cores.
+ * Justification: Empirically I've found that two threads per
+ * processor gives higher throughput. */
+ if (sd->flags & SCULPT_USE_OPENMP) {
+ cache->num_threads = 2 * omp_get_num_procs();
+ omp_set_num_threads(cache->num_threads);
+ }
+ else
+#endif
+ {
+ (void)sd;
+ cache->num_threads = 1;
+ }
+
+ if (ss->multires) {
+ int i, gridsize, array_mem_size;
+ BLI_pbvh_node_get_grids(ss->pbvh, NULL, NULL, NULL, NULL,
+ &gridsize, NULL, NULL);
+
+ array_mem_size = cache->num_threads * sizeof(void*);
+
+ cache->tmpgrid_co = MEM_mallocN(array_mem_size, "tmpgrid_co array");
+ cache->tmprow_co = MEM_mallocN(array_mem_size, "tmprow_co array");
+ cache->tmpgrid_mask = MEM_mallocN(array_mem_size, "tmpgrid_mask array");
+ cache->tmprow_mask = MEM_mallocN(array_mem_size, "tmprow_mask array");
+
+ for (i = 0; i < cache->num_threads; i++) {
+ const size_t row_size = sizeof(float) * gridsize;
+ const size_t co_row_size = 3 * row_size;
+
+ cache->tmprow_co[i] = MEM_mallocN(co_row_size, "tmprow_co");
+ cache->tmpgrid_co[i] = MEM_mallocN(co_row_size * gridsize, "tmpgrid_co");
+ cache->tmprow_mask[i] = MEM_mallocN(row_size, "tmprow_mask");
+ cache->tmpgrid_mask[i] = MEM_mallocN(row_size * gridsize, "tmpgrid_mask");
+ }
+ }
+}
+
+static void sculpt_omp_done(SculptSession *ss)
+{
+ if (ss->multires) {
+ int i;
+
+ for (i = 0; i < ss->cache->num_threads; i++) {
+ MEM_freeN(ss->cache->tmpgrid_co[i]);
+ MEM_freeN(ss->cache->tmprow_co[i]);
+ MEM_freeN(ss->cache->tmpgrid_mask[i]);
+ MEM_freeN(ss->cache->tmprow_mask[i]);
+ }
+
+ MEM_freeN(ss->cache->tmpgrid_co);
+ MEM_freeN(ss->cache->tmprow_co);
+ MEM_freeN(ss->cache->tmpgrid_mask);
+ MEM_freeN(ss->cache->tmprow_mask);
+ }
+}
+
/* Initialize the stroke cache invariants from operator properties */
static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSession *ss, wmOperator *op, const float mouse[2])
{
@@ -3346,6 +3401,8 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
cache->first_time = 1;
cache->vertex_rotation = 0;
+
+ sculpt_omp_start(sd, ss);
}
static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
@@ -3585,15 +3642,15 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
one of smooth brush, autosmooth, mask smooth, or shift-key
smooth) */
static int sculpt_any_smooth_mode(const Brush *brush,
- StrokeCache *cache,
- int stroke_mode)
+ StrokeCache *cache,
+ int stroke_mode)
{
return ((stroke_mode == BRUSH_STROKE_SMOOTH) ||
- (cache && cache->alt_smooth) ||
- (brush->sculpt_tool == SCULPT_TOOL_SMOOTH) ||
- (brush->autosmooth_factor > 0) ||
- ((brush->sculpt_tool == SCULPT_TOOL_MASK) &&
- (brush->mask_tool == BRUSH_MASK_SMOOTH)));
+ (cache && cache->alt_smooth) ||
+ (brush->sculpt_tool == SCULPT_TOOL_SMOOTH) ||
+ (brush->autosmooth_factor > 0) ||
+ ((brush->sculpt_tool == SCULPT_TOOL_MASK) &&
+ (brush->mask_tool == BRUSH_MASK_SMOOTH)));
}
static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob)
@@ -3605,7 +3662,7 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob)
Brush *brush = paint_brush(&sd->paint);
sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob,
- sculpt_any_smooth_mode(brush, ss->cache, 0));
+ sculpt_any_smooth_mode(brush, ss->cache, 0));
}
}
@@ -3798,19 +3855,6 @@ static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op,
sculpt_undo_push_begin(sculpt_tool_name(sd));
-#ifdef _OPENMP
- /* If using OpenMP then create a number of threads two times the
- * number of processor cores.
- * Justification: Empirically I've found that two threads per
- * processor gives higher throughput. */
- if (sd->flags & SCULPT_USE_OPENMP) {
- int num_procs;
-
- num_procs = omp_get_num_procs();
- omp_set_num_threads(2 * num_procs);
- }
-#endif
-
return 1;
}
else
@@ -3847,6 +3891,8 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ sculpt_omp_done(ss);
+
/* reset values used to draw brush after completing the stroke */
sd->draw_anchored = 0;
sd->draw_pressure = 0;
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index c8660179945..db1d4ed1155 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -435,6 +435,12 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn)
break;
}
break;
+ case NC_WINDOW:
+ if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
+ /* force redraw/refresh after undo/redo - [#28962] */
+ ED_area_tag_refresh(sa);
+ }
+ break;
}
}
@@ -464,9 +470,21 @@ static void action_refresh(const bContext *C, ScrArea *sa)
* NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
*/
if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
+ ARegion *ar;
+
+ /* Perform syncing of channel state incl. selection
+ * Active action setting also occurs here (as part of anim channel filtering in anim_filter.c)
+ */
ANIM_sync_animchannels_to_data(C);
saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC;
+
+ /* Tag everything for redraw
+ * - Regions (such as header) need to be manually tagged for redraw too
+ * or else they don't update [#28962]
+ */
ED_area_tag_redraw(sa);
+ for (ar = sa->regionbase.first; ar; ar = ar->next)
+ ED_region_tag_redraw(ar);
}
/* region updates? */
diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt
index ec5e81e4b2c..ecc4dea8b05 100644
--- a/source/blender/editors/space_clip/CMakeLists.txt
+++ b/source/blender/editors/space_clip/CMakeLists.txt
@@ -52,6 +52,7 @@ set(SRC
clip_utils.c
space_clip.c
tracking_ops.c
+ tracking_select.c
clip_intern.h
)
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index ca2ae6e8461..9b3d713d040 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -59,7 +59,7 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
/* Panels */
@@ -165,7 +165,8 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
block = uiLayoutAbsoluteBlock(layout);
- scopes->track_preview_height = (scopes->track_preview_height <= UI_UNIT_Y)?UI_UNIT_Y : scopes->track_preview_height;
+ scopes->track_preview_height =
+ (scopes->track_preview_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->track_preview_height;
uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin,
scopes->track_preview_height, scopes, 0, 0, 0, 0, "");
@@ -173,27 +174,27 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
/********************* Marker Template ************************/
-#define B_MARKER_POS 3
-#define B_MARKER_OFFSET 4
-#define B_MARKER_PAT_DIM 5
-#define B_MARKER_SEARCH_POS 6
-#define B_MARKER_SEARCH_DIM 7
-#define B_MARKER_FLAG 8
+#define B_MARKER_POS 3
+#define B_MARKER_OFFSET 4
+#define B_MARKER_PAT_DIM 5
+#define B_MARKER_SEARCH_POS 6
+#define B_MARKER_SEARCH_DIM 7
+#define B_MARKER_FLAG 8
typedef struct {
- int compact; /* compact mode */
+ int compact; /* compact mode */
MovieClip *clip;
- MovieClipUser *user; /* user of clip */
+ MovieClipUser *user; /* user of clip */
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
- int framenr; /* current frame number */
- float marker_pos[2]; /* position of marker in pixel coords */
- float marker_pat[2]; /* position and dimensions of marker pattern in pixel coords */
- float track_offset[2]; /* offset of "parenting" point */
- float marker_search_pos[2], marker_search[2]; /* position and dimensions of marker search in pixel coords */
- int marker_flag; /* marker's flags */
+ int framenr; /* current frame number */
+ float marker_pos[2]; /* position of marker in pixel coords */
+ float marker_pat[2]; /* position and dimensions of marker pattern in pixel coords */
+ float track_offset[2]; /* offset of "parenting" point */
+ float marker_search_pos[2], marker_search[2]; /* position and dimensions of marker search in pixel coords */
+ int marker_flag; /* marker's flags */
} MarkerUpdateCb;
static void to_pixel_space(float r[2], float a[2], int width, int height)
@@ -205,13 +206,13 @@ static void to_pixel_space(float r[2], float a[2], int width, int height)
static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
{
- MarkerUpdateCb *cb = (MarkerUpdateCb*) arg_cb;
+ MarkerUpdateCb *cb = (MarkerUpdateCb *) arg_cb;
MovieTrackingMarker *marker;
if (!cb->compact)
return;
- marker = BKE_tracking_ensure_marker(cb->track, cb->framenr);
+ marker = BKE_tracking_marker_ensure(cb->track, cb->framenr);
marker->flag = cb->marker_flag;
@@ -220,13 +221,13 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
static void marker_block_handler(bContext *C, void *arg_cb, int event)
{
- MarkerUpdateCb *cb = (MarkerUpdateCb*) arg_cb;
+ MarkerUpdateCb *cb = (MarkerUpdateCb *) arg_cb;
MovieTrackingMarker *marker;
int width, height, ok = FALSE;
BKE_movieclip_get_size(cb->clip, cb->user, &width, &height);
- marker = BKE_tracking_ensure_marker(cb->track, cb->framenr);
+ marker = BKE_tracking_marker_ensure(cb->track, cb->framenr);
if (event == B_MARKER_POS) {
marker->pos[0] = cb->marker_pos[0] / width;
@@ -258,7 +259,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
cb->marker->pattern_corners[a][1] *= scale_y;
}
- BKE_tracking_clamp_marker(cb->marker, CLAMP_PAT_DIM);
+ BKE_tracking_marker_clamp(cb->marker, CLAMP_PAT_DIM);
ok = TRUE;
}
@@ -274,7 +275,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
sub_v2_v2v2(cb->marker->search_min, delta, side);
add_v2_v2v2(cb->marker->search_max, delta, side);
- BKE_tracking_clamp_marker(cb->marker, CLAMP_SEARCH_POS);
+ BKE_tracking_marker_clamp(cb->marker, CLAMP_SEARCH_POS);
ok = TRUE;
}
@@ -295,7 +296,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
cb->marker->search_max[0] += dim[0];
cb->marker->search_max[1] += dim[1];
- BKE_tracking_clamp_marker(cb->marker, CLAMP_SEARCH_DIM);
+ BKE_tracking_marker_clamp(cb->marker, CLAMP_SEARCH_DIM);
ok = TRUE;
}
@@ -364,7 +365,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
user = userptr->data;
track = trackptr->data;
- marker = BKE_tracking_get_marker(track, user->framenr);
+ marker = BKE_tracking_marker_get(track, user->framenr);
cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
cb->compact = compact;
@@ -431,7 +432,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
tip = "Marker is enabled at current frame";
uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &cb->marker_flag,
- 0, 0, 0, 0, tip);
+ 0, 0, 0, 0, tip);
col = uiLayoutColumn(layout, 1);
uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0);
@@ -441,31 +442,31 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
uiDefBut(block, LABEL, 0, "Position:", 0, 190, 300, 19, NULL, 0, 0, 0, 0, "");
uiDefButF(block, NUM, B_MARKER_POS, "X:", 10, 171, 145, 19, &cb->marker_pos[0],
- -10*width, 10.0*width, step, digits, "X-position of marker at frame in screen coordinates");
+ -10 * width, 10.0 * width, step, digits, "X-position of marker at frame in screen coordinates");
uiDefButF(block, NUM, B_MARKER_POS, "Y:", 165, 171, 145, 19, &cb->marker_pos[1],
- -10*height, 10.0*height, step, digits, "Y-position of marker at frame in screen coordinates");
+ -10 * height, 10.0 * height, step, digits, "Y-position of marker at frame in screen coordinates");
uiDefBut(block, LABEL, 0, "Offset:", 0, 152, 300, 19, NULL, 0, 0, 0, 0, "");
uiDefButF(block, NUM, B_MARKER_OFFSET, "X:", 10, 133, 145, 19, &cb->track_offset[0],
- -10*width, 10.0*width, step, digits, "X-offset to parenting point");
+ -10 * width, 10.0 * width, step, digits, "X-offset to parenting point");
uiDefButF(block, NUM, B_MARKER_OFFSET, "Y:", 165, 133, 145, 19, &cb->track_offset[1],
- -10*height, 10.0*height, step, digits, "Y-offset to parenting point");
+ -10 * height, 10.0 * height, step, digits, "Y-offset to parenting point");
uiDefBut(block, LABEL, 0, "Pattern Area:", 0, 114, 300, 19, NULL, 0, 0, 0, 0, "");
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Width:", 10, 95, 300, 19, &cb->marker_pat[0], 3.0f,
- 10.0*width, step, digits, "Width of marker's pattern in screen coordinates");
+ 10.0 * width, step, digits, "Width of marker's pattern in screen coordinates");
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Height:", 10, 76, 300, 19, &cb->marker_pat[1], 3.0f,
- 10.0*height, step, digits, "Height of marker's pattern in screen coordinates");
+ 10.0 * height, step, digits, "Height of marker's pattern in screen coordinates");
uiDefBut(block, LABEL, 0, "Search Area:", 0, 57, 300, 19, NULL, 0, 0, 0, 0, "");
uiDefButF(block, NUM, B_MARKER_SEARCH_POS, "X:", 10, 38, 145, 19, &cb->marker_search_pos[0],
- -width, width, step, digits, "X-position of search at frame relative to marker's position");
+ -width, width, step, digits, "X-position of search at frame relative to marker's position");
uiDefButF(block, NUM, B_MARKER_SEARCH_POS, "Y:", 165, 38, 145, 19, &cb->marker_search_pos[1],
- -height, height, step, digits, "X-position of search at frame relative to marker's position");
+ -height, height, step, digits, "X-position of search at frame relative to marker's position");
uiDefButF(block, NUM, B_MARKER_SEARCH_DIM, "Width:", 10, 19, 300, 19, &cb->marker_search[0], 3.0f,
- 10.0*width, step, digits, "Width of marker's search in screen soordinates");
+ 10.0 * width, step, digits, "Width of marker's search in screen soordinates");
uiDefButF(block, NUM, B_MARKER_SEARCH_DIM, "Height:", 10, 0, 300, 19, &cb->marker_search[1], 3.0f,
- 10.0*height, step, digits, "Height of marker's search in screen soordinates");
+ 10.0 * height, step, digits, "Height of marker's search in screen soordinates");
uiBlockEndAlign(block);
}
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 67609fee653..361a3a7d906 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -30,7 +30,7 @@
*/
#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
@@ -61,7 +61,7 @@
#include "RNA_access.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
static void track_channel_color(MovieTrackingTrack *track, float default_color[3], float color[3])
{
@@ -83,10 +83,10 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh
{
/* coordinates for diamond shape */
static const float _unit_diamond_shape[4][2] = {
- {0.0f, 1.0f}, /* top vert */
- {1.0f, 0.0f}, /* mid-right */
- {0.0f, -1.0f}, /* bottom vert */
- {-1.0f, 0.0f} /* mid-left */
+ {0.0f, 1.0f}, /* top vert */
+ {1.0f, 0.0f}, /* mid-right */
+ {0.0f, -1.0f}, /* bottom vert */
+ {-1.0f, 0.0f} /* mid-left */
};
static GLuint displist1 = 0;
static GLuint displist2 = 0;
@@ -95,26 +95,26 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh
/* initialize 2 display lists for diamond shape - one empty, one filled */
if (displist1 == 0) {
displist1 = glGenLists(1);
- glNewList(displist1, GL_COMPILE);
-
- glBegin(GL_LINE_LOOP);
- glVertex2fv(_unit_diamond_shape[0]);
- glVertex2fv(_unit_diamond_shape[1]);
- glVertex2fv(_unit_diamond_shape[2]);
- glVertex2fv(_unit_diamond_shape[3]);
- glEnd();
+ glNewList(displist1, GL_COMPILE);
+
+ glBegin(GL_LINE_LOOP);
+ glVertex2fv(_unit_diamond_shape[0]);
+ glVertex2fv(_unit_diamond_shape[1]);
+ glVertex2fv(_unit_diamond_shape[2]);
+ glVertex2fv(_unit_diamond_shape[3]);
+ glEnd();
glEndList();
}
if (displist2 == 0) {
displist2 = glGenLists(1);
- glNewList(displist2, GL_COMPILE);
-
- glBegin(GL_QUADS);
- glVertex2fv(_unit_diamond_shape[0]);
- glVertex2fv(_unit_diamond_shape[1]);
- glVertex2fv(_unit_diamond_shape[2]);
- glVertex2fv(_unit_diamond_shape[3]);
- glEnd();
+ glNewList(displist2, GL_COMPILE);
+
+ glBegin(GL_QUADS);
+ glVertex2fv(_unit_diamond_shape[0]);
+ glVertex2fv(_unit_diamond_shape[1]);
+ glVertex2fv(_unit_diamond_shape[2]);
+ glVertex2fv(_unit_diamond_shape[3]);
+ glEnd();
glEndList();
}
@@ -158,6 +158,12 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
MovieTrackingDopesheetChannel *channel;
float y, xscale, yscale;
float strip[4], selected_strip[4];
+ float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2);
+
+ /* don't use totrect set, as the width stays the same
+ * (NOTE: this is ok here, the configuration is pretty straightforward)
+ */
+ v2d->tot.ymin = (float)(-height);
y = (float) CHANNEL_FIRST;
@@ -210,7 +216,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
if (start_frame != end_frame) {
glRectf(start_frame, (float) y - STRIP_HEIGHT_HALF,
- end_frame, (float) y + STRIP_HEIGHT_HALF);
+ end_frame, (float) y + STRIP_HEIGHT_HALF);
draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha);
draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha);
}
@@ -307,10 +313,10 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
else
UI_ThemeColor(TH_TEXT);
- font_height = BLF_height(fontid, track->name);
+ font_height = BLF_height(fontid, channel->name);
BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD,
- y - font_height / 2.0f, 0.0f);
- BLF_draw(fontid, track->name, strlen(track->name));
+ y - font_height / 2.0f, 0.0f);
+ BLF_draw(fontid, channel->name, strlen(channel->name));
}
/* adjust y-position for next one */
diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c
index 914e82472bb..716994f7487 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_ops.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c
@@ -59,6 +59,23 @@
#include "clip_intern.h" // own include
+#if 0
+static int ED_space_clip_dopesheet_poll(bContext *C)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+
+ if (sc && sc->clip) {
+ if (sc->view == SC_VIEW_DOPESHEET) {
+ ARegion *ar = CTX_wm_region(C);
+
+ return ar->regiontype == RGN_TYPE_PREVIEW;
+ }
+ }
+
+ return FALSE;
+}
+#endif
+
/********************** select channel operator *********************/
static int dopesheet_select_channel_poll(bContext *C)
@@ -76,8 +93,10 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
MovieTrackingDopesheetChannel *channel;
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
float location[2];
int extend = RNA_boolean_get(op->ptr, "extend");
int current_channel_index = 0, channel_index;
@@ -96,6 +115,7 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
if (track->flag & TRACK_DOPE_SEL) {
tracking->act_track = track;
+ BKE_tracking_track_select(tracksbase, track, TRACK_AREA_ALL, TRUE);
}
}
else if (!extend)
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 2e16a9095f0..8deb83b6f0d 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -32,7 +32,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "DNA_mask_types.h"
#include "MEM_guardedalloc.h"
@@ -69,7 +69,7 @@
#include "BLF_api.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" // own include
/*********************** main area drawing *************************/
@@ -98,8 +98,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
float x;
int *points, totseg, i, a;
float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1);
- MovieTrackingTrack *act_track = BKE_tracking_active_track(&clip->tracking);
- MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(&clip->tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(&clip->tracking);
+ MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(&clip->tracking);
glEnable(GL_BLEND);
@@ -277,10 +277,10 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
glScalef(zoomx, zoomy, 1.0f);
glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height);
- glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, height);
+ glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
+ glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f);
+ glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height);
+ glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, height);
glEnd();
glPopMatrix();
@@ -320,10 +320,10 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
glMultMatrixf(sc->stabmat);
glBegin(GL_LINE_LOOP);
- glVertex2f(0.0f, 0.0f);
- glVertex2f(width, 0.0f);
- glVertex2f(width, height);
- glVertex2f(0.0f, height);
+ glVertex2f(0.0f, 0.0f);
+ glVertex2f(width, 0.0f);
+ glVertex2f(width, height);
+ glVertex2f(0.0f, height);
glEnd();
glPopMatrix();
@@ -346,14 +346,14 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
start_frame = framenr = ED_space_clip_clip_framenr(sc);
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
if (marker->framenr != framenr || marker->flag & MARKER_DISABLED)
return;
a = count;
i = framenr - 1;
while (i >= framenr - count) {
- marker = BKE_tracking_get_marker(track, i);
+ marker = BKE_tracking_marker_get(track, i);
if (!marker || marker->flag & MARKER_DISABLED)
break;
@@ -375,7 +375,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
b = count;
i = framenr;
while (i <= framenr + count) {
- marker = BKE_tracking_get_marker(track, i);
+ marker = BKE_tracking_marker_get(track, i);
if (!marker || marker->flag & MARKER_DISABLED)
break;
@@ -399,17 +399,17 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if (TRACK_VIEW_SELECTED(sc, track)) {
glPointSize(5.0f);
glBegin(GL_POINTS);
- for (i = a; i < b; i++) {
- if (i != curindex)
- glVertex2f(path[i][0], path[i][1]);
- }
+ for (i = a; i < b; i++) {
+ if (i != curindex)
+ glVertex2f(path[i][0], path[i][1]);
+ }
glEnd();
}
glLineWidth(3.0f);
glBegin(GL_LINE_STRIP);
- for (i = a; i < b; i++)
- glVertex2f(path[i][0], path[i][1]);
+ for (i = a; i < b; i++)
+ glVertex2f(path[i][0], path[i][1]);
glEnd();
glLineWidth(1.0f);
}
@@ -419,25 +419,25 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if (TRACK_VIEW_SELECTED(sc, track)) {
glPointSize(3.0f);
glBegin(GL_POINTS);
- for (i = a; i < b; i++) {
- if (i == count + 1)
- UI_ThemeColor(TH_PATH_AFTER);
+ for (i = a; i < b; i++) {
+ if (i == count + 1)
+ UI_ThemeColor(TH_PATH_AFTER);
- if (i != curindex)
- glVertex2f(path[i][0], path[i][1]);
- }
+ if (i != curindex)
+ glVertex2f(path[i][0], path[i][1]);
+ }
glEnd();
}
UI_ThemeColor(TH_PATH_BEFORE);
glBegin(GL_LINE_STRIP);
- for (i = a; i < b; i++) {
- if (i == count + 1)
- UI_ThemeColor(TH_PATH_AFTER);
+ for (i = a; i < b; i++) {
+ if (i == count + 1)
+ UI_ThemeColor(TH_PATH_AFTER);
- glVertex2f(path[i][0], path[i][1]);
- }
+ glVertex2f(path[i][0], path[i][1]);
+ }
glEnd();
glPointSize(1.0f);
}
@@ -470,24 +470,24 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
if (tiny) glPointSize(3.0f);
else glPointSize(4.0f);
glBegin(GL_POINTS);
- glVertex2f(pos[0], pos[1]);
+ glVertex2f(pos[0], pos[1]);
glEnd();
glPointSize(1.0f);
}
else {
if (!tiny) glLineWidth(3.0f);
glBegin(GL_LINES);
- glVertex2f(pos[0] + px[0]*2, pos[1]);
- glVertex2f(pos[0] + px[0]*8, pos[1]);
+ glVertex2f(pos[0] + px[0] * 2, pos[1]);
+ glVertex2f(pos[0] + px[0] * 8, pos[1]);
- glVertex2f(pos[0] - px[0]*2, pos[1]);
- glVertex2f(pos[0] - px[0]*8, pos[1]);
+ glVertex2f(pos[0] - px[0] * 2, pos[1]);
+ glVertex2f(pos[0] - px[0] * 8, pos[1]);
- glVertex2f(pos[0], pos[1] - px[1]*2);
- glVertex2f(pos[0], pos[1] - px[1]*8);
+ glVertex2f(pos[0], pos[1] - px[1] * 2);
+ glVertex2f(pos[0], pos[1] - px[1] * 8);
- glVertex2f(pos[0], pos[1] + px[1]*2);
- glVertex2f(pos[0], pos[1] + px[1]*8);
+ glVertex2f(pos[0], pos[1] + px[1] * 2);
+ glVertex2f(pos[0], pos[1] + px[1] * 8);
glEnd();
if (!tiny) glLineWidth(1.0f);
}
@@ -502,10 +502,10 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
glBegin(GL_LINE_LOOP);
- glVertex2fv(marker->pattern_corners[0]);
- glVertex2fv(marker->pattern_corners[1]);
- glVertex2fv(marker->pattern_corners[2]);
- glVertex2fv(marker->pattern_corners[3]);
+ glVertex2fv(marker->pattern_corners[0]);
+ glVertex2fv(marker->pattern_corners[1]);
+ glVertex2fv(marker->pattern_corners[2]);
+ glVertex2fv(marker->pattern_corners[3]);
glEnd();
}
@@ -513,10 +513,10 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0);
if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
glBegin(GL_LINE_LOOP);
- glVertex2f(marker->search_min[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_max[1]);
- glVertex2f(marker->search_min[0], marker->search_max[1]);
+ glVertex2f(marker->search_min[0], marker->search_min[1]);
+ glVertex2f(marker->search_max[0], marker->search_min[1]);
+ glVertex2f(marker->search_max[0], marker->search_max[1]);
+ glVertex2f(marker->search_min[0], marker->search_max[1]);
glEnd();
}
glPopMatrix();
@@ -546,7 +546,7 @@ static void track_colors(MovieTrackingTrack *track, int act, float col[3], float
}
static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- float marker_pos[2], int width, int height, int act, int sel)
+ float marker_pos[2], int width, int height, int act, int sel)
{
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
int show_search = 0;
@@ -588,7 +588,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
glPointSize(2.0f);
glBegin(GL_POINTS);
- glVertex2f(pos[0], pos[1]);
+ glVertex2f(pos[0], pos[1]);
glEnd();
if (!tiny)
@@ -596,17 +596,17 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
else {
glBegin(GL_LINES);
- glVertex2f(pos[0] + px[0]*3, pos[1]);
- glVertex2f(pos[0] + px[0]*7, pos[1]);
+ glVertex2f(pos[0] + px[0] * 3, pos[1]);
+ glVertex2f(pos[0] + px[0] * 7, pos[1]);
- glVertex2f(pos[0] - px[0]*3, pos[1]);
- glVertex2f(pos[0] - px[0]*7, pos[1]);
+ glVertex2f(pos[0] - px[0] * 3, pos[1]);
+ glVertex2f(pos[0] - px[0] * 7, pos[1]);
- glVertex2f(pos[0], pos[1] - px[1]*3);
- glVertex2f(pos[0], pos[1] - px[1]*7);
+ glVertex2f(pos[0], pos[1] - px[1] * 3);
+ glVertex2f(pos[0], pos[1] - px[1] * 7);
- glVertex2f(pos[0], pos[1] + px[1]*3);
- glVertex2f(pos[0], pos[1] + px[1]*7);
+ glVertex2f(pos[0], pos[1] + px[1] * 3);
+ glVertex2f(pos[0], pos[1] + px[1] * 7);
glEnd();
glColor3f(0.0f, 0.0f, 0.0f);
@@ -616,8 +616,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
glLogicOp(GL_NOR);
glBegin(GL_LINES);
- glVertex2fv(pos);
- glVertex2fv(marker_pos);
+ glVertex2fv(pos);
+ glVertex2fv(marker_pos);
glEnd();
glDisable(GL_COLOR_LOGIC_OP);
@@ -656,16 +656,16 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
glBegin(GL_LINE_LOOP);
- glVertex2fv(marker->pattern_corners[0]);
- glVertex2fv(marker->pattern_corners[1]);
- glVertex2fv(marker->pattern_corners[2]);
- glVertex2fv(marker->pattern_corners[3]);
+ glVertex2fv(marker->pattern_corners[0]);
+ glVertex2fv(marker->pattern_corners[1]);
+ glVertex2fv(marker->pattern_corners[2]);
+ glVertex2fv(marker->pattern_corners[3]);
glEnd();
}
/* search */
show_search = TRACK_VIEW_SELECTED(sc, track) &&
- ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0);
+ ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0);
if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
if (track->flag & TRACK_LOCKED) {
if (act)
@@ -689,10 +689,10 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
glBegin(GL_LINE_LOOP);
- glVertex2f(marker->search_min[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_max[1]);
- glVertex2f(marker->search_min[0], marker->search_max[1]);
+ glVertex2f(marker->search_min[0], marker->search_min[1]);
+ glVertex2f(marker->search_max[0], marker->search_min[1]);
+ glVertex2f(marker->search_max[0], marker->search_max[1]);
+ glVertex2f(marker->search_min[0], marker->search_max[1]);
glEnd();
}
@@ -733,10 +733,10 @@ static void draw_marker_slide_square(float x, float y, float dx, float dy, int o
}
glBegin(GL_QUADS);
- glVertex3f(x - tdx, y + tdy, 0.0f);
- glVertex3f(x + tdx, y + tdy, 0.0f);
- glVertex3f(x + tdx, y - tdy, 0.0f);
- glVertex3f(x - tdx, y - tdy, 0.0f);
+ glVertex3f(x - tdx, y + tdy, 0.0f);
+ glVertex3f(x + tdx, y + tdy, 0.0f);
+ glVertex3f(x + tdx, y - tdy, 0.0f);
+ glVertex3f(x - tdx, y - tdy, 0.0f);
glEnd();
}
@@ -753,9 +753,9 @@ static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int
}
glBegin(GL_TRIANGLES);
- glVertex3f(x, y, 0.0f);
- glVertex3f(x - tdx, y, 0.0f);
- glVertex3f(x, y + tdy, 0.0f);
+ glVertex3f(x, y, 0.0f);
+ glVertex3f(x - tdx, y, 0.0f);
+ glVertex3f(x, y + tdy, 0.0f);
glEnd();
}
@@ -811,6 +811,11 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
}
if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) {
+ int i;
+ float pat_min[2], pat_max[2];
+ float dx = 12.0f / width, dy = 12.0f / height;
+ float tilt_ctrl[2];
+
if (!outline) {
if (track->pat_flag & SELECT)
glColor3fv(scol);
@@ -818,26 +823,42 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
glColor3fv(col);
}
- /* XXX: need to be real check if affine tracking is enabled, but for now not
- * sure how to do this, so assume affine tracker is always enabled */
- if (TRUE) {
- int i;
-
- /* pattern's corners sliding squares */
- for (i = 0; i < 4; i++) {
- draw_marker_slide_square(marker->pattern_corners[i][0], marker->pattern_corners[i][1],
- patdx / 1.5f, patdy / 1.5f, outline, px);
- }
+ /* pattern's corners sliding squares */
+ for (i = 0; i < 4; i++) {
+ draw_marker_slide_square(marker->pattern_corners[i][0], marker->pattern_corners[i][1],
+ patdx / 1.5f, patdy / 1.5f, outline, px);
}
- else {
- /* pattern offset square */
- draw_marker_slide_square(marker->pattern_corners[3][0], marker->pattern_corners[3][1],
- patdx, patdy, outline, px);
- /* pattern re-sizing triangle */
- draw_marker_slide_triangle(marker->pattern_corners[1][0], marker->pattern_corners[1][1],
- patdx, patdy, outline, px);
- }
+ /* ** sliders to control overall pattern ** */
+ add_v2_v2v2(tilt_ctrl, marker->pattern_corners[1], marker->pattern_corners[2]);
+
+ BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
+
+ glEnable(GL_LINE_STIPPLE);
+ glLineStipple(3, 0xaaaa);
+
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(pat_min[0] - dx, pat_min[1] - dy);
+ glVertex2f(pat_max[0] + dx, pat_min[1] - dy);
+ glVertex2f(pat_max[0] + dx, pat_max[1] + dy);
+ glVertex2f(pat_min[0] - dx, pat_max[1] + dy);
+ glEnd();
+
+ glBegin(GL_LINES);
+ glVertex2f(0.0f, 0.0f);
+ glVertex2fv(tilt_ctrl);
+ glEnd();
+
+ glDisable(GL_LINE_STIPPLE);
+
+ /* marker's offset slider */
+ draw_marker_slide_square(pat_min[0] - dx, pat_max[1] + dy, patdx, patdy, outline, px);
+
+ /* pattern re-sizing triangle */
+ draw_marker_slide_triangle(pat_max[0] + dx, pat_min[1] - dy, patdx, patdy, outline, px);
+
+ /* slider to control pattern tilt */
+ draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px);
}
glPopMatrix();
@@ -874,7 +895,7 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
if ((sc->flag & SC_SHOW_MARKER_SEARCH) &&
- ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0))
+ ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0))
{
dx = marker->search_min[0];
dy = marker->search_min[1];
@@ -893,8 +914,8 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
mul_m4_v3(sc->stabmat, pos);
- pos[0] = pos[0]*zoomx;
- pos[1] = pos[1]*zoomy - fontsize;
+ pos[0] = pos[0] * zoomx;
+ pos[1] = pos[1] * zoomy - fontsize;
if (marker->flag & MARKER_DISABLED)
strcpy(state, "disabled");
@@ -934,8 +955,8 @@ static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx
y = -v2d->cur.ymin / (v2d->cur.ymax - v2d->cur.ymin);
/* convert proportional distances to screen coordinates */
- *regionx = v2d->mask.xmin + x*(v2d->mask.xmax - v2d->mask.xmin);
- *regiony = v2d->mask.ymin + y*(v2d->mask.ymax - v2d->mask.ymin);
+ *regionx = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin);
+ *regiony = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin);
}
static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
@@ -943,7 +964,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
{
float x, y;
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track, *act_track;
MovieTrackingMarker *marker;
int framenr = ED_space_clip_clip_framenr(sc);
@@ -967,7 +988,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
glMultMatrixf(sc->stabmat);
glScalef(width, height, 0);
- act_track = BKE_tracking_active_track(tracking);
+ act_track = BKE_tracking_track_get_active(tracking);
if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
int count = 0;
@@ -976,7 +997,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
track = tracksbase->first;
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0) {
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker))
count++;
@@ -987,13 +1008,13 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
/* undistort */
if (count) {
- marker_pos = MEM_callocN(2*sizeof(float)*count, "draw_tracking_tracks marker_pos");
+ marker_pos = MEM_callocN(2 * sizeof(float) * count, "draw_tracking_tracks marker_pos");
track = tracksbase->first;
fp = marker_pos;
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0) {
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker)) {
ED_clip_point_undistorted_pos(sc, marker->pos, fp);
@@ -1025,7 +1046,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
fp = marker_pos;
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0) {
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker)) {
copy_v2_v2(cur_pos, fp ? fp : marker->pos);
@@ -1050,7 +1071,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0) {
int act = track == act_track;
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker)) {
if (!act) {
@@ -1071,7 +1092,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
/* active marker would be displayed on top of everything else */
if (act_track) {
if ((act_track->flag & TRACK_HIDDEN) == 0) {
- marker = BKE_tracking_get_marker(act_track, framenr);
+ marker = BKE_tracking_marker_get(act_track, framenr);
if (MARKER_VISIBLE(sc, act_track, marker)) {
copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos);
@@ -1083,19 +1104,19 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
}
if (sc->flag & SC_SHOW_BUNDLES) {
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
float pos[4], vec[4], mat[4][4], aspy;
glEnable(GL_POINT_SMOOTH);
glPointSize(3.0f);
aspy = 1.0f / clip->tracking.camera.pixel_aspect;
- BKE_tracking_projection_matrix(tracking, object, framenr, width, height, mat);
+ BKE_tracking_get_projection_matrix(tracking, object, framenr, width, height, mat);
track = tracksbase->first;
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0 && track->flag & TRACK_HAS_BUNDLE) {
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker)) {
float npos[2];
@@ -1107,7 +1128,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
pos[0] = (pos[0] / (pos[3] * 2.0f) + 0.5f) * width;
pos[1] = (pos[1] / (pos[3] * 2.0f) + 0.5f) * height * aspy;
- BKE_tracking_apply_intrinsics(tracking, pos, npos);
+ BKE_tracking_distort_v2(tracking, pos, npos);
if (npos[0] >= 0.0f && npos[1] >= 0.0f && npos[0] <= width && npos[1] <= height * aspy) {
vec[0] = (marker->pos[0] + track->offset[0]) * width;
@@ -1121,10 +1142,10 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_POINTS);
- if (undistort)
- glVertex3f(pos[0] / width, pos[1] / (height * aspy), 0);
- else
- glVertex3f(npos[0] / width, npos[1] / (height * aspy), 0);
+ if (undistort)
+ glVertex3f(pos[0] / width, pos[1] / (height * aspy), 0);
+ else
+ glVertex3f(npos[0] / width, npos[1] / (height * aspy), 0);
glEnd();
}
}
@@ -1145,7 +1166,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
fp = marker_pos;
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0) {
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker)) {
int act = track == act_track;
@@ -1215,7 +1236,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
for (i = 0; i <= n; i++) {
for (j = 0; j <= n; j++) {
if (i == 0 || j == 0 || i == n || j == n) {
- BKE_tracking_apply_intrinsics(tracking, pos, tpos);
+ BKE_tracking_distort_v2(tracking, pos, tpos);
for (a = 0; a < 4; a++) {
int ok;
@@ -1246,7 +1267,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
pos[0] = idx[a][0] * dx;
pos[1] = idx[a][1] * dy;
- BKE_tracking_invert_intrinsics(tracking, pos, tpos);
+ BKE_tracking_undistort_v2(tracking, pos, tpos);
DO_MINMAX2(tpos, min, max);
}
@@ -1257,10 +1278,10 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
for (i = 0; i <= n; i++) {
for (j = 0; j <= n; j++) {
- BKE_tracking_apply_intrinsics(tracking, pos, grid[i][j]);
+ BKE_tracking_distort_v2(tracking, pos, grid[i][j]);
grid[i][j][0] /= width;
- grid[i][j][1] /= height*aspy;
+ grid[i][j][1] /= height * aspy;
pos[0] += dx;
}
@@ -1273,27 +1294,27 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
for (i = 0; i <= n; i++) {
glBegin(GL_LINE_STRIP);
- for (j = 0; j <= n; j++) {
- glVertex2fv(grid[i][j]);
- }
+ for (j = 0; j <= n; j++) {
+ glVertex2fv(grid[i][j]);
+ }
glEnd();
}
for (j = 0; j <= n; j++) {
glBegin(GL_LINE_STRIP);
- for (i = 0; i <= n; i++) {
- glVertex2fv(grid[i][j]);
- }
+ for (i = 0; i <= n; i++) {
+ glVertex2fv(grid[i][j]);
+ }
glEnd();
}
}
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
- MovieTrackingTrack *track = BKE_tracking_active_track(&sc->clip->tracking);
+ MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking);
if (track) {
int framenr = sc->user.framenr;
- MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
offsx = marker->pos[0];
offsy = marker->pos[1];
@@ -1328,40 +1349,40 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
if (stroke->flag & GP_STROKE_2DSPACE) {
if (stroke->totpoints > 1) {
glBegin(GL_LINE_STRIP);
- for (i = 0; i < stroke->totpoints - 1; i++) {
- float npos[2], dpos[2], len;
- int steps;
+ for (i = 0; i < stroke->totpoints - 1; i++) {
+ float npos[2], dpos[2], len;
+ int steps;
- pos[0] = (stroke->points[i].x + offsx) * width;
- pos[1] = (stroke->points[i].y + offsy) * height * aspy;
+ pos[0] = (stroke->points[i].x + offsx) * width;
+ pos[1] = (stroke->points[i].y + offsy) * height * aspy;
- npos[0] = (stroke->points[i + 1].x + offsx) * width;
- npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;
+ npos[0] = (stroke->points[i + 1].x + offsx) * width;
+ npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;
- len = len_v2v2(pos, npos);
- steps = ceil(len / 5.0f);
+ len = len_v2v2(pos, npos);
+ steps = ceil(len / 5.0f);
- /* we want to distort only long straight lines */
- if (stroke->totpoints == 2) {
- BKE_tracking_invert_intrinsics(tracking, pos, pos);
- BKE_tracking_invert_intrinsics(tracking, npos, npos);
- }
+ /* we want to distort only long straight lines */
+ if (stroke->totpoints == 2) {
+ BKE_tracking_undistort_v2(tracking, pos, pos);
+ BKE_tracking_undistort_v2(tracking, npos, npos);
+ }
- sub_v2_v2v2(dpos, npos, pos);
- mul_v2_fl(dpos, 1.0f / steps);
+ sub_v2_v2v2(dpos, npos, pos);
+ mul_v2_fl(dpos, 1.0f / steps);
- for (j = 0; j <= steps; j++) {
- BKE_tracking_apply_intrinsics(tracking, pos, tpos);
- glVertex2f(tpos[0] / width, tpos[1] / (height*aspy));
+ for (j = 0; j <= steps; j++) {
+ BKE_tracking_distort_v2(tracking, pos, tpos);
+ glVertex2f(tpos[0] / width, tpos[1] / (height * aspy));
- add_v2_v2(pos, dpos);
- }
+ add_v2_v2(pos, dpos);
}
+ }
glEnd();
}
else if (stroke->totpoints == 1) {
glBegin(GL_POINTS);
- glVertex2f(stroke->points[0].x + offsx, stroke->points[0].y + offsy);
+ glVertex2f(stroke->points[0].x + offsx, stroke->points[0].y + offsy);
glEnd();
}
}
@@ -1410,7 +1431,7 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene)
else
copy_v2_v2(loc, sc->loc);
- BKE_tracking_stabdata_to_mat4(width, height, aspect, loc, sc->scale, sc->angle, sc->stabmat);
+ BKE_tracking_stabilization_data_to_mat4(width, height, aspect, loc, sc->scale, sc->angle, sc->stabmat);
unit_m4(smat);
smat[0][0] = 1.0f / width;
@@ -1463,13 +1484,15 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
glMultMatrixf(sc->unistabmat);
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
- MovieTrackingTrack *track = BKE_tracking_active_track(&sc->clip->tracking);
+ MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking);
if (track) {
int framenr = sc->user.framenr;
- MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
-
- glTranslatef(marker->pos[0], marker->pos[1], 0.0f);
+ /* don't get the exact marker since it may not exist for the frame */
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+ if (marker) {
+ glTranslatef(marker->pos[0], marker->pos[1], 0.0f);
+ }
}
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 504d96df072..0bad9f86ea1 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -113,7 +113,7 @@ int ED_space_clip_maskedit_mask_poll(bContext *C)
MovieClip *clip = CTX_data_edit_movieclip(C);
if (clip) {
- SpaceClip *sc= CTX_wm_space_clip(C);
+ SpaceClip *sc = CTX_wm_space_clip(C);
return sc->mask != NULL;
}
@@ -250,12 +250,12 @@ void ED_space_clip_mask_aspect(SpaceClip *sc, float *aspx, float *aspy)
#endif
if (*aspx < *aspy) {
- *aspy= *aspy / *aspx;
- *aspx= 1.0f;
+ *aspy = *aspy / *aspx;
+ *aspx = 1.0f;
}
else {
- *aspx= *aspx / *aspy;
- *aspy= 1.0f;
+ *aspx = *aspx / *aspy;
+ *aspy = 1.0f;
}
}
@@ -297,12 +297,12 @@ void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *asp
*aspy *= (float)h;
if (*aspx < *aspy) {
- *aspy= *aspy / *aspx;
- *aspx= 1.0f;
+ *aspy = *aspy / *aspx;
+ *aspx = 1.0f;
}
else {
- *aspx= *aspx / *aspy;
- *aspy= 1.0f;
+ *aspx = *aspx / *aspy;
+ *aspy = 1.0f;
}
}
@@ -342,7 +342,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
MovieClip *clip = ED_space_clip(sc);
MovieTrackingTrack *track;
int width, height, ok = FALSE;
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
INIT_MINMAX2(min, max);
@@ -351,7 +351,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track)) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, sc->user.framenr);
if (marker) {
float pos[3];
@@ -425,9 +425,9 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit)
return TRUE;
}
-void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2])
+void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2])
{
- copy_v2_v2(nco, co);
+ copy_v2_v2(r_co, co);
if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
MovieClip *clip = ED_space_clip(sc);
@@ -436,13 +436,13 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2])
ED_space_clip_size(sc, &width, &height);
- nco[0] *= width;
- nco[1] *= height * aspy;
+ r_co[0] *= width;
+ r_co[1] *= height * aspy;
- BKE_tracking_invert_intrinsics(&clip->tracking, nco, nco);
+ BKE_tracking_undistort_v2(&clip->tracking, r_co, r_co);
- nco[0] /= width;
- nco[1] /= height * aspy;
+ r_co[0] /= width;
+ r_co[1] /= height * aspy;
}
}
@@ -451,7 +451,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y
ARegion *ar = CTX_wm_region(C);
SpaceClip *sc = CTX_wm_space_clip(C);
int sx, sy, width, height;
- float zoomx, zoomy, pos[3] = {0.0f, 0.0f, 0.0f}, imat[4][4];
+ float zoomx, zoomy, pos[3], imat[4][4];
ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_size(sc, &width, &height);
@@ -460,6 +460,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y
pos[0] = (x - sx) / zoomx;
pos[1] = (y - sy) / zoomy;
+ pos[2] = 0.0f;
invert_m4_m4(imat, sc->stabmat);
mul_v3_m4v3(pos, imat, pos);
@@ -473,7 +474,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y
float aspy = 1.0f / tracking->camera.pixel_aspect;
float tmp[2] = {*xr * width, *yr * height * aspy};
- BKE_tracking_apply_intrinsics(tracking, tmp, tmp);
+ BKE_tracking_distort_v2(tracking, tmp, tmp);
*xr = tmp[0] / width;
*yr = tmp[1] / (height * aspy);
@@ -484,7 +485,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y
* \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords.
* better name here? view_to_track / track_to_view or so?
*/
-void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, float co[2], float nco[2])
+void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2])
{
float zoomx, zoomy;
float pos[3];
@@ -496,12 +497,13 @@ void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, float co[2],
ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
ED_clip_point_undistorted_pos(sc, co, pos);
+ pos[2] = 0.0f;
/* untested */
mul_v3_m4v3(pos, sc->stabmat, pos);
- nco[0] = (pos[0] * width * zoomx) + (float)sx;
- nco[1] = (pos[1] * height * zoomy) + (float)sy;
+ r_co[0] = (pos[0] * width * zoomx) + (float)sx;
+ r_co[1] = (pos[1] * height * zoomy) + (float)sy;
}
void ED_clip_mouse_pos(bContext *C, wmEvent *event, float co[2])
@@ -521,7 +523,7 @@ typedef struct SpaceClipDrawContext {
unsigned last_texture; /* ID of previously used texture, so it'll be restored after clip drawing */
/* fields to check if cache is still valid */
- int framenr, start_frame;
+ int framenr, start_frame, frame_offset;
short render_size, render_flag;
} SpaceClipDrawContext;
@@ -563,6 +565,7 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
need_rebind |= context->render_size != sc->user.render_size;
need_rebind |= context->render_flag != sc->user.render_flag;
need_rebind |= context->start_frame != clip->start_frame;
+ need_rebind |= context->frame_offset != clip->frame_offset;
if (need_rebind) {
int width = ibuf->x, height = ibuf->y;
@@ -620,6 +623,7 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
context->render_size = sc->user.render_size;
context->render_flag = sc->user.render_flag;
context->start_frame = clip->start_frame;
+ context->frame_offset = clip->frame_offset;
}
else {
/* displaying exactly the same image which was loaded t oa texture,
@@ -675,11 +679,11 @@ void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask)
{
sc->mask = mask;
- if (sc->mask && sc->mask->id.us==0) {
+ if (sc->mask && sc->mask->id.us == 0) {
sc->clip->id.us = 1;
}
if (C) {
- WM_event_add_notifier(C, NC_MASK|NA_SELECTED, mask);
+ WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask);
}
}
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 8d30242c128..323594ea469 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -31,7 +31,7 @@
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "MEM_guardedalloc.h"
@@ -57,7 +57,7 @@
#include "BLF_api.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" // own include
static void draw_curve_knot(float x, float y, float xscale, float yscale, float hsize)
{
@@ -88,7 +88,8 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float
}
static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track),
- MovieTrackingMarker *UNUSED(marker), int UNUSED(coord), int scene_framenr, float val)
+ MovieTrackingMarker *UNUSED(marker), int UNUSED(coord),
+ int scene_framenr, float val)
{
glVertex2f(scene_framenr, val);
}
@@ -123,7 +124,7 @@ void tracking_segment_end_cb(void *UNUSED(userdata))
}
static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
- MovieTrackingMarker *marker, int coord, int scene_framenr, float val)
+ MovieTrackingMarker *marker, int coord, int scene_framenr, float val)
{
struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } *data = userdata;
int sel = 0, sel_flag;
@@ -148,7 +149,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
{
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
int width, height;
struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } userdata;
@@ -162,30 +163,34 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
userdata.sel = FALSE;
userdata.act_track = act_track;
UI_view2d_getscale(v2d, &userdata.xscale, &userdata.yscale);
- clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL);
+ clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ &userdata, tracking_segment_knot_cb, NULL, NULL);
/* draw graph lines */
glEnable(GL_BLEND);
- clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb,
- tracking_segment_start_cb, tracking_segment_end_cb);
+ clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ act_track, tracking_segment_point_cb, tracking_segment_start_cb,
+ tracking_segment_end_cb);
glDisable(GL_BLEND);
/* selected knot handles on top of curves */
userdata.sel = TRUE;
- clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL);
+ clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ &userdata, tracking_segment_knot_cb, NULL, NULL);
}
static void draw_frame_curves(SpaceClip *sc)
{
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(tracking);
+ MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
int i, lines = 0, prevfra = 0;
glColor3f(0.0f, 0.0f, 1.0f);
for (i = 0; i < reconstruction->camnr; i++) {
MovieReconstructedCamera *camera = &reconstruction->cameras[i];
+ int framenr;
if (lines && camera->framenr != prevfra + 1) {
glEnd();
@@ -197,7 +202,8 @@ static void draw_frame_curves(SpaceClip *sc)
lines = 1;
}
- glVertex2f(camera->framenr, camera->error);
+ framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, camera->framenr);
+ glVertex2f(framenr, camera->error);
prevfra = camera->framenr;
}
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 79e199a8f06..b7687eba717 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -29,7 +29,7 @@
* \ingroup spclip
*/
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
@@ -57,7 +57,7 @@
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" // own include
/******************** common graph-editing utilities ********************/
@@ -96,16 +96,16 @@ static void toggle_selection_cb(void *userdata, MovieTrackingMarker *marker)
/******************** mouse select operator ********************/
typedef struct {
- int coord, /* coordinate index of found entuty (0 = X-axis, 1 = Y-axis) */
- has_prev; /* if there's valid coordinate of previous point of curve segment */
+ int coord, /* coordinate index of found entuty (0 = X-axis, 1 = Y-axis) */
+ has_prev; /* if there's valid coordinate of previous point of curve segment */
- float min_dist, /* minimal distance between mouse and currently found entuty */
- mouse_co[2], /* mouse coordinate */
- prev_co[2], /* coordinate of previeous point of segment */
- min_co[2]; /* coordinate of entity with minimal distance */
+ float min_dist, /* minimal distance between mouse and currently found entuty */
+ mouse_co[2], /* mouse coordinate */
+ prev_co[2], /* coordinate of previeous point of segment */
+ min_co[2]; /* coordinate of entity with minimal distance */
- MovieTrackingTrack *track; /* nearest found track */
- MovieTrackingMarker *marker; /* nearest found marker */
+ MovieTrackingTrack *track; /* nearest found track */
+ MovieTrackingMarker *marker; /* nearest found marker */
} MouseSelectUserData;
static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack *track,
@@ -170,7 +170,7 @@ static int mouse_select_knot(bContext *C, float co[2], int extend)
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
static const int delta = 6;
if (act_track) {
@@ -190,7 +190,9 @@ static int mouse_select_knot(bContext *C, float co[2], int extend)
if (!extend) {
SelectUserData selectdata = {SEL_DESELECT};
- clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb);
+ clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
+ sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata,
+ toggle_selection_cb);
}
if (userdata.coord == 0)
@@ -211,11 +213,12 @@ static int mouse_select_curve(bContext *C, float co[2], int extend)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
MouseSelectUserData userdata;
mouse_select_init_data(&userdata, co);
- clip_graph_tracking_values_iterate(sc, &userdata, find_nearest_tracking_segment_cb,
+ clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ &userdata, find_nearest_tracking_segment_cb,
NULL, find_nearest_tracking_segment_end_cb);
if (userdata.track) {
@@ -227,11 +230,16 @@ static int mouse_select_curve(bContext *C, float co[2], int extend)
}
else if (act_track != userdata.track) {
SelectUserData selectdata = {SEL_DESELECT};
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
tracking->act_track = userdata.track;
+ BKE_tracking_track_select(tracksbase, userdata.track, TRACK_AREA_ALL, TRUE);
/* deselect all knots on newly selected curve */
- clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb);
+ clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
+ sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata,
+ toggle_selection_cb);
}
return TRUE;
@@ -261,7 +269,7 @@ static int mouse_select(bContext *C, float co[2], int extend)
static int select_exec(bContext *C, wmOperator *op)
{
float co[2];
- int extend = RNA_boolean_get(op->ptr, "extend");
+ int extend = RNA_boolean_get(op->ptr, "extend");
RNA_float_get_array(op->ptr, "location", co);
@@ -296,9 +304,9 @@ void CLIP_OT_graph_select(wmOperatorType *ot)
/* properties */
RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
- "Location", "Mouse location to select nearest entity", -100.0f, 100.0f);
+ "Location", "Mouse location to select nearest entity", -100.0f, 100.0f);
RNA_def_boolean(ot->srna, "extend", 0,
- "Extend", "Extend selection rather than clearing the existing selection");
+ "Extend", "Extend selection rather than clearing the existing selection");
}
/********************** border select operator *********************/
@@ -339,7 +347,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
BorderSelectuserData userdata;
rcti rect;
@@ -394,7 +402,7 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
MovieTrackingMarker *marker;
int action = RNA_enum_get(op->ptr, "action");
int a;
@@ -460,8 +468,8 @@ static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
if (act_track)
clip_delete_track(C, clip, tracksbase, act_track);
@@ -492,8 +500,8 @@ static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
if (act_track) {
int a = 0;
@@ -556,7 +564,9 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
userdata.max = -FLT_MAX;
userdata.min = FLT_MAX;
- clip_graph_tracking_values_iterate(sc, &userdata, view_all_cb, NULL, NULL);
+ clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
+ sc->flag & SC_SHOW_GRAPH_HIDDEN, &userdata,
+ view_all_cb, NULL, NULL);
/* set extents of view to start/end frames */
v2d->cur.xmin = (float) SFRA;
@@ -640,7 +650,7 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
MovieTrackingMarker *marker;
int action = RNA_enum_get(op->ptr, "action");
int a;
@@ -671,10 +681,10 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op)
void CLIP_OT_graph_disable_markers(wmOperatorType *ot)
{
static EnumPropertyItem actions_items[] = {
- {0, "DISABLE", 0, "Disable", "Disable selected markers"},
- {1, "ENABLE", 0, "Enable", "Enable selected markers"},
- {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
- {0, NULL, 0, NULL, NULL}
+ {0, "DISABLE", 0, "Disable", "Disable selected markers"},
+ {1, "ENABLE", 0, "Enable", "Enable selected markers"},
+ {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 6908e488157..5bc195a1ae2 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -43,18 +43,18 @@ struct SpaceClip;
struct wmOperatorType;
/* channel heights */
-#define CHANNEL_FIRST -UI_UNIT_Y
-#define CHANNEL_HEIGHT UI_UNIT_Y
-#define CHANNEL_HEIGHT_HALF (UI_UNIT_Y / 2.0f)
-#define CHANNEL_SKIP 2
-#define CHANNEL_STEP (CHANNEL_HEIGHT + CHANNEL_SKIP)
+#define CHANNEL_FIRST -UI_UNIT_Y
+#define CHANNEL_HEIGHT UI_UNIT_Y
+#define CHANNEL_HEIGHT_HALF (UI_UNIT_Y / 2.0f)
+#define CHANNEL_SKIP 2
+#define CHANNEL_STEP (CHANNEL_HEIGHT + CHANNEL_SKIP)
-#define CHANNEL_PAD 4
+#define CHANNEL_PAD 4
/* extra padding for lengths (to go under scrollers) */
-#define EXTRA_SCROLL_PAD 100.0f
+#define EXTRA_SCROLL_PAD 100.0f
-#define STRIP_HEIGHT_HALF 5
+#define STRIP_HEIGHT_HALF 5
/* internal exports only */
@@ -110,17 +110,17 @@ void ED_clip_tool_props_register(struct ARegionType *art);
/* clip_utils.c */
void clip_graph_tracking_values_iterate_track(struct SpaceClip *sc, struct MovieTrackingTrack *track, void *userdata,
- void (*func) (void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
- void (*segment_start) (void *userdata, struct MovieTrackingTrack *track, int coord),
- void (*segment_end) (void *userdata));
+ void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
+ void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
+ void (*segment_end)(void *userdata));
-void clip_graph_tracking_values_iterate(struct SpaceClip *sc, void *userdata,
- void (*func) (void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
- void (*segment_start) (void *userdata, struct MovieTrackingTrack *track, int coord),
- void (*segment_end) (void *userdata));
+void clip_graph_tracking_values_iterate(struct SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
+ void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
+ void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
+ void (*segment_end)(void *userdata));
-void clip_graph_tracking_iterate(struct SpaceClip *sc, void *userdata,
- void (*func) (void *userdata, struct MovieTrackingMarker *marker));
+void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
+ void (*func)(void *userdata, struct MovieTrackingMarker *marker));
void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track);
void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker);
@@ -131,12 +131,8 @@ void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scen
void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene);
/* tracking_ops.c */
-void CLIP_OT_select(struct wmOperatorType *ot);
-void CLIP_OT_select_all(struct wmOperatorType *ot);
-void CLIP_OT_select_border(struct wmOperatorType *ot);
-void CLIP_OT_select_lasso(struct wmOperatorType *ot);
-void CLIP_OT_select_circle(struct wmOperatorType *ot);
-void CLIP_OT_select_grouped(struct wmOperatorType *ot);
+struct MovieTrackingTrack *tracking_marker_check_slide(struct bContext *C, struct wmEvent *event,
+ int *area_r, int *action_r, int *corner_r);
void CLIP_OT_add_marker(struct wmOperatorType *ot);
void CLIP_OT_delete_track(struct wmOperatorType *ot);
@@ -182,4 +178,12 @@ void CLIP_OT_tracking_object_remove(struct wmOperatorType *ot);
void CLIP_OT_copy_tracks(struct wmOperatorType *ot);
void CLIP_OT_paste_tracks(struct wmOperatorType *ot);
+/* tracking_select.c */
+void CLIP_OT_select(struct wmOperatorType *ot);
+void CLIP_OT_select_all(struct wmOperatorType *ot);
+void CLIP_OT_select_border(struct wmOperatorType *ot);
+void CLIP_OT_select_lasso(struct wmOperatorType *ot);
+void CLIP_OT_select_circle(struct wmOperatorType *ot);
+void CLIP_OT_select_grouped(struct wmOperatorType *ot);
+
#endif /* __CLIP_INTERN_H__ */
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 73eb8ee77ff..d5ec65e68c7 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -986,7 +986,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog
}
if (build_undistort_count)
- distortion = BKE_tracking_distortion_create();
+ distortion = BKE_tracking_distortion_new();
for (cfra = sfra; cfra <= efra; cfra++) {
if (clip->source != MCLIP_SRC_MOVIE)
@@ -1003,7 +1003,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog
}
if (distortion)
- BKE_tracking_distortion_destroy(distortion);
+ BKE_tracking_distortion_free(distortion);
if (*stop)
pj->stop = 1;
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 6b69f316880..3f8fd5966ec 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -30,7 +30,7 @@
*/
#include "DNA_scene_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "MEM_guardedalloc.h"
@@ -61,12 +61,13 @@
#include "UI_resources.h"
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" // own include
void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack *track, void *userdata,
- void (*func) (void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
- void (*segment_start) (void *userdata, MovieTrackingTrack *track, int coord),
- void (*segment_end) (void *userdata))
+ void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord,
+ int scene_framenr, float val),
+ void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
+ void (*segment_end)(void *userdata))
{
MovieClip *clip = ED_space_clip(sc);
int width, height, coord;
@@ -121,51 +122,54 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack
}
}
-void clip_graph_tracking_values_iterate(SpaceClip *sc, void *userdata,
- void (*func) (void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
- void (*segment_start) (void *userdata, MovieTrackingTrack *track, int coord),
- void (*segment_end) (void *userdata))
+void clip_graph_tracking_values_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
+ void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int coord, int scene_framenr, float val),
+ void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
+ void (*segment_end)(void *userdata))
{
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
- track = tracksbase->first;
- while (track) {
- if (TRACK_VIEW_SELECTED(sc, track)) {
- clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end);
- }
+ for (track = tracksbase->first; track; track = track->next) {
+ if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ continue;
+
+ if (selected_only && !TRACK_SELECTED(track))
+ continue;
- track = track->next;
+ clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end);
}
}
-void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata,
- void (*func) (void *userdata, MovieTrackingMarker *marker))
+void clip_graph_tracking_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
+ void (*func)(void *userdata, MovieTrackingMarker *marker))
{
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
- track = tracksbase->first;
- while (track) {
- if (TRACK_VIEW_SELECTED(sc, track)) {
- int i;
+ for (track = tracksbase->first; track; track = track->next) {
+ int i;
- for (i = 0; i < track->markersnr; i++) {
- MovieTrackingMarker *marker = &track->markers[i];
+ if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ continue;
- if (marker->flag & MARKER_DISABLED)
- continue;
+ if (selected_only && !TRACK_SELECTED(track))
+ continue;
- if (func)
- func(userdata, marker);
- }
- }
+ for (i = 0; i < track->markersnr; i++) {
+ MovieTrackingMarker *marker = &track->markers[i];
+
+ if (marker->flag & MARKER_DISABLED)
+ continue;
- track = track->next;
+ if (func)
+ func(userdata, marker);
+ }
}
}
@@ -173,7 +177,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie
{
MovieTracking *tracking = &clip->tracking;
MovieTrackingStabilization *stab = &tracking->stabilization;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
int has_bundle = FALSE, update_stab = FALSE;
@@ -190,7 +194,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie
if (track->flag & TRACK_HAS_BUNDLE)
has_bundle = TRUE;
- BKE_tracking_free_track(track);
+ BKE_tracking_track_free(track);
BLI_freelinkN(tracksbase, track);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
@@ -213,7 +217,7 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase,
clip_delete_track(C, clip, tracksbase, track);
}
else {
- BKE_tracking_delete_marker(track, marker->framenr);
+ BKE_tracking_marker_delete(track, marker->framenr);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
}
@@ -244,11 +248,11 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
- vec[1] = v2d->cur.ymin;
- glVertex2fv(vec);
+ vec[1] = v2d->cur.ymin;
+ glVertex2fv(vec);
- vec[1] = v2d->cur.ymax;
- glVertex2fv(vec);
+ vec[1] = v2d->cur.ymax;
+ glVertex2fv(vec);
glEnd();
glLineWidth(1.0);
@@ -272,10 +276,10 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
/* 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);
+ 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);
+ 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);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 54724881e37..174b7fcb373 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -35,7 +35,7 @@
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
#include "DNA_movieclip_types.h"
-#include "DNA_view3d_types.h" /* for pivot point */
+#include "DNA_view3d_types.h" /* for pivot point */
#include "MEM_guardedalloc.h"
@@ -71,7 +71,7 @@
#include "RNA_access.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
static void init_preview_region(const bContext *C, ARegion *ar)
{
@@ -215,6 +215,15 @@ static void clip_scopes_tag_refresh(ScrArea *sa)
sc->scopes.ok = FALSE;
}
+static void clip_scopes_check_gpencil_change(ScrArea *sa)
+{
+ SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
+
+ if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
+ clip_scopes_tag_refresh(sa);
+ }
+}
+
static void clip_stabilization_tag_refresh(ScrArea *sa)
{
SpaceClip *sc = (SpaceClip *) sa->spacedata.first;
@@ -299,7 +308,7 @@ static SpaceLink *clip_new(const bContext *C)
/* not spacelink itself */
static void clip_free(SpaceLink *sl)
{
- SpaceClip *sc = (SpaceClip*) sl;
+ SpaceClip *sc = (SpaceClip *) sl;
sc->clip = NULL;
@@ -397,9 +406,10 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_SCREEN:
- switch (wmn->data) {
+ switch (wmn->data) {
case ND_ANIMPLAY:
case ND_GPENCIL:
+ clip_scopes_check_gpencil_change(sa);
ED_area_tag_redraw(sa);
break;
}
@@ -634,17 +644,17 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CLIP_OT_slide_marker", LEFTMOUSE, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_disable_markers", DKEY, KM_PRESS, KM_SHIFT, 0);
- RNA_enum_set(kmi->ptr, "action", 2); /* toggle */
+ RNA_enum_set(kmi->ptr, "action", 2); /* toggle */
/* tracks */
WM_keymap_add_item(keymap, "CLIP_OT_delete_track", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CLIP_OT_delete_track", XKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_lock_tracks", LKEY, KM_PRESS, KM_CTRL, 0);
- RNA_enum_set(kmi->ptr, "action", 0); /* lock */
+ RNA_enum_set(kmi->ptr, "action", 0); /* lock */
kmi = WM_keymap_add_item(keymap, "CLIP_OT_lock_tracks", LKEY, KM_PRESS, KM_ALT, 0);
- RNA_enum_set(kmi->ptr, "action", 1); /* unlock */
+ RNA_enum_set(kmi->ptr, "action", 1); /* unlock */
kmi = WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", FALSE);
@@ -733,7 +743,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
/* tracks */
kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_disable_markers", DKEY, KM_PRESS, KM_SHIFT, 0);
- RNA_enum_set(kmi->ptr, "action", 2); /* toggle */
+ RNA_enum_set(kmi->ptr, "action", 2); /* toggle */
transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
@@ -742,7 +752,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
keymap = WM_keymap_find(keyconf, "Clip Dopesheet Editor", SPACE_CLIP, 0);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_select_channel", ACTIONMOUSE, KM_PRESS, 0, 0);
- RNA_boolean_set(kmi->ptr, "extend", TRUE); /* toggle */
+ RNA_boolean_set(kmi->ptr, "extend", TRUE); /* toggle */
}
const char *clip_context_dir[] = {"edit_movieclip", "edit_mask", NULL};
@@ -1074,7 +1084,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
/* if tracking is in progress, we should synchronize framenr from clipuser
* so latest tracked frame would be shown */
if (clip && clip->tracking_context)
- BKE_tracking_sync_user(&sc->user, clip->tracking_context);
+ BKE_tracking_context_sync_user(clip->tracking_context, &sc->user);
if (sc->flag & SC_LOCK_SELECTION) {
ImBuf *tmpibuf = NULL;
@@ -1101,9 +1111,6 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
clip_draw_main(sc, ar, scene);
- /* Grease Pencil */
- clip_draw_grease_pencil((bContext *)C, 1);
-
if (sc->mode == SC_MODE_MASKEDIT) {
int x, y;
int width, height;
@@ -1147,6 +1154,9 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
glPopMatrix();
}
+ /* Grease Pencil */
+ clip_draw_grease_pencil((bContext *)C, 1);
+
/* reset view matrix */
UI_view2d_view_restore(C);
@@ -1161,7 +1171,7 @@ static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn)
case NC_SCREEN:
if (wmn->data == ND_GPENCIL)
ED_region_tag_redraw(ar);
- break;
+ break;
}
}
@@ -1205,7 +1215,7 @@ static void graph_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- unitx = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
+ unitx = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
unity = V2D_UNIT_VALUES;
scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -1223,7 +1233,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
short unit = 0;
if (clip)
- BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
+ BKE_tracking_dopesheet_update(&clip->tracking);
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1232,7 +1242,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* time grid */
- unit = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
+ unit = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP,
V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
@@ -1284,7 +1294,7 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
if (clip)
- BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
+ BKE_tracking_dopesheet_update(&clip->tracking);
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1331,10 +1341,10 @@ static void clip_header_area_listener(ARegion *ar, wmNotifier *wmn)
case ND_TOOLSETTINGS:
/* TODO - should do this when in mask mode only but no datas available */
// if (sc->mode == SC_MODE_MASKEDIT)
- {
- ED_region_tag_redraw(ar);
- }
- break;
+ {
+ ED_region_tag_redraw(ar);
+ }
+ break;
}
break;
}
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index f6e9622f0a5..8ca483c94d3 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -35,7 +35,7 @@
#include "DNA_constraint_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
@@ -77,9 +77,7 @@
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
-
-static float dist_to_crns(float co[2], float pos[2], float crns[4][2]);
+#include "clip_intern.h" // own include
/********************** add marker operator *********************/
@@ -87,16 +85,16 @@ static void add_marker(SpaceClip *sc, float x, float y)
{
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
int width, height;
int framenr = ED_space_clip_clip_framenr(sc);
ED_space_clip_size(sc, &width, &height);
- track = BKE_tracking_add_track(tracking, tracksbase, x, y, framenr, width, height);
+ track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height);
- BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, 0);
+ BKE_tracking_track_select(tracksbase, track, TRACK_AREA_ALL, 0);
clip->tracking.act_track = track;
}
@@ -154,7 +152,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot)
/* properties */
RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
- "Location", "Location of marker on frame", -1.0f, 1.0f);
+ "Location", "Location of marker on frame", -1.0f, 1.0f);
}
/********************** delete track operator *********************/
@@ -164,7 +162,7 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track = tracksbase->first, *next;
while (track) {
@@ -204,7 +202,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track = tracksbase->first, *next;
int framenr = ED_space_clip_clip_framenr(sc);
int has_selection = 0;
@@ -213,7 +211,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op))
next = track->next;
if (TRACK_VIEW_SELECTED(sc, track)) {
- MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
if (marker) {
has_selection |= track->markersnr > 1;
@@ -251,32 +249,43 @@ void CLIP_OT_delete_marker(wmOperatorType *ot)
/********************** slide marker operator *********************/
-#define SLIDE_ACTION_POS 0
-#define SLIDE_ACTION_SIZE 1
-#define SLIDE_ACTION_OFFSET 2
+#define SLIDE_ACTION_POS 0
+#define SLIDE_ACTION_SIZE 1
+#define SLIDE_ACTION_OFFSET 2
+#define SLIDE_ACTION_TILT_SIZE 3
typedef struct {
- int area, action;
+ short area, action;
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
int mval[2];
int width, height;
float *min, *max, *pos, *offset, (*corners)[2];
- float smin[2], smax[2], spos[2], soff[2], scorners[4][2];
- float (*smarkers)[2];
+ float spos[2];
+
+ short lock, accurate;
- int lock, accurate, scale;
+ /* data to restore on cancel */
+ float old_search_min[2], old_search_max[2], old_pos[2], old_offset[2];
+ float old_corners[4][2];
+ float (*old_markers)[2];
} SlideMarkerData;
+static void slide_marker_tilt_slider(MovieTrackingMarker *marker, float slider[2])
+{
+ add_v2_v2v2(slider, marker->pattern_corners[1], marker->pattern_corners[2]);
+ add_v2_v2(slider, marker->pos);
+}
+
static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTrack *track,
MovieTrackingMarker *marker, wmEvent *event,
- int area, int corner, int action, int width, int height)
+ int area, int corner, int action, int width, int height)
{
SlideMarkerData *data = MEM_callocN(sizeof(SlideMarkerData), "slide marker data");
int framenr = ED_space_clip_clip_framenr(sc);
- marker = BKE_tracking_ensure_marker(track, framenr);
+ marker = BKE_tracking_marker_ensure(track, framenr);
data->area = area;
data->action = action;
@@ -286,8 +295,6 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
if (area == TRACK_AREA_POINT) {
data->pos = marker->pos;
data->offset = track->offset;
- copy_v2_v2(data->spos, marker->pos);
- copy_v2_v2(data->soff, track->offset);
}
else if (area == TRACK_AREA_PAT) {
if (action == SLIDE_ACTION_SIZE) {
@@ -299,36 +306,25 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
data->pos = marker->pos;
data->offset = track->offset;
- copy_v2_v2(data->soff, track->offset);
-
- data->smarkers = MEM_callocN(sizeof(*data->smarkers)*track->markersnr, "slide marekrs");
+ data->old_markers = MEM_callocN(sizeof(*data->old_markers) * track->markersnr, "slide marekrs");
for (a = 0; a < track->markersnr; a++)
- copy_v2_v2(data->smarkers[a], track->markers[a].pos);
+ copy_v2_v2(data->old_markers[a], track->markers[a].pos);
}
else if (action == SLIDE_ACTION_POS) {
data->corners = marker->pattern_corners;
data->pos = marker->pattern_corners[corner];
-
copy_v2_v2(data->spos, data->pos);
}
+ else if (action == SLIDE_ACTION_TILT_SIZE) {
+ data->corners = marker->pattern_corners;
+ slide_marker_tilt_slider(marker, data->spos);
+ }
}
else if (area == TRACK_AREA_SEARCH) {
data->min = marker->search_min;
data->max = marker->search_max;
}
- if ((area == TRACK_AREA_SEARCH) ||
- (area == TRACK_AREA_PAT && action != SLIDE_ACTION_OFFSET))
- {
- if (data->corners) {
- memcpy(data->scorners, data->corners, sizeof(data->scorners));
- }
- else {
- copy_v2_v2(data->smin, data->min);
- copy_v2_v2(data->smax, data->max);
- }
- }
-
data->mval[0] = event->mval[0];
data->mval[1] = event->mval[1];
@@ -338,16 +334,24 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
if (action == SLIDE_ACTION_SIZE)
data->lock = 1;
+ /* backup marker's settings */
+ memcpy(data->old_corners, marker->pattern_corners, sizeof(data->old_corners));
+ copy_v2_v2(data->old_search_min, marker->search_min);
+ copy_v2_v2(data->old_search_max, marker->search_max);
+ copy_v2_v2(data->old_pos, marker->pos);
+ copy_v2_v2(data->old_offset, track->offset);
+
return data;
}
-static int mouse_on_corner(SpaceClip *sc, MovieTrackingMarker *marker,
- int area, float co[2], int corner, int width, int height)
+static int mouse_on_slide_zone(SpaceClip *sc, MovieTrackingMarker *marker,
+ int area, float co[2], float slide_zone[2],
+ float padding, int width, int height)
{
+ const float size = 12.0f;
int inside = 0;
- float size = 12.0f;
float min[2], max[2];
- float crn[2], dx, dy, tdx, tdy;
+ float dx, dy;
if (area == TRACK_AREA_SEARCH) {
copy_v2_v2(min, marker->search_min);
@@ -357,29 +361,52 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingMarker *marker,
BKE_tracking_marker_pattern_minmax(marker, min, max);
}
+ min[0] -= padding / width;
+ min[1] -= padding / height;
+ max[0] += padding / width;
+ max[1] += padding / height;
+
dx = size / width / sc->zoom;
dy = size / height / sc->zoom;
- tdx = 5.0f / width / sc->zoom;
- tdy = 5.0f / height / sc->zoom;
+ dx = MIN2(dx, (max[0] - min[0]) / 6.0f);
+ dy = MIN2(dy, (max[1] - min[1]) / 6.0f);
+
+ return IN_RANGE_INCL(co[0], slide_zone[0] - dx, slide_zone[0] + dx) &&
+ IN_RANGE_INCL(co[1], slide_zone[1] - dy, slide_zone[1] + dy);
+
+ return inside;
+}
+
+static int mouse_on_corner(SpaceClip *sc, MovieTrackingMarker *marker,
+ int area, float co[2], int corner, float padding,
+ int width, int height)
+{
+ float min[2], max[2], crn[2];
+
+ if (area == TRACK_AREA_SEARCH) {
+ copy_v2_v2(min, marker->search_min);
+ copy_v2_v2(max, marker->search_max);
+ }
+ else {
+ BKE_tracking_marker_pattern_minmax(marker, min, max);
+ }
- dx = MIN2(dx, (max[0] - min[0]) / 6.0f) + tdx;
- dy = MIN2(dy, (max[1] - min[1]) / 6.0f) + tdy;
+ min[0] -= padding / width;
+ min[1] -= padding / height;
+ max[0] += padding / width;
+ max[1] += padding / height;
if (corner == 0) {
crn[0] = marker->pos[0] + max[0];
crn[1] = marker->pos[1] + min[1];
-
- inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + tdx && co[1] >= crn[1] - tdy && co[1] <= crn[1] + dy;
}
else {
crn[0] = marker->pos[0] + min[0];
crn[1] = marker->pos[1] + max[1];
-
- inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + dx && co[1] >= crn[1] - dy && co[1] <= crn[1] + dy;
}
- return inside;
+ return mouse_on_slide_zone(sc, marker, area, co, crn, padding, width, height);
}
static int get_mouse_pattern_corner(SpaceClip *sc, MovieTrackingMarker *marker, float co[2], int width, int height)
@@ -397,11 +424,11 @@ static int get_mouse_pattern_corner(SpaceClip *sc, MovieTrackingMarker *marker,
len = MIN2(cur_len, len);
}
- dx = 6.0f / width / sc->zoom;
- dy = 6.0f / height / sc->zoom;
+ dx = 12.0f / width / sc->zoom;
+ dy = 12.0f / height / sc->zoom;
- dx = MIN2(dx * 2.0f / 3.0f, len / 6.0f);
- dy = MIN2(dy * 2.0f / 3.0f, len * width / height / 6.0f);
+ dx = MIN2(dx, len * 2.0f / 3.0f);
+ dy = MIN2(dy, len * width / height * 2.0f / 3.0f);
for (i = 0; i < 4; i++) {
float crn[2];
@@ -438,6 +465,15 @@ static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki
return co[0] >= pos[0] - dx && co[0] <= pos[0] + dx && co[1] >= pos[1] - dy && co[1] <= pos[1] + dy;
}
+static int mouse_on_tilt(SpaceClip *sc, MovieTrackingMarker *marker, float co[2], int width, int height)
+{
+ float slider[2];
+
+ slide_marker_tilt_slider(marker, slider);
+
+ return mouse_on_slide_zone(sc, marker, TRACK_AREA_PAT, co, slider, 0.0f, width, height);
+}
+
static int slide_check_corners(float (*corners)[2])
{
int i, next, prev;
@@ -485,16 +521,16 @@ static void show_cursor(bContext *C)
WM_cursor_set(win, CURSOR_STD);
}
-static void *slide_marker_customdata(bContext *C, wmEvent *event)
+MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int *area_r, int *action_r, int *corner_r)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTrackingTrack *track;
int width, height;
float co[2];
- void *customdata = NULL;
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
int framenr = ED_space_clip_clip_framenr(sc);
+ int action = -1, area = 0, corner = -1;
ED_space_clip_size(sc, &width, &height);
@@ -506,58 +542,102 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+ int ok = FALSE;
if ((marker->flag & MARKER_DISABLED) == 0) {
- if (!customdata) {
- if (mouse_on_offset(sc, track, marker, co, width, height))
- customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, 0,
- SLIDE_ACTION_POS, width, height);
+ if (mouse_on_offset(sc, track, marker, co, width, height)) {
+ area = TRACK_AREA_POINT;
+ action = SLIDE_ACTION_POS;
+ ok = TRUE;
}
- if (sc->flag & SC_SHOW_MARKER_SEARCH) {
- if (mouse_on_corner(sc, marker, TRACK_AREA_SEARCH, co, 1, width, height)) {
- customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, 0,
- SLIDE_ACTION_OFFSET, width, height);
+ if (!ok && (sc->flag & SC_SHOW_MARKER_SEARCH)) {
+ if (mouse_on_corner(sc, marker, TRACK_AREA_SEARCH, co, 1, 0.0f, width, height)) {
+ area = TRACK_AREA_SEARCH;
+ action = SLIDE_ACTION_OFFSET;
+ ok = TRUE;
}
- else if (mouse_on_corner(sc, marker, TRACK_AREA_SEARCH, co, 0, width, height)) {
- customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, 0,
- SLIDE_ACTION_SIZE, width, height);
+ else if (mouse_on_corner(sc, marker, TRACK_AREA_SEARCH, co, 0, 0.0f, width, height)) {
+ area = TRACK_AREA_SEARCH;
+ action = SLIDE_ACTION_SIZE;
+ ok = TRUE;
}
}
- if (!customdata && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
- /* XXX: need to be real check if affine tracking is enabled, but for now not
- * sure how to do this, so assume affine tracker is always enabled */
- if (TRUE) {
- int corner = get_mouse_pattern_corner(sc, marker, co, width, height);
+ if (!ok && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
+ int current_corner = get_mouse_pattern_corner(sc, marker, co, width, height);
- if (corner != -1) {
- customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, corner,
- SLIDE_ACTION_POS, width, height);
- }
+ if (current_corner != -1) {
+ area = TRACK_AREA_PAT;
+ action = SLIDE_ACTION_POS;
+ corner = current_corner;
+ ok = TRUE;
}
else {
- if (mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 1, width, height)) {
- customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, 0,
- SLIDE_ACTION_OFFSET, width, height);
+ if (mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 1, 12.0f, width, height)) {
+ area = TRACK_AREA_PAT;
+ action = SLIDE_ACTION_OFFSET;
+ ok = TRUE;
}
-
- if (!customdata && mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 0, width, height)) {
- customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, 0,
- SLIDE_ACTION_SIZE, width, height);
+ if (!ok && mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 0, 12.0f, width, height)) {
+ area = TRACK_AREA_PAT;
+ action = SLIDE_ACTION_SIZE;
+ ok = TRUE;
+ }
+ if (!ok && mouse_on_tilt(sc, marker, co, width, height)) {
+ area = TRACK_AREA_PAT;
+ action = SLIDE_ACTION_TILT_SIZE;
+ ok = TRUE;
}
}
}
- if (customdata)
- break;
+ if (ok) {
+ if (area_r)
+ *area_r = area;
+
+ if (action_r)
+ *action_r = action;
+
+ if (corner_r)
+ *corner_r = corner;
+
+ return track;
+ }
}
}
track = track->next;
}
+ return NULL;
+}
+
+static void *slide_marker_customdata(bContext *C, wmEvent *event)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieTrackingTrack *track;
+ int width, height;
+ float co[2];
+ void *customdata = NULL;
+ int framenr = ED_space_clip_clip_framenr(sc);
+ int area, action, corner;
+
+ ED_space_clip_size(sc, &width, &height);
+
+ if (width == 0 || height == 0)
+ return NULL;
+
+ ED_clip_mouse_pos(C, event, co);
+
+ track = tracking_marker_check_slide(C, event, &area, &action, &corner);
+ if (track) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+
+ customdata = create_slide_marker_data(sc, track, marker, event, area, corner, action, width, height);
+ }
+
return customdata;
}
@@ -587,40 +667,27 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event)
static void cancel_mouse_slide(SlideMarkerData *data)
{
- /* cancel sliding */
- if (data->area == TRACK_AREA_POINT) {
- if (data->action == SLIDE_ACTION_OFFSET)
- copy_v2_v2(data->offset, data->soff);
- else
- copy_v2_v2(data->pos, data->spos);
- }
- else {
- if ((data->action == SLIDE_ACTION_SIZE) ||
- (data->action == SLIDE_ACTION_POS && data->area == TRACK_AREA_PAT))
- {
- if (data->corners) {
- memcpy(data->corners, data->scorners, sizeof(data->scorners));
- }
- else {
- copy_v2_v2(data->min, data->smin);
- copy_v2_v2(data->max, data->smax);
- }
- }
- else {
- int a;
+ MovieTrackingTrack *track = data->track;
+ MovieTrackingMarker *marker = data->marker;
- for (a = 0; a < data->track->markersnr; a++)
- copy_v2_v2(data->track->markers[a].pos, data->smarkers[a]);
+ memcpy(marker->pattern_corners, data->old_corners, sizeof(marker->pattern_corners));
+ copy_v2_v2(marker->search_min, data->old_search_min);
+ copy_v2_v2(marker->search_max, data->old_search_max);
+ copy_v2_v2(marker->pos, data->old_pos);
+ copy_v2_v2(track->offset, data->old_offset);
- copy_v2_v2(data->offset, data->soff);
- }
+ if (data->old_markers) {
+ int a;
+
+ for (a = 0; a < data->track->markersnr; a++)
+ copy_v2_v2(data->track->markers[a].pos, data->old_markers[a]);
}
}
static void free_slide_data(SlideMarkerData *data)
{
- if (data->smarkers)
- MEM_freeN(data->smarkers);
+ if (data->old_markers)
+ MEM_freeN(data->old_markers);
MEM_freeN(data);
}
@@ -640,14 +707,10 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
if (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY))
data->lock = event->val == KM_RELEASE;
- if (data->action == SLIDE_ACTION_POS)
- if (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY))
- data->scale = event->val == KM_PRESS;
-
if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY))
data->accurate = event->val == KM_PRESS;
- /* no break! update area size */
+ /* no break! update area size */
case MOUSEMOVE:
mdelta[0] = event->mval[0] - data->mval[0];
@@ -667,95 +730,144 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
if (data->area == TRACK_AREA_POINT) {
if (data->action == SLIDE_ACTION_OFFSET) {
- data->offset[0] = data->soff[0] + dx;
- data->offset[1] = data->soff[1] + dy;
+ data->offset[0] = data->old_offset[0] + dx;
+ data->offset[1] = data->old_offset[1] + dy;
}
else {
- data->pos[0] = data->spos[0] + dx;
- data->pos[1] = data->spos[1] + dy;
+ data->pos[0] = data->old_pos[0] + dx;
+ data->pos[1] = data->old_pos[1] + dy;
}
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
DAG_id_tag_update(&sc->clip->id, 0);
}
- else {
+ else if (data->area == TRACK_AREA_PAT) {
if (data->action == SLIDE_ACTION_SIZE) {
- if (data->corners) {
- data->corners[0][0] = data->scorners[0][0] - dx;
- data->corners[0][1] = data->scorners[0][1] + dy;
+ float start[2], end[2];
+ float scale;
- data->corners[1][0] = data->scorners[1][0] + dx;
- data->corners[1][1] = data->scorners[1][1] + dy;
+ ED_clip_point_stable_pos(C, data->mval[0], data->mval[1], &start[0], &start[1]);
- data->corners[2][0] = data->scorners[2][0] + dx;
- data->corners[2][1] = data->scorners[2][1] - dy;
+ sub_v2_v2(start, data->old_pos);
- data->corners[3][0] = data->scorners[3][0] - dx;
- data->corners[3][1] = data->scorners[3][1] - dy;
- }
- else {
- data->min[0] = data->smin[0] - dx;
- data->max[0] = data->smax[0] + dx;
+ if (len_v2(start) > 0.0f) {
+ float mval[2];
+
+ if (data->accurate) {
+ mval[0] = data->mval[0] + (event->mval[0] - data->mval[0]) / 5.0f;
+ mval[1] = data->mval[1] + (event->mval[1] - data->mval[1]) / 5.0f;
+ }
+ else {
+ mval[0] = event->mval[0];
+ mval[1] = event->mval[1];
+ }
+
+ ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]);
+
+ sub_v2_v2(end, data->old_pos);
+
+ scale = len_v2(end) / len_v2(start);
+
+ if (scale > 0.0f) {
+ int a;
- data->min[1] = data->smin[1] + dy;
- data->max[1] = data->smax[1] - dy;
+ for (a = 0; a < 4; a++) {
+ mul_v2_v2fl(data->corners[a], data->old_corners[a], scale);
+ }
+ }
}
- if (data->area == TRACK_AREA_SEARCH)
- BKE_tracking_clamp_marker(data->marker, CLAMP_SEARCH_DIM);
- else
- BKE_tracking_clamp_marker(data->marker, CLAMP_PAT_DIM);
+ BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM);
}
else if (data->action == SLIDE_ACTION_OFFSET) {
float d[2] = {dx, dy};
+ int a;
- if (data->area == TRACK_AREA_SEARCH) {
- add_v2_v2v2(data->min, data->smin, d);
- add_v2_v2v2(data->max, data->smax, d);
- }
- else {
- int a;
+ for (a = 0; a < data->track->markersnr; a++)
+ add_v2_v2v2(data->track->markers[a].pos, data->old_markers[a], d);
- for (a = 0; a < data->track->markersnr; a++)
- add_v2_v2v2(data->track->markers[a].pos, data->smarkers[a], d);
+ sub_v2_v2v2(data->offset, data->old_offset, d);
+ }
+ else if (data->action == SLIDE_ACTION_POS) {
+ float spos[2];
- sub_v2_v2v2(data->offset, data->soff, d);
+ copy_v2_v2(spos, data->pos);
+
+ data->pos[0] = data->spos[0] + dx;
+ data->pos[1] = data->spos[1] + dy;
+
+ if (!slide_check_corners(data->corners)) {
+ copy_v2_v2(data->pos, spos);
}
- if (data->area == TRACK_AREA_SEARCH)
- BKE_tracking_clamp_marker(data->marker, CLAMP_SEARCH_POS);
+ /* currently only patterns are allowed to have such combination of event and data */
+ BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM);
}
- else if (data->action == SLIDE_ACTION_POS) {
- if (data->scale) {
- float scale = 1.0f + 10.0f * (dx - dy);
+ else if (data->action == SLIDE_ACTION_TILT_SIZE) {
+ float start[2], end[2];
+ float scale = 1.0f, angle = 0.0f;
+ int a;
+ float mval[2];
+
+ if (data->accurate) {
+ mval[0] = data->mval[0] + (event->mval[0] - data->mval[0]) / 5.0f;
+ mval[1] = data->mval[1] + (event->mval[1] - data->mval[1]) / 5.0f;
+ }
+ else {
+ mval[0] = event->mval[0];
+ mval[1] = event->mval[1];
+ }
- if (scale > 0.0f) {
- int a;
+ sub_v2_v2v2(start, data->spos, data->old_pos);
- for (a = 0; a < 4; a++) {
- mul_v2_v2fl(data->corners[a], data->scorners[a], scale);
- }
+ ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]);
+ sub_v2_v2(end, data->old_pos);
+
+ if (len_v2(start) > 0.0f) {
+ scale = len_v2(end) / len_v2(start);
+
+ if (scale < 0.0f) {
+ scale = 0.0;
}
}
- else {
- float spos[2];
- copy_v2_v2(spos, data->pos);
+ angle = -angle_signed_v2v2(start, end);
- /* corners might've been scaled before, restore their original position */
- memcpy(data->corners, data->scorners, sizeof(data->scorners));
+ for (a = 0; a < 4; a++) {
+ float vec[2];
- data->pos[0] = data->spos[0] + dx;
- data->pos[1] = data->spos[1] + dy;
+ mul_v2_v2fl(data->corners[a], data->old_corners[a], scale);
- if (!slide_check_corners(data->corners)) {
- copy_v2_v2(data->pos, spos);
- }
+ copy_v2_v2(vec, data->corners[a]);
+ vec[0] *= data->width;
+ vec[1] *= data->height;
+
+ data->corners[a][0] = (vec[0] * cos(angle) - vec[1] * sin(angle)) / data->width;
+ data->corners[a][1] = (vec[1] * cos(angle) + vec[0] * sin(angle)) / data->height;
}
- /* currently only patterns are allowed to have such combination of event and data */
- BKE_tracking_clamp_marker(data->marker, CLAMP_PAT_DIM);
+ BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM);
+
+ }
+ }
+ else if (data->area == TRACK_AREA_SEARCH) {
+ if (data->action == SLIDE_ACTION_SIZE) {
+ data->min[0] = data->old_search_min[0] - dx;
+ data->max[0] = data->old_search_max[0] + dx;
+
+ data->min[1] = data->old_search_min[1] + dy;
+ data->max[1] = data->old_search_max[1] - dy;
+
+ BKE_tracking_marker_clamp(data->marker, CLAMP_SEARCH_DIM);
+ }
+ else if (data->area == TRACK_AREA_SEARCH) {
+ float d[2] = {dx, dy};
+
+ add_v2_v2v2(data->min, data->old_search_min, d);
+ add_v2_v2v2(data->max, data->old_search_max, d);
}
+
+ BKE_tracking_marker_clamp(data->marker, CLAMP_SEARCH_POS);
}
data->marker->flag &= ~MARKER_TRACKED;
@@ -807,710 +919,17 @@ void CLIP_OT_slide_marker(wmOperatorType *ot)
/* properties */
RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX,
- "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX);
-}
-
-/********************** mouse select operator *********************/
-
-static int mouse_on_side(float co[2], float x1, float y1, float x2, float y2, float epsx, float epsy)
-{
- if (x1 > x2)
-
- SWAP(float, x1, x2);
-
- if (y1 > y2)
- SWAP(float, y1, y2);
-
- return (co[0] >= x1 - epsx && co[0] <= x2 + epsx) && (co[1] >= y1 - epsy && co[1] <= y2 + epsy);
-}
-
-static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2], float epsx, float epsy)
-{
- return mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + max[0], pos[1] + min[1], epsx, epsy) ||
- mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + min[0], pos[1] + max[1], epsx, epsy) ||
- mouse_on_side(co, pos[0] + min[0], pos[1] + max[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy) ||
- mouse_on_side(co, pos[0] + max[0], pos[1] + min[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy);
-}
-
-static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx, float epsy)
-{
- float dist = dist_to_crns(co, pos, crns);
-
- return dist < MAX2(epsx, epsy);
-}
-
-static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track)
-{
- int framenr = ED_space_clip_clip_framenr(sc);
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
- float pat_min[2], pat_max[2];
- float epsx, epsy;
- int width, height;
-
- ED_space_clip_size(sc, &width, &height);
-
- BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
-
- epsx = MIN4(pat_min[0] - marker->search_min[0], marker->search_max[0] - pat_max[0],
- fabsf(pat_min[0]), fabsf(pat_max[0])) / 2;
- epsy = MIN4(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1],
- fabsf(pat_min[1]), fabsf(pat_max[1])) / 2;
-
- epsx = MAX2(epsx, 2.0f / width);
- epsy = MAX2(epsy, 2.0f / height);
-
- if (sc->flag & SC_SHOW_MARKER_SEARCH) {
- if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy))
- return TRACK_AREA_SEARCH;
- }
-
- if ((marker->flag & MARKER_DISABLED) == 0) {
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
- if (mouse_on_crns(co, marker->pos, marker->pattern_corners, epsx, epsy))
- return TRACK_AREA_PAT;
-
- epsx = 12.0f / width;
- epsy = 12.0f / height;
-
- if (fabsf(co[0] - marker->pos[0] - track->offset[0]) < epsx &&
- fabsf(co[1] - marker->pos[1] - track->offset[1]) <= epsy)
- {
- return TRACK_AREA_POINT;
- }
- }
-
- return TRACK_AREA_NONE;
-}
-
-static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2])
-{
- float d1, d2, d3, d4;
- float p[2] = {co[0] - pos[0], co[1] - pos[1]};
- float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]};
- float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]};
-
- d1 = dist_to_line_segment_v2(p, v1, v2);
- d2 = dist_to_line_segment_v2(p, v2, v3);
- d3 = dist_to_line_segment_v2(p, v3, v4);
- d4 = dist_to_line_segment_v2(p, v4, v1);
-
- return MIN4(d1, d2, d3, d4);
-}
-
-static float dist_to_crns(float co[2], float pos[2], float crns[4][2])
-{
- float d1, d2, d3, d4;
- float p[2] = {co[0] - pos[0], co[1] - pos[1]};
- float *v1 = crns[0], *v2 = crns[1],
- *v3 = crns[2], *v4 = crns[3];
-
- d1 = dist_to_line_segment_v2(p, v1, v2);
- d2 = dist_to_line_segment_v2(p, v2, v3);
- d3 = dist_to_line_segment_v2(p, v3, v4);
- d4 = dist_to_line_segment_v2(p, v4, v1);
-
- return MIN4(d1, d2, d3, d4);
-}
-
-static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbase, float co[2])
-{
- MovieTrackingTrack *track = NULL, *cur;
- float mindist = 0.0f;
- int framenr = ED_space_clip_clip_framenr(sc);
-
- cur = tracksbase->first;
- while (cur) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(cur, framenr);
-
- if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, cur, marker)) {
- float dist, d1, d2 = FLT_MAX, d3 = FLT_MAX;
-
- /* distance to marker point */
- d1 = sqrtf((co[0] - marker->pos[0] - cur->offset[0]) * (co[0] - marker->pos[0] - cur->offset[0]) +
- (co[1] - marker->pos[1] - cur->offset[1]) * (co[1] - marker->pos[1] - cur->offset[1]));
-
- /* distance to pattern boundbox */
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
- d2 = dist_to_crns(co, marker->pos, marker->pattern_corners);
-
- /* distance to search boundbox */
- if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur))
- d3 = dist_to_rect(co, marker->pos, marker->search_min, marker->search_max);
-
- /* choose minimal distance. useful for cases of overlapped markers. */
- dist = MIN3(d1, d2, d3);
-
- if (track == NULL || dist < mindist) {
- track = cur;
- mindist = dist;
- }
- }
-
- cur = cur->next;
- }
-
- return track;
-}
-
-static int mouse_select(bContext *C, float co[2], int extend)
-{
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip(sc);
- MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
- MovieTrackingTrack *track = NULL; /* selected marker */
-
- track = find_nearest_track(sc, tracksbase, co);
-
- if (track) {
- int area = track_mouse_area(sc, co, track);
-
- if (!extend || !TRACK_VIEW_SELECTED(sc, track))
- area = TRACK_AREA_ALL;
-
- if (extend && TRACK_AREA_SELECTED(track, area)) {
- if (track == act_track)
- BKE_tracking_deselect_track(track, area);
- else
- clip->tracking.act_track = track;
- }
- else {
- if (area == TRACK_AREA_POINT)
- area = TRACK_AREA_ALL;
-
- BKE_tracking_select_track(tracksbase, track, area, extend);
- clip->tracking.act_track = track;
- }
- }
-
- if (!extend) {
- sc->xlockof = 0.0f;
- sc->ylockof = 0.0f;
- }
-
- BKE_tracking_dopesheet_tag_update(tracking);
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static int select_exec(bContext *C, wmOperator *op)
-{
- float co[2];
- int extend;
-
- RNA_float_get_array(op->ptr, "location", co);
- extend = RNA_boolean_get(op->ptr, "extend");
-
- return mouse_select(C, co, extend);
-}
-
-static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
- float co[2];
- int extend = RNA_boolean_get(op->ptr, "extend");
-
- if (!extend) {
- SlideMarkerData *slidedata = slide_marker_customdata(C, event);
-
- if (slidedata) {
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip(sc);
-
- clip->tracking.act_track = slidedata->track;
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
-
- MEM_freeN(slidedata);
-
- return OPERATOR_PASS_THROUGH;
- }
- }
-
- ED_clip_mouse_pos(C, event, co);
- RNA_float_set_array(op->ptr, "location", co);
-
- return select_exec(C, op);
-}
-
-void CLIP_OT_select(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Select";
- ot->description = "Select tracking markers";
- ot->idname = "CLIP_OT_select";
-
- /* api callbacks */
- ot->exec = select_exec;
- ot->invoke = select_invoke;
- //ot->poll = ED_space_clip_tracking_poll; // so mask view can Ctrl+RMB markers
- ot->poll = ED_space_clip_view_clip_poll;
-
- /* flags */
- ot->flag = OPTYPE_UNDO;
-
- /* properties */
- RNA_def_boolean(ot->srna, "extend", 0,
- "Extend", "Extend selection rather than clearing the existing selection");
- RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
- "Location", "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds", -100.0f, 100.0f);
-}
-
-/********************** border select operator *********************/
-
-static int border_select_exec(bContext *C, wmOperator *op)
-{
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip(sc);
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *track;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- rcti rect;
- rctf rectf;
- int change = FALSE, mode, extend;
- int framenr = ED_space_clip_clip_framenr(sc);
-
- /* get rectangle from operator */
- rect.xmin = RNA_int_get(op->ptr, "xmin");
- rect.ymin = RNA_int_get(op->ptr, "ymin");
- rect.xmax = RNA_int_get(op->ptr, "xmax");
- rect.ymax = RNA_int_get(op->ptr, "ymax");
-
- ED_clip_point_stable_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
- ED_clip_point_stable_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
-
- mode = RNA_int_get(op->ptr, "gesture_mode");
- extend = RNA_boolean_get(op->ptr, "extend");
-
- /* do actual selection */
- track = tracksbase->first;
- while (track) {
- if ((track->flag & TRACK_HIDDEN) == 0) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
-
- if (MARKER_VISIBLE(sc, track, marker)) {
- if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) {
- BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT);
- }
- else if (!extend) {
- BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 1);
- }
-
- change = TRUE;
- }
- }
-
- track = track->next;
- }
-
- if (change) {
- BKE_tracking_dopesheet_tag_update(tracking);
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
-
- return OPERATOR_FINISHED;
- }
-
- return OPERATOR_CANCELLED;
-}
-
-void CLIP_OT_select_border(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Border Select";
- ot->description = "Select markers using border selection";
- ot->idname = "CLIP_OT_select_border";
-
- /* api callbacks */
- ot->invoke = WM_border_select_invoke;
- ot->exec = border_select_exec;
- ot->modal = WM_border_select_modal;
- ot->poll = ED_space_clip_tracking_poll;
-
- /* flags */
- ot->flag = OPTYPE_UNDO;
-
- /* properties */
- WM_operator_properties_gesture_border(ot, TRUE);
-}
-
-
-static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select)
-{
- ARegion *ar = CTX_wm_region(C);
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip(sc);
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *track;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- rcti rect;
- int change = FALSE;
- int framenr = ED_space_clip_clip_framenr(sc);
-
- /* get rectangle from operator */
- BLI_lasso_boundbox(&rect, mcords, moves);
-
- /* do actual selection */
- track = tracksbase->first;
- while (track) {
- if ((track->flag & TRACK_HIDDEN) == 0) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
-
- if (MARKER_VISIBLE(sc, track, marker)) {
- float screen_co[2];
-
- /* marker in screen coords */
- ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co);
-
- if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) &&
- BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED))
- {
- BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, !select);
- }
-
- change = TRUE;
- }
- }
-
- track = track->next;
- }
-
- if (change) {
- BKE_tracking_dopesheet_tag_update(tracking);
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- }
-
- return change;
-}
-
-static int clip_lasso_select_exec(bContext *C, wmOperator *op)
-{
- int mcords_tot;
- int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
-
- if (mcords) {
- short select;
-
- select = !RNA_boolean_get(op->ptr, "deselect");
- do_lasso_select_marker(C, mcords, mcords_tot, select);
-
- MEM_freeN(mcords);
-
- return OPERATOR_FINISHED;
- }
- return OPERATOR_PASS_THROUGH;
-}
-
-void CLIP_OT_select_lasso(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Lasso Select";
- ot->description = "Select markers using lasso selection";
- ot->idname = "CLIP_OT_select_lasso";
-
- /* api callbacks */
- ot->invoke = WM_gesture_lasso_invoke;
- ot->modal = WM_gesture_lasso_modal;
- ot->exec = clip_lasso_select_exec;
- ot->poll = ED_space_clip_tracking_poll;
- ot->cancel = WM_gesture_lasso_cancel;
-
- /* flags */
- ot->flag = OPTYPE_UNDO;
-
- /* properties */
- RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
- RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
- RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
-}
-
-/********************** circle select operator *********************/
-
-static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], float ellipse[2])
-{
- /* normalized ellipse: ell[0] = scaleX, ell[1] = scaleY */
- float x, y;
-
- x = (marker->pos[0] - offset[0])*ellipse[0];
- y = (marker->pos[1] - offset[1])*ellipse[1];
-
- return x*x + y*y < 1.0f;
-}
-
-static int circle_select_exec(bContext *C, wmOperator *op)
-{
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip(sc);
- ARegion *ar = CTX_wm_region(C);
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *track;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- int x, y, radius, width, height, mode, change = FALSE;
- float zoomx, zoomy, offset[2], ellipse[2];
- int framenr = ED_space_clip_clip_framenr(sc);
-
- /* get operator properties */
- x = RNA_int_get(op->ptr, "x");
- y = RNA_int_get(op->ptr, "y");
- radius = RNA_int_get(op->ptr, "radius");
-
- mode = RNA_int_get(op->ptr, "gesture_mode");
-
- /* compute ellipse and position in unified coordinates */
- ED_space_clip_size(sc, &width, &height);
- ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
-
- ellipse[0] = width * zoomx / radius;
- ellipse[1] = height * zoomy / radius;
-
- ED_clip_point_stable_pos(C, x, y, &offset[0], &offset[1]);
-
- /* do selection */
- track = tracksbase->first;
- while (track) {
- if ((track->flag & TRACK_HIDDEN) == 0) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
-
- if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) {
- BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT);
-
- change = TRUE;
- }
- }
-
- track = track->next;
- }
-
- if (change) {
- BKE_tracking_dopesheet_tag_update(tracking);
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
-
- return OPERATOR_FINISHED;
- }
-
- return OPERATOR_CANCELLED;
-}
-
-void CLIP_OT_select_circle(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Circle Select";
- ot->description = "Select markers using circle selection";
- ot->idname = "CLIP_OT_select_circle";
-
- /* api callbacks */
- ot->invoke = WM_gesture_circle_invoke;
- ot->modal = WM_gesture_circle_modal;
- ot->exec = circle_select_exec;
- ot->poll = ED_space_clip_tracking_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
- RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
- RNA_def_int(ot->srna, "radius", 0, INT_MIN, INT_MAX, "Radius", "", INT_MIN, INT_MAX);
- RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
-}
-
-/********************** select all operator *********************/
-
-static int select_all_exec(bContext *C, wmOperator *op)
-{
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip(sc);
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *track = NULL; /* selected track */
- MovieTrackingMarker *marker;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- int action = RNA_enum_get(op->ptr, "action");
- int framenr = ED_space_clip_clip_framenr(sc);
- int has_selection = FALSE;
-
- if (action == SEL_TOGGLE) {
- action = SEL_SELECT;
- track = tracksbase->first;
- while (track) {
- if (TRACK_VIEW_SELECTED(sc, track)) {
- marker = BKE_tracking_get_marker(track, framenr);
-
- if (MARKER_VISIBLE(sc, track, marker)) {
- action = SEL_DESELECT;
- break;
- }
- }
-
- track = track->next;
- }
- }
-
- track = tracksbase->first;
- while (track) {
- if ((track->flag & TRACK_HIDDEN) == 0) {
- marker = BKE_tracking_get_marker(track, framenr);
-
- if (MARKER_VISIBLE(sc, track, marker)) {
- switch (action) {
- case SEL_SELECT:
- track->flag |= SELECT;
- track->pat_flag |= SELECT;
- track->search_flag |= SELECT;
- break;
- case SEL_DESELECT:
- track->flag &= ~SELECT;
- track->pat_flag &= ~SELECT;
- track->search_flag &= ~SELECT;
- break;
- case SEL_INVERT:
- track->flag ^= SELECT;
- track->pat_flag ^= SELECT;
- track->search_flag ^= SELECT;
- break;
- }
- }
- }
-
- if (TRACK_VIEW_SELECTED(sc, track))
- has_selection = TRUE;
-
- track = track->next;
- }
-
- if (!has_selection)
- sc->flag &= ~SC_LOCK_SELECTION;
-
- BKE_tracking_dopesheet_tag_update(tracking);
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-void CLIP_OT_select_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "(De)select All";
- ot->description = "Change selection of all tracking markers";
- ot->idname = "CLIP_OT_select_all";
-
- /* api callbacks */
- ot->exec = select_all_exec;
- ot->poll = ED_space_clip_tracking_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- WM_operator_properties_select_all(ot);
-}
-
-/********************** select grouped operator *********************/
-
-static int select_groped_exec(bContext *C, wmOperator *op)
-{
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip(sc);
- MovieTrackingTrack *track;
- MovieTrackingMarker *marker;
- MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- int group = RNA_enum_get(op->ptr, "group");
- int framenr = ED_space_clip_clip_framenr(sc);
-
- track = tracksbase->first;
- while (track) {
- int ok = FALSE;
-
- marker = BKE_tracking_get_marker(track, framenr);
-
- if (group == 0) { /* Keyframed */
- ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED) == 0;
- }
- else if (group == 1) { /* Estimated */
- ok = marker->framenr != framenr;
- }
- else if (group == 2) { /* tracked */
- ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED);
- }
- else if (group == 3) { /* locked */
- ok = track->flag & TRACK_LOCKED;
- }
- else if (group == 4) { /* disabled */
- ok = marker->flag & MARKER_DISABLED;
- }
- else if (group == 5) { /* color */
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
-
- if (act_track) {
- ok = (track->flag & TRACK_CUSTOMCOLOR) == (act_track->flag & TRACK_CUSTOMCOLOR);
-
- if (ok && track->flag & TRACK_CUSTOMCOLOR)
- ok = equals_v3v3(track->color, act_track->color);
- }
- }
- else if (group == 6) { /* failed */
- ok = (track->flag & TRACK_HAS_BUNDLE) == 0;
- }
-
- if (ok) {
- track->flag |= SELECT;
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
- track->pat_flag |= SELECT;
- if (sc->flag & SC_SHOW_MARKER_SEARCH)
- track->search_flag |= SELECT;
- }
-
- track = track->next;
- }
-
- BKE_tracking_dopesheet_tag_update(tracking);
-
- WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
-
- return OPERATOR_FINISHED;
-}
-
-void CLIP_OT_select_grouped(wmOperatorType *ot)
-{
- static EnumPropertyItem select_group_items[] = {
- {0, "KEYFRAMED", 0, "Keyframed tracks", "Select all keyframed tracks"},
- {1, "ESTIMATED", 0, "Estimated tracks", "Select all estimated tracks"},
- {2, "TRACKED", 0, "Tracked tracks", "Select all tracked tracks"},
- {3, "LOCKED", 0, "Locked tracks", "Select all locked tracks"},
- {4, "DISABLED", 0, "Disabled tracks", "Select all disabled tracks"},
- {5, "COLOR", 0, "Tracks with same color", "Select all tracks with same color as active track"},
- {6, "FAILED", 0, "Failed Tracks", "Select all tracks which failed to be reconstructed"},
- {0, NULL, 0, NULL, NULL}
- };
-
- /* identifiers */
- ot->name = "Select Grouped";
- ot->description = "Select all tracks from specified group";
- ot->idname = "CLIP_OT_select_grouped";
-
- /* api callbacks */
- ot->exec = select_groped_exec;
- ot->poll = ED_space_clip_tracking_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* proeprties */
- RNA_def_enum(ot->srna, "group", select_group_items, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute");
+ "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX);
}
/********************** track operator *********************/
typedef struct TrackMarkersJob {
- struct MovieTrackingContext *context; /* tracking context */
- int sfra, efra, lastfra; /* Start, end and recently tracked frames */
- int backwards; /* Backwards tracking flag */
- MovieClip *clip; /* Clip which is tracking */
- float delay; /* Delay in milliseconds to allow tracking at fixed FPS */
+ struct MovieTrackingContext *context; /* tracking context */
+ int sfra, efra, lastfra; /* Start, end and recently tracked frames */
+ int backwards; /* Backwards tracking flag */
+ MovieClip *clip; /* Clip which is tracking */
+ float delay; /* Delay in milliseconds to allow tracking at fixed FPS */
struct Main *main;
struct Scene *scene;
@@ -1525,14 +944,14 @@ static int track_markers_testbreak(void)
static int track_count_markers(SpaceClip *sc, MovieClip *clip)
{
int tot = 0;
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
int framenr = ED_space_clip_clip_framenr(sc);
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (!marker || (marker->flag & MARKER_DISABLED) == 0)
tot++;
@@ -1546,7 +965,7 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip)
static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip)
{
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
int hidden = 0;
if ((sc->flag & SC_SHOW_MARKER_PATTERN) == 0)
@@ -1560,7 +979,7 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip)
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0)
- BKE_tracking_track_flag(track, hidden, SELECT, 1);
+ BKE_tracking_track_flag_clear(track, hidden, SELECT);
track = track->next;
}
@@ -1569,7 +988,7 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip)
static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit_r)
{
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
int framenr = ED_space_clip_clip_framenr(sc);
int frames_limit = 0;
@@ -1580,7 +999,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit
while (track) {
if (TRACK_VIEW_SELECTED(sc, track)) {
if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) {
- BKE_tracking_ensure_marker(track, framenr);
+ BKE_tracking_marker_ensure(track, framenr);
if (track->frames_limit) {
if (frames_limit == 0)
@@ -1685,15 +1104,15 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo
double start_time = PIL_check_seconds_timer(), exec_time;
- if (!BKE_tracking_next(tmj->context))
+ if (!BKE_tracking_context_step(tmj->context))
break;
exec_time = PIL_check_seconds_timer() - start_time;
if (tmj->delay > (float)exec_time)
PIL_sleep_ms(tmj->delay - (float)exec_time);
}
- else if (!BKE_tracking_next(tmj->context))
- break;
+ else if (!BKE_tracking_context_step(tmj->context))
+ break;
*do_update = TRUE;
*progress = (float)(framenr - tmj->sfra) / (tmj->efra - tmj->sfra);
@@ -1716,7 +1135,7 @@ static void track_markers_updatejob(void *tmv)
{
TrackMarkersJob *tmj = (TrackMarkersJob *)tmv;
- BKE_tracking_sync(tmj->context);
+ BKE_tracking_context_sync(tmj->context);
}
static void track_markers_freejob(void *tmv)
@@ -1727,7 +1146,7 @@ static void track_markers_freejob(void *tmv)
tmj->scene->r.cfra = BKE_movieclip_remap_clip_to_scene_frame(tmj->clip, tmj->lastfra);
ED_update_for_newframe(tmj->main, tmj->scene, 0);
- BKE_tracking_sync(tmj->context);
+ BKE_tracking_context_sync(tmj->context);
BKE_tracking_context_free(tmj->context);
MEM_freeN(tmj);
@@ -1774,7 +1193,7 @@ static int track_markers_exec(bContext *C, wmOperator *op)
context = BKE_tracking_context_new(clip, &sc->user, backwards, sequence);
while (framenr != efra) {
- if (!BKE_tracking_next(context))
+ if (!BKE_tracking_context_step(context))
break;
if (backwards) framenr--;
@@ -1784,7 +1203,7 @@ static int track_markers_exec(bContext *C, wmOperator *op)
break;
}
- BKE_tracking_sync(context);
+ BKE_tracking_context_sync(context);
BKE_tracking_context_free(context);
/* update scene current frame to the lastes tracked frame */
@@ -1911,10 +1330,10 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
Scene *scene = CTX_data_scene(C);
MovieTracking *tracking = &clip->tracking;
MovieTrackingSettings *settings = &clip->tracking.settings;
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
int width, height;
- if (!BKE_tracking_can_reconstruct(tracking, object, error_msg, max_error))
+ if (!BKE_tracking_reconstruction_check(tracking, object, error_msg, max_error))
return 0;
/* could fail if footage uses images with different sizes */
@@ -1926,7 +1345,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
scj->user = sc->user;
scj->context = BKE_tracking_reconstruction_context_new(tracking, object,
- settings->keyframe1, settings->keyframe2, width, height);
+ settings->keyframe1, settings->keyframe2, width, height);
tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats");
@@ -1945,8 +1364,8 @@ static void solve_camera_startjob(void *scv, short *stop, short *do_update, floa
{
SolveCameraJob *scj = (SolveCameraJob *)scv;
- BKE_tracking_solve_reconstruction(scj->context, stop, do_update, progress,
- scj->stats_message, sizeof(scj->stats_message));
+ BKE_tracking_reconstruction_solve(scj->context, stop, do_update, progress,
+ scj->stats_message, sizeof(scj->stats_message));
}
static void solve_camera_freejob(void *scv)
@@ -1963,7 +1382,7 @@ static void solve_camera_freejob(void *scv)
return;
}
- solved = BKE_tracking_finish_reconstruction(scj->context, tracking);
+ solved = BKE_tracking_reconstruction_finish(scj->context, tracking);
if (!solved)
BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct, see console for details");
@@ -1979,7 +1398,7 @@ static void solve_camera_freejob(void *scv)
/* set blender camera focal length so result would look fine there */
if (scene->camera) {
- Camera *camera = (Camera*)scene->camera->data;
+ Camera *camera = (Camera *)scene->camera->data;
int width, height;
BKE_movieclip_get_size(clip, &scj->user, &width, &height);
@@ -2033,7 +1452,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(tracking);
+ MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
wmJob *steve;
char error_msg[256] = "\0";
@@ -2115,8 +1534,8 @@ static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
- MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
+ MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
MovieTrackingTrack *track = tracksbase->first;
while (track) {
@@ -2163,20 +1582,20 @@ static int clear_track_path_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTrackingTrack *track;
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
int action = RNA_enum_get(op->ptr, "action");
int clear_active = RNA_boolean_get(op->ptr, "clear_active");
int framenr = ED_space_clip_clip_framenr(sc);
if (clear_active) {
- track = BKE_tracking_active_track(&clip->tracking);
- BKE_tracking_clear_path(track, framenr, action);
+ track = BKE_tracking_track_get_active(&clip->tracking);
+ BKE_tracking_track_path_clear(track, framenr, action);
}
else {
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track))
- BKE_tracking_clear_path(track, framenr, action);
+ BKE_tracking_track_path_clear(track, framenr, action);
track = track->next;
}
@@ -2190,10 +1609,10 @@ static int clear_track_path_exec(bContext *C, wmOperator *op)
void CLIP_OT_clear_track_path(wmOperatorType *ot)
{
static EnumPropertyItem clear_path_actions[] = {
- {TRACK_CLEAR_UPTO, "UPTO", 0, "Clear up-to", "Clear path up to current frame"},
- {TRACK_CLEAR_REMAINED, "REMAINED", 0, "Clear remained", "Clear path at remaining frames (after current)"},
- {TRACK_CLEAR_ALL, "ALL", 0, "Clear all", "Clear the whole path"},
- {0, NULL, 0, NULL, NULL}
+ {TRACK_CLEAR_UPTO, "UPTO", 0, "Clear up-to", "Clear path up to current frame"},
+ {TRACK_CLEAR_REMAINED, "REMAINED", 0, "Clear remained", "Clear path at remaining frames (after current)"},
+ {TRACK_CLEAR_ALL, "ALL", 0, "Clear all", "Clear the whole path"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -2220,14 +1639,14 @@ static int disable_markers_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track = tracksbase->first;
int action = RNA_enum_get(op->ptr, "action");
int framenr = ED_space_clip_clip_framenr(sc);
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
if (action == 0)
marker->flag |= MARKER_DISABLED;
@@ -2249,10 +1668,10 @@ static int disable_markers_exec(bContext *C, wmOperator *op)
void CLIP_OT_disable_markers(wmOperatorType *ot)
{
static EnumPropertyItem actions_items[] = {
- {0, "DISABLE", 0, "Disable", "Disable selected markers"},
- {1, "ENABLE", 0, "Enable", "Enable selected markers"},
- {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
- {0, NULL, 0, NULL, NULL}
+ {0, "DISABLE", 0, "Disable", "Disable selected markers"},
+ {1, "ENABLE", 0, "Enable", "Enable selected markers"},
+ {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -2302,7 +1721,7 @@ static Object *get_orientation_object(bContext *C)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
Object *object = NULL;
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
@@ -2328,7 +1747,7 @@ static int set_orientation_poll(bContext *C)
if (clip) {
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
return TRUE;
@@ -2346,7 +1765,7 @@ static int count_selected_bundles(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
int tot = 0;
@@ -2428,7 +1847,8 @@ static int set_origin_exec(bContext *C, wmOperator *op)
int selected_count = count_selected_bundles(C);
if (selected_count == 0) {
- BKE_report(op->reports, RPT_ERROR, "At least one track with bundle should be selected to define origin position");
+ BKE_report(op->reports, RPT_ERROR,
+ "At least one track with bundle should be selected to define origin position");
return OPERATOR_CANCELLED;
}
@@ -2440,9 +1860,9 @@ static int set_origin_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- tracking_object = BKE_tracking_active_object(tracking);
+ tracking_object = BKE_tracking_object_get_active(tracking);
- tracksbase = BKE_tracking_object_tracks(tracking, tracking_object);
+ tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
track = tracksbase->first;
zero_v3(median);
@@ -2455,7 +1875,7 @@ static int set_origin_exec(bContext *C, wmOperator *op)
}
mul_v3_fl(median, 1.0f / selected_count);
- BKE_get_tracking_mat(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(scene, camera, mat);
mul_v3_m4v3(vec, mat, median);
@@ -2498,16 +1918,16 @@ void CLIP_OT_set_origin(wmOperatorType *ot)
/********************** set floor operator *********************/
static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingObject *tracking_object,
- MovieTrackingTrack *track, char axis)
+ MovieTrackingTrack *track, char axis)
{
Object *camera = get_camera_with_movieclip(scene, clip);
int is_camera = tracking_object->flag & TRACKING_OBJECT_CAMERA;
- int flip = FALSE;
+ int flip = FALSE;
float mat[4][4], vec[3], obmat[4][4], dvec[3];
BKE_object_to_mat4(ob, obmat);
- BKE_get_tracking_mat(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(scene, camera, mat);
mul_v3_m4v3(vec, mat, track->bundle_pos);
copy_v3_v3(dvec, vec);
@@ -2625,7 +2045,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
float rot[4][4] = {{0.0f, 0.0f, -1.0f, 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{1.0f, 0.0f, 0.0f, 0.0f},
- {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */
+ {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */
if (count_selected_bundles(C) != 3) {
BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor");
@@ -2633,9 +2053,9 @@ static int set_plane_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- tracking_object = BKE_tracking_active_object(tracking);
- tracksbase = BKE_tracking_object_tracks(tracking, tracking_object);
- act_track = BKE_tracking_active_track(tracking);
+ tracking_object = BKE_tracking_object_get_active(tracking);
+ tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
+ act_track = BKE_tracking_track_get_active(tracking);
object = get_orientation_object(C);
if (!object) {
@@ -2644,7 +2064,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_get_tracking_mat(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(scene, camera, mat);
/* get 3 bundles to use as reference */
track = tracksbase->first;
@@ -2723,9 +2143,9 @@ static int set_plane_exec(bContext *C, wmOperator *op)
void CLIP_OT_set_plane(wmOperatorType *ot)
{
static EnumPropertyItem plane_items[] = {
- {0, "FLOOR", 0, "Floor", "Set floor plane"},
- {1, "WALL", 0, "Wall", "Set wall plane"},
- {0, NULL, 0, NULL, NULL}
+ {0, "FLOOR", 0, "Floor", "Set floor plane"},
+ {1, "WALL", 0, "Wall", "Set wall plane"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -2751,7 +2171,7 @@ static int set_axis_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
MovieTrackingTrack *track;
Scene *scene = CTX_data_scene(C);
Object *object;
@@ -2771,7 +2191,7 @@ static int set_axis_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- tracksbase = BKE_tracking_object_tracks(tracking, tracking_object);
+ tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
track = tracksbase->first;
while (track) {
@@ -2795,9 +2215,9 @@ static int set_axis_exec(bContext *C, wmOperator *op)
void CLIP_OT_set_axis(wmOperatorType *ot)
{
static EnumPropertyItem axis_actions[] = {
- {0, "X", 0, "X", "Align bundle align X axis"},
- {1, "Y", 0, "Y", "Align bundle align Y axis"},
- {0, NULL, 0, NULL, NULL}
+ {0, "X", 0, "X", "Align bundle align X axis"},
+ {1, "Y", 0, "Y", "Align bundle align Y axis"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -2823,12 +2243,12 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
MovieTrackingTrack *track;
Scene *scene = CTX_data_scene(C);
Object *object = NULL;
Object *camera = get_camera_with_movieclip(scene, clip);
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
int tot = 0;
float vec[2][3], mat[4][4], scale;
float dist = RNA_float_get(op->ptr, "distance");
@@ -2846,7 +2266,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution)
return OPERATOR_CANCELLED;
}
- BKE_get_tracking_mat(scene, camera, mat);
+ BKE_tracking_get_camera_object_matrix(scene, camera, mat);
track = tracksbase->first;
while (track) {
@@ -2927,7 +2347,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot)
/* properties */
RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX,
- "Distance", "Distance between selected tracks", -100.0f, 100.0f);
+ "Distance", "Distance between selected tracks", -100.0f, 100.0f);
}
/********************** set solution scale operator *********************/
@@ -2941,7 +2361,7 @@ static int set_solution_scale_poll(bContext *C)
if (clip) {
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
return (tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0;
}
@@ -2983,7 +2403,7 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot)
/* properties */
RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX,
- "Distance", "Distance between selected tracks", -100.0f, 100.0f);
+ "Distance", "Distance between selected tracks", -100.0f, 100.0f);
}
/********************** set principal center operator *********************/
@@ -3030,8 +2450,8 @@ static int hide_tracks_exec(bContext *C, wmOperator *op)
MovieClip *clip = ED_space_clip(sc);
MovieTrackingTrack *track;
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
int unselected;
unselected = RNA_boolean_get(op->ptr, "unselected");
@@ -3088,7 +2508,7 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
track = tracksbase->first;
@@ -3147,7 +2567,7 @@ static int detect_features_exec(bContext *C, wmOperator *op)
int clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS;
ImBuf *ibuf = BKE_movieclip_get_ibuf_flag(clip, &sc->user, clip_flag, MOVIECLIP_CACHE_SKIP);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track = tracksbase->first;
int placement = RNA_enum_get(op->ptr, "placement");
int margin = RNA_int_get(op->ptr, "margin");
@@ -3177,7 +2597,7 @@ static int detect_features_exec(bContext *C, wmOperator *op)
}
BKE_tracking_detect_fast(tracking, tracksbase, ibuf, framenr, margin,
- min_trackability, min_distance, layer, place_outside_layer);
+ min_trackability, min_distance, layer, place_outside_layer);
IMB_freeImBuf(ibuf);
@@ -3189,10 +2609,10 @@ static int detect_features_exec(bContext *C, wmOperator *op)
void CLIP_OT_detect_features(wmOperatorType *ot)
{
static EnumPropertyItem placement_items[] = {
- {0, "FRAME", 0, "Whole Frame", "Place markers across the whole frame"},
- {1, "INSIDE_GPENCIL", 0, "Inside grease pencil", "Place markers only inside areas outlined with grease pencil"},
- {2, "OUTSIDE_GPENCIL", 0, "Outside grease pencil", "Place markers only outside areas outlined with grease pencil"},
- {0, NULL, 0, NULL, NULL}
+ {0, "FRAME", 0, "Whole Frame", "Place markers across the whole frame"},
+ {1, "INSIDE_GPENCIL", 0, "Inside grease pencil", "Place markers only inside areas outlined with grease pencil"},
+ {2, "OUTSIDE_GPENCIL", 0, "Outside grease pencil", "Place markers only outside areas outlined with grease pencil"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -3225,8 +2645,8 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
int pos = RNA_enum_get(op->ptr, "position");
int delta;
- if (pos <= 1) { /* jump to path */
- track = BKE_tracking_active_track(&clip->tracking);
+ if (pos <= 1) { /* jump to path */
+ track = BKE_tracking_track_get_active(&clip->tracking);
if (!track)
return OPERATOR_CANCELLED;
@@ -3235,7 +2655,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
while (sc->user.framenr + delta >= SFRA && sc->user.framenr + delta <= EFRA) {
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr + delta);
- MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
if (!marker || marker->flag & MARKER_DISABLED)
break;
@@ -3243,11 +2663,11 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
sc->user.framenr += delta;
}
}
- else { /* to to failed frame */
+ else { /* to to failed frame */
if (clip->tracking.reconstruction.flag & TRACKING_RECONSTRUCTED) {
int a = ED_space_clip_clip_framenr(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
delta = pos == 3 ? 1 : -1;
@@ -3256,7 +2676,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
while (a + delta >= SFRA && a + delta <= EFRA) {
MovieReconstructedCamera *cam;
- cam = BKE_tracking_get_reconstructed_camera(tracking, object, a);
+ cam = BKE_tracking_camera_get_reconstructed(tracking, object, a);
if (!cam) {
sc->user.framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, a);
@@ -3284,11 +2704,11 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
void CLIP_OT_frame_jump(wmOperatorType *ot)
{
static EnumPropertyItem position_items[] = {
- {0, "PATHSTART", 0, "Path Start", "Jump to start of current path"},
- {1, "PATHEND", 0, "Path End", "Jump to end of current path"},
- {2, "FAILEDPREV", 0, "Previous Failed", "Jump to previous failed frame"},
- {2, "FAILNEXT", 0, "Next Failed", "Jump to next failed frame"},
- {0, NULL, 0, NULL, NULL}
+ {0, "PATHSTART", 0, "Path Start", "Jump to start of current path"},
+ {1, "PATHEND", 0, "Path End", "Jump to end of current path"},
+ {2, "FAILEDPREV", 0, "Previous Failed", "Jump to previous failed frame"},
+ {2, "FAILNEXT", 0, "Next Failed", "Jump to next failed frame"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -3314,10 +2734,10 @@ static int join_tracks_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *act_track, *track, *next;
- act_track = BKE_tracking_active_track(tracking);
+ act_track = BKE_tracking_track_get_active(tracking);
if (!act_track) {
BKE_report(op->reports, RPT_ERROR, "No active track to join to");
@@ -3329,12 +2749,12 @@ static int join_tracks_exec(bContext *C, wmOperator *op)
next = track->next;
if (TRACK_VIEW_SELECTED(sc, track) && track != act_track) {
- BKE_tracking_join_tracks(act_track, track);
+ BKE_tracking_tracks_join(act_track, track);
if (tracking->stabilization.rot_track == track)
tracking->stabilization.rot_track = act_track;
- BKE_tracking_free_track(track);
+ BKE_tracking_track_free(track);
BLI_freelinkN(tracksbase, track);
}
@@ -3368,7 +2788,7 @@ static int lock_tracks_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track = tracksbase->first;
int action = RNA_enum_get(op->ptr, "action");
@@ -3392,10 +2812,10 @@ static int lock_tracks_exec(bContext *C, wmOperator *op)
void CLIP_OT_lock_tracks(wmOperatorType *ot)
{
static EnumPropertyItem actions_items[] = {
- {0, "LOCK", 0, "Lock", "Lock selected tracks"},
- {1, "UNLOCK", 0, "Unlock", "Unlock selected tracks"},
- {2, "TOGGLE", 0, "Toggle", "Toggle locked flag for selected tracks"},
- {0, NULL, 0, NULL, NULL}
+ {0, "LOCK", 0, "Lock", "Lock selected tracks"},
+ {1, "UNLOCK", 0, "Unlock", "Unlock selected tracks"},
+ {2, "TOGGLE", 0, "Toggle", "Toggle locked flag for selected tracks"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -3421,8 +2841,8 @@ static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- MovieTrackingTrack *track, *act_track = BKE_tracking_active_track(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *track, *act_track = BKE_tracking_track_get_active(tracking);
if (!act_track)
return OPERATOR_CANCELLED;
@@ -3468,7 +2888,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
MovieTrackingStabilization *stab = &tracking->stabilization;
int update = 0;
@@ -3518,7 +2938,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op))
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingStabilization *stab = &tracking->stabilization;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
int a = 0, update = 0;
@@ -3577,14 +2997,14 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
MovieTrackingTrack *track;
int update = 0;
track = tracksbase->first;
while (track) {
if (track->flag & TRACK_USE_2D_STAB) {
- BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0);
+ BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
update = 1;
}
@@ -3620,7 +3040,7 @@ static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
if (act_track) {
MovieTrackingStabilization *stab = &tracking->stabilization;
@@ -3660,7 +3080,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del)
int markersnr = track->markersnr;
if (del)
- new_markers = MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers");
+ new_markers = MEM_callocN(markersnr * sizeof(MovieTrackingMarker), "track cleaned markers");
for (a = 0; a < markersnr; a++) {
int end = 0;
@@ -3750,8 +3170,8 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
- MovieTrackingTrack *track, *next, *act_track = BKE_tracking_active_track(tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *track, *next, *act_track = BKE_tracking_track_get_active(tracking);
int frames = RNA_int_get(op->ptr, "frames");
int action = RNA_enum_get(op->ptr, "action");
float error = RNA_float_get(op->ptr, "error");
@@ -3767,17 +3187,17 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
int ok = 1;
ok = (is_track_clean(track, frames, action == TRACKING_CLEAN_DELETE_SEGMENT)) &&
- (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE) == 0 || track->error < error);
+ (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE) == 0 || track->error < error);
if (!ok) {
if (action == TRACKING_CLEAN_SELECT) {
- BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0);
+ BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
}
else if (action == TRACKING_CLEAN_DELETE_TRACK) {
if (track == act_track)
clip->tracking.act_track = NULL;
- BKE_tracking_free_track(track);
+ BKE_tracking_track_free(track);
BLI_freelinkN(tracksbase, track);
track = NULL;
}
@@ -3787,7 +3207,7 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
if (track == act_track)
clip->tracking.act_track = NULL;
- BKE_tracking_free_track(track);
+ BKE_tracking_track_free(track);
BLI_freelinkN(tracksbase, track);
}
}
@@ -3821,10 +3241,10 @@ static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
void CLIP_OT_clean_tracks(wmOperatorType *ot)
{
static EnumPropertyItem actions_items[] = {
- {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"},
- {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete unclean tracks"},
- {TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete unclean segments of tracks"},
- {0, NULL, 0, NULL, NULL}
+ {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"},
+ {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete unclean tracks"},
+ {TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete unclean segments of tracks"},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -3856,7 +3276,7 @@ static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op))
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- BKE_tracking_new_object(tracking, "Object");
+ BKE_tracking_object_add(tracking, "Object");
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
@@ -3887,14 +3307,14 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op)
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *object;
- object = BKE_tracking_active_object(tracking);
+ object = BKE_tracking_object_get_active(tracking);
if (object->flag & TRACKING_OBJECT_CAMERA) {
BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking can't be deleted");
return OPERATOR_CANCELLED;
}
- BKE_tracking_remove_object(tracking, object);
+ BKE_tracking_object_delete(tracking, object);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
@@ -3923,7 +3343,7 @@ static int copy_tracks_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
clear_invisible_track_selection(sc, clip);
@@ -3963,7 +3383,7 @@ static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
BKE_tracking_clipboard_paste_tracks(tracking, object);
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
new file mode 100644
index 00000000000..640af498c1f
--- /dev/null
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -0,0 +1,783 @@
+/*
+ * ***** 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) 2011 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_clip/tracking_select.c
+ * \ingroup spclip
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_camera_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_movieclip_types.h"
+#include "DNA_object_types.h" /* SELECT */
+#include "DNA_scene_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+#include "BLI_listbase.h"
+#include "BLI_rect.h"
+#include "BLI_lasso.h"
+#include "BLI_blenlib.h"
+
+#include "BKE_main.h"
+#include "BKE_context.h"
+#include "BKE_constraint.h"
+#include "BKE_movieclip.h"
+#include "BKE_tracking.h"
+#include "BKE_global.h"
+#include "BKE_depsgraph.h"
+#include "BKE_object.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+#include "BKE_library.h"
+#include "BKE_sound.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+#include "ED_clip.h"
+#include "ED_keyframing.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "UI_interface.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "PIL_time.h"
+
+#include "UI_view2d.h"
+
+#include "clip_intern.h" // own include
+
+static float dist_to_crns(float co[2], float pos[2], float crns[4][2]);
+
+/********************** mouse select operator *********************/
+
+static int mouse_on_side(float co[2], float x1, float y1, float x2, float y2, float epsx, float epsy)
+{
+ if (x1 > x2)
+
+ SWAP(float, x1, x2);
+
+ if (y1 > y2)
+ SWAP(float, y1, y2);
+
+ return (co[0] >= x1 - epsx && co[0] <= x2 + epsx) && (co[1] >= y1 - epsy && co[1] <= y2 + epsy);
+}
+
+static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2], float epsx, float epsy)
+{
+ return mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + max[0], pos[1] + min[1], epsx, epsy) ||
+ mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + min[0], pos[1] + max[1], epsx, epsy) ||
+ mouse_on_side(co, pos[0] + min[0], pos[1] + max[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy) ||
+ mouse_on_side(co, pos[0] + max[0], pos[1] + min[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy);
+}
+
+static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx, float epsy)
+{
+ float dist = dist_to_crns(co, pos, crns);
+
+ return dist < MAX2(epsx, epsy);
+}
+
+static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track)
+{
+ int framenr = ED_space_clip_clip_framenr(sc);
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+ float pat_min[2], pat_max[2];
+ float epsx, epsy;
+ int width, height;
+
+ ED_space_clip_size(sc, &width, &height);
+
+ BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
+
+ epsx = MIN4(pat_min[0] - marker->search_min[0], marker->search_max[0] - pat_max[0],
+ fabsf(pat_min[0]), fabsf(pat_max[0])) / 2;
+ epsy = MIN4(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1],
+ fabsf(pat_min[1]), fabsf(pat_max[1])) / 2;
+
+ epsx = MAX2(epsx, 2.0f / width);
+ epsy = MAX2(epsy, 2.0f / height);
+
+ if (sc->flag & SC_SHOW_MARKER_SEARCH) {
+ if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy))
+ return TRACK_AREA_SEARCH;
+ }
+
+ if ((marker->flag & MARKER_DISABLED) == 0) {
+ if (sc->flag & SC_SHOW_MARKER_PATTERN)
+ if (mouse_on_crns(co, marker->pos, marker->pattern_corners, epsx, epsy))
+ return TRACK_AREA_PAT;
+
+ epsx = 12.0f / width;
+ epsy = 12.0f / height;
+
+ if (fabsf(co[0] - marker->pos[0] - track->offset[0]) < epsx &&
+ fabsf(co[1] - marker->pos[1] - track->offset[1]) <= epsy)
+ {
+ return TRACK_AREA_POINT;
+ }
+ }
+
+ return TRACK_AREA_NONE;
+}
+
+static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2])
+{
+ float d1, d2, d3, d4;
+ float p[2] = {co[0] - pos[0], co[1] - pos[1]};
+ float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]};
+ float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]};
+
+ d1 = dist_to_line_segment_v2(p, v1, v2);
+ d2 = dist_to_line_segment_v2(p, v2, v3);
+ d3 = dist_to_line_segment_v2(p, v3, v4);
+ d4 = dist_to_line_segment_v2(p, v4, v1);
+
+ return MIN4(d1, d2, d3, d4);
+}
+
+static float dist_to_crns(float co[2], float pos[2], float crns[4][2])
+{
+ float d1, d2, d3, d4;
+ float p[2] = {co[0] - pos[0], co[1] - pos[1]};
+ float *v1 = crns[0], *v2 = crns[1];
+ float *v3 = crns[2], *v4 = crns[3];
+
+ d1 = dist_to_line_segment_v2(p, v1, v2);
+ d2 = dist_to_line_segment_v2(p, v2, v3);
+ d3 = dist_to_line_segment_v2(p, v3, v4);
+ d4 = dist_to_line_segment_v2(p, v4, v1);
+
+ return MIN4(d1, d2, d3, d4);
+}
+
+static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbase, float co[2])
+{
+ MovieTrackingTrack *track = NULL, *cur;
+ float mindist = 0.0f;
+ int framenr = ED_space_clip_clip_framenr(sc);
+
+ cur = tracksbase->first;
+ while (cur) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(cur, framenr);
+
+ if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, cur, marker)) {
+ float dist, d1, d2 = FLT_MAX, d3 = FLT_MAX;
+
+ /* distance to marker point */
+ d1 = sqrtf((co[0] - marker->pos[0] - cur->offset[0]) * (co[0] - marker->pos[0] - cur->offset[0]) +
+ (co[1] - marker->pos[1] - cur->offset[1]) * (co[1] - marker->pos[1] - cur->offset[1]));
+
+ /* distance to pattern boundbox */
+ if (sc->flag & SC_SHOW_MARKER_PATTERN)
+ d2 = dist_to_crns(co, marker->pos, marker->pattern_corners);
+
+ /* distance to search boundbox */
+ if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur))
+ d3 = dist_to_rect(co, marker->pos, marker->search_min, marker->search_max);
+
+ /* choose minimal distance. useful for cases of overlapped markers. */
+ dist = MIN3(d1, d2, d3);
+
+ if (track == NULL || dist < mindist) {
+ track = cur;
+ mindist = dist;
+ }
+ }
+
+ cur = cur->next;
+ }
+
+ return track;
+}
+
+static int mouse_select(bContext *C, float co[2], int extend)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip(sc);
+ MovieTracking *tracking = &clip->tracking;
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
+ MovieTrackingTrack *track = NULL; /* selected marker */
+
+ track = find_nearest_track(sc, tracksbase, co);
+
+ if (track) {
+ int area = track_mouse_area(sc, co, track);
+
+ if (!extend || !TRACK_VIEW_SELECTED(sc, track))
+ area = TRACK_AREA_ALL;
+
+ if (extend && TRACK_AREA_SELECTED(track, area)) {
+ if (track == act_track)
+ BKE_tracking_track_deselect(track, area);
+ else
+ clip->tracking.act_track = track;
+ }
+ else {
+ if (area == TRACK_AREA_POINT)
+ area = TRACK_AREA_ALL;
+
+ BKE_tracking_track_select(tracksbase, track, area, extend);
+ clip->tracking.act_track = track;
+ }
+ }
+
+ if (!extend) {
+ sc->xlockof = 0.0f;
+ sc->ylockof = 0.0f;
+ }
+
+ BKE_tracking_dopesheet_tag_update(tracking);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static int select_exec(bContext *C, wmOperator *op)
+{
+ float co[2];
+ int extend;
+
+ RNA_float_get_array(op->ptr, "location", co);
+ extend = RNA_boolean_get(op->ptr, "extend");
+
+ return mouse_select(C, co, extend);
+}
+
+static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ float co[2];
+ int extend = RNA_boolean_get(op->ptr, "extend");
+
+ if (!extend) {
+ MovieTrackingTrack *track = tracking_marker_check_slide(C, event, NULL, NULL, NULL);
+
+ if (track) {
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip(sc);
+
+ clip->tracking.act_track = track;
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+
+ return OPERATOR_PASS_THROUGH;
+ }
+ }
+
+ ED_clip_mouse_pos(C, event, co);
+ RNA_float_set_array(op->ptr, "location", co);
+
+ return select_exec(C, op);
+}
+
+void CLIP_OT_select(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select";
+ ot->description = "Select tracking markers";
+ ot->idname = "CLIP_OT_select";
+
+ /* api callbacks */
+ ot->exec = select_exec;
+ ot->invoke = select_invoke;
+ //ot->poll = ED_space_clip_tracking_poll; // so mask view can Ctrl+RMB markers
+ ot->poll = ED_space_clip_view_clip_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", 0,
+ "Extend", "Extend selection rather than clearing the existing selection");
+ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
+ "Location", "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds", -100.0f, 100.0f);
+}
+
+/********************** border select operator *********************/
+
+static int border_select_exec(bContext *C, wmOperator *op)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip(sc);
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingTrack *track;
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ rcti rect;
+ rctf rectf;
+ int change = FALSE, mode, extend;
+ int framenr = ED_space_clip_clip_framenr(sc);
+
+ /* get rectangle from operator */
+ rect.xmin = RNA_int_get(op->ptr, "xmin");
+ rect.ymin = RNA_int_get(op->ptr, "ymin");
+ rect.xmax = RNA_int_get(op->ptr, "xmax");
+ rect.ymax = RNA_int_get(op->ptr, "ymax");
+
+ ED_clip_point_stable_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
+ ED_clip_point_stable_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+
+ mode = RNA_int_get(op->ptr, "gesture_mode");
+ extend = RNA_boolean_get(op->ptr, "extend");
+
+ /* do actual selection */
+ track = tracksbase->first;
+ while (track) {
+ if ((track->flag & TRACK_HIDDEN) == 0) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+
+ if (MARKER_VISIBLE(sc, track, marker)) {
+ if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) {
+ if (mode == GESTURE_MODAL_SELECT)
+ BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
+ else
+ BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
+ }
+ else if (!extend) {
+ BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
+ }
+
+ change = TRUE;
+ }
+ }
+
+ track = track->next;
+ }
+
+ if (change) {
+ BKE_tracking_dopesheet_tag_update(tracking);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+void CLIP_OT_select_border(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Border Select";
+ ot->description = "Select markers using border selection";
+ ot->idname = "CLIP_OT_select_border";
+
+ /* api callbacks */
+ ot->invoke = WM_border_select_invoke;
+ ot->exec = border_select_exec;
+ ot->modal = WM_border_select_modal;
+ ot->poll = ED_space_clip_tracking_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+
+ /* properties */
+ WM_operator_properties_gesture_border(ot, TRUE);
+}
+
+/********************** lasso select operator *********************/
+
+static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select)
+{
+ ARegion *ar = CTX_wm_region(C);
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip(sc);
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingTrack *track;
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ rcti rect;
+ int change = FALSE;
+ int framenr = ED_space_clip_clip_framenr(sc);
+
+ /* get rectangle from operator */
+ BLI_lasso_boundbox(&rect, mcords, moves);
+
+ /* do actual selection */
+ track = tracksbase->first;
+ while (track) {
+ if ((track->flag & TRACK_HIDDEN) == 0) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+
+ if (MARKER_VISIBLE(sc, track, marker)) {
+ float screen_co[2];
+
+ /* marker in screen coords */
+ ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co);
+
+ if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) &&
+ BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED))
+ {
+ if (select)
+ BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
+ else
+ BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
+ }
+
+ change = TRUE;
+ }
+ }
+
+ track = track->next;
+ }
+
+ if (change) {
+ BKE_tracking_dopesheet_tag_update(tracking);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
+
+ return change;
+}
+
+static int clip_lasso_select_exec(bContext *C, wmOperator *op)
+{
+ int mcords_tot;
+ int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
+
+ if (mcords) {
+ short select;
+
+ select = !RNA_boolean_get(op->ptr, "deselect");
+ do_lasso_select_marker(C, mcords, mcords_tot, select);
+
+ MEM_freeN(mcords);
+
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_PASS_THROUGH;
+}
+
+void CLIP_OT_select_lasso(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Lasso Select";
+ ot->description = "Select markers using lasso selection";
+ ot->idname = "CLIP_OT_select_lasso";
+
+ /* api callbacks */
+ ot->invoke = WM_gesture_lasso_invoke;
+ ot->modal = WM_gesture_lasso_modal;
+ ot->exec = clip_lasso_select_exec;
+ ot->poll = ED_space_clip_tracking_poll;
+ ot->cancel = WM_gesture_lasso_cancel;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
+ RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
+ RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
+}
+
+/********************** circle select operator *********************/
+
+static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], float ellipse[2])
+{
+ /* normalized ellipse: ell[0] = scaleX, ell[1] = scaleY */
+ float x, y;
+
+ x = (marker->pos[0] - offset[0]) * ellipse[0];
+ y = (marker->pos[1] - offset[1]) * ellipse[1];
+
+ return x * x + y * y < 1.0f;
+}
+
+static int circle_select_exec(bContext *C, wmOperator *op)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip(sc);
+ ARegion *ar = CTX_wm_region(C);
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingTrack *track;
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ int x, y, radius, width, height, mode, change = FALSE;
+ float zoomx, zoomy, offset[2], ellipse[2];
+ int framenr = ED_space_clip_clip_framenr(sc);
+
+ /* get operator properties */
+ x = RNA_int_get(op->ptr, "x");
+ y = RNA_int_get(op->ptr, "y");
+ radius = RNA_int_get(op->ptr, "radius");
+
+ mode = RNA_int_get(op->ptr, "gesture_mode");
+
+ /* compute ellipse and position in unified coordinates */
+ ED_space_clip_size(sc, &width, &height);
+ ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
+
+ ellipse[0] = width * zoomx / radius;
+ ellipse[1] = height * zoomy / radius;
+
+ ED_clip_point_stable_pos(C, x, y, &offset[0], &offset[1]);
+
+ /* do selection */
+ track = tracksbase->first;
+ while (track) {
+ if ((track->flag & TRACK_HIDDEN) == 0) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
+
+ if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) {
+ if (mode == GESTURE_MODAL_SELECT)
+ BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
+ else
+ BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
+
+ change = TRUE;
+ }
+ }
+
+ track = track->next;
+ }
+
+ if (change) {
+ BKE_tracking_dopesheet_tag_update(tracking);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+void CLIP_OT_select_circle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Circle Select";
+ ot->description = "Select markers using circle selection";
+ ot->idname = "CLIP_OT_select_circle";
+
+ /* api callbacks */
+ ot->invoke = WM_gesture_circle_invoke;
+ ot->modal = WM_gesture_circle_modal;
+ ot->exec = circle_select_exec;
+ ot->poll = ED_space_clip_tracking_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "radius", 0, INT_MIN, INT_MAX, "Radius", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
+}
+
+/********************** select all operator *********************/
+
+static int select_all_exec(bContext *C, wmOperator *op)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip(sc);
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingTrack *track = NULL; /* selected track */
+ MovieTrackingMarker *marker;
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ int action = RNA_enum_get(op->ptr, "action");
+ int framenr = ED_space_clip_clip_framenr(sc);
+ int has_selection = FALSE;
+
+ if (action == SEL_TOGGLE) {
+ action = SEL_SELECT;
+ track = tracksbase->first;
+ while (track) {
+ if (TRACK_VIEW_SELECTED(sc, track)) {
+ marker = BKE_tracking_marker_get(track, framenr);
+
+ if (MARKER_VISIBLE(sc, track, marker)) {
+ action = SEL_DESELECT;
+ break;
+ }
+ }
+
+ track = track->next;
+ }
+ }
+
+ track = tracksbase->first;
+ while (track) {
+ if ((track->flag & TRACK_HIDDEN) == 0) {
+ marker = BKE_tracking_marker_get(track, framenr);
+
+ if (MARKER_VISIBLE(sc, track, marker)) {
+ switch (action) {
+ case SEL_SELECT:
+ track->flag |= SELECT;
+ track->pat_flag |= SELECT;
+ track->search_flag |= SELECT;
+ break;
+ case SEL_DESELECT:
+ track->flag &= ~SELECT;
+ track->pat_flag &= ~SELECT;
+ track->search_flag &= ~SELECT;
+ break;
+ case SEL_INVERT:
+ track->flag ^= SELECT;
+ track->pat_flag ^= SELECT;
+ track->search_flag ^= SELECT;
+ break;
+ }
+ }
+ }
+
+ if (TRACK_VIEW_SELECTED(sc, track))
+ has_selection = TRUE;
+
+ track = track->next;
+ }
+
+ if (!has_selection)
+ sc->flag &= ~SC_LOCK_SELECTION;
+
+ BKE_tracking_dopesheet_tag_update(tracking);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_select_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "(De)select All";
+ ot->description = "Change selection of all tracking markers";
+ ot->idname = "CLIP_OT_select_all";
+
+ /* api callbacks */
+ ot->exec = select_all_exec;
+ ot->poll = ED_space_clip_tracking_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ WM_operator_properties_select_all(ot);
+}
+
+/********************** select grouped operator *********************/
+
+static int select_groped_exec(bContext *C, wmOperator *op)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip(sc);
+ MovieTrackingTrack *track;
+ MovieTrackingMarker *marker;
+ MovieTracking *tracking = &clip->tracking;
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ int group = RNA_enum_get(op->ptr, "group");
+ int framenr = ED_space_clip_clip_framenr(sc);
+
+ track = tracksbase->first;
+ while (track) {
+ int ok = FALSE;
+
+ marker = BKE_tracking_marker_get(track, framenr);
+
+ if (group == 0) { /* Keyframed */
+ ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED) == 0;
+ }
+ else if (group == 1) { /* Estimated */
+ ok = marker->framenr != framenr;
+ }
+ else if (group == 2) { /* tracked */
+ ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED);
+ }
+ else if (group == 3) { /* locked */
+ ok = track->flag & TRACK_LOCKED;
+ }
+ else if (group == 4) { /* disabled */
+ ok = marker->flag & MARKER_DISABLED;
+ }
+ else if (group == 5) { /* color */
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
+
+ if (act_track) {
+ ok = (track->flag & TRACK_CUSTOMCOLOR) == (act_track->flag & TRACK_CUSTOMCOLOR);
+
+ if (ok && track->flag & TRACK_CUSTOMCOLOR)
+ ok = equals_v3v3(track->color, act_track->color);
+ }
+ }
+ else if (group == 6) { /* failed */
+ ok = (track->flag & TRACK_HAS_BUNDLE) == 0;
+ }
+
+ if (ok) {
+ track->flag |= SELECT;
+ if (sc->flag & SC_SHOW_MARKER_PATTERN)
+ track->pat_flag |= SELECT;
+ if (sc->flag & SC_SHOW_MARKER_SEARCH)
+ track->search_flag |= SELECT;
+ }
+
+ track = track->next;
+ }
+
+ BKE_tracking_dopesheet_tag_update(tracking);
+
+ WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
+
+ return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_select_grouped(wmOperatorType *ot)
+{
+ static EnumPropertyItem select_group_items[] = {
+ {0, "KEYFRAMED", 0, "Keyframed tracks", "Select all keyframed tracks"},
+ {1, "ESTIMATED", 0, "Estimated tracks", "Select all estimated tracks"},
+ {2, "TRACKED", 0, "Tracked tracks", "Select all tracked tracks"},
+ {3, "LOCKED", 0, "Locked tracks", "Select all locked tracks"},
+ {4, "DISABLED", 0, "Disabled tracks", "Select all disabled tracks"},
+ {5, "COLOR", 0, "Tracks with same color", "Select all tracks with same color as active track"},
+ {6, "FAILED", 0, "Failed Tracks", "Select all tracks which failed to be reconstructed"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Select Grouped";
+ ot->description = "Select all tracks from specified group";
+ ot->idname = "CLIP_OT_select_grouped";
+
+ /* api callbacks */
+ ot->exec = select_groped_exec;
+ ot->poll = ED_space_clip_tracking_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* proeprties */
+ RNA_def_enum(ot->srna, "group", select_group_items, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute");
+}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 998ebac1cb9..ac71eb972f6 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -565,7 +565,6 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d)
/* draw in View2D space? */
if (onlyv2d) {
/* draw grease-pencil ('image' strokes) */
- //if (sima->flag & SI_DISPGP)
draw_gpencil_2dimage(C);
}
else {
@@ -573,7 +572,6 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d)
//SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C);
/* draw grease-pencil ('screen' strokes) */
- //if (sima->flag & SI_DISPGP)
draw_gpencil_view2d(C, 0);
}
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 97f3bd744dc..7e67e737cc2 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2110,11 +2110,6 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
Histogram *hist = &sima->sample_line_hist;
float x1f, y1f, x2f, y2f;
- int x1, y1, x2, y2;
- int i, x, y;
- float *fp;
- float rgb[3];
- unsigned char *cp;
if (ibuf == NULL) {
ED_space_image_release_buffer(sima, lock);
@@ -2128,55 +2123,13 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view(&ar->v2d, x_start, y_start, &x1f, &y1f);
UI_view2d_region_to_view(&ar->v2d, x_end, y_end, &x2f, &y2f);
- x1 = 0.5f + x1f * ibuf->x;
- x2 = 0.5f + x2f * ibuf->x;
- y1 = 0.5f + y1f * ibuf->y;
- y2 = 0.5f + y2f * ibuf->y;
-
- hist->channels = 3;
- hist->x_resolution = 256;
- hist->xmax = 1.0f;
- hist->ymax = 1.0f;
- /* persistent draw */
hist->co[0][0] = x1f;
hist->co[0][1] = y1f;
hist->co[1][0] = x2f;
hist->co[1][1] = y2f;
- hist->flag |= HISTO_FLAG_SAMPLELINE; /* keep drawing the flag after */
- for (i = 0; i < 256; i++) {
- x = (int)(0.5f + x1 + (float)i * (x2 - x1) / 255.0f);
- y = (int)(0.5f + y1 + (float)i * (y2 - y1) / 255.0f);
-
- if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
- hist->data_luma[i] = hist->data_r[i] = hist->data_g[i] = hist->data_b[i] = hist->data_a[i] = 0.0f;
- }
- else {
- if (ibuf->rect_float) {
- fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
-
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- linearrgb_to_srgb_v3_v3(rgb, fp);
- else
- copy_v3_v3(rgb, fp);
-
- hist->data_luma[i] = rgb_to_luma(rgb);
- hist->data_r[i] = rgb[0];
- hist->data_g[i] = rgb[1];
- hist->data_b[i] = rgb[2];
- hist->data_a[i] = fp[3];
- }
- else if (ibuf->rect) {
- cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
- hist->data_luma[i] = (float)rgb_to_luma_byte(cp) / 255.0f;
- hist->data_r[i] = (float)cp[0] / 255.0f;
- hist->data_g[i] = (float)cp[1] / 255.0f;
- hist->data_b[i] = (float)cp[2] / 255.0f;
- hist->data_a[i] = (float)cp[3] / 255.0f;
- }
- }
- }
+ BKE_histogram_update_sample_line(hist, ibuf, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0);
ED_space_image_release_buffer(sima, lock);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 6652a7470c2..32e6f588e27 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -914,6 +914,9 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar)
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
+ if (!sima->scopes.ok) {
+ BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ }
scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
}
ED_space_image_release_buffer(sima, lock);
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 12c369874fe..8aa56823baf 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2018,6 +2018,14 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C
static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "space", 0, "", ICON_NONE);
+
+ if (RNA_enum_get(ptr, "space") == CMP_SCALE_RENDERPERCENT) {
+ uiLayout *row;
+ uiItemR(layout, ptr, "frame_method", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ row = uiLayoutRow(layout, TRUE);
+ uiItemR(row, ptr, "offset_x", 0, "X", ICON_NONE);
+ uiItemR(row, ptr, "offset_y", 0, "Y", ICON_NONE);
+ }
}
static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -2421,6 +2429,41 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C),
static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL);
+ uiItemR(layout, ptr, "smooth_mask", 0, NULL, ICON_NONE);
+
+}
+
+static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ bNode *node= ptr->data;
+
+ uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL);
+
+ if (node->id) {
+ MovieClip *clip = (MovieClip *) node->id;
+ uiLayout *col;
+ PointerRNA tracking_ptr;
+
+ RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr);
+
+ col = uiLayoutColumn(layout, 1);
+ uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
+ }
+}
+
+static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ /* bNode *node= ptr->data; */ /* UNUSED */
+
+ uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "clip_white", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "dilate_distance", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
}
/* only once called */
@@ -2615,6 +2658,12 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_MASK:
ntype->uifunc= node_composit_buts_mask;
break;
+ case CMP_NODE_KEYINGSCREEN:
+ ntype->uifunc = node_composit_buts_keyingscreen;
+ break;
+ case CMP_NODE_KEYING:
+ ntype->uifunc = node_composit_buts_keying;
+ break;
default:
ntype->uifunc = NULL;
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 921aceb7b2e..c65bbd6e15f 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1138,15 +1138,15 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
glDisable(GL_BLEND);
/* draw grease-pencil ('canvas' strokes) */
- if (/*(snode->flag & SNODE_DISPGP) &&*/ (snode->nodetree))
- draw_gpencil_view2d((bContext*)C, 1);
+ if (snode->nodetree)
+ draw_gpencil_view2d(C, 1);
/* reset view matrix */
UI_view2d_view_restore(C);
/* draw grease-pencil (screen strokes, and also paintbuffer) */
- if (/*(snode->flag & SNODE_DISPGP) && */(snode->nodetree))
- draw_gpencil_view2d((bContext*)C, 0);
+ if (snode->nodetree)
+ draw_gpencil_view2d(C, 0);
/* scrollers */
scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index b4e07546fa9..81e375f26bc 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -46,11 +46,15 @@
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_world_types.h"
+#include "DNA_action_types.h"
+#include "DNA_anim_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BKE_action.h"
+#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
@@ -94,6 +98,7 @@
#include "GPU_material.h"
#include "node_intern.h"
+#include "NOD_socket.h"
static EnumPropertyItem socket_in_out_items[] = {
{ SOCK_IN, "SOCK_IN", 0, "Input", "" },
@@ -1109,6 +1114,155 @@ void NODE_OT_group_socket_move_down(wmOperatorType *ot)
/* ******************** Ungroup operator ********************** */
+/* returns 1 if its OK */
+static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
+{
+ bNodeLink *link, *linkn;
+ bNode *node, *nextn;
+ bNodeTree *ngroup, *wgroup;
+ ListBase anim_basepaths = {NULL, NULL};
+
+ ngroup= (bNodeTree *)gnode->id;
+ if (ngroup==NULL) return 0;
+
+ /* clear new pointers, set in copytree */
+ for (node= ntree->nodes.first; node; node= node->next)
+ node->new_node= NULL;
+
+ /* wgroup is a temporary copy of the NodeTree we're merging in
+ * - all of wgroup's nodes are transferred across to their new home
+ * - ngroup (i.e. the source NodeTree) is left unscathed
+ */
+ wgroup= ntreeCopyTree(ngroup);
+
+ /* add the nodes into the ntree */
+ for (node= wgroup->nodes.first; node; node= nextn) {
+ nextn= node->next;
+
+ /* keep track of this node's RNA "base" path (the part of the path identifying the node)
+ * if the old nodetree has animation data which potentially covers this node
+ */
+ if (wgroup->adt) {
+ PointerRNA ptr;
+ char *path;
+
+ RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
+ path = RNA_path_from_ID_to_struct(&ptr);
+
+ if (path)
+ BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
+
+ /* migrate node */
+ BLI_remlink(&wgroup->nodes, node);
+ BLI_addtail(&ntree->nodes, node);
+
+ node->locx += gnode->locx;
+ node->locy += gnode->locy;
+
+ node->flag |= NODE_SELECT;
+ }
+
+ /* restore external links to and from the gnode */
+ for (link= ntree->links.first; link; link= link->next) {
+ if (link->fromnode==gnode) {
+ if (link->fromsock->groupsock) {
+ bNodeSocket *gsock= link->fromsock->groupsock;
+ if (gsock->link) {
+ if (gsock->link->fromnode) {
+ /* NB: using the new internal copies here! the groupsock pointer still maps to the old tree */
+ link->fromnode = (gsock->link->fromnode ? gsock->link->fromnode->new_node : NULL);
+ link->fromsock = gsock->link->fromsock->new_sock;
+ }
+ else {
+ /* group output directly maps to group input */
+ bNodeSocket *insock= node_group_find_input(gnode, gsock->link->fromsock);
+ if (insock->link) {
+ link->fromnode = insock->link->fromnode;
+ link->fromsock = insock->link->fromsock;
+ }
+ }
+ }
+ else {
+ /* copy the default input value from the group socket default to the external socket */
+ node_socket_convert_default_value(link->tosock->type, link->tosock->default_value, gsock->type, gsock->default_value);
+ }
+ }
+ }
+ }
+ /* remove internal output links, these are not used anymore */
+ for (link=wgroup->links.first; link; link= linkn) {
+ linkn = link->next;
+ if (!link->tonode)
+ nodeRemLink(wgroup, link);
+ }
+ /* restore links from internal nodes */
+ for (link= wgroup->links.first; link; link= link->next) {
+ /* indicates link to group input */
+ if (!link->fromnode) {
+ /* NB: can't use find_group_node_input here,
+ * because gnode sockets still point to the old tree!
+ */
+ bNodeSocket *insock;
+ for (insock= gnode->inputs.first; insock; insock= insock->next)
+ if (insock->groupsock->new_sock == link->fromsock)
+ break;
+ if (insock->link) {
+ link->fromnode = insock->link->fromnode;
+ link->fromsock = insock->link->fromsock;
+ }
+ else {
+ /* copy the default input value from the group node socket default to the internal socket */
+ node_socket_convert_default_value(link->tosock->type, link->tosock->default_value, insock->type, insock->default_value);
+ nodeRemLink(wgroup, link);
+ }
+ }
+ }
+
+ /* add internal links to the ntree */
+ for (link= wgroup->links.first; link; link= linkn) {
+ linkn= link->next;
+ BLI_remlink(&wgroup->links, link);
+ BLI_addtail(&ntree->links, link);
+ }
+
+ /* and copy across the animation,
+ * note that the animation data's action can be NULL here */
+ if (wgroup->adt) {
+ LinkData *ld, *ldn=NULL;
+ bAction *waction;
+
+ /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
+ waction = wgroup->adt->action = BKE_action_copy(wgroup->adt->action);
+
+ /* now perform the moving */
+ BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);
+
+ /* paths + their wrappers need to be freed */
+ for (ld = anim_basepaths.first; ld; ld = ldn) {
+ ldn = ld->next;
+
+ MEM_freeN(ld->data);
+ BLI_freelinkN(&anim_basepaths, ld);
+ }
+
+ /* free temp action too */
+ if (waction) {
+ BKE_libblock_free(&G.main->action, waction);
+ }
+ }
+
+ /* delete the group instance. this also removes old input links! */
+ nodeFreeNode(ntree, gnode);
+
+ /* free the group tree (takes care of user count) */
+ BKE_libblock_free(&G.main->nodetree, wgroup);
+
+ ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
+
+ return 1;
+}
+
static int node_group_ungroup_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -1129,7 +1283,10 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "Not a group");
return OPERATOR_CANCELLED;
}
- else if (!node_group_ungroup(snode->edittree, gnode)) {
+ else if (node_group_ungroup(snode->nodetree, gnode)) {
+ ntreeUpdateTree(snode->nodetree);
+ }
+ else {
BKE_report(op->reports, RPT_WARNING, "Can't ungroup");
return OPERATOR_CANCELLED;
}
@@ -1155,6 +1312,200 @@ void NODE_OT_group_ungroup(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/* ******************** Separate operator ********************** */
+
+/* returns 1 if its OK */
+static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make_copy)
+{
+ bNodeLink *link, *link_next;
+ bNode *node, *node_next, *newnode;
+ bNodeTree *ngroup;
+ ListBase anim_basepaths = {NULL, NULL};
+
+ ngroup= (bNodeTree *)gnode->id;
+ if (ngroup==NULL) return 0;
+
+ /* deselect all nodes in the target tree */
+ for (node=ntree->nodes.first; node; node=node->next)
+ node_deselect(node);
+
+ /* clear new pointers, set in nodeCopyNode */
+ for (node= ngroup->nodes.first; node; node= node->next)
+ node->new_node= NULL;
+
+ /* add selected nodes into the ntree */
+ for (node= ngroup->nodes.first; node; node= node_next) {
+ node_next = node->next;
+ if (!(node->flag & NODE_SELECT))
+ continue;
+
+ if (make_copy) {
+ /* make a copy */
+ newnode = nodeCopyNode(ngroup, node);
+ }
+ else {
+ /* use the existing node */
+ newnode = node;
+ }
+
+ /* keep track of this node's RNA "base" path (the part of the path identifying the node)
+ * if the old nodetree has animation data which potentially covers this node
+ */
+ if (ngroup->adt) {
+ PointerRNA ptr;
+ char *path;
+
+ RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr);
+ path = RNA_path_from_ID_to_struct(&ptr);
+
+ if (path)
+ BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
+
+ /* ensure valid parent pointers, detach if parent stays inside the group */
+ if (newnode->parent && !(newnode->parent->flag & NODE_SELECT))
+ nodeDetachNode(newnode);
+
+ /* migrate node */
+ BLI_remlink(&ngroup->nodes, newnode);
+ BLI_addtail(&ntree->nodes, newnode);
+
+ newnode->locx += gnode->locx;
+ newnode->locy += gnode->locy;
+ }
+
+ /* add internal links to the ntree */
+ for (link= ngroup->links.first; link; link= link_next) {
+ int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT));
+ int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT));
+ link_next = link->next;
+
+ if (make_copy) {
+ /* make a copy of internal links */
+ if (fromselect && toselect)
+ nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock, link->tonode->new_node, link->tosock->new_sock);
+ }
+ else {
+ /* move valid links over, delete broken links */
+ if (fromselect && toselect) {
+ BLI_remlink(&ngroup->links, link);
+ BLI_addtail(&ntree->links, link);
+ }
+ else if (fromselect || toselect) {
+ nodeRemLink(ngroup, link);
+ }
+ }
+ }
+
+ /* and copy across the animation,
+ * note that the animation data's action can be NULL here */
+ if (ngroup->adt) {
+ LinkData *ld, *ldn=NULL;
+
+ /* now perform the moving */
+ BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths);
+
+ /* paths + their wrappers need to be freed */
+ for (ld = anim_basepaths.first; ld; ld = ldn) {
+ ldn = ld->next;
+
+ MEM_freeN(ld->data);
+ BLI_freelinkN(&anim_basepaths, ld);
+ }
+ }
+
+ ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
+ if (!make_copy)
+ ngroup->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
+
+ return 1;
+}
+
+typedef enum eNodeGroupSeparateType {
+ NODE_GS_COPY,
+ NODE_GS_MOVE
+} eNodeGroupSeparateType;
+
+/* Operator Property */
+EnumPropertyItem node_group_separate_types[] = {
+ {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"},
+ {NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+static int node_group_separate_exec(bContext *C, wmOperator *op)
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *gnode;
+ int type = RNA_enum_get(op->ptr, "type");
+
+ ED_preview_kill_jobs(C);
+
+ /* are we inside of a group? */
+ gnode= node_tree_get_editgroup(snode->nodetree);
+ if (!gnode) {
+ BKE_report(op->reports, RPT_WARNING, "Not inside node group");
+ return OPERATOR_CANCELLED;
+ }
+
+ switch (type) {
+ case NODE_GS_COPY:
+ if (!node_group_separate_selected(snode->nodetree, gnode, 1)) {
+ BKE_report(op->reports, RPT_WARNING, "Can't separate nodes");
+ return OPERATOR_CANCELLED;
+ }
+ break;
+ case NODE_GS_MOVE:
+ if (!node_group_separate_selected(snode->nodetree, gnode, 0)) {
+ BKE_report(op->reports, RPT_WARNING, "Can't separate nodes");
+ return OPERATOR_CANCELLED;
+ }
+ break;
+ }
+
+ /* switch to parent tree */
+ snode_make_group_editable(snode, NULL);
+
+ ntreeUpdateTree(snode->nodetree);
+
+ snode_notify(C, snode);
+ snode_dag_update(C, snode);
+
+ return OPERATOR_FINISHED;
+}
+
+static int node_group_separate_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
+{
+ uiPopupMenu *pup = uiPupMenuBegin(C, "Separate", ICON_NONE);
+ uiLayout *layout = uiPupMenuLayout(pup);
+
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
+ uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_COPY);
+ uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_MOVE);
+
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+}
+
+void NODE_OT_group_separate(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Separate";
+ ot->description = "Separate selected nodes from the node group";
+ ot->idname = "NODE_OT_group_separate";
+
+ /* api callbacks */
+ ot->invoke = node_group_separate_invoke;
+ ot->exec = node_group_separate_exec;
+ ot->poll = ED_operator_node_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", "");
+}
+
/* ************************** Node generic ************** */
/* is rct in visible part of node? */
@@ -3249,10 +3600,219 @@ void NODE_OT_render_changed(wmOperatorType *ot)
/* ****************** Make Group operator ******************* */
+static int node_group_make_test(bNodeTree *ntree, bNode *gnode)
+{
+ bNode *node;
+ bNodeLink *link;
+ int totnode = 0;
+
+ /* is there something to group? also do some clearing */
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node == gnode)
+ continue;
+
+ if (node->flag & NODE_SELECT) {
+ /* no groups in groups */
+ if (node->type==NODE_GROUP)
+ return 0;
+ totnode++;
+ }
+
+ node->done = 0;
+ }
+ if (totnode==0) return 0;
+
+ /* check if all connections are OK, no unselected node has both
+ * inputs and outputs to a selection */
+ for (link= ntree->links.first; link; link= link->next) {
+ if (link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT && link->fromnode != gnode)
+ link->tonode->done |= 1;
+ if (link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT && link->tonode != gnode)
+ link->fromnode->done |= 2;
+ }
+
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node == gnode)
+ continue;
+ if ((node->flag & NODE_SELECT)==0)
+ if (node->done==3)
+ break;
+ }
+ if (node)
+ return 0;
+
+ return 1;
+}
+
+static void node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, float *max)
+{
+ bNode *node;
+ INIT_MINMAX2(min, max);
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node == gnode)
+ continue;
+ if (node->flag & NODE_SELECT) {
+ DO_MINMAX2((&node->locx), min, max);
+ }
+ }
+}
+
+static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode)
+{
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNodeLink *link, *linkn;
+ bNode *node, *nextn;
+ bNodeSocket *gsock;
+ ListBase anim_basepaths = {NULL, NULL};
+ float min[2], max[2];
+
+ /* deselect all nodes in the target tree */
+ for (node = ngroup->nodes.first; node; node=node->next)
+ node_deselect(node);
+
+ node_get_selected_minmax(ntree, gnode, min, max);
+
+ /* move nodes over */
+ for (node= ntree->nodes.first; node; node= nextn) {
+ nextn= node->next;
+ if (node == gnode)
+ continue;
+ if (node->flag & NODE_SELECT) {
+ /* keep track of this node's RNA "base" path (the part of the pat identifying the node)
+ * if the old nodetree has animation data which potentially covers this node
+ */
+ if (ntree->adt) {
+ PointerRNA ptr;
+ char *path;
+
+ RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
+ path = RNA_path_from_ID_to_struct(&ptr);
+
+ if (path)
+ BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
+
+ /* ensure valid parent pointers, detach if parent stays outside the group */
+ if (node->parent && !(node->parent->flag & NODE_SELECT))
+ nodeDetachNode(node);
+
+ /* change node-collection membership */
+ BLI_remlink(&ntree->nodes, node);
+ BLI_addtail(&ngroup->nodes, node);
+
+ node->locx-= 0.5f*(min[0]+max[0]);
+ node->locy-= 0.5f*(min[1]+max[1]);
+ }
+ }
+
+ /* move animation data over */
+ if (ntree->adt) {
+ LinkData *ld, *ldn=NULL;
+
+ BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths);
+
+ /* paths + their wrappers need to be freed */
+ for (ld = anim_basepaths.first; ld; ld = ldn) {
+ ldn = ld->next;
+
+ MEM_freeN(ld->data);
+ BLI_freelinkN(&anim_basepaths, ld);
+ }
+ }
+
+ /* node groups don't use internal cached data */
+ ntreeFreeCache(ngroup);
+
+ /* relink external sockets */
+ for (link= ntree->links.first; link; link= linkn) {
+ int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT) && link->fromnode != gnode);
+ int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT) && link->tonode != gnode);
+ linkn= link->next;
+
+ if (gnode && ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode))) {
+ /* remove all links to/from the gnode.
+ * this can remove link information, but there's no general way to preserve it.
+ */
+ nodeRemLink(ntree, link);
+ }
+ else if (fromselect && toselect) {
+ BLI_remlink(&ntree->links, link);
+ BLI_addtail(&ngroup->links, link);
+ }
+ else if (toselect) {
+ gsock = node_group_expose_socket(ngroup, link->tosock, SOCK_IN);
+ link->tosock->link = nodeAddLink(ngroup, NULL, gsock, link->tonode, link->tosock);
+ link->tosock = node_group_add_extern_socket(ntree, &gnode->inputs, SOCK_IN, gsock);
+ link->tonode = gnode;
+ }
+ else if (fromselect) {
+ /* search for existing group node socket */
+ for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next)
+ if (gsock->link && gsock->link->fromsock==link->fromsock)
+ break;
+ if (!gsock) {
+ gsock = node_group_expose_socket(ngroup, link->fromsock, SOCK_OUT);
+ gsock->link = nodeAddLink(ngroup, link->fromnode, link->fromsock, NULL, gsock);
+ link->fromsock = node_group_add_extern_socket(ntree, &gnode->outputs, SOCK_OUT, gsock);
+ }
+ else
+ link->fromsock = node_group_find_output(gnode, gsock);
+ link->fromnode = gnode;
+ }
+ }
+
+ /* update of the group tree */
+ ngroup->update |= NTREE_UPDATE;
+ /* update of the tree containing the group instance node */
+ ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
+
+ return 1;
+}
+
+static bNode *node_group_make_from_selected(bNodeTree *ntree)
+{
+ bNode *gnode;
+ bNodeTree *ngroup;
+ float min[2], max[2];
+ bNodeTemplate ntemp;
+
+ node_get_selected_minmax(ntree, NULL, min, max);
+
+ /* new nodetree */
+ ngroup= ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP);
+
+ /* make group node */
+ ntemp.type = NODE_GROUP;
+ ntemp.ngroup = ngroup;
+ gnode= nodeAddNode(ntree, &ntemp);
+ gnode->locx= 0.5f*(min[0]+max[0]);
+ gnode->locy= 0.5f*(min[1]+max[1]);
+
+ node_group_make_insert_selected(ntree, gnode);
+
+ /* update of the tree containing the group instance node */
+ ntree->update |= NTREE_UPDATE_NODES;
+
+ return gnode;
+}
+
+typedef enum eNodeGroupMakeType {
+ NODE_GM_NEW,
+ NODE_GM_INSERT
+} eNodeGroupMakeType;
+
+/* Operator Property */
+EnumPropertyItem node_group_make_types[] = {
+ {NODE_GM_NEW, "NEW", 0, "New", "Create a new node group from selected nodes"},
+ {NODE_GM_INSERT, "INSERT", 0, "Insert", "Insert into active node group"},
+ {0, NULL, 0, NULL, NULL}
+};
+
static int node_group_make_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNode *gnode;
+ int type = RNA_enum_get(op->ptr, "type");
if (snode->edittree!=snode->nodetree) {
BKE_report(op->reports, RPT_WARNING, "Can not add a new Group in a Group");
@@ -3272,25 +3832,70 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
-
- ED_preview_kill_jobs(C);
- gnode= node_group_make_from_selected(snode->nodetree);
- if (gnode==NULL) {
- BKE_report(op->reports, RPT_WARNING, "Can not make Group");
- return OPERATOR_CANCELLED;
+ ED_preview_kill_jobs(C);
+
+ switch (type) {
+ case NODE_GM_NEW:
+ if (node_group_make_test(snode->nodetree, NULL)) {
+ gnode = node_group_make_from_selected(snode->nodetree);
+ }
+ else {
+ BKE_report(op->reports, RPT_WARNING, "Can not make Group");
+ return OPERATOR_CANCELLED;
+ }
+ break;
+ case NODE_GM_INSERT:
+ gnode = nodeGetActive(snode->nodetree);
+ if (!gnode || gnode->type != NODE_GROUP) {
+ BKE_report(op->reports, RPT_WARNING, "No active Group node");
+ return OPERATOR_CANCELLED;
+ }
+ if (node_group_make_test(snode->nodetree, gnode)) {
+ node_group_make_insert_selected(snode->nodetree, gnode);
+ }
+ else {
+ BKE_report(op->reports, RPT_WARNING, "Can not insert into Group");
+ return OPERATOR_CANCELLED;
+ }
+ break;
}
- else {
+
+ if (gnode) {
nodeSetActive(snode->nodetree, gnode);
- ntreeUpdateTree(snode->nodetree);
+ snode_make_group_editable(snode, gnode);
}
+ if (gnode)
+ ntreeUpdateTree((bNodeTree *)gnode->id);
+ ntreeUpdateTree(snode->nodetree);
+
snode_notify(C, snode);
snode_dag_update(C, snode);
return OPERATOR_FINISHED;
}
+static int node_group_make_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *act = nodeGetActive(snode->edittree);
+ uiPopupMenu *pup = uiPupMenuBegin(C, "Make Group", ICON_NONE);
+ uiLayout *layout = uiPupMenuLayout(pup);
+
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
+ uiItemEnumO(layout, "NODE_OT_group_make", NULL, 0, "type", NODE_GM_NEW);
+
+ /* if active node is a group, add insert option */
+ if (act && act->type == NODE_GROUP) {
+ uiItemEnumO(layout, "NODE_OT_group_make", NULL, 0, "type", NODE_GM_INSERT);
+ }
+
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+}
+
void NODE_OT_group_make(wmOperatorType *ot)
{
/* identifiers */
@@ -3299,11 +3904,14 @@ void NODE_OT_group_make(wmOperatorType *ot)
ot->idname = "NODE_OT_group_make";
/* api callbacks */
+ ot->invoke = node_group_make_invoke;
ot->exec = node_group_make_exec;
ot->poll = ED_operator_node_active;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_enum(ot->srna, "type", node_group_make_types, NODE_GM_NEW, "Type", "");
}
/* ****************** Hide operator *********************** */
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 9e873799f1c..d9dbd646fa5 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -149,6 +149,7 @@ void NODE_OT_add_reroute(struct wmOperatorType *ot);
void NODE_OT_group_make(struct wmOperatorType *ot);
void NODE_OT_group_ungroup(struct wmOperatorType *ot);
+void NODE_OT_group_separate(struct wmOperatorType *ot);
void NODE_OT_group_edit(struct wmOperatorType *ot);
void NODE_OT_group_socket_add(struct wmOperatorType *ot);
void NODE_OT_group_socket_remove(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 8a977d2f112..ff1661f0327 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -83,6 +83,7 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_group_make);
WM_operatortype_append(NODE_OT_group_ungroup);
+ WM_operatortype_append(NODE_OT_group_separate);
WM_operatortype_append(NODE_OT_group_edit);
WM_operatortype_append(NODE_OT_group_socket_add);
WM_operatortype_append(NODE_OT_group_socket_remove);
@@ -269,6 +270,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "NODE_OT_group_separate", PKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_group_edit", TABKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_read_renderlayers", RKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 66919935d48..e069ba2a5fc 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -468,7 +468,7 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn)
}
}
-const char *node_context_dir[] = {"selected_nodes", NULL};
+const char *node_context_dir[] = {"selected_nodes", "active_node", NULL};
static int node_context(const bContext *C, const char *member, bContextDataResult *result)
{
@@ -492,16 +492,11 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
return 1;
}
else if (CTX_data_equals(member, "active_node")) {
- bNode *node;
-
if (snode->edittree) {
- for (node=snode->edittree->nodes.last; node; node=node->prev) {
- if (node->flag & NODE_ACTIVE) {
- CTX_data_pointer_set(result, &snode->edittree->id, &RNA_Node, node);
- break;
- }
- }
+ bNode *node = nodeGetActive(snode->edittree);
+ CTX_data_pointer_set(result, &snode->edittree->id, &RNA_Node, node);
}
+
CTX_data_type_set(result, CTX_DATA_TYPE_POINTER);
return 1;
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index e5f7b8fd76d..eb740e441b7 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -35,6 +35,7 @@
#include "DNA_group_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
+#include "DNA_material_types.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@@ -48,6 +49,7 @@
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BKE_material.h"
#include "ED_object.h"
#include "ED_screen.h"
@@ -1816,3 +1818,68 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot)
RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object");
RNA_def_string(ot->srna, "scene", "Scene", MAX_ID_NAME, "Scene", "Target Scene");
}
+
+static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ Main *bmain = CTX_data_main(C);
+ Material *ma = NULL;
+ Object *ob = NULL;
+ SpaceOops *soops = CTX_wm_space_outliner(C);
+ ARegion *ar = CTX_wm_region(C);
+ TreeElement *te = NULL;
+ TreeElement *te_found = NULL;
+ char mat_name[MAX_ID_NAME - 2];
+ 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, "object", te_found->name);
+ ob = (Object *)BKE_libblock_find_name(ID_OB, te_found->name);
+
+ RNA_string_get(op->ptr, "material", mat_name);
+ ma = (Material *)BKE_libblock_find_name(ID_MA, mat_name);
+
+ if (ELEM(NULL, ob, ma)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ assign_material(ob, ma, ob->totcol + 1);
+
+ DAG_ids_flush_update(bmain, 0);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+ WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, ma);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+void OUTLINER_OT_material_drop(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Drop Material on Object";
+ ot->description = "Drag material to object in Outliner";
+ ot->idname = "OUTLINER_OT_material_drop";
+
+ /* api callbacks */
+ ot->invoke = material_drop_invoke;
+
+ ot->poll = ED_operator_outliner_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object");
+ RNA_def_string(ot->srna, "material", "Material", MAX_ID_NAME, "Material", "Target Material");
+}
+
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 5274410214a..65de2a27568 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -221,6 +221,7 @@ 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);
void OUTLINER_OT_scene_drop(struct wmOperatorType *ot);
+void OUTLINER_OT_material_drop(struct wmOperatorType *ot);
/* outliner_tools.c ---------------------------------------------- */
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 0b3a226cca1..1dd043409a5 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -77,6 +77,7 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_parent_drop);
WM_operatortype_append(OUTLINER_OT_parent_clear);
WM_operatortype_append(OUTLINER_OT_scene_drop);
+ WM_operatortype_append(OUTLINER_OT_material_drop);
}
void outliner_keymap(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index c78be8bd223..489a4efe891 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -194,6 +194,35 @@ static void outliner_scene_drop_copy(wmDrag *drag, wmDropBox *drop)
RNA_string_set(drop->ptr, "object", id->name + 2);
}
+static int outliner_material_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_MA) {
+ /* Ensure item under cursor is valid drop target */
+ /* Find object hovered over */
+ for (te = soops->tree.first; te; te = te->next) {
+ if (outliner_dropzone_parent(C, event, te, fmval))
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static void outliner_material_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+ ID *id = (ID *)drag->poin;
+
+ RNA_string_set(drop->ptr, "material", id->name + 2);
+}
+
/* region dropbox definition */
static void outliner_dropboxes(void)
{
@@ -202,6 +231,7 @@ static void outliner_dropboxes(void)
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);
WM_dropbox_add(lb, "OUTLINER_OT_scene_drop", outliner_scene_drop_poll, outliner_scene_drop_copy);
+ WM_dropbox_add(lb, "OUTLINER_OT_material_drop", outliner_material_drop_poll, outliner_material_drop_copy);
}
static void outliner_main_area_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index bfd9ed95ee4..7bee8c2bebf 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -20,6 +20,7 @@
set(INC
../include
+ ../../blenfont
../../blenkernel
../../blenlib
../../blenloader
diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript
index 65aadfa1c8a..ec06eacae9c 100644
--- a/source/blender/editors/space_sequencer/SConscript
+++ b/source/blender/editors/space_sequencer/SConscript
@@ -5,7 +5,7 @@ sources = env.Glob('*.c')
incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
-incs += ' ../../makesrna ../../blenloader'
+incs += ' ../../makesrna ../../blenloader ../../blenfont'
incs += ' #/intern/audaspace/intern'
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index aeedafa9992..1e452f2052d 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -25,8 +25,6 @@
* \ingroup spseq
*/
-
-
#include <string.h>
#include <stdio.h>
@@ -36,10 +34,13 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
+#include "ED_gpencil.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -48,6 +49,19 @@
#include "sequencer_intern.h"
+/* **************************** buttons ********************************* */
+
+void sequencer_buttons_register(ARegionType *art)
+{
+ PanelType *pt;
+
+ pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil");
+ strcpy(pt->idname, "SEQUENCER_PT_gpencil");
+ strcpy(pt->label, N_("Grease Pencil"));
+ pt->draw= gpencil_panel_standard;
+ BLI_addtail(&art->paneltypes, pt);
+}
+
/* **************** operator to open/close properties view ************* */
static int sequencer_properties(bContext *C, wmOperator *UNUSED(op))
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index b674943b2dc..e48450e93bd 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -58,6 +58,7 @@
#include "BIF_glutil.h"
#include "ED_anim_api.h"
+#include "ED_gpencil.h"
#include "ED_markers.h"
#include "ED_mask.h"
#include "ED_types.h"
@@ -975,17 +976,15 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
}
/* draw grease-pencil (image aligned) */
-// if (sseq->flag & SEQ_DRAW_GPENCIL)
-// XXX draw_gpencil_2dimage(sa, ibuf);
+ draw_gpencil_2dimage(C);
IMB_freeImBuf(ibuf);
- /* draw grease-pencil (screen aligned) */
-// if (sseq->flag & SEQ_DRAW_GPENCIL)
-// XXX draw_gpencil_view2d(sa, 0);
-
/* ortho at pixel level */
UI_view2d_view_restore(C);
+
+ /* draw grease-pencil (screen aligned) */
+ draw_gpencil_view2d(C, 0);
//if (sc->mode == SC_MODE_MASKEDIT) {
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 25a322c6905..14d2ccdbbbe 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -174,7 +174,7 @@ struct ImBuf *make_zebra_view_from_ibuf(struct ImBuf * ibuf, float perc);
struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf);
/* sequencer_buttons.c */
-
+void sequencer_buttons_register(struct ARegionType *art);
void SEQUENCER_OT_properties(struct wmOperatorType *ot);
#endif /* __SEQUENCER_INTERN_H__ */
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 3643f92d334..b8bf764fabc 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -325,27 +325,43 @@ static void sequencer_main_area_draw(const bContext *C, ARegion *ar)
/* ************* dropboxes ************* */
-static int image_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
+static int image_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
{
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ int hand;
+
if (drag->type == WM_DRAG_PATH)
if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
- return 1;
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL)
+ return 1;
+
return 0;
}
-static int movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
+static int movie_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
{
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ int hand;
+
if (drag->type == WM_DRAG_PATH)
if (ELEM3(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */
- return 1;
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL)
+ return 1;
return 0;
}
-static int sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
+static int sound_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
{
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ int hand;
+
if (drag->type == WM_DRAG_PATH)
if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) /* rule might not work? */
- return 1;
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL)
+ return 1;
return 0;
}
@@ -485,6 +501,11 @@ static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch (wmn->category) {
+ case NC_SCREEN:
+ if (wmn->data == ND_GPENCIL) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
case NC_SCENE:
switch (wmn->data) {
case ND_FRAME:
@@ -534,6 +555,11 @@ static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch (wmn->category) {
+ case NC_SCREEN:
+ if (wmn->data == ND_GPENCIL) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
case NC_SCENE:
switch (wmn->data) {
case ND_FRAME:
@@ -590,7 +616,7 @@ void ED_spacetype_sequencer(void)
art->init = sequencer_preview_area_init;
art->draw = sequencer_preview_area_draw;
art->listener = sequencer_preview_area_listener;
- art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION;
+ art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
BLI_addhead(&st->regiontypes, art);
/* regions: listview/buttons */
@@ -602,6 +628,8 @@ void ED_spacetype_sequencer(void)
art->init = sequencer_buttons_area_init;
art->draw = sequencer_buttons_area_draw;
BLI_addhead(&st->regiontypes, art);
+
+ sequencer_buttons_register(art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 7e84ab062ca..3be74b2811d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1566,12 +1566,12 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
float mat[4][4], imat[4][4];
unsigned char col[4], scol[4];
int tracknr = *global_track_index;
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, tracking_object);
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
UI_GetThemeColor4ubv(TH_TEXT, col);
UI_GetThemeColor4ubv(TH_SELECT, scol);
- BKE_get_tracking_mat(scene, base->object, mat);
+ BKE_tracking_get_camera_object_matrix(scene, base->object, mat);
glPushMatrix();
@@ -1587,7 +1587,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
else {
float obmat[4][4];
- BKE_tracking_get_interpolated_camera(tracking, tracking_object, scene->r.cfra, obmat);
+ BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, scene->r.cfra, obmat);
invert_m4_m4(imat, obmat);
glMultMatrixf(imat);
@@ -1685,7 +1685,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
if ((dflag & DRAW_PICKING) == 0) {
if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA)) {
MovieTrackingReconstruction *reconstruction;
- reconstruction = BKE_tracking_object_reconstruction(tracking, tracking_object);
+ reconstruction = BKE_tracking_object_get_reconstruction(tracking, tracking_object);
if (reconstruction->camnr) {
MovieReconstructedCamera *camera = reconstruction->cameras;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 6d9507ebff1..fcb4f97bcbe 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1547,6 +1547,8 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
(bgpic->view & (1 << rv3d->view)) || /* check agaist flags */
(rv3d->persp == RV3D_CAMOB && bgpic->view == (1 << RV3D_VIEW_CAMERA)))
{
+ float image_aspect[2];
+
/* disable individual images */
if ((bgpic->flag & V3D_BGPIC_DISABLED))
continue;
@@ -1558,6 +1560,9 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
continue;
BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0);
ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser);
+
+ image_aspect[0] = ima->aspx;
+ image_aspect[1] = ima->aspx;
}
else if (bgpic->source == V3D_BGPIC_MOVIE) {
clip = NULL;
@@ -1574,6 +1579,9 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
BKE_movieclip_user_set_frame(&bgpic->cuser, CFRA);
ibuf = BKE_movieclip_get_ibuf(clip, &bgpic->cuser);
+ image_aspect[0] = clip->aspx;
+ image_aspect[1] = clip->aspx;
+
/* working with ibuf from image and clip has got different workflow now.
* ibuf acquired from clip is referenced by cache system and should
* be dereferenced after usage. */
@@ -1609,6 +1617,50 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
x2 = ar->winrct.xmax;
y2 = ar->winrct.ymax;
}
+
+ /* apply offset last - camera offset is different to offset in blender units */
+ /* so this has some sane way of working - this matches camera's shift _exactly_ */
+ {
+ const float max_dim = maxf(x2 - x1, y2 - y1);
+ const float xof_scale = bgpic->xof * max_dim;
+ const float yof_scale = bgpic->yof * max_dim;
+
+ x1 += xof_scale;
+ y1 += yof_scale;
+ x2 += xof_scale;
+ y2 += yof_scale;
+ }
+
+ /* aspect correction */
+ if (bgpic->flag & V3D_BGPIC_CAMERA_ASPECT) {
+ /* apply aspect from clip */
+ const float w_src = ibuf->x * image_aspect[0];
+ const float h_src = ibuf->y * image_aspect[1];
+
+ /* destination aspect is already applied from the camera frame */
+ const float w_dst = x1 - x2;
+ const float h_dst = y1 - y2;
+
+ const float asp_src = w_src / h_src;
+ const float asp_dst = w_dst / h_dst;
+
+ if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
+ if ((asp_src > asp_dst) == ((bgpic->flag & V3D_BGPIC_CAMERA_CROP) != 0)) {
+ /* fit X */
+ const float div = asp_src / asp_dst;
+ const float cent = (x1 + x2) / 2.0f;
+ x1 = ((x1 - cent) * div) + cent;
+ x2 = ((x2 - cent) * div) + cent;
+ }
+ else {
+ /* fit Y */
+ const float div = asp_dst / asp_src;
+ const float cent = (y1 + y2) / 2.0f;
+ y1 = ((y1 - cent) * div) + cent;
+ y2 = ((y2 - cent) * div) + cent;
+ }
+ }
+ }
}
else {
float sco[2];
@@ -2778,13 +2830,17 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
cliprct.ymin += ar->winrct.ymin;
cliprct.ymax += ar->winrct.ymin;
- cliprct.xmin = MAX2(cliprct.xmin, ar->winrct.xmin);
- cliprct.ymin = MAX2(cliprct.ymin, ar->winrct.ymin);
- cliprct.xmax = MIN2(cliprct.xmax, ar->winrct.xmax);
- cliprct.ymax = MIN2(cliprct.ymax, ar->winrct.ymax);
+ cliprct.xmin = CLAMPIS(cliprct.xmin, ar->winrct.xmin, ar->winrct.xmax);
+ cliprct.ymin = CLAMPIS(cliprct.ymin, ar->winrct.ymin, ar->winrct.ymax);
+ cliprct.xmax = CLAMPIS(cliprct.xmax, ar->winrct.xmin, ar->winrct.xmax);
+ cliprct.ymax = CLAMPIS(cliprct.ymax, ar->winrct.ymin, ar->winrct.ymax);
- glGetIntegerv(GL_SCISSOR_BOX, scissor);
- glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin);
+ if(cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) {
+ glGetIntegerv(GL_SCISSOR_BOX, scissor);
+ glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin);
+ }
+ else
+ return 0;
}
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -2795,11 +2851,6 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
else
fdrawcheckerboard(0, 0, ar->winx, ar->winy);
- if (draw_border) {
- /* restore scissor as it was before */
- glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
- }
-
/* render result draw */
type = rv3d->render_engine->type;
type->view_draw(rv3d->render_engine, C);
@@ -2807,6 +2858,11 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
if (v3d->flag & V3D_DISPBGPICS)
view3d_draw_bgpic(scene, ar, v3d, TRUE, TRUE);
+ if (draw_border) {
+ /* restore scissor as it was before */
+ glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+ }
+
return 1;
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index d2f2fdcaa81..f9ebd4e39c1 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1303,11 +1303,11 @@ static void deselect_all_tracks(MovieTracking *tracking)
object = tracking->objects.first;
while (object) {
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
MovieTrackingTrack *track = tracksbase->first;
while (track) {
- BKE_tracking_deselect_track(track, TRACK_AREA_ALL);
+ BKE_tracking_track_deselect(track, TRACK_AREA_ALL);
track = track->next;
}
@@ -1408,18 +1408,18 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese
ListBase *tracksbase;
MovieTrackingTrack *track;
- track = BKE_tracking_indexed_track(&clip->tracking, hitresult >> 16, &tracksbase);
+ track = BKE_tracking_track_get_indexed(&clip->tracking, hitresult >> 16, &tracksbase);
if (TRACK_SELECTED(track) && extend) {
changed = 0;
- BKE_tracking_deselect_track(track, TRACK_AREA_ALL);
+ BKE_tracking_track_deselect(track, TRACK_AREA_ALL);
}
else {
int oldsel = TRACK_SELECTED(track) ? 1 : 0;
if (!extend)
deselect_all_tracks(tracking);
- BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, extend);
+ BKE_tracking_track_select(tracksbase, track, TRACK_AREA_ALL, extend);
if (oldsel != (TRACK_SELECTED(track) ? 1 : 0))
changed = 1;
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 5af1829af5a..1991d4bce4f 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -831,12 +831,12 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
copy_m4_m4(cammat, ob->obmat);
- BKE_get_tracking_mat(scene, ob, mat);
+ BKE_tracking_get_camera_object_matrix(scene, ob, mat);
INIT_MINMAX(min, max);
for (object = tracking->objects.first; object; object = object->next) {
- ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
MovieTrackingTrack *track = tracksbase->first;
float obmat[4][4];
@@ -846,7 +846,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
else {
float imat[4][4];
- BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, imat);
+ BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, scene->r.cfra, imat);
invert_m4(imat);
mult_m4_m4m4(obmat, cammat, imat);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 8bafce70ec4..d32206c4335 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -51,7 +51,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_mask_types.h"
#include "DNA_movieclip_types.h"
-#include "DNA_scene_types.h" /* PET modes */
+#include "DNA_scene_types.h" /* PET modes */
#include "RNA_access.h"
@@ -105,7 +105,7 @@ static int doEdgeSlide(TransInfo *t, float perc);
void setTransformViewMatrices(TransInfo *t)
{
- if (t->spacetype==SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
+ if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = t->ar->regiondata;
copy_m4_m4(t->viewmat, rv3d->viewmat);
@@ -129,12 +129,12 @@ static void convertViewVec2D(View2D *v2d, float vec[3], int dx, int dy)
{
float divx, divy;
- divx= v2d->mask.xmax - v2d->mask.xmin;
- divy= v2d->mask.ymax - v2d->mask.ymin;
+ divx = v2d->mask.xmax - v2d->mask.xmin;
+ divy = v2d->mask.ymax - v2d->mask.ymin;
- vec[0]= (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
- vec[1]= (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
- vec[2]= 0.0f;
+ vec[0] = (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
+ vec[1] = (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
+ vec[2] = 0.0f;
}
void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
@@ -145,7 +145,7 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
mval_f[1] = dy;
ED_view3d_win_to_delta(t->ar, mval_f, r_vec);
}
- else if (t->spacetype==SPACE_IMAGE) {
+ else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy;
convertViewVec2D(t->view, r_vec, dx, dy);
@@ -160,17 +160,17 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
else if (ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
convertViewVec2D(&t->ar->v2d, r_vec, dx, dy);
}
- else if (t->spacetype==SPACE_CLIP) {
+ else if (t->spacetype == SPACE_CLIP) {
View2D *v2d = t->view;
float divx, divy;
float mulx, muly;
float aspx = 1.0f, aspy = 1.0f;
- divx = v2d->mask.xmax-v2d->mask.xmin;
- divy = v2d->mask.ymax-v2d->mask.ymin;
+ divx = v2d->mask.xmax - v2d->mask.xmin;
+ divy = v2d->mask.ymax - v2d->mask.ymin;
- mulx = (v2d->cur.xmax-v2d->cur.xmin);
- muly = (v2d->cur.ymax-v2d->cur.ymin);
+ mulx = (v2d->cur.xmax - v2d->cur.xmin);
+ muly = (v2d->cur.ymax - v2d->cur.ymin);
if (t->options & CTX_MASK) {
/* clamp w/h, mask only */
@@ -201,18 +201,18 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
void projectIntView(TransInfo *t, const float vec[3], int adr[2])
{
- if (t->spacetype==SPACE_VIEW3D) {
+ if (t->spacetype == SPACE_VIEW3D) {
if (t->ar->regiontype == RGN_TYPE_WINDOW)
project_int_noclip(t->ar, vec, adr);
}
- else if (t->spacetype==SPACE_IMAGE) {
+ else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy, v[2];
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
- v[0]= vec[0]/aspx;
- v[1]= vec[1]/aspy;
+ v[0] = vec[0] / aspx;
+ v[1] = vec[1] / aspy;
- UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
+ UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
}
else if (t->spacetype == SPACE_ACTION) {
int out[2] = {0, 0};
@@ -222,32 +222,32 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
if (sact->flag & SACTION_DRAWTIME) {
//vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
/* same as below */
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
+ UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
}
else
#endif
{
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
+ UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
}
- adr[0]= out[0];
- adr[1]= out[1];
+ adr[0] = out[0];
+ adr[1] = out[1];
}
else if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int out[2] = {0, 0};
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
- adr[0]= out[0];
- adr[1]= out[1];
+ UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+ adr[0] = out[0];
+ adr[1] = out[1];
}
- else if (t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */
+ else if (t->spacetype == SPACE_SEQ) { /* XXX not tested yet, but should work */
int out[2] = {0, 0};
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
- adr[0]= out[0];
- adr[1]= out[1];
+ UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+ adr[0] = out[0];
+ adr[1] = out[1];
}
- else if (t->spacetype==SPACE_CLIP) {
+ else if (t->spacetype == SPACE_CLIP) {
float v[2];
float aspx = 1.0f, aspy = 1.0f;
@@ -261,7 +261,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
v[0] /= aspx;
v[1] /= aspy;
- UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
+ UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
}
}
@@ -294,11 +294,11 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
void applyAspectRatio(TransInfo *t, float vec[2])
{
- if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
- SpaceImage *sima= t->sa->spacedata.first;
+ if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
+ SpaceImage *sima = t->sa->spacedata.first;
float aspx, aspy;
- if ((sima->flag & SI_COORDFLOATS)==0) {
+ if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
ED_space_image_size(sima, &width, &height);
@@ -310,7 +310,7 @@ void applyAspectRatio(TransInfo *t, float vec[2])
vec[0] /= aspx;
vec[1] /= aspy;
}
- else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) {
+ else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
SpaceClip *sc = t->sa->spacedata.first;
float aspx, aspy;
@@ -334,11 +334,11 @@ void applyAspectRatio(TransInfo *t, float vec[2])
void removeAspectRatio(TransInfo *t, float vec[2])
{
- if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
- SpaceImage *sima= t->sa->spacedata.first;
+ if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
+ SpaceImage *sima = t->sa->spacedata.first;
float aspx, aspy;
- if ((sima->flag & SI_COORDFLOATS)==0) {
+ if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
ED_space_image_size(sima, &width, &height);
@@ -350,7 +350,7 @@ void removeAspectRatio(TransInfo *t, float vec[2])
vec[0] *= aspx;
vec[1] *= aspy;
}
- else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) {
+ else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
SpaceClip *sc = t->sa->spacedata.first;
float aspx = 1.0f, aspy = 1.0f;
@@ -373,55 +373,55 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
/* Do we need more refined tags? */
if (t->flag & T_POSE)
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
else
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
/* for realtime animation record - send notifiers recognised by animation editors */
// XXX: is this notifier a lame duck?
if ((t->animtimer) && IS_AUTOKEY_ON(t->scene))
- WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
}
else if (t->spacetype == SPACE_ACTION) {
//SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
- WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_IPO) {
//SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
- WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NLA) {
- WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NODE) {
//ED_area_tag_redraw(t->sa);
- WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE_VIEW, NULL);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
}
else if (t->spacetype == SPACE_SEQ) {
- WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, NULL);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL);
}
- else if (t->spacetype==SPACE_IMAGE) {
+ else if (t->spacetype == SPACE_IMAGE) {
// XXX how to deal with lock?
- SpaceImage *sima= (SpaceImage*)t->sa->spacedata.first;
- if (sima->lock) WM_event_add_notifier(C, NC_GEOM|ND_DATA, t->obedit->data);
+ SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
+ if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data);
else ED_area_tag_redraw(t->sa);
}
- else if (t->spacetype==SPACE_CLIP) {
- SpaceClip *sc = (SpaceClip*)t->sa->spacedata.first;
+ else if (t->spacetype == SPACE_CLIP) {
+ SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first;
if (ED_space_clip_show_trackedit(sc)) {
MovieClip *clip = ED_space_clip(sc);
/* objects could be parented to tracking data, so send this for viewport refresh */
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
- WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip);
+ WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
}
else if (ED_space_clip_show_maskedit(sc)) {
Mask *mask = ED_space_clip_mask(sc);
- WM_event_add_notifier(C, NC_MASK|NA_EDITED, mask);
+ WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
}
}
}
@@ -433,19 +433,19 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
/* if autokeying is enabled, send notifiers that keyframes were added */
if (IS_AUTOKEY_ON(t->scene))
- WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
/* XXX temp, first hack to get auto-render in compositor work (ton) */
- WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM_DONE, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM_DONE, CTX_data_scene(C));
}
#if 0 // TRANSFORM_FIX_ME
- if (t->spacetype==SPACE_VIEW3D) {
+ if (t->spacetype == SPACE_VIEW3D) {
allqueue(REDRAWBUTSOBJECT, 0);
allqueue(REDRAWVIEW3D, 0);
}
- else if (t->spacetype==SPACE_IMAGE) {
+ else if (t->spacetype == SPACE_IMAGE) {
allqueue(REDRAWIMAGE, 0);
allqueue(REDRAWVIEW3D, 0);
}
@@ -469,7 +469,7 @@ void BIF_selectOrientation(void)
#if 0 // TRANSFORM_FIX_ME
short val;
char *str_menu = BIF_menustringTransformOrientation("Orientation");
- val= pupmenu(str_menu);
+ val = pupmenu(str_menu);
MEM_freeN(str_menu);
if (val >= 0) {
@@ -497,8 +497,8 @@ static void view_editmove(unsigned short UNUSED(event))
switch (event) {
case WHEELUPMOUSE:
- if ( G.qual & LR_SHIFTKEY ) {
- if ( G.qual & LR_ALTKEY ) {
+ if (G.qual & LR_SHIFTKEY) {
+ if (G.qual & LR_ALTKEY) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD2);
G.qual |= LR_SHIFTKEY;
@@ -507,8 +507,8 @@ static void view_editmove(unsigned short UNUSED(event))
persptoetsen(PAD2);
}
}
- else if ( G.qual & LR_CTRLKEY ) {
- if ( G.qual & LR_ALTKEY ) {
+ else if (G.qual & LR_CTRLKEY) {
+ if (G.qual & LR_ALTKEY) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD4);
G.qual |= LR_CTRLKEY;
@@ -525,8 +525,8 @@ static void view_editmove(unsigned short UNUSED(event))
refresh = 1;
break;
case WHEELDOWNMOUSE:
- if ( G.qual & LR_SHIFTKEY ) {
- if ( G.qual & LR_ALTKEY ) {
+ if (G.qual & LR_SHIFTKEY) {
+ if (G.qual & LR_ALTKEY) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD8);
G.qual |= LR_SHIFTKEY;
@@ -535,8 +535,8 @@ static void view_editmove(unsigned short UNUSED(event))
persptoetsen(PAD8);
}
}
- else if ( G.qual & LR_CTRLKEY ) {
- if ( G.qual & LR_ALTKEY ) {
+ else if (G.qual & LR_CTRLKEY) {
+ if (G.qual & LR_ALTKEY) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD6);
G.qual |= LR_CTRLKEY;
@@ -562,27 +562,27 @@ static void view_editmove(unsigned short UNUSED(event))
/* ************************************************* */
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
-#define TFM_MODAL_CANCEL 1
-#define TFM_MODAL_CONFIRM 2
-#define TFM_MODAL_TRANSLATE 3
-#define TFM_MODAL_ROTATE 4
-#define TFM_MODAL_RESIZE 5
-#define TFM_MODAL_SNAP_INV_ON 6
-#define TFM_MODAL_SNAP_INV_OFF 7
-#define TFM_MODAL_SNAP_TOGGLE 8
-#define TFM_MODAL_AXIS_X 9
-#define TFM_MODAL_AXIS_Y 10
-#define TFM_MODAL_AXIS_Z 11
-#define TFM_MODAL_PLANE_X 12
-#define TFM_MODAL_PLANE_Y 13
-#define TFM_MODAL_PLANE_Z 14
-#define TFM_MODAL_CONS_OFF 15
-#define TFM_MODAL_ADD_SNAP 16
-#define TFM_MODAL_REMOVE_SNAP 17
+#define TFM_MODAL_CANCEL 1
+#define TFM_MODAL_CONFIRM 2
+#define TFM_MODAL_TRANSLATE 3
+#define TFM_MODAL_ROTATE 4
+#define TFM_MODAL_RESIZE 5
+#define TFM_MODAL_SNAP_INV_ON 6
+#define TFM_MODAL_SNAP_INV_OFF 7
+#define TFM_MODAL_SNAP_TOGGLE 8
+#define TFM_MODAL_AXIS_X 9
+#define TFM_MODAL_AXIS_Y 10
+#define TFM_MODAL_AXIS_Z 11
+#define TFM_MODAL_PLANE_X 12
+#define TFM_MODAL_PLANE_Y 13
+#define TFM_MODAL_PLANE_Z 14
+#define TFM_MODAL_CONS_OFF 15
+#define TFM_MODAL_ADD_SNAP 16
+#define TFM_MODAL_REMOVE_SNAP 17
/* 18 and 19 used by numinput, defined in transform.h
* */
-#define TFM_MODAL_PROPSIZE_UP 20
-#define TFM_MODAL_PROPSIZE_DOWN 21
+#define TFM_MODAL_PROPSIZE_UP 20
+#define TFM_MODAL_PROPSIZE_DOWN 21
#define TFM_MODAL_AUTOIK_LEN_INC 22
#define TFM_MODAL_AUTOIK_LEN_DEC 23
@@ -590,42 +590,43 @@ static void view_editmove(unsigned short UNUSED(event))
#define TFM_MODAL_EDGESLIDE_DOWN 25
/* called in transform_ops.c, on each regeneration of keymaps */
-wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf)
+wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{
static EnumPropertyItem modal_items[] = {
- {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
- {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
- {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
- {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
- {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
- {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap On", ""},
- {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""},
- {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""},
- {TFM_MODAL_AXIS_X, "AXIS_X", 0, "Orientation X axis", ""},
- {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Orientation Y axis", ""},
- {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Orientation Z axis", ""},
- {TFM_MODAL_PLANE_X, "PLANE_X", 0, "Orientation X plane", ""},
- {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Orientation Y plane", ""},
- {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Orientation Z plane", ""},
- {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""},
- {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
- {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
- {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
- {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
- {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""},
- {TFM_MODAL_PROPSIZE_DOWN, "PROPORTIONAL_SIZE_DOWN", 0, "Decrease Proportional Influence", ""},
- {TFM_MODAL_AUTOIK_LEN_INC, "AUTOIK_CHAIN_LEN_UP", 0, "Increase Max AutoIK Chain Length", ""},
- {TFM_MODAL_AUTOIK_LEN_DEC, "AUTOIK_CHAIN_LEN_DOWN", 0, "Decrease Max AutoIK Chain Length", ""},
- {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select next Edge Slide Edge", ""},
- {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""},
- {0, NULL, 0, NULL, NULL}};
-
- wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map");
+ {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
+ {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
+ {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
+ {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
+ {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
+ {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap On", ""},
+ {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""},
+ {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""},
+ {TFM_MODAL_AXIS_X, "AXIS_X", 0, "Orientation X axis", ""},
+ {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Orientation Y axis", ""},
+ {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Orientation Z axis", ""},
+ {TFM_MODAL_PLANE_X, "PLANE_X", 0, "Orientation X plane", ""},
+ {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Orientation Y plane", ""},
+ {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Orientation Z plane", ""},
+ {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""},
+ {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
+ {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
+ {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
+ {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
+ {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""},
+ {TFM_MODAL_PROPSIZE_DOWN, "PROPORTIONAL_SIZE_DOWN", 0, "Decrease Proportional Influence", ""},
+ {TFM_MODAL_AUTOIK_LEN_INC, "AUTOIK_CHAIN_LEN_UP", 0, "Increase Max AutoIK Chain Length", ""},
+ {TFM_MODAL_AUTOIK_LEN_DEC, "AUTOIK_CHAIN_LEN_DOWN", 0, "Decrease Max AutoIK Chain Length", ""},
+ {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select next Edge Slide Edge", ""},
+ {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Transform Modal Map");
/* this function is called for each spacetype, only needs to add map once */
if (keymap && keymap->modal_items) return NULL;
- keymap= WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items);
+ keymap = WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items);
/* items for modal map */
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL);
@@ -695,8 +696,7 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
msg1[sizeof(msg1) - 2] = axis;
msg2[sizeof(msg2) - 2] = axis;
msg3[sizeof(msg3) - 2] = axis;
- constraint_plane = ((CON_AXIS0 | CON_AXIS1 | CON_AXIS2) &
- (~constraint_axis));
+ constraint_plane = ((CON_AXIS0 | CON_AXIS1 | CON_AXIS2) & (~constraint_axis));
if (edit_2d && (key_type != ZKEY)) {
if (cmode == axis) {
@@ -733,7 +733,7 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
int transformEvent(TransInfo *t, wmEvent *event)
{
- float mati[3][3]= MAT3_UNITY;
+ float mati[3][3] = MAT3_UNITY;
char cmode = constraintModeToChar(t);
int handled = 1;
@@ -767,7 +767,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
break;
case TFM_MODAL_TRANSLATE:
/* only switch when... */
- if ( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
+ if (ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
resetTransRestrictions(t);
restoreTransObjects(t);
initTranslation(t);
@@ -786,7 +786,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
case TFM_MODAL_ROTATE:
/* only switch when... */
if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
- if ( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
+ if (ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
resetTransRestrictions(t);
@@ -805,7 +805,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
break;
case TFM_MODAL_RESIZE:
/* only switch when... */
- if ( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
+ if (ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
resetTransRestrictions(t);
restoreTransObjects(t);
initResize(t);
@@ -835,7 +835,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
t->redraw |= TREDRAW_HARD;
break;
case TFM_MODAL_AXIS_X:
- if ((t->flag & T_NO_CONSTRAINT)==0) {
+ if ((t->flag & T_NO_CONSTRAINT) == 0) {
if (cmode == 'X') {
stopConstraint(t);
}
@@ -851,7 +851,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
}
break;
case TFM_MODAL_AXIS_Y:
- if ((t->flag & T_NO_CONSTRAINT)==0) {
+ if ((t->flag & T_NO_CONSTRAINT) == 0) {
if (cmode == 'Y') {
stopConstraint(t);
}
@@ -867,7 +867,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
}
break;
case TFM_MODAL_AXIS_Z:
- if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+ if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
if (cmode == 'Z') {
stopConstraint(t);
}
@@ -878,40 +878,40 @@ int transformEvent(TransInfo *t, wmEvent *event)
}
break;
case TFM_MODAL_PLANE_X:
- if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+ if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
if (cmode == 'X') {
stopConstraint(t);
}
else {
- setUserConstraint(t, t->current_orientation, (CON_AXIS1|CON_AXIS2), "locking %s X");
+ setUserConstraint(t, t->current_orientation, (CON_AXIS1 | CON_AXIS2), "locking %s X");
}
t->redraw |= TREDRAW_HARD;
}
break;
case TFM_MODAL_PLANE_Y:
- if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+ if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
if (cmode == 'Y') {
stopConstraint(t);
}
else {
- setUserConstraint(t, t->current_orientation, (CON_AXIS0|CON_AXIS2), "locking %s Y");
+ setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS2), "locking %s Y");
}
t->redraw |= TREDRAW_HARD;
}
break;
case TFM_MODAL_PLANE_Z:
- if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+ if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
if (cmode == 'Z') {
stopConstraint(t);
}
else {
- setUserConstraint(t, t->current_orientation, (CON_AXIS0|CON_AXIS1), "locking %s Z");
+ setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS1), "locking %s Z");
}
t->redraw |= TREDRAW_HARD;
}
break;
case TFM_MODAL_CONS_OFF:
- if ((t->flag & T_NO_CONSTRAINT)==0) {
+ if ((t->flag & T_NO_CONSTRAINT) == 0) {
stopConstraint(t);
t->redraw |= TREDRAW_HARD;
}
@@ -926,16 +926,16 @@ int transformEvent(TransInfo *t, wmEvent *event)
break;
case TFM_MODAL_PROPSIZE_UP:
if (t->flag & T_PROP_EDIT) {
- t->prop_size*= 1.1f;
- if (t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO)
- t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far);
+ t->prop_size *= 1.1f;
+ if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
+ t->prop_size = MIN2(t->prop_size, ((View3D *)t->view)->far);
calculatePropRatio(t);
}
t->redraw |= TREDRAW_HARD;
break;
case TFM_MODAL_PROPSIZE_DOWN:
if (t->flag & T_PROP_EDIT) {
- t->prop_size*= 0.90909090f;
+ t->prop_size *= 0.90909090f;
calculatePropRatio(t);
}
t->redraw |= TREDRAW_HARD;
@@ -965,170 +965,170 @@ int transformEvent(TransInfo *t, wmEvent *event)
/* else do non-mapped events */
else if (event->val == KM_PRESS) {
switch (event->type) {
- case RIGHTMOUSE:
- t->state = TRANS_CANCEL;
- break;
- /* enforce redraw of transform when modifiers are used */
- case LEFTSHIFTKEY:
- case RIGHTSHIFTKEY:
- t->modifiers |= MOD_CONSTRAINT_PLANE;
- t->redraw |= TREDRAW_HARD;
- break;
+ case RIGHTMOUSE:
+ t->state = TRANS_CANCEL;
+ break;
+ /* enforce redraw of transform when modifiers are used */
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY:
+ t->modifiers |= MOD_CONSTRAINT_PLANE;
+ t->redraw |= TREDRAW_HARD;
+ break;
- case SPACEKEY:
- if ((t->spacetype==SPACE_VIEW3D) && event->alt) {
+ case SPACEKEY:
+ if ((t->spacetype == SPACE_VIEW3D) && event->alt) {
#if 0 // TRANSFORM_FIX_ME
- int mval[2];
+ int mval[2];
- getmouseco_sc(mval);
- BIF_selectOrientation();
- calc_manipulator_stats(curarea);
- copy_m3_m4(t->spacemtx, G.vd->twmat);
- warp_pointer(mval[0], mval[1]);
+ getmouseco_sc(mval);
+ BIF_selectOrientation();
+ calc_manipulator_stats(curarea);
+ copy_m3_m4(t->spacemtx, G.vd->twmat);
+ warp_pointer(mval[0], mval[1]);
#endif
- }
- else {
- t->state = TRANS_CONFIRM;
- }
- break;
-
- case MIDDLEMOUSE:
- if ((t->flag & T_NO_CONSTRAINT)==0) {
- /* exception for switching to dolly, or trackball, in camera view */
- if (t->flag & T_CAMERA) {
- if (t->mode==TFM_TRANSLATION)
- setLocalConstraint(t, (CON_AXIS2), "along local Z");
- else if (t->mode==TFM_ROTATION) {
- restoreTransObjects(t);
- initTrackball(t);
- }
}
else {
- t->modifiers |= MOD_CONSTRAINT_SELECT;
- if (t->con.mode & CON_APPLY) {
- stopConstraint(t);
+ t->state = TRANS_CONFIRM;
+ }
+ break;
+
+ case MIDDLEMOUSE:
+ if ((t->flag & T_NO_CONSTRAINT) == 0) {
+ /* exception for switching to dolly, or trackball, in camera view */
+ if (t->flag & T_CAMERA) {
+ if (t->mode == TFM_TRANSLATION)
+ setLocalConstraint(t, (CON_AXIS2), "along local Z");
+ else if (t->mode == TFM_ROTATION) {
+ restoreTransObjects(t);
+ initTrackball(t);
+ }
}
else {
- if (event->shift) {
- initSelectConstraint(t, t->spacemtx);
+ t->modifiers |= MOD_CONSTRAINT_SELECT;
+ if (t->con.mode & CON_APPLY) {
+ stopConstraint(t);
}
else {
- /* bit hackish... but it prevents mmb select to print the orientation from menu */
- strcpy(t->spacename, "global");
- initSelectConstraint(t, mati);
+ if (event->shift) {
+ initSelectConstraint(t, t->spacemtx);
+ }
+ else {
+ /* bit hackish... but it prevents mmb select to print the orientation from menu */
+ strcpy(t->spacename, "global");
+ initSelectConstraint(t, mati);
+ }
+ postSelectConstraint(t);
}
- postSelectConstraint(t);
}
+ t->redraw |= TREDRAW_HARD;
}
- t->redraw |= TREDRAW_HARD;
- }
- break;
- case ESCKEY:
- t->state = TRANS_CANCEL;
- break;
- case PADENTER:
- case RETKEY:
- t->state = TRANS_CONFIRM;
- break;
- case GKEY:
- /* only switch when... */
- if ( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
- resetTransRestrictions(t);
- restoreTransObjects(t);
- initTranslation(t);
- initSnapping(t, NULL); // need to reinit after mode change
- t->redraw |= TREDRAW_HARD;
- }
- break;
- case SKEY:
- /* only switch when... */
- if ( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
- resetTransRestrictions(t);
- restoreTransObjects(t);
- initResize(t);
- initSnapping(t, NULL); // need to reinit after mode change
- t->redraw |= TREDRAW_HARD;
- }
- break;
- case RKEY:
- /* only switch when... */
- if (!(t->options & CTX_TEXTURE)) {
- if ( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
-
+ break;
+ case ESCKEY:
+ t->state = TRANS_CANCEL;
+ break;
+ case PADENTER:
+ case RETKEY:
+ t->state = TRANS_CONFIRM;
+ break;
+ case GKEY:
+ /* only switch when... */
+ if (ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
resetTransRestrictions(t);
+ restoreTransObjects(t);
+ initTranslation(t);
+ initSnapping(t, NULL); // need to reinit after mode change
+ t->redraw |= TREDRAW_HARD;
+ }
+ break;
+ case SKEY:
+ /* only switch when... */
+ if (ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
+ resetTransRestrictions(t);
+ restoreTransObjects(t);
+ initResize(t);
+ initSnapping(t, NULL); // need to reinit after mode change
+ t->redraw |= TREDRAW_HARD;
+ }
+ break;
+ case RKEY:
+ /* only switch when... */
+ if (!(t->options & CTX_TEXTURE)) {
+ if (ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
- if (t->mode == TFM_ROTATION) {
- restoreTransObjects(t);
- initTrackball(t);
- }
- else {
- restoreTransObjects(t);
- initRotation(t);
+ resetTransRestrictions(t);
+
+ if (t->mode == TFM_ROTATION) {
+ restoreTransObjects(t);
+ initTrackball(t);
+ }
+ else {
+ restoreTransObjects(t);
+ initRotation(t);
+ }
+ initSnapping(t, NULL); // need to reinit after mode change
+ t->redraw |= TREDRAW_HARD;
}
- initSnapping(t, NULL); // need to reinit after mode change
+ }
+ break;
+ case CKEY:
+ if (event->alt) {
+ t->flag ^= T_PROP_CONNECTED;
+ sort_trans_data_dist(t);
+ calculatePropRatio(t);
+ t->redraw = 1;
+ }
+ else {
+ stopConstraint(t);
t->redraw |= TREDRAW_HARD;
}
- }
- break;
- case CKEY:
- if (event->alt) {
- t->flag ^= T_PROP_CONNECTED;
- sort_trans_data_dist(t);
- calculatePropRatio(t);
- t->redraw= 1;
- }
- else {
- stopConstraint(t);
- t->redraw |= TREDRAW_HARD;
- }
- break;
- case XKEY:
- case YKEY:
- case ZKEY:
- transform_event_xyz_constraint(t, event->type, cmode);
- break;
- case OKEY:
- if (t->flag & T_PROP_EDIT && event->shift) {
- t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX;
- calculatePropRatio(t);
- t->redraw |= TREDRAW_HARD;
- }
- break;
- case PADPLUSKEY:
- if (event->alt && t->flag & T_PROP_EDIT) {
- t->prop_size *= 1.1f;
- if (t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO)
- t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far);
- calculatePropRatio(t);
- }
- t->redraw= 1;
- break;
- case PAGEUPKEY:
- case WHEELDOWNMOUSE:
- if (t->flag & T_AUTOIK) {
- transform_autoik_update(t, 1);
- }
- else view_editmove(event->type);
- t->redraw= 1;
- break;
- case PADMINUS:
- if (event->alt && t->flag & T_PROP_EDIT) {
- t->prop_size*= 0.90909090f;
- calculatePropRatio(t);
- }
- t->redraw= 1;
- break;
- case PAGEDOWNKEY:
- case WHEELUPMOUSE:
- if (t->flag & T_AUTOIK) {
- transform_autoik_update(t, -1);
- }
- else view_editmove(event->type);
- t->redraw= 1;
- break;
- default:
- handled = 0;
- break;
+ break;
+ case XKEY:
+ case YKEY:
+ case ZKEY:
+ transform_event_xyz_constraint(t, event->type, cmode);
+ break;
+ case OKEY:
+ if (t->flag & T_PROP_EDIT && event->shift) {
+ t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX;
+ calculatePropRatio(t);
+ t->redraw |= TREDRAW_HARD;
+ }
+ break;
+ case PADPLUSKEY:
+ if (event->alt && t->flag & T_PROP_EDIT) {
+ t->prop_size *= 1.1f;
+ if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
+ t->prop_size = MIN2(t->prop_size, ((View3D *)t->view)->far);
+ calculatePropRatio(t);
+ }
+ t->redraw = 1;
+ break;
+ case PAGEUPKEY:
+ case WHEELDOWNMOUSE:
+ if (t->flag & T_AUTOIK) {
+ transform_autoik_update(t, 1);
+ }
+ else view_editmove(event->type);
+ t->redraw = 1;
+ break;
+ case PADMINUS:
+ if (event->alt && t->flag & T_PROP_EDIT) {
+ t->prop_size *= 0.90909090f;
+ calculatePropRatio(t);
+ }
+ t->redraw = 1;
+ break;
+ case PAGEDOWNKEY:
+ case WHEELUPMOUSE:
+ if (t->flag & T_AUTOIK) {
+ transform_autoik_update(t, -1);
+ }
+ else view_editmove(event->type);
+ t->redraw = 1;
+ break;
+ default:
+ handled = 0;
+ break;
}
// Numerical input events
@@ -1138,30 +1138,30 @@ int transformEvent(TransInfo *t, wmEvent *event)
t->redraw |= handleSnapping(t, event);
}
- else if (event->val==KM_RELEASE) {
+ else if (event->val == KM_RELEASE) {
switch (event->type) {
- case LEFTSHIFTKEY:
- case RIGHTSHIFTKEY:
- t->modifiers &= ~MOD_CONSTRAINT_PLANE;
- t->redraw |= TREDRAW_HARD;
- break;
-
- case MIDDLEMOUSE:
- if ((t->flag & T_NO_CONSTRAINT)==0) {
- t->modifiers &= ~MOD_CONSTRAINT_SELECT;
- postSelectConstraint(t);
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY:
+ t->modifiers &= ~MOD_CONSTRAINT_PLANE;
t->redraw |= TREDRAW_HARD;
- }
- break;
+ break;
+
+ case MIDDLEMOUSE:
+ if ((t->flag & T_NO_CONSTRAINT) == 0) {
+ t->modifiers &= ~MOD_CONSTRAINT_SELECT;
+ postSelectConstraint(t);
+ t->redraw |= TREDRAW_HARD;
+ }
+ break;
// case LEFTMOUSE:
// case RIGHTMOUSE:
// if (WM_modal_tweak_exit(event, t->event_type))
//// if (t->options & CTX_TWEAK)
// t->state = TRANS_CONFIRM;
// break;
- default:
- handled = 0;
- break;
+ default:
+ handled = 0;
+ break;
}
/* confirm transform if launch key is released after mouse move */
@@ -1194,11 +1194,11 @@ int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int c
t->mode = TFM_DUMMY;
- initTransInfo(C, t, NULL, NULL); // internal data, mouse, vectors
+ initTransInfo(C, t, NULL, NULL); // internal data, mouse, vectors
- createTransData(C, t); // make TransData structs from selection
+ createTransData(C, t); // make TransData structs from selection
- t->around = centerMode; // override userdefined mode
+ t->around = centerMode; // override userdefined mode
if (t->total == 0) {
success = FALSE;
@@ -1302,7 +1302,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
glBegin(GL_LINE_STRIP);
- for ( angle = angle_start; angle < angle_end; angle += delta) {
+ for (angle = angle_start; angle < angle_end; angle += delta) {
glVertex2f(cosf(angle) * size, sinf(angle) * size);
}
glVertex2f(cosf(angle_end) * size, sinf(angle_end) * size);
@@ -1312,35 +1312,35 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
static int helpline_poll(bContext *C)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
- if (ar && ar->regiontype==RGN_TYPE_WINDOW)
+ if (ar && ar->regiontype == RGN_TYPE_WINDOW)
return 1;
return 0;
}
static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
{
- TransInfo *t = (TransInfo*)customdata;
+ TransInfo *t = (TransInfo *)customdata;
if (t->helpline != HLP_NONE && !(t->flag & T_USES_MANIPULATOR)) {
float vecrot[3], cent[2];
int mval[2];
- mval[0]= x;
- mval[1]= y;
+ mval[0] = x;
+ mval[1] = y;
copy_v3_v3(vecrot, t->center);
if (t->flag & T_EDIT) {
- Object *ob= t->obedit;
+ Object *ob = t->obedit;
if (ob) mul_m4_v3(ob->obmat, vecrot);
}
else if (t->flag & T_POSE) {
- Object *ob=t->poseobj;
+ Object *ob = t->poseobj;
if (ob) mul_m4_v3(ob->obmat, vecrot);
}
- projectFloatView(t, vecrot, cent); // no overflow in extreme cases
+ projectFloatView(t, vecrot, cent); // no overflow in extreme cases
glPushMatrix();
@@ -1385,67 +1385,67 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
glLineWidth(1.0);
break;
case HLP_ANGLE:
- {
- float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
- float angle = atan2f(dy, dx);
- float dist = sqrtf(dx*dx + dy*dy);
- float delta_angle = MIN2(15.0f / dist, (float)M_PI/4.0f);
- float spacing_angle = MIN2(5.0f / dist, (float)M_PI/12.0f);
- UI_ThemeColor(TH_WIRE);
+ {
+ float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
+ float angle = atan2f(dy, dx);
+ float dist = sqrtf(dx * dx + dy * dy);
+ float delta_angle = MIN2(15.0f / dist, (float)M_PI / 4.0f);
+ float spacing_angle = MIN2(5.0f / dist, (float)M_PI / 12.0f);
+ UI_ThemeColor(TH_WIRE);
- setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2iv(t->mval);
- glVertex2fv(cent);
- glEnd();
+ setlinestyle(3);
+ glBegin(GL_LINE_STRIP);
+ glVertex2iv(t->mval);
+ glVertex2fv(cent);
+ glEnd();
- glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0);
+ glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0);
- setlinestyle(0);
- glLineWidth(3.0);
- drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
- drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
+ setlinestyle(0);
+ glLineWidth(3.0);
+ drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
+ drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
- glPushMatrix();
+ glPushMatrix();
- glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
- glRotatef(RAD2DEGF(angle - delta_angle), 0, 0, 1);
+ glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
+ glRotatef(RAD2DEGF(angle - delta_angle), 0, 0, 1);
- drawArrowHead(DOWN, 5);
+ drawArrowHead(DOWN, 5);
- glPopMatrix();
+ glPopMatrix();
- glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
- glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1);
+ glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
+ glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1);
- drawArrowHead(UP, 5);
+ drawArrowHead(UP, 5);
- glLineWidth(1.0);
- break;
- }
- case HLP_TRACKBALL:
- {
- unsigned char col[3], col2[3];
- UI_GetThemeColor3ubv(TH_GRID, col);
+ glLineWidth(1.0);
+ break;
+ }
+ case HLP_TRACKBALL:
+ {
+ unsigned char col[3], col2[3];
+ UI_GetThemeColor3ubv(TH_GRID, col);
- glTranslatef(mval[0], mval[1], 0);
+ glTranslatef(mval[0], mval[1], 0);
- glLineWidth(3.0);
+ glLineWidth(3.0);
- UI_make_axis_color(col, col2, 'X');
- glColor3ubv((GLubyte *)col2);
+ UI_make_axis_color(col, col2, 'X');
+ glColor3ubv((GLubyte *)col2);
- drawArrow(RIGHT, 5, 10, 5);
- drawArrow(LEFT, 5, 10, 5);
+ drawArrow(RIGHT, 5, 10, 5);
+ drawArrow(LEFT, 5, 10, 5);
- UI_make_axis_color(col, col2, 'Y');
- glColor3ubv((GLubyte *)col2);
+ UI_make_axis_color(col, col2, 'Y');
+ glColor3ubv((GLubyte *)col2);
- drawArrow(UP, 5, 10, 5);
- drawArrow(DOWN, 5, 10, 5);
- glLineWidth(1.0);
- break;
- }
+ drawArrow(UP, 5, 10, 5);
+ drawArrow(DOWN, 5, 10, 5);
+ glLineWidth(1.0);
+ break;
+ }
}
glPopMatrix();
@@ -1479,12 +1479,12 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
PropertyRNA *prop;
// Save back mode in case we're in the generic operator
- if ((prop= RNA_struct_find_property(op->ptr, "mode"))) {
+ if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
RNA_property_enum_set(op->ptr, prop, t->mode);
}
- if ((prop= RNA_struct_find_property(op->ptr, "value"))) {
- float *values= (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
+ if ((prop = RNA_struct_find_property(op->ptr, "value"))) {
+ float *values = (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
if (RNA_property_array_check(prop)) {
RNA_property_float_set_array(op->ptr, prop, values);
}
@@ -1494,8 +1494,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
/* convert flag to enum */
- switch (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
- case (T_PROP_EDIT|T_PROP_CONNECTED):
+ switch (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ case (T_PROP_EDIT | T_PROP_CONNECTED):
proportional = PROP_EDIT_CONNECTED;
break;
case T_PROP_EDIT:
@@ -1604,7 +1604,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->state = TRANS_STARTING;
- if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
+ if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
if (RNA_property_boolean_get(op->ptr, prop)) {
options |= CTX_TEXTURE;
}
@@ -1655,7 +1655,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
else
unit_m3(t->spacemtx);
- createTransData(C, t); // make TransData structs from selection
+ createTransData(C, t); // make TransData structs from selection
if (t->total == 0) {
postTrans(C, t);
@@ -1695,114 +1695,114 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
initMouseInput(t, &t->mouse, t->center2d, t->imval);
switch (mode) {
- case TFM_TRANSLATION:
- initTranslation(t);
- break;
- case TFM_ROTATION:
- initRotation(t);
- break;
- case TFM_RESIZE:
- initResize(t);
- break;
- case TFM_SKIN_RESIZE:
- initSkinResize(t);
- break;
- case TFM_TOSPHERE:
- initToSphere(t);
- break;
- case TFM_SHEAR:
- initShear(t);
- break;
- case TFM_WARP:
- initWarp(t);
- break;
- case TFM_SHRINKFATTEN:
- initShrinkFatten(t);
- break;
- case TFM_TILT:
- initTilt(t);
- break;
- case TFM_CURVE_SHRINKFATTEN:
- initCurveShrinkFatten(t);
- break;
- case TFM_MASK_SHRINKFATTEN:
- initMaskShrinkFatten(t);
- break;
- case TFM_TRACKBALL:
- initTrackball(t);
- break;
- case TFM_PUSHPULL:
- initPushPull(t);
- break;
- case TFM_CREASE:
- initCrease(t);
- break;
- case TFM_BONESIZE:
- { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
- bArmature *arm= t->poseobj->data;
- if (arm->drawtype==ARM_ENVELOPE)
+ case TFM_TRANSLATION:
+ initTranslation(t);
+ break;
+ case TFM_ROTATION:
+ initRotation(t);
+ break;
+ case TFM_RESIZE:
+ initResize(t);
+ break;
+ case TFM_SKIN_RESIZE:
+ initSkinResize(t);
+ break;
+ case TFM_TOSPHERE:
+ initToSphere(t);
+ break;
+ case TFM_SHEAR:
+ initShear(t);
+ break;
+ case TFM_WARP:
+ initWarp(t);
+ break;
+ case TFM_SHRINKFATTEN:
+ initShrinkFatten(t);
+ break;
+ case TFM_TILT:
+ initTilt(t);
+ break;
+ case TFM_CURVE_SHRINKFATTEN:
+ initCurveShrinkFatten(t);
+ break;
+ case TFM_MASK_SHRINKFATTEN:
+ initMaskShrinkFatten(t);
+ break;
+ case TFM_TRACKBALL:
+ initTrackball(t);
+ break;
+ case TFM_PUSHPULL:
+ initPushPull(t);
+ break;
+ case TFM_CREASE:
+ initCrease(t);
+ break;
+ case TFM_BONESIZE:
+ { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
+ bArmature *arm = t->poseobj->data;
+ if (arm->drawtype == ARM_ENVELOPE)
initBoneEnvelope(t);
else
initBoneSize(t);
}
break;
- case TFM_BONE_ENVELOPE:
- initBoneEnvelope(t);
- break;
- case TFM_EDGE_SLIDE:
- initEdgeSlide(t);
- break;
- case TFM_BONE_ROLL:
- initBoneRoll(t);
- break;
- case TFM_TIME_TRANSLATE:
- initTimeTranslate(t);
- break;
- case TFM_TIME_SLIDE:
- initTimeSlide(t);
- break;
- case TFM_TIME_SCALE:
- initTimeScale(t);
- break;
- case TFM_TIME_DUPLICATE:
- /* same as TFM_TIME_EXTEND, but we need the mode info for later
- * so that duplicate-culling will work properly
- */
- if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
- initTranslation(t);
- else
- initTimeTranslate(t);
- t->mode = mode;
- break;
- case TFM_TIME_EXTEND:
- /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
- * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
- * (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
- * depending on which editor this was called from
- */
- if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
- initTranslation(t);
- else
+ case TFM_BONE_ENVELOPE:
+ initBoneEnvelope(t);
+ break;
+ case TFM_EDGE_SLIDE:
+ initEdgeSlide(t);
+ break;
+ case TFM_BONE_ROLL:
+ initBoneRoll(t);
+ break;
+ case TFM_TIME_TRANSLATE:
initTimeTranslate(t);
- break;
- case TFM_BAKE_TIME:
- initBakeTime(t);
- break;
- case TFM_MIRROR:
- initMirror(t);
- break;
- case TFM_BEVEL:
- initBevel(t);
- break;
- case TFM_BWEIGHT:
- initBevelWeight(t);
- break;
- case TFM_ALIGN:
- initAlign(t);
- break;
- case TFM_SEQ_SLIDE:
- initSeqSlide(t);
- break;
+ break;
+ case TFM_TIME_SLIDE:
+ initTimeSlide(t);
+ break;
+ case TFM_TIME_SCALE:
+ initTimeScale(t);
+ break;
+ case TFM_TIME_DUPLICATE:
+ /* same as TFM_TIME_EXTEND, but we need the mode info for later
+ * so that duplicate-culling will work properly
+ */
+ if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
+ initTranslation(t);
+ else
+ initTimeTranslate(t);
+ t->mode = mode;
+ break;
+ case TFM_TIME_EXTEND:
+ /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
+ * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
+ * (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
+ * depending on which editor this was called from
+ */
+ if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
+ initTranslation(t);
+ else
+ initTimeTranslate(t);
+ break;
+ case TFM_BAKE_TIME:
+ initBakeTime(t);
+ break;
+ case TFM_MIRROR:
+ initMirror(t);
+ break;
+ case TFM_BEVEL:
+ initBevel(t);
+ break;
+ case TFM_BWEIGHT:
+ initBevelWeight(t);
+ break;
+ case TFM_ALIGN:
+ initAlign(t);
+ break;
+ case TFM_SEQ_SLIDE:
+ initSeqSlide(t);
+ break;
}
if (t->state == TRANS_CANCEL) {
@@ -1813,13 +1813,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
/* overwrite initial values if operator supplied a non-null vector */
if ((prop = RNA_struct_find_property(op->ptr, "value")) && RNA_property_is_set(op->ptr, prop)) {
- float values[4]= {0}; /* in case value isn't length 4, avoid uninitialized memory */
+ float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory */
if (RNA_property_array_check(prop)) {
RNA_float_get_array(op->ptr, "value", values);
}
else {
- values[0]= RNA_float_get(op->ptr, "value");
+ values[0] = RNA_float_get(op->ptr, "value");
}
copy_v4_v4(t->values, values);
@@ -1915,11 +1915,11 @@ int transformEnd(bContext *C, TransInfo *t)
/* handle restoring objects */
if (t->state == TRANS_CANCEL) {
/* exception, edge slide transformed UVs too */
- if (t->mode==TFM_EDGE_SLIDE)
+ if (t->mode == TFM_EDGE_SLIDE)
doEdgeSlide(t, 0.0f);
exit_code = OPERATOR_CANCELLED;
- restoreTransObjects(t); // calls recalcData()
+ restoreTransObjects(t); // calls recalcData()
}
else {
exit_code = OPERATOR_FINISHED;
@@ -1943,7 +1943,7 @@ int transformEnd(bContext *C, TransInfo *t)
// if (t->undostr) ED_undo_push(C, t->undostr);
// else ED_undo_push(C, transform_to_undostr(t));
}
- t->undostr= NULL;
+ t->undostr = NULL;
viewRedrawForce(C, t);
}
@@ -1958,31 +1958,31 @@ int transformEnd(bContext *C, TransInfo *t)
static void protectedTransBits(short protectflag, float *vec)
{
if (protectflag & OB_LOCK_LOCX)
- vec[0]= 0.0f;
+ vec[0] = 0.0f;
if (protectflag & OB_LOCK_LOCY)
- vec[1]= 0.0f;
+ vec[1] = 0.0f;
if (protectflag & OB_LOCK_LOCZ)
- vec[2]= 0.0f;
+ vec[2] = 0.0f;
}
static void protectedSizeBits(short protectflag, float *size)
{
if (protectflag & OB_LOCK_SCALEX)
- size[0]= 1.0f;
+ size[0] = 1.0f;
if (protectflag & OB_LOCK_SCALEY)
- size[1]= 1.0f;
+ size[1] = 1.0f;
if (protectflag & OB_LOCK_SCALEZ)
- size[2]= 1.0f;
+ size[2] = 1.0f;
}
static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
{
if (protectflag & OB_LOCK_ROTX)
- eul[0]= oldeul[0];
+ eul[0] = oldeul[0];
if (protectflag & OB_LOCK_ROTY)
- eul[1]= oldeul[1];
+ eul[1] = oldeul[1];
if (protectflag & OB_LOCK_ROTZ)
- eul[2]= oldeul[2];
+ eul[2] = oldeul[2];
}
@@ -1991,19 +1991,19 @@ static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
static void protectedAxisAngleBits(short protectflag, float axis[3], float *angle, float oldAxis[3], float oldAngle)
{
/* check that protection flags are set */
- if ((protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) == 0)
+ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
return;
if (protectflag & OB_LOCK_ROT4D) {
/* axis-angle getting limited as 4D entities that they are... */
if (protectflag & OB_LOCK_ROTW)
- *angle= oldAngle;
+ *angle = oldAngle;
if (protectflag & OB_LOCK_ROTX)
- axis[0]= oldAxis[0];
+ axis[0] = oldAxis[0];
if (protectflag & OB_LOCK_ROTY)
- axis[1]= oldAxis[1];
+ axis[1] = oldAxis[1];
if (protectflag & OB_LOCK_ROTZ)
- axis[2]= oldAxis[2];
+ axis[2] = oldAxis[2];
}
else {
/* axis-angle get limited with euler... */
@@ -2013,18 +2013,18 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle);
if (protectflag & OB_LOCK_ROTX)
- eul[0]= oldeul[0];
+ eul[0] = oldeul[0];
if (protectflag & OB_LOCK_ROTY)
- eul[1]= oldeul[1];
+ eul[1] = oldeul[1];
if (protectflag & OB_LOCK_ROTZ)
- eul[2]= oldeul[2];
+ eul[2] = oldeul[2];
eulO_to_axis_angle(axis, angle, eul, EULER_ORDER_DEFAULT);
/* when converting to axis-angle, we need a special exception for the case when there is no axis */
if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
/* for now, rotate around y-axis then (so that it simply becomes the roll) */
- axis[1]= 1.0f;
+ axis[1] = 1.0f;
}
}
}
@@ -2033,37 +2033,37 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
static void protectedQuaternionBits(short protectflag, float *quat, float *oldquat)
{
/* check that protection flags are set */
- if ((protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) == 0)
+ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
return;
if (protectflag & OB_LOCK_ROT4D) {
/* quaternions getting limited as 4D entities that they are... */
if (protectflag & OB_LOCK_ROTW)
- quat[0]= oldquat[0];
+ quat[0] = oldquat[0];
if (protectflag & OB_LOCK_ROTX)
- quat[1]= oldquat[1];
+ quat[1] = oldquat[1];
if (protectflag & OB_LOCK_ROTY)
- quat[2]= oldquat[2];
+ quat[2] = oldquat[2];
if (protectflag & OB_LOCK_ROTZ)
- quat[3]= oldquat[3];
+ quat[3] = oldquat[3];
}
else {
/* quaternions get limited with euler... (compatibility mode) */
float eul[3], oldeul[3], nquat[4], noldquat[4];
float qlen;
- qlen= normalize_qt_qt(nquat, quat);
+ qlen = normalize_qt_qt(nquat, quat);
normalize_qt_qt(noldquat, oldquat);
quat_to_eul(eul, nquat);
quat_to_eul(oldeul, noldquat);
if (protectflag & OB_LOCK_ROTX)
- eul[0]= oldeul[0];
+ eul[0] = oldeul[0];
if (protectflag & OB_LOCK_ROTY)
- eul[1]= oldeul[1];
+ eul[1] = oldeul[1];
if (protectflag & OB_LOCK_ROTZ)
- eul[2]= oldeul[2];
+ eul[2] = oldeul[2];
eul_to_quat(quat, eul);
@@ -2071,7 +2071,9 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
mul_qt_fl(quat, qlen);
/* quaternions flip w sign to accumulate rotations correctly */
- if ( (nquat[0]<0.0f && quat[0]>0.0f) || (nquat[0]>0.0f && quat[0]<0.0f) ) {
+ if ((nquat[0] < 0.0f && quat[0] > 0.0f) ||
+ (nquat[0] > 0.0f && quat[0] < 0.0f))
+ {
mul_qt_fl(quat, -1.0f);
}
}
@@ -2082,22 +2084,22 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
static void constraintTransLim(TransInfo *t, TransData *td)
{
if (td->con) {
- bConstraintTypeInfo *ctiLoc= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
- bConstraintTypeInfo *ctiDist= get_constraint_typeinfo(CONSTRAINT_TYPE_DISTLIMIT);
+ bConstraintTypeInfo *ctiLoc = get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
+ bConstraintTypeInfo *ctiDist = get_constraint_typeinfo(CONSTRAINT_TYPE_DISTLIMIT);
- bConstraintOb cob= {NULL};
+ bConstraintOb cob = {NULL};
bConstraint *con;
float ctime = (float)(t->scene->r.cfra);
/* Make a temporary bConstraintOb for using these limit constraints
- * - they only care that cob->matrix is correctly set ;-)
+ * - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
unit_m4(cob.matrix);
copy_v3_v3(cob.matrix[3], td->loc);
/* Evaluate valid constraints */
- for (con= td->con; con; con= con->next) {
+ for (con = td->con; con; con = con->next) {
bConstraintTypeInfo *cti = NULL;
ListBase targets = {NULL, NULL};
float tmat[4][4];
@@ -2108,16 +2110,16 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* only use it if it's tagged for this purpose (and the right type) */
if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
- bLocLimitConstraint *data= con->data;
+ bLocLimitConstraint *data = con->data;
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0)
continue;
cti = ctiLoc;
}
else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) {
- bDistLimitConstraint *data= con->data;
+ bDistLimitConstraint *data = con->data;
- if ((data->flag & LIMITDIST_TRANSFORM)==0)
+ if ((data->flag & LIMITDIST_TRANSFORM) == 0)
continue;
cti = ctiDist;
}
@@ -2160,7 +2162,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
{
/* Make a temporary bConstraintOb for use by limit constraints
- * - they only care that cob->matrix is correctly set ;-)
+ * - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
memset(cob, 0, sizeof(bConstraintOb));
@@ -2168,8 +2170,8 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
if (td->ext->rotOrder == ROT_MODE_QUAT) {
/* quats */
/* objects and bones do normalization first too, otherwise
- * we don't necessarily end up with a rotation matrix, and
- * then conversion back to quat gives a different result */
+ * we don't necessarily end up with a rotation matrix, and
+ * then conversion back to quat gives a different result */
float quat[4];
normalize_qt_qt(quat, td->ext->quat);
quat_to_mat4(cob->matrix, quat);
@@ -2188,24 +2190,24 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
{
if (td->con) {
- bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT);
+ bConstraintTypeInfo *cti = get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT);
bConstraintOb cob;
bConstraint *con;
int do_limit = FALSE;
/* Evaluate valid constraints */
- for (con= td->con; con; con= con->next) {
+ for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
- bRotLimitConstraint *data= con->data;
+ bRotLimitConstraint *data = con->data;
float tmat[4][4];
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0)
continue;
/* skip incompatable spacetypes */
@@ -2258,12 +2260,12 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
static void constraintSizeLim(TransInfo *t, TransData *td)
{
if (td->con && td->ext) {
- bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
- bConstraintOb cob= {NULL};
+ bConstraintTypeInfo *cti = get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
+ bConstraintOb cob = {NULL};
bConstraint *con;
/* Make a temporary bConstraintOb for using these limit constraints
- * - they only care that cob->matrix is correctly set ;-)
+ * - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
@@ -2279,18 +2281,18 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
/* Evaluate valid constraints */
- for (con= td->con; con; con= con->next) {
+ for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
- bSizeLimitConstraint *data= con->data;
+ bSizeLimitConstraint *data = con->data;
float tmat[4][4];
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0)
continue;
/* do space conversions */
@@ -2381,8 +2383,8 @@ void initWarp(TransInfo *t)
mid_v3_v3v3(t->center, min, max);
- if (max[0] == min[0]) max[0] += 0.1f; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */
- t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */
+ if (max[0] == min[0]) max[0] += 0.1f; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */
+ t->val = (max[0] - min[0]) / 2.0f; /* t->val is X dimension projected boundbox */
}
int handleEventWarp(TransInfo *t, wmEvent *event)
@@ -2409,7 +2411,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
int i;
char str[50];
- curs= give_cursor(t->scene, t->view);
+ curs = give_cursor(t->scene, t->view);
/*
* gcursor is the one used for helpline.
* It has to be in the same space as the drawing loop
@@ -2469,18 +2471,18 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
mul_m4_v3(t->viewmat, vec);
sub_v3_v3(vec, t->viewmat[3]);
- dist= vec[0]-cursor[0];
+ dist = vec[0] - cursor[0];
/* t->val is X dimension projected boundbox */
- phi0= (circumfac*dist/t->val);
+ phi0 = (circumfac * dist / t->val);
- vec[1]= (vec[1]-cursor[1]);
+ vec[1] = (vec[1] - cursor[1]);
- co= (float)cos(phi0);
- si= (float)sin(phi0);
- loc[0]= -si*vec[1]+cursor[0];
- loc[1]= co*vec[1]+cursor[1];
- loc[2]= vec[2];
+ co = (float)cos(phi0);
+ si = (float)sin(phi0);
+ loc[0] = -si * vec[1] + cursor[0];
+ loc[1] = co * vec[1] + cursor[1];
+ loc[2] = vec[2];
mul_m4_v3(t->viewinv, loc);
sub_v3_v3(loc, t->viewinv[3]);
@@ -2533,7 +2535,7 @@ int handleEventShear(TransInfo *t, wmEvent *event)
// Use customData pointer to signal Shear direction
if (t->customData == NULL) {
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
- t->customData = (void*)1;
+ t->customData = (void *)1;
}
else {
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
@@ -2591,7 +2593,7 @@ int Shear(TransInfo *t, const int UNUSED(mval[2]))
mul_m3_m3m3(tmat, smat, persmat);
mul_m3_m3m3(totmat, persinv, tmat);
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -2654,7 +2656,7 @@ void initResize(TransInfo *t)
static void headerResize(TransInfo *t, float vec[3], char *str)
{
char tvec[60];
- char *spos= str;
+ char *spos = str;
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
}
@@ -2666,14 +2668,14 @@ static void headerResize(TransInfo *t, float vec[3], char *str)
if (t->con.mode & CON_APPLY) {
switch (t->num.idx_max) {
- case 0:
- spos += sprintf(spos, "Scale: %s%s %s", &tvec[0], t->con.text, t->proptext);
- break;
- case 1:
- spos += sprintf(spos, "Scale: %s : %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
- break;
- case 2:
- spos += sprintf(spos, "Scale: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+ case 0:
+ spos += sprintf(spos, "Scale: %s%s %s", &tvec[0], t->con.text, t->proptext);
+ break;
+ case 1:
+ spos += sprintf(spos, "Scale: %s : %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
+ break;
+ case 2:
+ spos += sprintf(spos, "Scale: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
}
}
else {
@@ -2683,15 +2685,15 @@ static void headerResize(TransInfo *t, float vec[3], char *str)
spos += sprintf(spos, "Scale X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
}
- if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
}
(void)spos;
}
-#define SIGN(a) (a<-FLT_EPSILON?1:a>FLT_EPSILON?2:3)
-#define VECSIGNFLIP(a, b) ((SIGN(a[0]) & SIGN(b[0]))==0 || (SIGN(a[1]) & SIGN(b[1]))==0 || (SIGN(a[2]) & SIGN(b[2]))==0)
+#define SIGN(a) (a<-FLT_EPSILON ? 1 : a>FLT_EPSILON ? 2 : 3)
+#define VECSIGNFLIP(a, b) ((SIGN(a[0]) & SIGN(b[0])) == 0 || (SIGN(a[1]) & SIGN(b[1])) == 0 || (SIGN(a[2]) & SIGN(b[2])) == 0)
/* smat is reference matrix, only scaled */
static void TransMat3ToSize(float mat[][3], float smat[][3], float *size)
@@ -2699,16 +2701,16 @@ static void TransMat3ToSize(float mat[][3], float smat[][3], float *size)
float vec[3];
copy_v3_v3(vec, mat[0]);
- size[0]= normalize_v3(vec);
+ size[0] = normalize_v3(vec);
copy_v3_v3(vec, mat[1]);
- size[1]= normalize_v3(vec);
+ size[1] = normalize_v3(vec);
copy_v3_v3(vec, mat[2]);
- size[2]= normalize_v3(vec);
+ size[2] = normalize_v3(vec);
/* first tried with dotproduct... but the sign flip is crucial */
- if ( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0];
- if ( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1];
- if ( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2];
+ if (VECSIGNFLIP(mat[0], smat[0]) ) size[0] = -size[0];
+ if (VECSIGNFLIP(mat[1], smat[1]) ) size[1] = -size[1];
+ if (VECSIGNFLIP(mat[2], smat[2]) ) size[2] = -size[2];
}
@@ -2731,10 +2733,10 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
/* local constraint shouldn't alter center */
if ((t->around == V3D_LOCAL) &&
- ( (t->flag & (T_OBJECT|T_POSE)) ||
- ((t->flag & T_EDIT) && (t->settings->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE))) ||
- (t->obedit && t->obedit->type == OB_ARMATURE))
- )
+ ( (t->flag & (T_OBJECT | T_POSE)) ||
+ ((t->flag & T_EDIT) && (t->settings->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_FACE))) ||
+ (t->obedit && t->obedit->type == OB_ARMATURE))
+ )
{
copy_v3_v3(center, td->center);
}
@@ -2748,7 +2750,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
if (td->ext) {
float fsize[3];
- if (t->flag & (T_OBJECT|T_TEXTURE|T_POSE)) {
+ if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) {
float obsizemat[3][3];
// Reorient the size mat to fit the oriented object.
mul_m3_m3m3(obsizemat, tmat, td->axismtx);
@@ -2762,19 +2764,19 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
protectedSizeBits(td->protectflag, fsize);
- if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't resize objects itself
+ if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't resize objects itself
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
- *td->val = td->ival * (1 + (fsize[0] - 1) * td->factor);
+ *td->val = td->ival * (1 + (fsize[0] - 1) * td->factor);
td->ext->size[0] = td->ext->isize[0];
td->ext->size[1] = td->ext->isize[1];
td->ext->size[2] = td->ext->isize[2];
- }
+ }
else {
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
- *td->val = td->ival;
+ *td->val = td->ival;
td->ext->size[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor);
td->ext->size[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor);
@@ -2801,7 +2803,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
mul_v3_fl(vec, td->factor);
- if (t->flag & (T_OBJECT|T_POSE)) {
+ if (t->flag & (T_OBJECT | T_POSE)) {
mul_m3_v3(td->smtx, vec);
}
@@ -2818,10 +2820,10 @@ int Resize(TransInfo *t, const int mval[2])
float ratio;
int i;
char str[200];
-
+
/* for manipulator, center handle, the scaling can't be done relative to center */
- if ( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) {
- ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
+ if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
+ ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f;
}
else {
ratio = t->values[0];
@@ -2850,11 +2852,11 @@ int Resize(TransInfo *t, const int mval[2])
t->con.applySize(t, NULL, mat);
}
- copy_m3_m3(t->mat, mat); // used in manipulator
+ copy_m3_m3(t->mat, mat); // used in manipulator
headerResize(t, size, str);
- for (i = 0, td=t->data; i < t->total; i++, td++) {
+ for (i = 0, td = t->data; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -2871,7 +2873,7 @@ int Resize(TransInfo *t, const int mval[2])
if (t->con.applySize)
t->con.applySize(t, NULL, mat);
- for (i = 0, td=t->data; i < t->total; i++, td++)
+ for (i = 0, td = t->data; i < t->total; i++, td++)
ElementResize(t, td, mat);
}
@@ -2996,7 +2998,7 @@ void initToSphere(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
// Calculate average radius
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
t->val += len_v3v3(t->center, td->iloc);
}
@@ -3038,7 +3040,7 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
float tratio;
if (td->flag & TD_NOACTION)
break;
@@ -3086,7 +3088,7 @@ void initRotation(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = (float)((5.0/180)*M_PI);
+ t->snap[1] = (float)((5.0 / 180) * M_PI);
t->snap[2] = t->snap[1] * 0.2f;
t->num.increment = 1.0f;
@@ -3108,8 +3110,8 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* local constraint shouldn't alter center */
if (around == V3D_LOCAL) {
- if ( (t->flag & (T_OBJECT|T_POSE)) ||
- (t->settings->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE)) ||
+ if ( (t->flag & (T_OBJECT | T_POSE)) ||
+ (t->settings->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_FACE)) ||
(t->obedit && t->obedit->type == OB_ARMATURE))
{
center = td->center;
@@ -3136,7 +3138,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
if (td->flag & TD_USEQUAT) {
mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
- mat3_to_quat(quat, fmat); // Actual transform
+ mat3_to_quat(quat, fmat); // Actual transform
if (td->ext->quat) {
mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
@@ -3168,9 +3170,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
if ((td->flag & TD_NO_LOC) == 0) {
sub_v3_v3v3(vec, td->center, center);
- mul_m3_v3(pmtx, vec); // To Global space
- mul_m3_v3(mat, vec); // Applying rotation
- mul_m3_v3(imtx, vec); // To Local space
+ mul_m3_v3(pmtx, vec); // To Global space
+ mul_m3_v3(mat, vec); // Applying rotation
+ mul_m3_v3(imtx, vec); // To Local space
add_v3_v3(vec, center);
/* vec now is the location where the object has to be */
@@ -3182,12 +3184,12 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* do nothing */
}
else if (td->flag & TD_PBONE_LOCAL_MTX_C) {
- mul_m3_v3(pmtx, vec); // To Global space
- mul_m3_v3(td->ext->l_smtx, vec);// To Pose space (Local Location)
+ mul_m3_v3(pmtx, vec); // To Global space
+ mul_m3_v3(td->ext->l_smtx, vec); // To Pose space (Local Location)
}
else {
- mul_m3_v3(pmtx, vec); // To Global space
- mul_m3_v3(td->smtx, vec);// To Pose space
+ mul_m3_v3(pmtx, vec); // To Global space
+ mul_m3_v3(td->smtx, vec); // To Pose space
}
protectedTransBits(td->protectflag, vec);
@@ -3202,7 +3204,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
* and ElementRotation() might be called in Translation context (with align snapping),
* we need to be sure to actually use the *rotation* matrix here...
* So no other way than storing it in some dedicated members of td->ext! */
- if ((t->flag & T_V3D_ALIGN)==0) { /* align mode doesn't rotate objects itself */
+ if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't rotate objects itself */
/* euler or quaternion/axis-angle? */
if (td->ext->rotOrder == ROT_MODE_QUAT) {
mul_serie_m3(fmat, td->ext->r_mtx, mat, td->ext->r_smtx, NULL, NULL, NULL, NULL, NULL);
@@ -3271,11 +3273,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
constraintTransLim(t, td);
/* rotation */
- if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
+ if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't rotate objects itself
/* euler or quaternion? */
if ((td->ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) {
mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
- mat3_to_quat(quat, fmat); // Actual transform
+ mat3_to_quat(quat, fmat); // Actual transform
mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
/* this function works on end result */
@@ -3288,7 +3290,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
- mat3_to_quat(quat, fmat); // Actual transform
+ mat3_to_quat(quat, fmat); // Actual transform
mul_qt_qtqt(tquat, quat, iquat);
quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat);
@@ -3331,7 +3333,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
vec_rot_to_mat3(mat, axis, angle);
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3353,7 +3355,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
int Rotation(TransInfo *t, const int UNUSED(mval[2]))
{
- char str[128], *spos= str;
+ char str[128], *spos = str;
float final;
@@ -3378,16 +3380,16 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c);
- spos+= sprintf(spos, "Rot: %s %s %s", &c[0], t->con.text, t->proptext);
+ spos += sprintf(spos, "Rot: %s %s %s", &c[0], t->con.text, t->proptext);
/* Clamp between -180 and 180 */
- final= angle_wrap_rad(DEG2RADF(final));
+ final = angle_wrap_rad(DEG2RADF(final));
}
else {
spos += sprintf(spos, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext);
}
- if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
}
(void)spos;
@@ -3416,7 +3418,7 @@ void initTrackball(TransInfo *t)
t->idx_max = 1;
t->num.idx_max = 1;
t->snap[0] = 0.0f;
- t->snap[1] = (float)((5.0/180)*M_PI);
+ t->snap[1] = (float)((5.0 / 180) * M_PI);
t->snap[2] = t->snap[1] * 0.2f;
t->num.increment = 1.0f;
@@ -3435,7 +3437,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
mul_m3_m3m3(mat, smat, totmat);
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3455,7 +3457,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
int Trackball(TransInfo *t, const int UNUSED(mval[2]))
{
- char str[128], *spos= str;
+ char str[128], *spos = str;
float axis1[3], axis2[3];
float mat[3][3], totmat[3][3], smat[3][3];
float phi[2];
@@ -3486,7 +3488,7 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
spos += sprintf(spos, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext);
}
- if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
}
(void)spos;
@@ -3522,7 +3524,7 @@ void initTranslation(TransInfo *t)
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
- t->idx_max = (t->flag & T_2D_EDIT)? 1: 2;
+ t->idx_max = (t->flag & T_2D_EDIT) ? 1 : 2;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
@@ -3550,7 +3552,7 @@ void initTranslation(TransInfo *t)
static void headerTranslation(TransInfo *t, float vec[3], char *str)
{
- char *spos= str;
+ char *spos = str;
char tvec[60];
char distvec[20];
char autoik[20];
@@ -3568,10 +3570,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
dist = len_v3(vec);
if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) {
- int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0;
+ int i, do_split = t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1 : 0;
- for (i=0; i<3; i++)
- bUnit_AsString(&tvec[i*20], 20, dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1);
+ for (i = 0; i < 3; i++)
+ bUnit_AsString(&tvec[i * 20], 20, dvec[i] * t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1);
}
else {
sprintf(&tvec[0], "%.4f", dvec[0]);
@@ -3581,33 +3583,33 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
}
if (!(t->flag & T_2D_EDIT) && t->scene->unit.system)
- bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0);
- else if ( dist > 1e10f || dist < -1e10f ) /* prevent string buffer overflow */
+ bUnit_AsString(distvec, sizeof(distvec), dist * t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0);
+ else if (dist > 1e10f || dist < -1e10f) /* prevent string buffer overflow */
sprintf(distvec, "%.4e", dist);
else
sprintf(distvec, "%.4f", dist);
if (t->flag & T_AUTOIK) {
- short chainlen= t->settings->autoik_chainlen;
+ short chainlen = t->settings->autoik_chainlen;
if (chainlen)
sprintf(autoik, "AutoIK-Len: %d", chainlen);
else
- autoik[0]= '\0';
+ autoik[0] = '\0';
}
else
- autoik[0]= '\0';
+ autoik[0] = '\0';
if (t->con.mode & CON_APPLY) {
switch (t->num.idx_max) {
- case 0:
- spos += sprintf(spos, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
- break;
- case 1:
- spos += sprintf(spos, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]);
- break;
- case 2:
- spos += sprintf(spos, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
+ case 0:
+ spos += sprintf(spos, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
+ break;
+ case 1:
+ spos += sprintf(spos, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]);
+ break;
+ case 2:
+ spos += sprintf(spos, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
}
}
else {
@@ -3617,7 +3619,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
spos += sprintf(spos, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
}
- if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
}
(void)spos;
@@ -3629,7 +3631,7 @@ static void applyTranslation(TransInfo *t, float vec[3])
float tvec[3];
int i;
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3733,7 +3735,7 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
void initShrinkFatten(TransInfo *t)
{
// If not in mesh edit mode, fallback to Resize
- if (t->obedit==NULL || t->obedit->type != OB_MESH) {
+ if (t->obedit == NULL || t->obedit->type != OB_MESH) {
initResize(t);
}
else {
@@ -3785,7 +3787,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
t->values[0] = distance;
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3818,12 +3820,12 @@ void initTilt(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = (float)((5.0/180)*M_PI);
+ t->snap[1] = (float)((5.0 / 180) * M_PI);
t->snap[2] = t->snap[1] * 0.2f;
t->num.increment = t->snap[1];
- t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+ t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
@@ -3855,7 +3857,7 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
sprintf(str, "Tilt: %.2f %s", RAD2DEGF(final), t->proptext);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3922,7 +3924,7 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
sprintf(str, "Shrink/Fatten: %3f", ratio);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3930,7 +3932,7 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
continue;
if (td->val) {
- *td->val= td->ival*ratio;
+ *td->val = td->ival * ratio;
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
if (*td->val <= 0.0f) *td->val = 0.001f;
@@ -3990,7 +3992,7 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
sprintf(str, "Shrink/Fatten: %3f", ratio);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4064,7 +4066,7 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
t->con.applyRot(t, NULL, axis, NULL);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4137,28 +4139,28 @@ int handleEventBevel(TransInfo *t, wmEvent *event)
if (!G.editBMesh) return 0;
switch (event->type) {
- case MIDDLEMOUSE:
- G.editBMesh->options ^= BME_BEVEL_VERT;
- t->state = TRANS_CANCEL;
- return 1;
- //case PADPLUSKEY:
- // G.editBMesh->options ^= BME_BEVEL_RES;
- // G.editBMesh->res += 1;
- // if (G.editBMesh->res > 4) {
- // G.editBMesh->res = 4;
- // }
- // t->state = TRANS_CANCEL;
- // return 1;
- //case PADMINUS:
- // G.editBMesh->options ^= BME_BEVEL_RES;
- // G.editBMesh->res -= 1;
- // if (G.editBMesh->res < 0) {
- // G.editBMesh->res = 0;
- // }
- // t->state = TRANS_CANCEL;
- // return 1;
- default:
- return 0;
+ case MIDDLEMOUSE:
+ G.editBMesh->options ^= BME_BEVEL_VERT;
+ t->state = TRANS_CANCEL;
+ return 1;
+ //case PADPLUSKEY:
+ // G.editBMesh->options ^= BME_BEVEL_RES;
+ // G.editBMesh->res += 1;
+ // if (G.editBMesh->res > 4) {
+ // G.editBMesh->res = 4;
+ // }
+ // t->state = TRANS_CANCEL;
+ // return 1;
+ //case PADMINUS:
+ // G.editBMesh->options ^= BME_BEVEL_RES;
+ // G.editBMesh->res -= 1;
+ // if (G.editBMesh->res < 0) {
+ // G.editBMesh->res = 0;
+ // }
+ // t->state = TRANS_CANCEL;
+ // return 1;
+ default:
+ return 0;
}
}
return 0;
@@ -4195,7 +4197,7 @@ int Bevel(TransInfo *t, const int UNUSED(mval[2]))
}
if (distance < 0) distance = -distance;
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->axismtx[1][0] > 0 && distance > td->axismtx[1][0]) {
d = td->axismtx[1][0];
}
@@ -4229,7 +4231,7 @@ void initBevelWeight(TransInfo *t)
t->num.increment = t->snap[1];
- t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+ t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
@@ -4267,7 +4269,7 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
sprintf(str, "Bevel Weight: %.3f %s", weight, t->proptext);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4302,7 +4304,7 @@ void initCrease(TransInfo *t)
t->num.increment = t->snap[1];
- t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+ t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
int Crease(TransInfo *t, const int UNUSED(mval[2]))
@@ -4340,7 +4342,7 @@ int Crease(TransInfo *t, const int UNUSED(mval[2]))
sprintf(str, "Crease: %.3f %s", crease, t->proptext);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4418,11 +4420,11 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
}
/* we've tucked the scale in loc */
- oldy= td->iloc[1];
+ oldy = td->iloc[1];
size_to_mat3(sizemat, td->iloc);
mul_m3_m3m3(tmat, tmat, sizemat);
mat3_to_size(td->loc, tmat);
- td->loc[1]= oldy;
+ td->loc[1] = oldy;
}
int BoneSize(TransInfo *t, const int mval[2])
@@ -4435,8 +4437,8 @@ int BoneSize(TransInfo *t, const int mval[2])
// TRANSFORM_FIX_ME MOVE TO MOUSE INPUT
/* for manipulator, center handle, the scaling can't be done relative to center */
- if ((t->flag & T_USES_MANIPULATOR) && t->con.mode==0) {
- ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
+ if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
+ ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f;
}
else {
ratio = t->values[0];
@@ -4457,11 +4459,11 @@ int BoneSize(TransInfo *t, const int mval[2])
t->con.applySize(t, NULL, mat);
}
- copy_m3_m3(t->mat, mat); // used in manipulator
+ copy_m3_m3(t->mat, mat); // used in manipulator
headerBoneSize(t, size, str);
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4496,7 +4498,7 @@ void initBoneEnvelope(TransInfo *t)
t->num.increment = t->snap[1];
- t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+ t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
@@ -4523,7 +4525,7 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
sprintf(str, "Envelope: %3f", ratio);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4533,9 +4535,9 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
if (td->val) {
/* if the old/original value was 0.0f, then just use ratio */
if (td->ival)
- *td->val= td->ival*ratio;
+ *td->val = td->ival * ratio;
else
- *td->val= ratio;
+ *td->val = ratio;
}
}
@@ -4565,7 +4567,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
{
BMLoop *firstl;
float a[3] = {0.0f, 0.0f, 0.0f}, n[3] = {0.0f, 0.0f, 0.0f};
- int i=0;
+ int i = 0;
firstl = l;
do {
@@ -4823,7 +4825,7 @@ static int createSlideVerts(TransInfo *t)
sv->down = BM_edge_other_vert(l->e, v);
}
- v2=v, v = BM_edge_other_vert(e, v);
+ v2 = v, v = BM_edge_other_vert(e, v);
e1 = e;
e = get_other_edge(v, e);
@@ -4880,8 +4882,8 @@ static int createSlideVerts(TransInfo *t)
/* search cross edges for visible edge to the mouse cursor,
* then use the shared vertex to calculate screen vector*/
dis2 = -1.0f;
- for (i=0; i<2; i++) {
- v = i?e->v1:e->v2;
+ for (i = 0; i < 2; i++) {
+ v = i ? e->v1 : e->v2;
BM_ITER_ELEM (e2, &iter2, v, BM_EDGES_OF_VERT) {
if (BM_elem_flag_test(e2, BM_ELEM_SELECT))
continue;
@@ -4923,7 +4925,7 @@ static int createSlideVerts(TransInfo *t)
/*create copies of faces for customdata projection*/
sv_array = sld->sv;
- for (i=0; i<sld->totsv; i++, sv_array++) {
+ for (i = 0; i < sld->totsv; i++, sv_array++) {
BMIter fiter, liter;
BMFace *f;
BMLoop *l;
@@ -4999,7 +5001,7 @@ void projectSVData(TransInfo *t, int final)
BLI_smallhash_init(&visit);
- for (i=0, sv = sld->sv; i < sld->totsv; sv++, i++) {
+ for (i = 0, sv = sld->sv; i < sld->totsv; sv++, i++) {
BMIter fiter;
BMFace *f;
@@ -5065,7 +5067,7 @@ void projectSVData(TransInfo *t, int final)
BMEdge *e_sel;
BM_ITER_ELEM (e_sel, &eiter, l->v, BM_EDGES_OF_VERT) {
- if (BM_elem_flag_test(e_sel, BM_ELEM_SELECT)) {;
+ if (BM_elem_flag_test(e_sel, BM_ELEM_SELECT)) {
break;
}
}
@@ -5131,7 +5133,7 @@ void freeSlideTempFaces(SlideData *sld)
BMFace *copyf;
copyf = BLI_smallhash_iternew(&sld->origfaces, &hiter, NULL);
- for (; copyf; copyf=BLI_smallhash_iternext(&hiter, NULL)) {
+ for (; copyf; copyf = BLI_smallhash_iternext(&hiter, NULL)) {
BM_face_verts_kill(sld->em->bm, copyf);
}
@@ -5152,7 +5154,7 @@ void freeSlideVerts(TransInfo *t)
LinkNode *look = sld->vertlist;
GHash *vertgh = sld->vhash;
while (look) {
- sv = BLI_ghash_lookup(vertgh, (EditVert*)look->link);
+ sv = BLI_ghash_lookup(vertgh, (EditVert *)look->link);
if (sv != NULL) {
sv->up->f &= !SELECT;
sv->down->f &= !SELECT;
@@ -5188,7 +5190,7 @@ void initEdgeSlide(TransInfo *t)
t->handleEvent = handleEventEdgeSlide;
if (!createSlideVerts(t)) {
- t->state= TRANS_CANCEL;
+ t->state = TRANS_CANCEL;
return;
}
@@ -5211,7 +5213,7 @@ void initEdgeSlide(TransInfo *t)
t->num.increment = t->snap[1];
- t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+ t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
int handleEventEdgeSlide(struct TransInfo *t, struct wmEvent *event)
@@ -5340,7 +5342,7 @@ static int doEdgeSlide(TransInfo *t, float perc)
sld->perc = perc;
sv = svlist;
- for (i=0; i<sld->totsv; i++, sv++) {
+ for (i = 0; i < sld->totsv; i++, sv++) {
if (sld->is_proportional == FALSE) {
TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
float cur_sel = curr_sv->edge_len;
@@ -5405,11 +5407,11 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c);
BLI_snprintf(str, sizeof(str), "Edge Slide: %s (E)ven: %s, (F)lipped: %s",
- &c[0], !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF" );
+ &c[0], !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF");
}
else {
BLI_snprintf(str, sizeof(str), "Edge Slide: %.2f (E)ven: %s, (F)lipped: %s",
- final, !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF" );
+ final, !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF");
}
CLAMP(final, -1.0f, 1.0f);
@@ -5443,12 +5445,12 @@ void initBoneRoll(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = (float)((5.0/180)*M_PI);
+ t->snap[1] = (float)((5.0 / 180) * M_PI);
t->snap[2] = t->snap[1] * 0.2f;
t->num.increment = 1.0f;
- t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+ t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
@@ -5523,11 +5525,11 @@ int BakeTime(TransInfo *t, const int mval[2])
if (t->mouse.precision) {
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
- time= (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
- time+= 0.1f*((float)(t->center2d[0]*fac - mval[0]) -time);
+ time = (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
+ time += 0.1f * ((float)(t->center2d[0] * fac - mval[0]) - time);
}
else {
- time = (float)(t->center2d[0] - mval[0])*fac;
+ time = (float)(t->center2d[0] - mval[0]) * fac;
}
snapGrid(t, &time);
@@ -5553,7 +5555,7 @@ int BakeTime(TransInfo *t, const int mval[2])
sprintf(str, "Time: %.3f %s", time, t->proptext);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -5612,7 +5614,7 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2]))
sprintf(str, "Mirror%s", t->con.text);
- for (i = 0, td=t->data; i < t->total; i++, td++) {
+ for (i = 0, td = t->data; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -5631,7 +5633,7 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2]))
size_to_mat3(mat, size);
- for (i = 0, td=t->data; i < t->total; i++, td++) {
+ for (i = 0, td = t->data; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -5672,7 +5674,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
/* saving original center */
copy_v3_v3(center, t->center);
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
float mat[3][3], invmat[3][3];
if (td->flag & TD_NOACTION)
@@ -5682,7 +5684,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
continue;
/* around local centers */
- if (t->flag & (T_OBJECT|T_POSE)) {
+ if (t->flag & (T_OBJECT | T_POSE)) {
copy_v3_v3(t->center, td->center);
}
else {
@@ -5746,7 +5748,7 @@ static void applySeqSlide(TransInfo *t, float val[2])
TransData *td = t->data;
int i;
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
float tvec[2];
if (td->flag & TD_NOACTION)
@@ -5803,38 +5805,38 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
// XXX these modifier checks should be keymappable
static short getAnimEdit_SnapMode(TransInfo *t)
{
- short autosnap= SACTSNAP_OFF;
+ short autosnap = SACTSNAP_OFF;
if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
if (saction)
- autosnap= saction->autosnap;
+ autosnap = saction->autosnap;
}
else if (t->spacetype == SPACE_IPO) {
- SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+ SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
if (sipo)
- autosnap= sipo->autosnap;
+ autosnap = sipo->autosnap;
}
else if (t->spacetype == SPACE_NLA) {
- SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
+ SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
if (snla)
- autosnap= snla->autosnap;
+ autosnap = snla->autosnap;
}
else {
- autosnap= SACTSNAP_OFF;
+ autosnap = SACTSNAP_OFF;
}
/* toggle autosnap on/off
- * - when toggling on, prefer nearest frame over 1.0 frame increments
+ * - when toggling on, prefer nearest frame over 1.0 frame increments
*/
if (t->modifiers & MOD_SNAP_INVERT) {
if (autosnap)
- autosnap= SACTSNAP_OFF;
+ autosnap = SACTSNAP_OFF;
else
- autosnap= SACTSNAP_FRAME;
+ autosnap = SACTSNAP_FRAME;
}
return autosnap;
@@ -5849,19 +5851,19 @@ static short getAnimEdit_DrawTime(TransInfo *t)
short drawtime;
if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
- drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
+ drawtime = (saction->flag & SACTION_DRAWTIME) ? 1 : 0;
}
else if (t->spacetype == SPACE_NLA) {
- SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
+ SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
- drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
+ drawtime = (snla->flag & SNLA_DRAWTIME) ? 1 : 0;
}
else if (t->spacetype == SPACE_IPO) {
- SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+ SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
- drawtime = (sipo->flag & SIPO_DRAWTIME)? 1 : 0;
+ drawtime = (sipo->flag & SIPO_DRAWTIME) ? 1 : 0;
}
else {
drawtime = 0;
@@ -5881,23 +5883,23 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
#if 0 /* 'do_time' disabled for now */
- const Scene *scene= t->scene;
- const short do_time= 0; //getAnimEdit_DrawTime(t); // NOTE: this works, but may be confusing behavior given the option's label, hence disabled
- const double secf= FPS;
+ const Scene *scene = t->scene;
+ const short do_time = 0; //getAnimEdit_DrawTime(t); // NOTE: this works, but may be confusing behavior given the option's label, hence disabled
+ const double secf = FPS;
#endif
double val;
/* convert frame to nla-action time (if needed) */
if (adt)
- val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
+ val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
else
- val= *(td->val);
+ val = *(td->val);
-#if 0 /* 'do_time' disabled for now */
+#if 0 /* 'do_time' disabled for now */
/* do the snapping to nearest frame/second */
if (do_time) {
- val= (float)(floor((val/secf) + 0.5f) * secf);
+ val = (float)(floor((val / secf) + 0.5f) * secf);
}
else
#endif
@@ -5907,9 +5909,9 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
/* convert frame out of nla-action time */
if (adt)
- *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
+ *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
else
- *(td->val)= val;
+ *(td->val) = val;
}
/* snap key to nearest marker? */
else if (autosnap == SACTSNAP_MARKER) {
@@ -5917,19 +5919,19 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
/* convert frame to nla-action time (if needed) */
if (adt)
- val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
+ val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
else
- val= *(td->val);
+ val = *(td->val);
/* snap to nearest marker */
// TODO: need some more careful checks for where data comes from
- val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
+ val = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
/* convert frame out of nla-action time */
if (adt)
- *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
+ *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
else
- *(td->val)= val;
+ *(td->val) = val;
}
/* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect)
@@ -5980,21 +5982,21 @@ static void headerTimeTranslate(TransInfo *t, char *str)
}
else {
const Scene *scene = t->scene;
- const short autosnap= getAnimEdit_SnapMode(t);
+ const short autosnap = getAnimEdit_SnapMode(t);
const short do_time = getAnimEdit_DrawTime(t);
- const double secf= FPS;
+ const double secf = FPS;
float val = t->values[0];
/* apply snapping + frame->seconds conversions */
if (autosnap == SACTSNAP_STEP) {
if (do_time)
- val= floorf((double)val / secf + 0.5);
+ val = floorf((double)val / secf + 0.5);
else
- val= floorf(val + 0.5f);
+ val = floorf(val + 0.5f);
}
else {
if (do_time)
- val= (float)((double)val / secf);
+ val = (float)((double)val / secf);
}
if (autosnap == SACTSNAP_FRAME)
@@ -6013,20 +6015,20 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
Scene *scene = t->scene;
int i;
- const short do_time= getAnimEdit_DrawTime(t);
- const double secf= FPS;
+ const short do_time = getAnimEdit_DrawTime(t);
+ const double secf = FPS;
- const short autosnap= getAnimEdit_SnapMode(t);
+ const short autosnap = getAnimEdit_SnapMode(t);
float deltax, val /* , valprev */;
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
- for (i = 0 ; i < t->total; i++, td++, td2d++) {
+ for (i = 0; i < t->total; i++, td++, td2d++) {
/* it is assumed that td->extra is a pointer to the AnimData,
* whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
- AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
/* valprev = *td->val; */ /* UNUSED */
@@ -6097,7 +6099,7 @@ void initTimeSlide(TransInfo *t)
{
/* this tool is only really available in the Action Editor... */
if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
/* set flag for drawing stuff */
saction->flag |= SACTION_MOVING;
@@ -6133,12 +6135,12 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
outputNumInput(&(t->num), tvec);
}
else {
- float minx= *((float *)(t->customData));
- float maxx= *((float *)(t->customData) + 1);
- float cval= t->values[0];
+ float minx = *((float *)(t->customData));
+ float maxx = *((float *)(t->customData) + 1);
+ float cval = t->values[0];
float val;
- val= 2.0f*(cval-sval) / (maxx-minx);
+ val = 2.0f * (cval - sval) / (maxx - minx);
CLAMP(val, -1.0f, 1.0f);
sprintf(&tvec[0], "%.4f", val);
@@ -6152,43 +6154,43 @@ static void applyTimeSlide(TransInfo *t, float sval)
TransData *td = t->data;
int i;
- float minx= *((float *)(t->customData));
- float maxx= *((float *)(t->customData) + 1);
+ float minx = *((float *)(t->customData));
+ float maxx = *((float *)(t->customData) + 1);
/* set value for drawing black line */
if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
float cvalf = t->values[0];
- saction->timeslide= cvalf;
+ saction->timeslide = cvalf;
}
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
* whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
- AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float cval = t->values[0];
/* apply NLA-mapping to necessary values */
if (adt)
- cval= BKE_nla_tweakedit_remap(adt, cval, NLATIME_CONVERT_UNMAP);
+ cval = BKE_nla_tweakedit_remap(adt, cval, NLATIME_CONVERT_UNMAP);
/* only apply to data if in range */
if ((sval > minx) && (sval < maxx)) {
- float cvalc= CLAMPIS(cval, minx, maxx);
+ float cvalc = CLAMPIS(cval, minx, maxx);
float timefac;
/* left half? */
if (td->ival < sval) {
- timefac= (sval - td->ival) / (sval - minx);
- *(td->val)= cvalc - timefac * (cvalc - minx);
+ timefac = (sval - td->ival) / (sval - minx);
+ *(td->val) = cvalc - timefac * (cvalc - minx);
}
else {
- timefac= (td->ival - sval) / (maxx - sval);
- *(td->val)= cvalc + timefac * (maxx - cvalc);
+ timefac = (td->ival - sval) / (maxx - sval);
+ *(td->val) = cvalc + timefac * (maxx - cvalc);
}
}
}
@@ -6198,8 +6200,8 @@ int TimeSlide(TransInfo *t, const int mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
- float minx= *((float *)(t->customData));
- float maxx= *((float *)(t->customData) + 1);
+ float minx = *((float *)(t->customData));
+ float maxx = *((float *)(t->customData) + 1);
char str[200];
/* calculate mouse co-ordinates */
@@ -6211,9 +6213,9 @@ int TimeSlide(TransInfo *t, const int mval[2])
t->values[0] = cval[0];
/* handle numeric-input stuff */
- t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx);
+ t->vec[0] = 2.0f * (cval[0] - sval[0]) / (maxx - minx);
applyNumInput(&t->num, &t->vec[0]);
- t->values[0] = (maxx-minx) * t->vec[0] / 2.0f + sval[0];
+ t->values[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0];
headerTimeSlide(t, sval[0], str);
applyTimeSlide(t, sval[0]);
@@ -6286,19 +6288,19 @@ static void applyTimeScale(TransInfo *t)
TransData2D *td2d = t->data2d;
int i;
- const short autosnap= getAnimEdit_SnapMode(t);
- const short do_time= getAnimEdit_DrawTime(t);
- const double secf= FPS;
+ const short autosnap = getAnimEdit_SnapMode(t);
+ const short do_time = getAnimEdit_DrawTime(t);
+ const double secf = FPS;
- for (i = 0 ; i < t->total; i++, td++, td2d++) {
+ for (i = 0; i < t->total; i++, td++, td2d++) {
/* it is assumed that td->extra is a pointer to the AnimData,
* whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
- AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
- float startx= CFRA;
- float fac= t->values[0];
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ float startx = CFRA;
+ float fac = t->values[0];
if (autosnap == SACTSNAP_STEP) {
if (do_time)
@@ -6309,7 +6311,7 @@ static void applyTimeScale(TransInfo *t)
/* check if any need to apply nla-mapping */
if (adt)
- startx= BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
+ startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
/* now, calculate the new value */
*(td->val) = ((td->ival - startx) * fac) + startx;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index b18d132f8df..d2910c5b602 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -77,7 +77,7 @@ static void constraintAutoValues(TransInfo *t, float vec[3])
{
int mode = t->con.mode;
if (mode & CON_APPLY) {
- float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f;
+ float nval = (t->flag & T_NULL_ONE) ? 1.0f : 0.0f;
if ((mode & CON_AXIS0) == 0) {
vec[0] = nval;
@@ -95,21 +95,21 @@ void constraintNumInput(TransInfo *t, float vec[3])
{
int mode = t->con.mode;
if (mode & CON_APPLY) {
- float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f;
+ float nval = (t->flag & T_NULL_ONE) ? 1.0f : 0.0f;
if (getConstraintSpaceDimension(t) == 2) {
- int axis = mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
- if (axis == (CON_AXIS0|CON_AXIS1)) {
+ int axis = mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+ if (axis == (CON_AXIS0 | CON_AXIS1)) {
/* vec[0] = vec[0]; */ /* same */
/* vec[1] = vec[1]; */ /* same */
vec[2] = nval;
}
- else if (axis == (CON_AXIS1|CON_AXIS2)) {
+ else if (axis == (CON_AXIS1 | CON_AXIS2)) {
vec[2] = vec[1];
vec[1] = vec[0];
vec[0] = nval;
}
- else if (axis == (CON_AXIS0|CON_AXIS2)) {
+ else if (axis == (CON_AXIS0 | CON_AXIS2)) {
/* vec[0] = vec[0]; */ /* same */
vec[2] = vec[1];
vec[1] = nval;
@@ -184,7 +184,7 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
{
if (t->spacetype == SPACE_VIEW3D) {
// View3D *v3d = t->sa->spacedata.first;
- const float min_dist= 1.0f; // v3d->near;
+ const float min_dist = 1.0f; /* v3d->near; */
float dir[3];
float l;
@@ -194,7 +194,7 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
}
project_v3_v3v3(dir, dir, t->viewinv[2]);
- l= len_v3(dir);
+ l = len_v3(dir);
if (l < min_dist) {
float diff[3];
@@ -211,7 +211,7 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
float norm[3], vec[3], factor, angle;
float t_con_center[3];
- if (in[0]==0.0f && in[1]==0.0f && in[2]==0.0f)
+ if (in[0] == 0.0f && in[1] == 0.0f && in[2] == 0.0f)
return;
copy_v3_v3(t_con_center, t->con.center);
@@ -232,12 +232,12 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
project_v3_v3v3(vec, in, t->viewinv[1]);
factor = dot_v3v3(t->viewinv[1], vec) * 2.0f;
/* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
- if (factor<0.0f) factor*= -factor;
- else factor*= factor;
+ if (factor < 0.0f) factor *= -factor;
+ else factor *= factor;
copy_v3_v3(out, axis);
normalize_v3(out);
- mul_v3_fl(out, -factor); /* -factor makes move down going backwards */
+ mul_v3_fl(out, -factor); /* -factor makes move down going backwards */
}
else {
float v[3], i1[3], i2[3];
@@ -276,10 +276,10 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
sub_v3_v3v3(out, i1, t_con_center);
/* possible some values become nan when
- * viewpoint and object are both zero */
- if (!finite(out[0])) out[0]= 0.0f;
- if (!finite(out[1])) out[1]= 0.0f;
- if (!finite(out[2])) out[2]= 0.0f;
+ * viewpoint and object are both zero */
+ if (!finite(out[0])) out[0] = 0.0f;
+ if (!finite(out[1])) out[1] = 0.0f;
+ if (!finite(out[2])) out[2] = 0.0f;
}
}
}
@@ -386,7 +386,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f
copy_v3_v3(out, pvec);
}
else {
- int i=0;
+ int i = 0;
out[0] = out[1] = out[2] = 0.0f;
if (t->con.mode & CON_AXIS0) {
@@ -475,21 +475,21 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3]
static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle)
{
if (!td && t->con.mode & CON_APPLY) {
- int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
+ int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
switch (mode) {
- case CON_AXIS0:
- case (CON_AXIS1|CON_AXIS2):
- copy_v3_v3(vec, t->con.mtx[0]);
- break;
- case CON_AXIS1:
- case (CON_AXIS0|CON_AXIS2):
- copy_v3_v3(vec, t->con.mtx[1]);
- break;
- case CON_AXIS2:
- case (CON_AXIS0|CON_AXIS1):
- copy_v3_v3(vec, t->con.mtx[2]);
- break;
+ case CON_AXIS0:
+ case (CON_AXIS1 | CON_AXIS2):
+ copy_v3_v3(vec, t->con.mtx[0]);
+ break;
+ case CON_AXIS1:
+ case (CON_AXIS0 | CON_AXIS2):
+ copy_v3_v3(vec, t->con.mtx[1]);
+ break;
+ case CON_AXIS2:
+ case (CON_AXIS0 | CON_AXIS1):
+ copy_v3_v3(vec, t->con.mtx[2]);
+ break;
}
/* don't flip axis if asked to or if num input */
if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
@@ -517,26 +517,26 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl
static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle)
{
if (t->con.mode & CON_APPLY) {
- int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
+ int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
/* on setup call, use first object */
if (td == NULL) {
- td= t->data;
+ td = t->data;
}
switch (mode) {
- case CON_AXIS0:
- case (CON_AXIS1|CON_AXIS2):
- copy_v3_v3(vec, td->axismtx[0]);
- break;
- case CON_AXIS1:
- case (CON_AXIS0|CON_AXIS2):
- copy_v3_v3(vec, td->axismtx[1]);
- break;
- case CON_AXIS2:
- case (CON_AXIS0|CON_AXIS1):
- copy_v3_v3(vec, td->axismtx[2]);
- break;
+ case CON_AXIS0:
+ case (CON_AXIS1 | CON_AXIS2):
+ copy_v3_v3(vec, td->axismtx[0]);
+ break;
+ case CON_AXIS1:
+ case (CON_AXIS0 | CON_AXIS2):
+ copy_v3_v3(vec, td->axismtx[1]);
+ break;
+ case CON_AXIS2:
+ case (CON_AXIS0 | CON_AXIS1):
+ copy_v3_v3(vec, td->axismtx[2]);
+ break;
}
if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
if (dot_v3v3(vec, t->viewinv[2]) > 0.0f) {
@@ -604,33 +604,33 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
char text[40];
switch (orientation) {
- case V3D_MANIP_GLOBAL:
+ case V3D_MANIP_GLOBAL:
{
- float mtx[3][3]= MAT3_UNITY;
+ float mtx[3][3] = MAT3_UNITY;
BLI_snprintf(text, sizeof(text), ftext, "global");
setConstraint(t, mtx, mode, text);
}
break;
- case V3D_MANIP_LOCAL:
- BLI_snprintf(text, sizeof(text), ftext, "local");
- setLocalConstraint(t, mode, text);
- break;
- case V3D_MANIP_NORMAL:
- BLI_snprintf(text, sizeof(text), ftext, "normal");
- setConstraint(t, t->spacemtx, mode, text);
- break;
- case V3D_MANIP_VIEW:
- BLI_snprintf(text, sizeof(text), ftext, "view");
- setConstraint(t, t->spacemtx, mode, text);
- break;
- case V3D_MANIP_GIMBAL:
- BLI_snprintf(text, sizeof(text), ftext, "gimbal");
- setConstraint(t, t->spacemtx, mode, text);
- break;
- default: /* V3D_MANIP_CUSTOM */
- BLI_snprintf(text, sizeof(text), ftext, t->spacename);
- setConstraint(t, t->spacemtx, mode, text);
- break;
+ case V3D_MANIP_LOCAL:
+ BLI_snprintf(text, sizeof(text), ftext, "local");
+ setLocalConstraint(t, mode, text);
+ break;
+ case V3D_MANIP_NORMAL:
+ BLI_snprintf(text, sizeof(text), ftext, "normal");
+ setConstraint(t, t->spacemtx, mode, text);
+ break;
+ case V3D_MANIP_VIEW:
+ BLI_snprintf(text, sizeof(text), ftext, "view");
+ setConstraint(t, t->spacemtx, mode, text);
+ break;
+ case V3D_MANIP_GIMBAL:
+ BLI_snprintf(text, sizeof(text), ftext, "gimbal");
+ setConstraint(t, t->spacemtx, mode, text);
+ break;
+ default: /* V3D_MANIP_CUSTOM */
+ BLI_snprintf(text, sizeof(text), ftext, t->spacename);
+ setConstraint(t, t->spacemtx, mode, text);
+ break;
}
t->con.orientation = orientation;
@@ -682,8 +682,8 @@ void drawConstraint(TransInfo *t)
setlinestyle(1);
glBegin(GL_LINE_STRIP);
- glVertex3fv(tc->center);
- glVertex3fv(vec);
+ glVertex3fv(tc->center);
+ glVertex3fv(vec);
glEnd();
setlinestyle(0);
@@ -733,7 +733,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
float aspx, aspy;
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
- glScalef(1.0f/aspx, 1.0f/aspy, 1.0);
+ glScalef(1.0f / aspx, 1.0f / aspy, 1.0);
}
set_inverted_drawing(1);
@@ -747,7 +747,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
static void drawObjectConstraint(TransInfo *t)
{
int i;
- TransData * td = t->data;
+ TransData *td = t->data;
/* Draw the first one lighter because that's the one who controls the others.
* Meaning the transformation is projected on that one and just copied on the others
@@ -767,7 +767,7 @@ static void drawObjectConstraint(TransInfo *t)
td++;
- for (i=1; i < t->total; i++, td++) {
+ for (i = 1; i < t->total; i++, td++) {
if (t->con.mode & CON_AXIS0) {
drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0);
}
@@ -791,7 +791,7 @@ void startConstraint(TransInfo *t)
void stopConstraint(TransInfo *t)
{
- t->con.mode &= ~(CON_APPLY|CON_SELECT);
+ t->con.mode &= ~(CON_APPLY | CON_SELECT);
*t->con.text = '\0';
t->num.idx_max = t->idx_max;
}
@@ -803,21 +803,21 @@ void getConstraintMatrix(TransInfo *t)
unit_m3(t->con.pmtx);
if (!(t->con.mode & CON_AXIS0)) {
- t->con.pmtx[0][0] =
- t->con.pmtx[0][1] =
- t->con.pmtx[0][2] = 0.0f;
+ t->con.pmtx[0][0] =
+ t->con.pmtx[0][1] =
+ t->con.pmtx[0][2] = 0.0f;
}
if (!(t->con.mode & CON_AXIS1)) {
- t->con.pmtx[1][0] =
- t->con.pmtx[1][1] =
- t->con.pmtx[1][2] = 0.0f;
+ t->con.pmtx[1][0] =
+ t->con.pmtx[1][1] =
+ t->con.pmtx[1][2] = 0.0f;
}
if (!(t->con.mode & CON_AXIS2)) {
- t->con.pmtx[2][0] =
- t->con.pmtx[2][1] =
- t->con.pmtx[2][2] = 0.0f;
+ t->con.pmtx[2][0] =
+ t->con.pmtx[2][1] =
+ t->con.pmtx[2][2] = 0.0f;
}
mul_m3_m3m3(mat, t->con.pmtx, t->con.imtx);
@@ -866,7 +866,7 @@ void postSelectConstraint(TransInfo *t)
static void setNearestAxis2d(TransInfo *t)
{
/* no correction needed... just use whichever one is lower */
- if ( abs(t->mval[0]-t->con.imval[0]) < abs(t->mval[1]-t->con.imval[1]) ) {
+ if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1]) ) {
t->con.mode |= CON_AXIS1;
BLI_snprintf(t->con.text, sizeof(t->con.text), " along Y axis");
}
@@ -895,10 +895,10 @@ static void setNearestAxis3d(TransInfo *t)
* of two 2D points 30 pixels apart (that's the last factor in the formula) after
* projecting them with window_to_3d_delta and then get the length of that vector.
*/
- zfac= t->persmat[0][3]*t->center[0]+ t->persmat[1][3]*t->center[1]+ t->persmat[2][3]*t->center[2]+ t->persmat[3][3];
- zfac = len_v3(t->persinv[0]) * 2.0f/t->ar->winx * zfac * 30.0f;
+ zfac = t->persmat[0][3] * t->center[0] + t->persmat[1][3] * t->center[1] + t->persmat[2][3] * t->center[2] + t->persmat[3][3];
+ zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f;
- for (i = 0; i<3; i++) {
+ for (i = 0; i < 3; i++) {
copy_v3_v3(axis, t->con.mtx[i]);
mul_v3_fl(axis, zfac);
@@ -922,7 +922,7 @@ static void setNearestAxis3d(TransInfo *t)
if (len[0] <= len[1] && len[0] <= len[2]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
- t->con.mode |= (CON_AXIS1|CON_AXIS2);
+ t->con.mode |= (CON_AXIS1 | CON_AXIS2);
BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s X axis", t->spacename);
}
else {
@@ -932,7 +932,7 @@ static void setNearestAxis3d(TransInfo *t)
}
else if (len[1] <= len[0] && len[1] <= len[2]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
- t->con.mode |= (CON_AXIS0|CON_AXIS2);
+ t->con.mode |= (CON_AXIS0 | CON_AXIS2);
BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Y axis", t->spacename);
}
else {
@@ -942,7 +942,7 @@ static void setNearestAxis3d(TransInfo *t)
}
else if (len[2] <= len[1] && len[2] <= len[0]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
- t->con.mode |= (CON_AXIS0|CON_AXIS1);
+ t->con.mode |= (CON_AXIS0 | CON_AXIS1);
BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Z axis", t->spacename);
}
else {
@@ -976,21 +976,21 @@ void setNearestAxis(TransInfo *t)
char constraintModeToChar(TransInfo *t)
{
- if ((t->con.mode & CON_APPLY)==0) {
+ if ((t->con.mode & CON_APPLY) == 0) {
return '\0';
}
- switch (t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2)) {
- case (CON_AXIS0):
- case (CON_AXIS1|CON_AXIS2):
- return 'X';
- case (CON_AXIS1):
- case (CON_AXIS0|CON_AXIS2):
- return 'Y';
- case (CON_AXIS2):
- case (CON_AXIS0|CON_AXIS1):
- return 'Z';
- default:
- return '\0';
+ switch (t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2)) {
+ case (CON_AXIS0):
+ case (CON_AXIS1 | CON_AXIS2):
+ return 'X';
+ case (CON_AXIS1):
+ case (CON_AXIS0 | CON_AXIS2):
+ return 'Y';
+ case (CON_AXIS2):
+ case (CON_AXIS0 | CON_AXIS1):
+ return 'Z';
+ default:
+ return '\0';
}
}
@@ -999,13 +999,13 @@ int isLockConstraint(TransInfo *t)
{
int mode = t->con.mode;
- if ( (mode & (CON_AXIS0|CON_AXIS1)) == (CON_AXIS0|CON_AXIS1))
+ if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1))
return 1;
- if ( (mode & (CON_AXIS1|CON_AXIS2)) == (CON_AXIS1|CON_AXIS2))
+ if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2))
return 1;
- if ( (mode & (CON_AXIS0|CON_AXIS2)) == (CON_AXIS0|CON_AXIS2))
+ if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2))
return 1;
return 0;
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 007ec3c5250..fbc59f4c2cb 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -107,7 +107,7 @@
#include "ED_mask.h"
#include "ED_util.h" /* for crazyspace correction */
-#include "WM_api.h" /* for WM_event_add_notifier to deal with stabilization nodes */
+#include "WM_api.h" /* for WM_event_add_notifier to deal with stabilization nodes */
#include "WM_types.h"
#include "UI_view2d.h"
@@ -162,10 +162,10 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, Tra
*head = *temp;
if (ihead < head) {
- qsort_trans_data(t, ihead, head-1, temp);
+ qsort_trans_data(t, ihead, head - 1, temp);
}
if (itail > head) {
- qsort_trans_data(t, head+1, itail, temp);
+ qsort_trans_data(t, head + 1, itail, temp);
}
}
@@ -217,18 +217,18 @@ static void set_prop_dist(TransInfo *t, short with_dist)
TransData *tob;
int a;
- for (a=0, tob= t->data; a<t->total; a++, tob++) {
+ for (a = 0, tob = t->data; a < t->total; a++, tob++) {
- tob->rdist= 0.0f; // init, it was mallocced
+ tob->rdist = 0.0f; // init, it was mallocced
- if ((tob->flag & TD_SELECTED)==0) {
+ if ((tob->flag & TD_SELECTED) == 0) {
TransData *td;
int i;
float dist, vec[3];
tob->rdist = -1.0f; // signal for next loop
- for (i = 0, td= t->data; i < t->total; i++, td++) {
+ for (i = 0, td = t->data; i < t->total; i++, td++) {
if (td->flag & TD_SELECTED) {
sub_v3_v3v3(vec, tob->center, td->center);
mul_m3_v3(tob->mtx, vec);
@@ -240,7 +240,7 @@ static void set_prop_dist(TransInfo *t, short with_dist)
tob->rdist = dist;
}
}
- else break; // by definition transdata has selected items in beginning
+ else break; // by definition transdata has selected items in beginning
}
if (with_dist) {
tob->dist = tob->rdist;
@@ -269,16 +269,16 @@ static void createTransTexspace(TransInfo *t)
}
id = ob->data;
- if (id == NULL || !ELEM3(GS(id->name), ID_ME, ID_CU, ID_MB )) {
+ if (id == NULL || !ELEM3(GS(id->name), ID_ME, ID_CU, ID_MB)) {
t->total = 0;
return;
}
t->total = 1;
- td= t->data= MEM_callocN(sizeof(TransData), "TransTexspace");
- td->ext= t->ext= MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+ td = t->data = MEM_callocN(sizeof(TransData), "TransTexspace");
+ td->ext = t->ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
- td->flag= TD_SELECTED;
+ td->flag = TD_SELECTED;
copy_v3_v3(td->center, ob->obmat[3]);
td->ob = ob;
@@ -306,7 +306,7 @@ static void createTransEdge(TransInfo *t)
BMEdge *eed;
BMIter iter;
float mtx[3][3], smtx[3][3];
- int count=0, countsel=0;
+ int count = 0, countsel = 0;
int propmode = t->flag & T_PROP_EDIT;
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
@@ -326,7 +326,7 @@ static void createTransEdge(TransInfo *t)
t->total = countsel;
}
- td= t->data= MEM_callocN(t->total * sizeof(TransData), "TransCrease");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransCrease");
copy_m3_m4(mtx, t->obedit->obmat);
invert_m3_m3(smtx, mtx);
@@ -340,11 +340,11 @@ static void createTransEdge(TransInfo *t)
add_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
mul_v3_fl(td->center, 0.5f);
- td->loc= NULL;
+ td->loc = NULL;
if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
- td->flag= TD_SELECTED;
+ td->flag = TD_SELECTED;
else
- td->flag= 0;
+ td->flag = 0;
copy_m3_m3(td->smtx, smtx);
@@ -369,15 +369,15 @@ static void createTransEdge(TransInfo *t)
static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan)
{
- bConstraint *con= pchan->constraints.first;
+ bConstraint *con = pchan->constraints.first;
- for (;con; con= con->next) {
- if (con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) {
- bKinematicConstraint *data= con->data;
+ for (; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) {
+ bKinematicConstraint *data = con->data;
- if (data->tar==NULL)
+ if (data->tar == NULL)
return data;
- if (data->tar->type==OB_ARMATURE && data->subtarget[0]==0)
+ if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)
return data;
}
}
@@ -388,44 +388,44 @@ static short apply_targetless_ik(Object *ob)
{
bPoseChannel *pchan, *parchan, *chanlist[256];
bKinematicConstraint *data;
- int segcount, apply= 0;
+ int segcount, apply = 0;
/* now we got a difficult situation... we have to find the
* target-less IK pchans, and apply transformation to the all
* pchans that were in the chain */
- for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- data= has_targetless_ik(pchan);
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ data = has_targetless_ik(pchan);
if (data && (data->flag & CONSTRAINT_IK_AUTO)) {
/* fill the array with the bones of the chain (armature.c does same, keep it synced) */
- segcount= 0;
+ segcount = 0;
/* exclude tip from chain? */
if (!(data->flag & CONSTRAINT_IK_TIP))
- parchan= pchan->parent;
+ parchan = pchan->parent;
else
- parchan= pchan;
+ parchan = pchan;
/* Find the chain's root & count the segments needed */
- for (; parchan; parchan=parchan->parent) {
- chanlist[segcount]= parchan;
+ for (; parchan; parchan = parchan->parent) {
+ chanlist[segcount] = parchan;
segcount++;
- if (segcount==data->rootbone || segcount>255) break; // 255 is weak
+ if (segcount == data->rootbone || segcount > 255) break; // 255 is weak
}
- for (;segcount;segcount--) {
+ for (; segcount; segcount--) {
Bone *bone;
- float rmat[4][4]/*, tmat[4][4], imat[4][4]*/;
+ float rmat[4][4] /*, tmat[4][4], imat[4][4]*/;
/* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK */
/* we put in channel the entire result of rmat= (channel * constraint * IK) */
/* pose_mat(b) = pose_mat(b-1) * offs_bone * rmat */
/* rmat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone ) */
- parchan= chanlist[segcount-1];
- bone= parchan->bone;
- bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */
+ parchan = chanlist[segcount - 1];
+ bone = parchan->bone;
+ bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */
BKE_armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat);
@@ -436,11 +436,11 @@ static short apply_targetless_ik(Object *ob)
copy_m3_m4(rmat3, rmat);
/* rotation */
- /* [#22409] is partially caused by this, as slight numeric error introduced during
- * the solving process leads to locked-axis values changing. However, we cannot modify
- * the values here, or else there are huge discreptancies between IK-solver (interactive)
- * and applied poses.
- */
+ /* [#22409] is partially caused by this, as slight numeric error introduced during
+ * the solving process leads to locked-axis values changing. However, we cannot modify
+ * the values here, or else there are huge discreptancies between IK-solver (interactive)
+ * and applied poses.
+ */
if (parchan->rotmode > 0)
mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3);
else if (parchan->rotmode == ROT_MODE_AXISANGLE)
@@ -470,7 +470,7 @@ static short apply_targetless_ik(Object *ob)
}
- apply= 1;
+ apply = 1;
data->flag &= ~CONSTRAINT_IK_AUTO;
}
}
@@ -480,7 +480,7 @@ static short apply_targetless_ik(Object *ob)
static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransData *td)
{
- Bone *bone= pchan->bone;
+ Bone *bone = pchan->bone;
float pmat[3][3], omat[3][3];
float cmat[3][3], tmat[3][3];
float vec[3];
@@ -499,40 +499,40 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->flag |= TD_NO_LOC;
}
- td->protectflag= pchan->protectflag;
+ td->protectflag = pchan->protectflag;
td->loc = pchan->loc;
copy_v3_v3(td->iloc, pchan->loc);
- td->ext->size= pchan->size;
+ td->ext->size = pchan->size;
copy_v3_v3(td->ext->isize, pchan->size);
if (pchan->rotmode > 0) {
- td->ext->rot= pchan->eul;
- td->ext->rotAxis= NULL;
- td->ext->rotAngle= NULL;
- td->ext->quat= NULL;
+ td->ext->rot = pchan->eul;
+ td->ext->rotAxis = NULL;
+ td->ext->rotAngle = NULL;
+ td->ext->quat = NULL;
copy_v3_v3(td->ext->irot, pchan->eul);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- td->ext->rot= NULL;
- td->ext->rotAxis= pchan->rotAxis;
- td->ext->rotAngle= &pchan->rotAngle;
- td->ext->quat= NULL;
+ td->ext->rot = NULL;
+ td->ext->rotAxis = pchan->rotAxis;
+ td->ext->rotAngle = &pchan->rotAngle;
+ td->ext->quat = NULL;
- td->ext->irotAngle= pchan->rotAngle;
+ td->ext->irotAngle = pchan->rotAngle;
copy_v3_v3(td->ext->irotAxis, pchan->rotAxis);
}
else {
- td->ext->rot= NULL;
- td->ext->rotAxis= NULL;
- td->ext->rotAngle= NULL;
- td->ext->quat= pchan->quat;
+ td->ext->rot = NULL;
+ td->ext->rotAxis = NULL;
+ td->ext->rotAngle = NULL;
+ td->ext->quat = pchan->quat;
copy_qt_qt(td->ext->iquat, pchan->quat);
}
- td->ext->rotOrder= pchan->rotmode;
+ td->ext->rotOrder = pchan->rotmode;
/* proper way to get parent transform + own transform + constraints transform */
@@ -559,11 +559,11 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
copy_m3_m4(tmat, pchan->constinv);
invert_m3_m3(cmat, tmat);
mul_serie_m3(td->mtx, pmat, omat, cmat, NULL, NULL, NULL, NULL, NULL);
- mul_serie_m3(td->ext->r_mtx, rpmat, omat, cmat, NULL,NULL,NULL,NULL,NULL);
+ mul_serie_m3(td->ext->r_mtx, rpmat, omat, cmat, NULL, NULL, NULL, NULL, NULL);
}
else {
- mul_serie_m3(td->mtx, pmat, omat, NULL, NULL,NULL,NULL,NULL,NULL);
- mul_serie_m3(td->ext->r_mtx, rpmat, omat, NULL, NULL,NULL,NULL,NULL,NULL);
+ mul_serie_m3(td->mtx, pmat, omat, NULL, NULL, NULL, NULL, NULL, NULL);
+ mul_serie_m3(td->ext->r_mtx, rpmat, omat, NULL, NULL, NULL, NULL, NULL, NULL);
}
invert_m3_m3(td->ext->r_smtx, td->ext->r_mtx);
}
@@ -588,25 +588,25 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
mul_m3_m3m3(td->axismtx, omat, pmat);
normalize_m3(td->axismtx);
- if (t->mode==TFM_BONESIZE) {
- bArmature *arm= t->poseobj->data;
+ if (t->mode == TFM_BONESIZE) {
+ bArmature *arm = t->poseobj->data;
- if (arm->drawtype==ARM_ENVELOPE) {
- td->loc= NULL;
- td->val= &bone->dist;
- td->ival= bone->dist;
+ if (arm->drawtype == ARM_ENVELOPE) {
+ td->loc = NULL;
+ td->val = &bone->dist;
+ td->ival = bone->dist;
}
else {
// abusive storage of scale in the loc pointer :)
- td->loc= &bone->xwidth;
+ td->loc = &bone->xwidth;
copy_v3_v3(td->iloc, td->loc);
- td->val= NULL;
+ td->val = NULL;
}
}
/* in this case we can do target-less IK grabbing */
- if (t->mode==TFM_TRANSLATION) {
- bKinematicConstraint *data= has_targetless_ik(pchan);
+ if (t->mode == TFM_TRANSLATION) {
+ bKinematicConstraint *data = has_targetless_ik(pchan);
if (data) {
if (data->flag & CONSTRAINT_IK_TIP) {
copy_v3_v3(data->grabtarget, pchan->pose_tail);
@@ -625,14 +625,14 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
}
/* store reference to first constraint */
- td->con= pchan->constraints.first;
+ td->con = pchan->constraints.first;
}
static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
{
- Bone *bone= lb->first;
+ Bone *bone = lb->first;
- for ( ; bone;bone= bone->next) {
+ for (; bone; bone = bone->next) {
if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) {
bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
}
@@ -654,7 +654,7 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
* returns total number of bones with BONE_TRANSFORM */
int count_set_pose_transflags(int *out_mode, short around, Object *ob)
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
bPoseChannel *pchan;
Bone *bone;
int mode = *out_mode;
@@ -699,7 +699,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM)
hastranslation = 1;
}
- else if ((pchan->protectflag & OB_LOCK_LOC)!=OB_LOCK_LOC)
+ else if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC)
hastranslation = 1;
}
else
@@ -720,26 +720,26 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
/* -------- Auto-IK ---------- */
/* adjust pose-channel's auto-ik chainlen */
-static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen)
+static void pchan_autoik_adjust(bPoseChannel *pchan, short chainlen)
{
bConstraint *con;
/* don't bother to search if no valid constraints */
- if ((pchan->constflag & (PCHAN_HAS_IK|PCHAN_HAS_TARGET))==0)
+ if ((pchan->constflag & (PCHAN_HAS_IK | PCHAN_HAS_TARGET)) == 0)
return;
/* check if pchan has ik-constraint */
- for (con= pchan->constraints.first; con; con= con->next) {
- if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) {
- bKinematicConstraint *data= con->data;
+ for (con = pchan->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) {
+ bKinematicConstraint *data = con->data;
/* only accept if a temporary one (for auto-ik) */
if (data->flag & CONSTRAINT_IK_TEMP) {
/* chainlen is new chainlen, but is limited by maximum chainlen */
- if ((chainlen==0) || (chainlen > data->max_rootbone))
- data->rootbone= data->max_rootbone;
+ if ((chainlen == 0) || (chainlen > data->max_rootbone))
+ data->rootbone = data->max_rootbone;
else
- data->rootbone= chainlen;
+ data->rootbone = chainlen;
}
}
}
@@ -748,7 +748,7 @@ static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen)
/* change the chain-length of auto-ik */
void transform_autoik_update(TransInfo *t, short mode)
{
- short *chainlen= &t->settings->autoik_chainlen;
+ short *chainlen = &t->settings->autoik_chainlen;
bPoseChannel *pchan;
/* mode determines what change to apply to chainlen */
@@ -766,7 +766,7 @@ void transform_autoik_update(TransInfo *t, short mode)
return;
/* apply to all pose-channels */
- for (pchan=t->poseobj->pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (pchan = t->poseobj->pose->chanbase.first; pchan; pchan = pchan->next) {
pchan_autoik_adjust(pchan, *chainlen);
}
}
@@ -778,17 +778,17 @@ static void pose_grab_with_ik_clear(Object *ob)
bPoseChannel *pchan;
bConstraint *con, *next;
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* clear all temporary lock flags */
- pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP|BONE_IK_NO_YDOF_TEMP|BONE_IK_NO_ZDOF_TEMP);
+ pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP | BONE_IK_NO_YDOF_TEMP | BONE_IK_NO_ZDOF_TEMP);
- pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_TARGET);
+ pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
/* remove all temporary IK-constraints added */
- for (con= pchan->constraints.first; con; con= next) {
- next= con->next;
- if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
- data= con->data;
+ for (con = pchan->constraints.first; con; con = next) {
+ next = con->next;
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+ data = con->data;
if (data->flag & CONSTRAINT_IK_TEMP) {
BLI_remlink(&pchan->constraints, con);
MEM_freeN(con->data);
@@ -796,7 +796,7 @@ static void pose_grab_with_ik_clear(Object *ob)
continue;
}
pchan->constflag |= PCHAN_HAS_IK;
- if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0))
+ if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
pchan->constflag |= PCHAN_HAS_TARGET;
}
}
@@ -815,21 +815,21 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
return 0;
/* Rule: not if there's already an IK on this channel */
- for (con= pchan->constraints.first; con; con= con->next) {
- if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
- data= con->data;
+ for (con = pchan->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+ data = con->data;
- if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]=='\0')) {
+ if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == '\0')) {
/* make reference to constraint to base things off later (if it's the last targetless constraint encountered) */
targetless = (bKinematicConstraint *)con->data;
/* but, if this is a targetless IK, we make it auto anyway (for the children loop) */
- if (con->enforce!=0.0f) {
+ if (con->enforce != 0.0f) {
data->flag |= CONSTRAINT_IK_AUTO;
/* if no chain length has been specified, just make things obey standard rotation locks too */
if (data->rootbone == 0) {
- for (; pchan; pchan=pchan->parent) {
+ for (; pchan; pchan = pchan->parent) {
/* here, we set ik-settings for bone from pchan->protectflag */
// XXX: careful with quats/axis-angle rotations where we're locking 4d components
if (pchan->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
@@ -842,23 +842,23 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
}
}
- if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0f))
+ if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f))
return 0;
}
}
con = add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
- pchan->constflag |= (PCHAN_HAS_IK|PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */
- data= con->data;
+ pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */
+ data = con->data;
if (targetless) {
/* if exists, use values from last targetless (but disabled) IK-constraint as base */
*data = *targetless;
}
else
- data->flag= CONSTRAINT_IK_TIP;
- data->flag |= CONSTRAINT_IK_TEMP|CONSTRAINT_IK_AUTO;
+ data->flag = CONSTRAINT_IK_TIP;
+ data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO;
copy_v3_v3(data->grabtarget, pchan->pose_tail);
- data->rootbone= 0; /* watch-it! has to be 0 here, since we're still on the same bone for the first time through the loop [#25885] */
+ data->rootbone = 0; /* watch-it! has to be 0 here, since we're still on the same bone for the first time through the loop [#25885] */
/* we only include bones that are part of a continual connected chain */
while (pchan) {
@@ -879,7 +879,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
}
/* make a copy of maximum chain-length */
- data->max_rootbone= data->rootbone;
+ data->max_rootbone = data->rootbone;
return 1;
}
@@ -888,19 +888,19 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
{
Bone *bonec;
- short wentdeeper=0, added=0;
+ short wentdeeper = 0, added = 0;
/* go deeper if children & children are connected */
- for (bonec= bone->childbase.first; bonec; bonec= bonec->next) {
+ for (bonec = bone->childbase.first; bonec; bonec = bonec->next) {
if (bonec->flag & BONE_CONNECTED) {
- wentdeeper= 1;
- added+= pose_grab_with_ik_children(pose, bonec);
+ wentdeeper = 1;
+ added += pose_grab_with_ik_children(pose, bonec);
}
}
- if (wentdeeper==0) {
- bPoseChannel *pchan= BKE_pose_channel_find_name(pose, bone->name);
+ if (wentdeeper == 0) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
if (pchan)
- added+= pose_grab_with_ik_add(pchan);
+ added += pose_grab_with_ik_add(pchan);
}
return added;
@@ -912,30 +912,30 @@ static short pose_grab_with_ik(Object *ob)
bArmature *arm;
bPoseChannel *pchan, *parent;
Bone *bonec;
- short tot_ik= 0;
+ short tot_ik = 0;
- if ((ob==NULL) || (ob->pose==NULL) || (ob->mode & OB_MODE_POSE)==0)
+ if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0)
return 0;
arm = ob->data;
/* Rule: allow multiple Bones (but they must be selected, and only one ik-solver per chain should get added) */
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->layer & arm->layer) {
if (pchan->bone->flag & BONE_SELECTED) {
/* Rule: no IK for solitatry (unconnected) bones */
- for (bonec=pchan->bone->childbase.first; bonec; bonec=bonec->next) {
+ for (bonec = pchan->bone->childbase.first; bonec; bonec = bonec->next) {
if (bonec->flag & BONE_CONNECTED) {
break;
}
}
- if ((pchan->bone->flag & BONE_CONNECTED)==0 && (bonec == NULL))
+ if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL))
continue;
/* rule: if selected Bone is not a root bone, it gets a temporal IK */
if (pchan->parent) {
/* only adds if there's no IK yet (and no parent bone was selected) */
- for (parent= pchan->parent; parent; parent= parent->parent) {
+ for (parent = pchan->parent; parent; parent = parent->parent) {
if (parent->bone->flag & BONE_SELECTED)
break;
}
@@ -961,17 +961,17 @@ static void createTransPose(TransInfo *t, Object *ob)
bPoseChannel *pchan;
TransData *td;
TransDataExtension *tdx;
- short ik_on= 0;
+ short ik_on = 0;
int i;
- t->total= 0;
+ t->total = 0;
/* check validity of state */
- arm= BKE_armature_from_object(ob);
- if ((arm==NULL) || (ob->pose==NULL)) return;
+ arm = BKE_armature_from_object(ob);
+ if ((arm == NULL) || (ob->pose == NULL)) return;
if (arm->flag & ARM_RESTPOS) {
- if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE)==0) {
+ if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE) == 0) {
// XXX use transform operator reports
// BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled");
return;
@@ -979,8 +979,8 @@ static void createTransPose(TransInfo *t, Object *ob)
}
/* do we need to add temporal IK chains? */
- if ((arm->flag & ARM_AUTO_IK) && t->mode==TFM_TRANSLATION) {
- ik_on= pose_grab_with_ik(ob);
+ if ((arm->flag & ARM_AUTO_IK) && t->mode == TFM_TRANSLATION) {
+ ik_on = pose_grab_with_ik(ob);
if (ik_on) t->flag |= T_AUTOIK;
}
@@ -990,26 +990,26 @@ static void createTransPose(TransInfo *t, Object *ob)
if (t->total == 0) return;
t->flag |= T_POSE;
- t->poseobj= ob; /* we also allow non-active objects to be transformed, in weightpaint */
+ t->poseobj = ob; /* we also allow non-active objects to be transformed, in weightpaint */
/* init trans data */
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransPoseBone");
- tdx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransPoseBoneExt");
- for (i=0; i<t->total; i++, td++, tdx++) {
- td->ext= tdx;
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransPoseBone");
+ tdx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "TransPoseBoneExt");
+ for (i = 0; i < t->total; i++, td++, tdx++) {
+ td->ext = tdx;
td->val = NULL;
}
/* use pose channels to fill trans data */
- td= t->data;
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ td = t->data;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
add_pose_transdata(t, pchan, ob, td);
td++;
}
}
- if (td != (t->data+t->total)) {
+ if (td != (t->data + t->total)) {
// XXX use transform operator reports
// BKE_report(op->reports, RPT_DEBUG, "Bone selection count error");
}
@@ -1023,18 +1023,18 @@ static void createTransPose(TransInfo *t, Object *ob)
static void createTransArmatureVerts(TransInfo *t)
{
EditBone *ebo;
- bArmature *arm= t->obedit->data;
+ bArmature *arm = t->obedit->data;
ListBase *edbo = arm->edbo;
TransData *td;
float mtx[3][3], smtx[3][3], delta[3], bonemat[3][3];
/* special hack for envelope drawmode and scaling:
- * to allow scaling the size of the envelope around single points,
+ * to allow scaling the size of the envelope around single points,
* mode should become TFM_BONE_ENVELOPE in this case
*/
// TODO: maybe we need a separate hotkey for it, but this is consistent with 2.4x for now
- if ((t->mode == TFM_RESIZE) && (arm->drawtype==ARM_ENVELOPE))
- t->mode= TFM_BONE_ENVELOPE;
+ if ((t->mode == TFM_RESIZE) && (arm->drawtype == ARM_ENVELOPE))
+ t->mode = TFM_BONE_ENVELOPE;
t->total = 0;
for (ebo = edbo->first; ebo; ebo = ebo->next) {
@@ -1061,19 +1061,19 @@ static void createTransArmatureVerts(TransInfo *t)
copy_m3_m4(mtx, t->obedit->obmat);
invert_m3_m3(smtx, mtx);
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransEditBone");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransEditBone");
for (ebo = edbo->first; ebo; ebo = ebo->next) {
- ebo->oldlength = ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
+ ebo->oldlength = ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
- if (t->mode==TFM_BONE_ENVELOPE) {
+ if (t->mode == TFM_BONE_ENVELOPE) {
if (ebo->flag & BONE_ROOTSEL) {
- td->val= &ebo->rad_head;
- td->ival= *td->val;
+ td->val = &ebo->rad_head;
+ td->ival = *td->val;
copy_v3_v3(td->center, ebo->head);
- td->flag= TD_SELECTED;
+ td->flag = TD_SELECTED;
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1085,10 +1085,10 @@ static void createTransArmatureVerts(TransInfo *t)
td++;
}
if (ebo->flag & BONE_TIPSEL) {
- td->val= &ebo->rad_tail;
- td->ival= *td->val;
+ td->val = &ebo->rad_tail;
+ td->ival = *td->val;
copy_v3_v3(td->center, ebo->tail);
- td->flag= TD_SELECTED;
+ td->flag = TD_SELECTED;
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1101,21 +1101,21 @@ static void createTransArmatureVerts(TransInfo *t)
}
}
- else if (t->mode==TFM_BONESIZE) {
+ else if (t->mode == TFM_BONESIZE) {
if (ebo->flag & BONE_SELECTED) {
- if (arm->drawtype==ARM_ENVELOPE) {
- td->loc= NULL;
- td->val= &ebo->dist;
- td->ival= ebo->dist;
+ if (arm->drawtype == ARM_ENVELOPE) {
+ td->loc = NULL;
+ td->val = &ebo->dist;
+ td->ival = ebo->dist;
}
else {
// abusive storage of scale in the loc pointer :)
- td->loc= &ebo->xwidth;
+ td->loc = &ebo->xwidth;
copy_v3_v3(td->iloc, td->loc);
- td->val= NULL;
+ td->val = NULL;
}
copy_v3_v3(td->center, ebo->head);
- td->flag= TD_SELECTED;
+ td->flag = TD_SELECTED;
/* use local bone matrix */
sub_v3_v3v3(delta, ebo->tail, ebo->head);
@@ -1132,14 +1132,14 @@ static void createTransArmatureVerts(TransInfo *t)
td++;
}
}
- else if (t->mode==TFM_BONE_ROLL) {
+ else if (t->mode == TFM_BONE_ROLL) {
if (ebo->flag & BONE_SELECTED) {
- td->loc= NULL;
- td->val= &(ebo->roll);
- td->ival= ebo->roll;
+ td->loc = NULL;
+ td->val = &(ebo->roll);
+ td->ival = ebo->roll;
copy_v3_v3(td->center, ebo->head);
- td->flag= TD_SELECTED;
+ td->flag = TD_SELECTED;
td->ext = NULL;
td->ob = t->obedit;
@@ -1150,11 +1150,11 @@ static void createTransArmatureVerts(TransInfo *t)
else {
if (ebo->flag & BONE_TIPSEL) {
copy_v3_v3(td->iloc, ebo->tail);
- copy_v3_v3(td->center, (t->around==V3D_LOCAL) ? ebo->head : td->iloc);
- td->loc= ebo->tail;
- td->flag= TD_SELECTED;
+ copy_v3_v3(td->center, (t->around == V3D_LOCAL) ? ebo->head : td->iloc);
+ td->loc = ebo->tail;
+ td->flag = TD_SELECTED;
if (ebo->flag & BONE_EDITMODE_LOCKED)
- td->protectflag = OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE;
+ td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1175,10 +1175,10 @@ static void createTransArmatureVerts(TransInfo *t)
if (ebo->flag & BONE_ROOTSEL) {
copy_v3_v3(td->iloc, ebo->head);
copy_v3_v3(td->center, td->iloc);
- td->loc= ebo->head;
- td->flag= TD_SELECTED;
+ td->loc = ebo->head;
+ td->flag = TD_SELECTED;
if (ebo->flag & BONE_EDITMODE_LOCKED)
- td->protectflag = OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE;
+ td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1203,40 +1203,40 @@ static void createTransArmatureVerts(TransInfo *t)
static void createTransMBallVerts(TransInfo *t)
{
- MetaBall *mb = (MetaBall*)t->obedit->data;
+ MetaBall *mb = (MetaBall *)t->obedit->data;
MetaElem *ml;
TransData *td;
TransDataExtension *tx;
float mtx[3][3], smtx[3][3];
- int count=0, countsel=0;
+ int count = 0, countsel = 0;
int propmode = t->flag & T_PROP_EDIT;
/* count totals */
- for (ml= mb->editelems->first; ml; ml= ml->next) {
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
if (ml->flag & SELECT) countsel++;
if (propmode) count++;
}
/* note: in prop mode we need at least 1 selected */
- if (countsel==0) return;
+ if (countsel == 0) return;
if (propmode) t->total = count;
else t->total = countsel;
- td = t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(MBall EditMode)");
- tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "MetaElement_TransExtension");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(MBall EditMode)");
+ tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "MetaElement_TransExtension");
copy_m3_m4(mtx, t->obedit->obmat);
invert_m3_m3(smtx, mtx);
- for (ml= mb->editelems->first; ml; ml= ml->next) {
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
if (propmode || (ml->flag & SELECT)) {
- td->loc= &ml->x;
+ td->loc = &ml->x;
copy_v3_v3(td->iloc, td->loc);
copy_v3_v3(td->center, td->loc);
- if (ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
- else td->flag= TD_USEQUAT;
+ if (ml->flag & SELECT) td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
+ else td->flag = TD_USEQUAT;
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1276,7 +1276,7 @@ static void createTransMBallVerts(TransInfo *t)
static void calc_distanceCurveVerts(TransData *head, TransData *tail)
{
TransData *td, *td_near = NULL;
- for (td = head; td<=tail; td++) {
+ for (td = head; td <= tail; td++) {
if (td->flag & TD_SELECTED) {
td_near = td;
td->dist = 0.0f;
@@ -1284,8 +1284,8 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail)
else if (td_near) {
float dist;
dist = len_v3v3(td_near->center, td->center);
- if (dist < (td-1)->dist) {
- td->dist = (td-1)->dist;
+ if (dist < (td - 1)->dist) {
+ td->dist = (td - 1)->dist;
}
else {
td->dist = dist;
@@ -1297,7 +1297,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail)
}
}
td_near = NULL;
- for (td = tail; td>=head; td--) {
+ for (td = tail; td >= head; td--) {
if (td->flag & TD_SELECTED) {
td_near = td;
td->dist = 0.0f;
@@ -1305,10 +1305,10 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail)
else if (td_near) {
float dist;
dist = len_v3v3(td_near->center, td->center);
- if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td+1)->dist < td->dist) {
+ if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td + 1)->dist < td->dist) {
td->flag &= ~TD_NOTCONNECTED;
- if (dist < (td+1)->dist) {
- td->dist = (td+1)->dist;
+ if (dist < (td + 1)->dist) {
+ td->dist = (td + 1)->dist;
}
else {
td->dist = dist;
@@ -1333,44 +1333,44 @@ static TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struc
static void createTransCurveVerts(bContext *C, TransInfo *t)
{
- Object *obedit= CTX_data_edit_object(C);
- Curve *cu= obedit->data;
+ Object *obedit = CTX_data_edit_object(C);
+ Curve *cu = obedit->data;
TransData *td = NULL;
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
float mtx[3][3], smtx[3][3];
int a;
- int count=0, countsel=0;
+ int count = 0, countsel = 0;
int propmode = t->flag & T_PROP_EDIT;
short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
ListBase *nurbs;
/* to be sure */
- if (cu->editnurb==NULL) return;
+ if (cu->editnurb == NULL) return;
/* count total of vertices, check identical as in 2nd loop for making transdata! */
- nurbs= BKE_curve_editNurbs_get(cu);
- for (nu= nurbs->first; nu; nu= nu->next) {
+ nurbs = BKE_curve_editNurbs_get(cu);
+ for (nu = nurbs->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
- for (a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
- if (bezt->hide==0) {
+ for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
+ if (bezt->hide == 0) {
if (hide_handles) {
- if (bezt->f2 & SELECT) countsel+=3;
- if (propmode) count+= 3;
+ if (bezt->f2 & SELECT) countsel += 3;
+ if (propmode) count += 3;
}
else {
if (bezt->f1 & SELECT) countsel++;
if (bezt->f2 & SELECT) countsel++;
if (bezt->f3 & SELECT) countsel++;
- if (propmode) count+= 3;
+ if (propmode) count += 3;
}
}
}
}
else {
- for (a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) {
- if (bp->hide==0) {
+ for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
+ if (bp->hide == 0) {
if (propmode) count++;
if (bp->f1 & SELECT) countsel++;
}
@@ -1378,22 +1378,22 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
}
}
/* note: in prop mode we need at least 1 selected */
- if (countsel==0) return;
+ if (countsel == 0) return;
if (propmode) t->total = count;
else t->total = countsel;
- t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Curve EditMode)");
+ t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Curve EditMode)");
copy_m3_m4(mtx, t->obedit->obmat);
invert_m3_m3(smtx, mtx);
td = t->data;
- for (nu= nurbs->first; nu; nu= nu->next) {
+ for (nu = nurbs->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
TransData *head, *tail;
head = tail = td;
- for (a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
- if (bezt->hide==0) {
+ for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
+ if (bezt->hide == 0) {
TransDataCurveHandleFlags *hdata = NULL;
if (propmode ||
@@ -1401,15 +1401,15 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
((bezt->f1 & SELECT) && hide_handles == 0))
{
copy_v3_v3(td->iloc, bezt->vec[0]);
- td->loc= bezt->vec[0];
- copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1:0]);
+ td->loc = bezt->vec[0];
+ copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1 : 0]);
if (hide_handles) {
- if (bezt->f2 & SELECT) td->flag= TD_SELECTED;
- else td->flag= 0;
+ if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
}
else {
- if (bezt->f1 & SELECT) td->flag= TD_SELECTED;
- else td->flag= 0;
+ if (bezt->f1 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
}
td->ext = NULL;
td->val = NULL;
@@ -1427,17 +1427,17 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
/* This is the Curve Point, the other two are handles */
if (propmode || (bezt->f2 & SELECT)) {
copy_v3_v3(td->iloc, bezt->vec[1]);
- td->loc= bezt->vec[1];
+ td->loc = bezt->vec[1];
copy_v3_v3(td->center, td->loc);
- if (bezt->f2 & SELECT) td->flag= TD_SELECTED;
- else td->flag= 0;
+ if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
td->ext = NULL;
- if (t->mode==TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
+ if (t->mode == TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
td->val = &(bezt->radius);
td->ival = bezt->radius;
}
- else if (t->mode==TFM_TILT) {
+ else if (t->mode == TFM_TILT) {
td->val = &(bezt->alfa);
td->ival = bezt->alfa;
}
@@ -1448,11 +1448,11 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
- if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0)
- /* If the middle is selected but the sides arnt, this is needed */
- if (hdata==NULL) { /* if the handle was not saved by the previous handle */
- hdata = initTransDataCurveHandles(td, bezt);
- }
+ if ((bezt->f1 & SELECT) == 0 && (bezt->f3 & SELECT) == 0)
+ /* If the middle is selected but the sides arnt, this is needed */
+ if (hdata == NULL) { /* if the handle was not saved by the previous handle */
+ hdata = initTransDataCurveHandles(td, bezt);
+ }
td++;
count++;
@@ -1463,20 +1463,20 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
((bezt->f3 & SELECT) && hide_handles == 0))
{
copy_v3_v3(td->iloc, bezt->vec[2]);
- td->loc= bezt->vec[2];
- copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1:2]);
+ td->loc = bezt->vec[2];
+ copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1 : 2]);
if (hide_handles) {
- if (bezt->f2 & SELECT) td->flag= TD_SELECTED;
- else td->flag= 0;
+ if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
}
else {
- if (bezt->f3 & SELECT) td->flag= TD_SELECTED;
- else td->flag= 0;
+ if (bezt->f3 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
}
td->ext = NULL;
td->val = NULL;
- if (hdata==NULL) { /* if the handle was not saved by the previous handle */
+ if (hdata == NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandles(td, bezt);
}
@@ -1489,12 +1489,12 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
}
}
else if (propmode && head != tail) {
- calc_distanceCurveVerts(head, tail-1);
+ calc_distanceCurveVerts(head, tail - 1);
head = tail;
}
}
if (propmode && head != tail)
- calc_distanceCurveVerts(head, tail-1);
+ calc_distanceCurveVerts(head, tail - 1);
/* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
* but for now just don't change handle types */
@@ -1506,17 +1506,17 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
else {
TransData *head, *tail;
head = tail = td;
- for (a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) {
- if (bp->hide==0) {
+ for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
+ if (bp->hide == 0) {
if (propmode || (bp->f1 & SELECT)) {
copy_v3_v3(td->iloc, bp->vec);
- td->loc= bp->vec;
+ td->loc = bp->vec;
copy_v3_v3(td->center, td->loc);
- if (bp->f1 & SELECT) td->flag= TD_SELECTED;
- else td->flag= 0;
+ if (bp->f1 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
td->ext = NULL;
- if (t->mode==TFM_CURVE_SHRINKFATTEN || t->mode==TFM_RESIZE) {
+ if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) {
td->val = &(bp->radius);
td->ival = bp->radius;
}
@@ -1534,12 +1534,12 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
}
}
else if (propmode && head != tail) {
- calc_distanceCurveVerts(head, tail-1);
+ calc_distanceCurveVerts(head, tail - 1);
head = tail;
}
}
if (propmode && head != tail)
- calc_distanceCurveVerts(head, tail-1);
+ calc_distanceCurveVerts(head, tail - 1);
}
}
}
@@ -1548,30 +1548,30 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
static void createTransLatticeVerts(TransInfo *t)
{
- Lattice *latt = ((Lattice*)t->obedit->data)->editlatt->latt;
+ Lattice *latt = ((Lattice *)t->obedit->data)->editlatt->latt;
TransData *td = NULL;
BPoint *bp;
float mtx[3][3], smtx[3][3];
int a;
- int count=0, countsel=0;
+ int count = 0, countsel = 0;
int propmode = t->flag & T_PROP_EDIT;
bp = latt->def;
a = latt->pntsu * latt->pntsv * latt->pntsw;
while (a--) {
- if (bp->hide==0) {
+ if (bp->hide == 0) {
if (bp->f1 & SELECT) countsel++;
if (propmode) count++;
}
bp++;
}
- /* note: in prop mode we need at least 1 selected */
- if (countsel==0) return;
+ /* note: in prop mode we need at least 1 selected */
+ if (countsel == 0) return;
if (propmode) t->total = count;
else t->total = countsel;
- t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Lattice EditMode)");
+ t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Lattice EditMode)");
copy_m3_m4(mtx, t->obedit->obmat);
invert_m3_m3(smtx, mtx);
@@ -1581,12 +1581,12 @@ static void createTransLatticeVerts(TransInfo *t)
a = latt->pntsu * latt->pntsv * latt->pntsw;
while (a--) {
if (propmode || (bp->f1 & SELECT)) {
- if (bp->hide==0) {
+ if (bp->hide == 0) {
copy_v3_v3(td->iloc, bp->vec);
- td->loc= bp->vec;
+ td->loc = bp->vec;
copy_v3_v3(td->center, td->loc);
- if (bp->f1 & SELECT) td->flag= TD_SELECTED;
- else td->flag= 0;
+ if (bp->f1 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1619,7 +1619,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
int count = 0, hasselected = 0;
int propmode = t->flag & T_PROP_EDIT;
- if (edit==NULL || t->settings->particle.selectmode==SCE_SELECT_PATH) return;
+ if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) return;
psys = edit->psys;
@@ -1628,19 +1628,19 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
base->flag |= BA_HAS_RECALC_DATA;
- for (i=0, point=edit->points; i<edit->totpoint; i++, point++) {
+ for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
point->flag &= ~PEP_TRANSFORM;
- transformparticle= 0;
-
- if ((point->flag & PEP_HIDE)==0) {
- for (k=0, key=point->keys; k<point->totkey; k++, key++) {
- if ((key->flag&PEK_HIDE)==0) {
- if (key->flag&PEK_SELECT) {
- hasselected= 1;
- transformparticle= 1;
+ transformparticle = 0;
+
+ if ((point->flag & PEP_HIDE) == 0) {
+ for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
+ if ((key->flag & PEK_HIDE) == 0) {
+ if (key->flag & PEK_SELECT) {
+ hasselected = 1;
+ transformparticle = 1;
}
else if (propmode)
- transformparticle= 1;
+ transformparticle = 1;
}
}
}
@@ -1651,8 +1651,8 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
}
}
- /* note: in prop mode we need at least 1 selected */
- if (hasselected==0) return;
+ /* note: in prop mode we need at least 1 selected */
+ if (hasselected == 0) return;
t->total = count;
td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)");
@@ -1666,7 +1666,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
invert_m4_m4(ob->imat, ob->obmat);
- for (i=0, point=edit->points; i<edit->totpoint; i++, point++) {
+ for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
TransData *head, *tail;
head = tail = td;
@@ -1675,7 +1675,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR))
psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
- for (k=0, key=point->keys; k<point->totkey; k++, key++) {
+ for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
if (key->flag & PEK_USE_WCO) {
copy_v3_v3(key->world_co, key->co);
mul_m4_v3(mat, key->world_co);
@@ -1696,7 +1696,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
unit_m3(td->smtx);
/* don't allow moving roots */
- if (k==0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
+ if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
td->protectflag |= OB_LOCK_LOC;
td->ob = ob;
@@ -1706,7 +1706,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
td->ival = *(key->time);
/* abuse size and quat for min/max values */
td->flag |= TD_NO_EXT;
- if (k==0) tx->size = NULL;
+ if (k == 0) tx->size = NULL;
else tx->size = (key - 1)->time;
if (k == point->totkey - 1) tx->quat = NULL;
@@ -1741,15 +1741,15 @@ void flushTransParticles(TransInfo *t)
/* we do transform in world space, so flush world space position
* back to particle local space (only for hair particles) */
- td= t->data;
- for (i=0, point=edit->points; i<edit->totpoint; i++, point++, td++) {
+ td = t->data;
+ for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) {
if (!(point->flag & PEP_TRANSFORM)) continue;
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
invert_m4_m4(imat, mat);
- for (k=0, key=point->keys; k<point->totkey; k++, key++) {
+ for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
copy_v3_v3(co, key->world_co);
mul_m4_v3(imat, co);
@@ -1771,7 +1771,7 @@ void flushTransParticles(TransInfo *t)
/* ********************* mesh ****************** */
/* proportional distance based on connectivity */
-#define THRESHOLDFACTOR (1.0f-0.0001f)
+#define THRESHOLDFACTOR (1.0f - 0.0001f)
/* I did this wrong, it should be a breadth-first search
* but instead it's a depth-first search, fudged
@@ -1781,10 +1781,10 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
{
BMVert **queue = NULL;
float *dqueue = NULL;
- int *tots = MEM_callocN(sizeof(int)*em->bm->totvert, "tots editmesh_set_connectivity_distance");
+ int *tots = MEM_callocN(sizeof(int) * em->bm->totvert, "tots editmesh_set_connectivity_distance");
BLI_array_declare(queue);
BLI_array_declare(dqueue);
- SmallHash svisit, *visit=&svisit;
+ SmallHash svisit, *visit = &svisit;
BMVert *v;
BMIter viter;
int i, start;
@@ -1796,7 +1796,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
BLI_smallhash_init(visit);
BM_ITER_MESH (v, &viter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)==0 || BM_elem_flag_test(v, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT) == 0 || BM_elem_flag_test(v, BM_ELEM_HIDDEN))
continue;
@@ -1849,7 +1849,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
BLI_smallhash_release(visit);
- for (i=0; i<em->bm->totvert; i++) {
+ for (i = 0; i < em->bm->totvert; i++) {
if (tots[i])
dists[i] /= (float)tots[i];
}
@@ -1860,7 +1860,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
}
/* loop-in-a-loop I know, but we need it! (ton) */
- static void get_face_center(float cent_r[3], BMVert *eve)
+static void get_face_center(float cent_r[3], BMVert *eve)
{
BMFace *efa;
@@ -1899,7 +1899,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
copy_v3_v3(td->center, td->loc);
- if (t->around==V3D_LOCAL) {
+ if (t->around == V3D_LOCAL) {
if (em->selectmode & SCE_SELECT_FACE)
get_face_center(td->center, eve);
else if (em->selectmode & SCE_SELECT_EDGE)
@@ -1909,12 +1909,12 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
// Setting normals
copy_v3_v3(td->axismtx[2], eve->no);
- td->axismtx[0][0] =
- td->axismtx[0][1] =
- td->axismtx[0][2] =
- td->axismtx[1][0] =
- td->axismtx[1][1] =
- td->axismtx[1][2] = 0.0f;
+ td->axismtx[0][0] =
+ td->axismtx[0][1] =
+ td->axismtx[0][2] =
+ td->axismtx[1][0] =
+ td->axismtx[1][1] =
+ td->axismtx[1][2] = 0.0f;
td->ext = NULL;
td->val = NULL;
@@ -1945,10 +1945,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
BMVert *eve;
BMIter iter;
BMVert *eve_act = NULL;
- float *mappedcos = NULL, *quats= NULL;
+ float *mappedcos = NULL, *quats = NULL;
float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
- float *dists=NULL;
- int count=0, countsel=0, a, totleft;
+ float *dists = NULL;
+ int count = 0, countsel = 0, a, totleft;
int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) : 0;
int mirror = 0;
char *selstate = NULL;
@@ -1977,10 +1977,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
BMEdge *eed;
eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
- for ( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
+ for (; eve; eve = BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
eed = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL);
- for ( ; eed; eed=BM_iter_step(&iter)) {
+ for (; eed; eed = BM_iter_step(&iter)) {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
BM_elem_flag_enable(eed->v1, BM_ELEM_TAG);
BM_elem_flag_enable(eed->v2, BM_ELEM_TAG);
@@ -1990,16 +1990,16 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
else {
BMFace *efa;
eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
- for ( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
+ for (; eve; eve = BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
efa = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL);
- for ( ; efa; efa=BM_iter_step(&iter)) {
+ for (; efa; efa = BM_iter_step(&iter)) {
if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BMIter liter;
BMLoop *l;
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, efa);
- for (; l; l=BM_iter_step(&liter)) {
+ for (; l; l = BM_iter_step(&liter)) {
BM_elem_flag_enable(l->v, BM_ELEM_TAG);
}
}
@@ -2011,7 +2011,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
* verts*/
selstate = MEM_callocN(sizeof(*selstate) * bm->totvert, __func__);
eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
- for (a=0; eve; eve=BM_iter_step(&iter), a++) {
+ for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
if (BM_elem_flag_test(eve, BM_ELEM_TAG)) {
selstate[a] = 1;
@@ -2044,10 +2044,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
else t->total = countsel;
- tob= t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Mesh EditMode)");
+ tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)");
if (t->mode == TFM_SKIN_RESIZE) {
tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension),
- "TransObData ext");
+ "TransObData ext");
}
copy_m3_m4(mtx, t->obedit->obmat);
@@ -2058,19 +2058,19 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
/* detect CrazySpace [tm] */
- if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1)>=0) {
+ if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) >= 0) {
if (modifiers_isCorrectableDeformed(t->obedit)) {
/* check if we can use deform matrices for modifier from the
* start up to stack, they are more accurate than quats */
- totleft= editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos);
+ totleft = editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos);
/* if we still have more modifiers, also do crazyspace
* correction with quats, relative to the coordinates after
* the modifiers that support deform matrices (defcos) */
if (totleft > 0) {
- mappedcos= crazyspace_get_mapped_editverts(t->scene, t->obedit);
- quats= MEM_mallocN((t->total)*sizeof(float)*4, "crazy quats");
- crazyspace_set_quats_editmesh(em, (float*)defcos, mappedcos, quats); /* BMESH_TODO, abuses vertex index, should use an int array */
+ mappedcos = crazyspace_get_mapped_editverts(t->scene, t->obedit);
+ quats = MEM_mallocN((t->total) * sizeof(float) * 4, "crazy quats");
+ crazyspace_set_quats_editmesh(em, (float *)defcos, mappedcos, quats); /* BMESH_TODO, abuses vertex index, should use an int array */
if (mappedcos)
MEM_freeN(mappedcos);
}
@@ -2083,8 +2083,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
/* find out which half we do */
if (mirror) {
eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
- for (a=0; eve; eve=BM_iter_step(&iter), a++) {
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && selstate[a] && eve->co[0]!=0.0f) {
+ for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && selstate[a] && eve->co[0] != 0.0f) {
if (eve->co[0] < 0.0f) {
t->mirror = -1;
mirror = -1;
@@ -2095,7 +2095,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
- for (a=0; eve; eve=BM_iter_step(&iter), a++) {
+ for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
if (propmode || selstate[a]) {
float *bweight = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_BWEIGHT);
@@ -2126,11 +2126,11 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
/* use both or either quat and defmat correction */
if (quats && BM_elem_index_get(eve) != -1) {
- quat_to_mat3(qmat, quats + 4*BM_elem_index_get(eve));
+ quat_to_mat3(qmat, quats + 4 * BM_elem_index_get(eve));
if (defmats)
mul_serie_m3(mat, mtx, qmat, defmats[a],
- NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL);
else
mul_m3_m3m3(mat, mtx, qmat);
}
@@ -2148,8 +2148,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
/* Mirror? */
- if ((mirror>0 && tob->iloc[0]>0.0f) || (mirror<0 && tob->iloc[0]<0.0f)) {
- BMVert *vmir= EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
+ if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) {
+ BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
if (vmir && vmir != eve) {
tob->extra = vmir;
}
@@ -2161,7 +2161,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
if (mirror != 0) {
tob = t->data;
- for (a = 0; a < t->total; a++, tob++ ) {
+ for (a = 0; a < t->total; a++, tob++) {
if (ABS(tob->loc[0]) <= 0.00001f) {
tob->flag |= TD_MIRROR_EDGE;
}
@@ -2192,13 +2192,13 @@ void flushTransNodes(TransInfo *t)
TransData2D *td;
/* flush to 2d vector from internally used 3d vector */
- for (a=0, td= t->data2d; a<t->total; a++, td++) {
- td->loc2d[0]= td->loc[0];
- td->loc2d[1]= td->loc[1];
+ for (a = 0, td = t->data2d; a < t->total; a++, td++) {
+ td->loc2d[0] = td->loc[0];
+ td->loc2d[1] = td->loc[1];
}
/* handle intersection with noodles */
- if (t->total==1) {
+ if (t->total == 1) {
ED_node_link_intersect_test(t->sa, 1);
}
}
@@ -2212,11 +2212,11 @@ void flushTransNodes(TransInfo *t)
void flushTransSeq(TransInfo *t)
{
- ListBase *seqbasep= BKE_sequencer_editing_get(t->scene, FALSE)->seqbasep; /* Editing null check already done */
+ ListBase *seqbasep = BKE_sequencer_editing_get(t->scene, FALSE)->seqbasep; /* Editing null check already done */
int a, new_frame, old_start;
- TransData *td= NULL;
- TransData2D *td2d= NULL;
- TransDataSeq *tdsq= NULL;
+ TransData *td = NULL;
+ TransData2D *td2d = NULL;
+ TransDataSeq *tdsq = NULL;
Sequence *seq;
@@ -2224,43 +2224,43 @@ void flushTransSeq(TransInfo *t)
/* prevent updating the same seq twice
* if the transdata order is changed this will mess up
* but so will TransDataSeq */
- Sequence *seq_prev= NULL;
+ Sequence *seq_prev = NULL;
/* flush to 2d vector from internally used 3d vector */
- for (a=0, td= t->data, td2d= t->data2d; a<t->total; a++, td++, td2d++) {
- tdsq= (TransDataSeq *)td->extra;
- seq= tdsq->seq;
+ for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
+ tdsq = (TransDataSeq *)td->extra;
+ seq = tdsq->seq;
old_start = seq->start;
- new_frame= (int)floor(td2d->loc[0] + 0.5f);
+ new_frame = (int)floor(td2d->loc[0] + 0.5f);
switch (tdsq->sel_flag) {
- case SELECT:
+ case SELECT:
#ifdef SEQ_TX_NESTED_METAS
- if ((seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
- seq->start= new_frame - tdsq->start_offset;
+ if ((seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
+ seq->start = new_frame - tdsq->start_offset;
#else
- if (seq->type != SEQ_TYPE_META && (seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
- seq->start= new_frame - tdsq->start_offset;
+ if (seq->type != SEQ_TYPE_META && (seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
+ seq->start = new_frame - tdsq->start_offset;
#endif
- if (seq->depth==0) {
- seq->machine= (int)floor(td2d->loc[1] + 0.5f);
- CLAMP(seq->machine, 1, MAXSEQ);
- }
- break;
- case SEQ_LEFTSEL: /* no vertical transform */
- seq_tx_set_final_left(seq, new_frame);
- seq_tx_handle_xlimits(seq, tdsq->flag&SEQ_LEFTSEL, tdsq->flag&SEQ_RIGHTSEL);
- seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
- break;
- case SEQ_RIGHTSEL: /* no vertical transform */
- seq_tx_set_final_right(seq, new_frame);
- seq_tx_handle_xlimits(seq, tdsq->flag&SEQ_LEFTSEL, tdsq->flag&SEQ_RIGHTSEL);
- seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
- break;
+ if (seq->depth == 0) {
+ seq->machine = (int)floor(td2d->loc[1] + 0.5f);
+ CLAMP(seq->machine, 1, MAXSEQ);
+ }
+ break;
+ case SEQ_LEFTSEL: /* no vertical transform */
+ seq_tx_set_final_left(seq, new_frame);
+ seq_tx_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL);
+ seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
+ break;
+ case SEQ_RIGHTSEL: /* no vertical transform */
+ seq_tx_set_final_right(seq, new_frame);
+ seq_tx_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL);
+ seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
+ break;
}
if (seq != seq_prev) {
- if (seq->depth==0) {
+ if (seq->depth == 0) {
/* Calculate this strip and all nested strips
* children are ALWAYS transformed first
* so we don't need to do this in another loop. */
@@ -2273,7 +2273,7 @@ void flushTransSeq(TransInfo *t)
if (tdsq->sel_flag == SELECT)
seq_offset_animdata(t->scene, seq, seq->start - old_start);
}
- seq_prev= seq;
+ seq_prev = seq;
}
@@ -2295,14 +2295,14 @@ void flushTransSeq(TransInfo *t)
/* need to do the overlap check in a new loop otherwise adjacent strips
* will not be updated and we'll get false positives */
- seq_prev= NULL;
- for (a=0, td= t->data, td2d= t->data2d; a<t->total; a++, td++, td2d++) {
+ seq_prev = NULL;
+ for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
- tdsq= (TransDataSeq *)td->extra;
- seq= tdsq->seq;
+ tdsq = (TransDataSeq *)td->extra;
+ seq = tdsq->seq;
if (seq != seq_prev) {
- if (seq->depth==0) {
+ if (seq->depth == 0) {
/* test overlap, displayes red outline */
seq->flag &= ~SEQ_OVERLAP;
if (seq_test_overlap(seqbasep, seq)) {
@@ -2310,7 +2310,7 @@ void flushTransSeq(TransInfo *t)
}
}
}
- seq_prev= seq;
+ seq_prev = seq;
}
}
@@ -2326,8 +2326,8 @@ static void UVsToTransData(SpaceImage *sima, TransData *td, TransData2D *td2d, f
* proportional editing to be consistent with the stretched uv coords
* that are displayed. this also means that for display and numinput,
* and when the the uv coords are flushed, these are converted each time */
- td2d->loc[0] = uv[0]*aspx;
- td2d->loc[1] = uv[1]*aspy;
+ td2d->loc[0] = uv[0] * aspx;
+ td2d->loc[1] = uv[1] * aspy;
td2d->loc[2] = 0.0f;
td2d->loc2d = uv;
@@ -2339,14 +2339,14 @@ static void UVsToTransData(SpaceImage *sima, TransData *td, TransData2D *td2d, f
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL; td->val= NULL;
+ td->ext = NULL; td->val = NULL;
if (selected) {
td->flag |= TD_SELECTED;
- td->dist= 0.0;
+ td->dist = 0.0;
}
else {
- td->dist= MAXFLOAT;
+ td->dist = MAXFLOAT;
}
unit_m3(td->mtx);
unit_m3(td->smtx);
@@ -2365,14 +2365,14 @@ static void createTransUVs(bContext *C, TransInfo *t)
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
- int count=0, countsel=0;
+ int count = 0, countsel = 0;
int propmode = t->flag & T_PROP_EDIT;
if (!ED_space_image_show_uvedit(sima, t->obedit)) return;
/* count */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
+ tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if (!uvedit_face_visible_test(scene, ima, efa, tf)) {
BM_elem_flag_disable(efa, BM_ELEM_TAG);
@@ -2389,20 +2389,20 @@ static void createTransUVs(bContext *C, TransInfo *t)
}
}
- /* note: in prop mode we need at least 1 selected */
- if (countsel==0) return;
+ /* note: in prop mode we need at least 1 selected */
+ if (countsel == 0) return;
- t->total= (propmode)? count: countsel;
- t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(UV Editing)");
+ t->total = (propmode) ? count : countsel;
+ t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(UV Editing)");
/* for each 2d uv coord a 3d vector is allocated, so that they can be
* treated just as if they were 3d verts */
- t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransObData2D(UV Editing)");
+ t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransObData2D(UV Editing)");
if (sima->flag & SI_CLIP_UV)
t->flag |= T_CLIP_UV;
- td= t->data;
- td2d= t->data2d;
+ td = t->data;
+ td2d = t->data2d;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
@@ -2430,17 +2430,17 @@ void flushTransUVs(TransInfo *t)
ED_space_image_uv_aspect(sima, &aspx, &aspy);
ED_space_image_size(sima, &width, &height);
- invx= 1.0f/aspx;
- invy= 1.0f/aspy;
+ invx = 1.0f / aspx;
+ invy = 1.0f / aspy;
/* flush to 2d vector from internally used 3d vector */
- for (a=0, td= t->data2d; a<t->total; a++, td++) {
- td->loc2d[0]= td->loc[0]*invx;
- td->loc2d[1]= td->loc[1]*invy;
+ for (a = 0, td = t->data2d; a < t->total; a++, td++) {
+ td->loc2d[0] = td->loc[0] * invx;
+ td->loc2d[1] = td->loc[1] * invy;
if ((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) {
- td->loc2d[0]= (float)floor(width*td->loc2d[0] + 0.5f)/width;
- td->loc2d[1]= (float)floor(height*td->loc2d[1] + 0.5f)/height;
+ td->loc2d[0] = (float)floor(width * td->loc2d[0] + 0.5f) / width;
+ td->loc2d[1] = (float)floor(height * td->loc2d[1] + 0.5f) / height;
}
}
}
@@ -2448,46 +2448,46 @@ void flushTransUVs(TransInfo *t)
int clipUVTransform(TransInfo *t, float *vec, int resize)
{
TransData *td;
- int a, clipx=1, clipy=1;
+ int a, clipx = 1, clipy = 1;
float aspx, aspy, min[2], max[2];
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
- min[0]= min[1]= 0.0f;
- max[0]= aspx; max[1]= aspy;
+ min[0] = min[1] = 0.0f;
+ max[0] = aspx; max[1] = aspy;
- for (a=0, td= t->data; a<t->total; a++, td++) {
+ for (a = 0, td = t->data; a < t->total; a++, td++) {
DO_MINMAX2(td->loc, min, max);
}
if (resize) {
- if (min[0] < 0.0f && t->center[0] > 0.0f && t->center[0] < aspx*0.5f)
- vec[0] *= t->center[0]/(t->center[0] - min[0]);
+ if (min[0] < 0.0f && t->center[0] > 0.0f && t->center[0] < aspx * 0.5f)
+ vec[0] *= t->center[0] / (t->center[0] - min[0]);
else if (max[0] > aspx && t->center[0] < aspx)
- vec[0] *= (t->center[0] - aspx)/(t->center[0] - max[0]);
+ vec[0] *= (t->center[0] - aspx) / (t->center[0] - max[0]);
else
- clipx= 0;
+ clipx = 0;
- if (min[1] < 0.0f && t->center[1] > 0.0f && t->center[1] < aspy*0.5f)
- vec[1] *= t->center[1]/(t->center[1] - min[1]);
+ if (min[1] < 0.0f && t->center[1] > 0.0f && t->center[1] < aspy * 0.5f)
+ vec[1] *= t->center[1] / (t->center[1] - min[1]);
else if (max[1] > aspy && t->center[1] < aspy)
- vec[1] *= (t->center[1] - aspy)/(t->center[1] - max[1]);
+ vec[1] *= (t->center[1] - aspy) / (t->center[1] - max[1]);
else
- clipy= 0;
+ clipy = 0;
}
else {
if (min[0] < 0.0f)
vec[0] -= min[0];
else if (max[0] > aspx)
- vec[0] -= max[0]-aspx;
+ vec[0] -= max[0] - aspx;
else
- clipx= 0;
+ clipx = 0;
if (min[1] < 0.0f)
vec[1] -= min[1];
else if (max[1] > aspy)
- vec[1] -= max[1]-aspy;
+ vec[1] -= max[1] - aspy;
else
- clipy= 0;
+ clipy = 0;
}
return (clipx || clipy);
@@ -2512,7 +2512,7 @@ static short FrameOnMouseSide(char side, float frame, float cframe)
static void createTransNlaData(bContext *C, TransInfo *t)
{
- Scene *scene= t->scene;
+ Scene *scene = t->scene;
SpaceNla *snla = NULL;
TransData *td = NULL;
TransDataNla *tdn = NULL;
@@ -2522,7 +2522,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
bAnimListElem *ale;
int filter;
- int count=0;
+ int count = 0;
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -2530,7 +2530,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
snla = (SpaceNla *)ac.sl;
/* filter data */
- filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* which side of the current frame should be allowed */
@@ -2539,7 +2539,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
float xmouse, ymouse;
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
- t->frame_side= (xmouse > CFRA) ? 'R' : 'L';
+ t->frame_side = (xmouse > CFRA) ? 'R' : 'L';
}
else {
/* normal transform - both sides of current frame are considered */
@@ -2547,15 +2547,15 @@ static void createTransNlaData(bContext *C, TransInfo *t)
}
/* loop 1: count how many strips are selected (consider each strip as 2 points) */
- for (ale= anim_data.first; ale; ale= ale->next) {
- NlaTrack *nlt= (NlaTrack *)ale->data;
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
/* make some meta-strips for chains of selected strips */
BKE_nlastrips_make_metas(&nlt->strips, 1);
/* only consider selected strips */
- for (strip= nlt->strips.first; strip; strip= strip->next) {
+ for (strip = nlt->strips.first; strip; strip = strip->next) {
// TODO: we can make strips have handles later on...
/* transition strips can't get directly transformed */
if (strip->type != NLASTRIP_TYPE_TRANSITION) {
@@ -2575,24 +2575,24 @@ static void createTransNlaData(bContext *C, TransInfo *t)
}
/* allocate memory for data */
- t->total= count;
+ t->total = count;
- t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(NLA Editor)");
- td= t->data;
- t->customData= MEM_callocN(t->total*sizeof(TransDataNla), "TransDataNla (NLA Editor)");
- tdn= t->customData;
+ t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(NLA Editor)");
+ td = t->data;
+ t->customData = MEM_callocN(t->total * sizeof(TransDataNla), "TransDataNla (NLA Editor)");
+ tdn = t->customData;
t->flag |= T_FREE_CUSTOMDATA;
/* loop 2: build transdata array */
- for (ale= anim_data.first; ale; ale= ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next) {
/* only if a real NLA-track */
if (ale->type == ANIMTYPE_NLATRACK) {
AnimData *adt = ale->adt;
- NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
/* only consider selected strips */
- for (strip= nlt->strips.first; strip; strip= strip->next) {
+ for (strip = nlt->strips.first; strip; strip = strip->next) {
// TODO: we can make strips have handles later on...
/* transition strips can't get directly transformed */
if (strip->type != NLASTRIP_TYPE_TRANSITION) {
@@ -2602,37 +2602,37 @@ static void createTransNlaData(bContext *C, TransInfo *t)
* - td structs are transform-elements operated on by the transform system
* and represent a single handle. The storage/pointer used (val or loc) depends on
* whether we're scaling or transforming. Ultimately though, the handles
- * the td writes to will simply be a dummy in tdn
+ * the td writes to will simply be a dummy in tdn
* - for each strip being transformed, a single tdn struct is used, so in some
* cases, there will need to be 1 of these tdn elements in the array skipped...
*/
float center[3], yval;
/* firstly, init tdn settings */
- tdn->id= ale->id;
- tdn->oldTrack= tdn->nlt= nlt;
- tdn->strip= strip;
- tdn->trackIndex= BLI_findindex(&adt->nla_tracks, nlt);
-
- yval= (float)(tdn->trackIndex * NLACHANNEL_STEP(snla));
-
- tdn->h1[0]= strip->start;
- tdn->h1[1]= yval;
- tdn->h2[0]= strip->end;
- tdn->h2[1]= yval;
-
- center[0]= (float)CFRA;
- center[1]= yval;
- center[2]= 0.0f;
+ tdn->id = ale->id;
+ tdn->oldTrack = tdn->nlt = nlt;
+ tdn->strip = strip;
+ tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt);
+
+ yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla));
+
+ tdn->h1[0] = strip->start;
+ tdn->h1[1] = yval;
+ tdn->h2[0] = strip->end;
+ tdn->h2[1] = yval;
+
+ center[0] = (float)CFRA;
+ center[1] = yval;
+ center[2] = 0.0f;
/* set td's based on which handles are applicable */
if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
/* just set tdn to assume that it only has one handle for now */
- tdn->handle= -1;
+ tdn->handle = -1;
/* now, link the transform data up to this data */
if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
- td->loc= tdn->h1;
+ td->loc = tdn->h1;
copy_v3_v3(td->iloc, tdn->h1);
/* store all the other gunk that is required by transform */
@@ -2640,30 +2640,30 @@ static void createTransNlaData(bContext *C, TransInfo *t)
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL; td->val= NULL;
+ td->ext = NULL; td->val = NULL;
td->flag |= TD_SELECTED;
- td->dist= 0.0f;
+ td->dist = 0.0f;
unit_m3(td->mtx);
unit_m3(td->smtx);
}
else {
/* time scaling only needs single value */
- td->val= &tdn->h1[0];
- td->ival= tdn->h1[0];
+ td->val = &tdn->h1[0];
+ td->ival = tdn->h1[0];
}
- td->extra= tdn;
+ td->extra = tdn;
td++;
}
if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
/* if tdn is already holding the start handle, then we're doing both, otherwise, only end */
- tdn->handle= (tdn->handle) ? 2 : 1;
+ tdn->handle = (tdn->handle) ? 2 : 1;
/* now, link the transform data up to this data */
if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
- td->loc= tdn->h2;
+ td->loc = tdn->h2;
copy_v3_v3(td->iloc, tdn->h2);
/* store all the other gunk that is required by transform */
@@ -2671,21 +2671,21 @@ static void createTransNlaData(bContext *C, TransInfo *t)
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL; td->val= NULL;
+ td->ext = NULL; td->val = NULL;
td->flag |= TD_SELECTED;
- td->dist= 0.0f;
+ td->dist = 0.0f;
unit_m3(td->mtx);
unit_m3(td->smtx);
}
else {
/* time scaling only needs single value */
- td->val= &tdn->h2[0];
- td->ival= tdn->h2[0];
+ td->val = &tdn->h2[0];
+ td->ival = tdn->h2[0];
}
- td->extra= tdn;
+ td->extra = tdn;
td++;
}
@@ -2713,11 +2713,11 @@ static void createTransNlaData(bContext *C, TransInfo *t)
* It also makes sure gp-frames are still stored in chronological order after
* transform.
*/
-static void posttrans_gpd_clean (bGPdata *gpd)
+static void posttrans_gpd_clean(bGPdata *gpd)
{
bGPDlayer *gpl;
- for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
+ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
ListBase sel_buffer = {NULL, NULL};
bGPDframe *gpf, *gpfn;
bGPDframe *gfs, *gfsn;
@@ -2725,9 +2725,9 @@ static void posttrans_gpd_clean (bGPdata *gpd)
/* loop 1: loop through and isolate selected gp-frames to buffer
* (these need to be sorted as they are isolated)
*/
- for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
- short added= 0;
- gpfn= gpf->next;
+ for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
+ short added = 0;
+ gpfn = gpf->next;
if (gpf->flag & GP_FRAME_SELECT) {
BLI_remlink(&gpl->frames, gpf);
@@ -2736,11 +2736,11 @@ static void posttrans_gpd_clean (bGPdata *gpd)
* - go backwards as most frames will still be in order,
* so doing it this way will be faster
*/
- for (gfs= sel_buffer.last; gfs; gfs= gfs->prev) {
+ for (gfs = sel_buffer.last; gfs; gfs = gfs->prev) {
/* if current (gpf) occurs after this one in buffer, add! */
if (gfs->framenum < gpf->framenum) {
BLI_insertlinkafter(&sel_buffer, gfs, gpf);
- added= 1;
+ added = 1;
break;
}
}
@@ -2755,19 +2755,19 @@ static void posttrans_gpd_clean (bGPdata *gpd)
/* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */
if (gpl->frames.first == NULL) {
- gpl->frames.first= sel_buffer.first;
- gpl->frames.last= sel_buffer.last;
+ gpl->frames.first = sel_buffer.first;
+ gpl->frames.last = sel_buffer.last;
continue;
}
/* loop 2: remove duplicates of frames in buffers */
- for (gpf= gpl->frames.first; gpf && sel_buffer.first; gpf= gpfn) {
- gpfn= gpf->next;
+ for (gpf = gpl->frames.first; gpf && sel_buffer.first; gpf = gpfn) {
+ gpfn = gpf->next;
/* loop through sel_buffer, emptying stuff from front of buffer if ok */
- for (gfs= sel_buffer.first; gfs && gpf; gfs= gfsn) {
- gfsn= gfs->next;
+ for (gfs = sel_buffer.first; gfs && gpf; gfs = gfsn) {
+ gfsn = gfs->next;
/* if this buffer frame needs to go before current, add it! */
if (gfs->framenum < gpf->framenum) {
@@ -2788,8 +2788,8 @@ static void posttrans_gpd_clean (bGPdata *gpd)
}
/* if anything is still in buffer, append to end */
- for (gfs= sel_buffer.first; gfs; gfs= gfsn) {
- gfsn= gfs->next;
+ for (gfs = sel_buffer.first; gfs; gfs = gfsn) {
+ gfsn = gfs->next;
BLI_remlink(&sel_buffer, gfs);
BLI_addtail(&gpl->frames, gfs);
@@ -2807,7 +2807,7 @@ static void posttrans_mask_clean(Mask *mask)
{
MaskLayer *masklay;
- for (masklay = mask->masklayers.first; masklay; masklay= masklay->next) {
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
ListBase sel_buffer = {NULL, NULL};
MaskLayerShape *masklay_shape, *masklay_shape_new;
MaskLayerShape *masklay_shape_sort, *masklay_shape_sort_new;
@@ -2815,9 +2815,9 @@ static void posttrans_mask_clean(Mask *mask)
/* loop 1: loop through and isolate selected gp-frames to buffer
* (these need to be sorted as they are isolated)
*/
- for (masklay_shape= masklay->splines_shapes.first; masklay_shape; masklay_shape= masklay_shape_new) {
- short added= 0;
- masklay_shape_new= masklay_shape->next;
+ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape_new) {
+ short added = 0;
+ masklay_shape_new = masklay_shape->next;
if (masklay_shape->flag & GP_FRAME_SELECT) {
BLI_remlink(&masklay->splines_shapes, masklay_shape);
@@ -2826,11 +2826,11 @@ static void posttrans_mask_clean(Mask *mask)
* - go backwards as most frames will still be in order,
* so doing it this way will be faster
*/
- for (masklay_shape_sort= sel_buffer.last; masklay_shape_sort; masklay_shape_sort= masklay_shape_sort->prev) {
+ for (masklay_shape_sort = sel_buffer.last; masklay_shape_sort; masklay_shape_sort = masklay_shape_sort->prev) {
/* if current (masklay_shape) occurs after this one in buffer, add! */
if (masklay_shape_sort->frame < masklay_shape->frame) {
BLI_insertlinkafter(&sel_buffer, masklay_shape_sort, masklay_shape);
- added= 1;
+ added = 1;
break;
}
}
@@ -2845,19 +2845,19 @@ static void posttrans_mask_clean(Mask *mask)
/* if all were selected (i.e. masklay->splines_shapes is empty), then just transfer sel-buf over */
if (masklay->splines_shapes.first == NULL) {
- masklay->splines_shapes.first= sel_buffer.first;
- masklay->splines_shapes.last= sel_buffer.last;
+ masklay->splines_shapes.first = sel_buffer.first;
+ masklay->splines_shapes.last = sel_buffer.last;
continue;
}
/* loop 2: remove duplicates of splines_shapes in buffers */
- for (masklay_shape= masklay->splines_shapes.first; masklay_shape && sel_buffer.first; masklay_shape= masklay_shape_new) {
- masklay_shape_new= masklay_shape->next;
+ for (masklay_shape = masklay->splines_shapes.first; masklay_shape && sel_buffer.first; masklay_shape = masklay_shape_new) {
+ masklay_shape_new = masklay_shape->next;
/* loop through sel_buffer, emptying stuff from front of buffer if ok */
- for (masklay_shape_sort= sel_buffer.first; masklay_shape_sort && masklay_shape; masklay_shape_sort= masklay_shape_sort_new) {
- masklay_shape_sort_new= masklay_shape_sort->next;
+ for (masklay_shape_sort = sel_buffer.first; masklay_shape_sort && masklay_shape; masklay_shape_sort = masklay_shape_sort_new) {
+ masklay_shape_sort_new = masklay_shape_sort->next;
/* if this buffer frame needs to go before current, add it! */
if (masklay_shape_sort->frame < masklay_shape->frame) {
@@ -2878,8 +2878,8 @@ static void posttrans_mask_clean(Mask *mask)
}
/* if anything is still in buffer, append to end */
- for (masklay_shape_sort= sel_buffer.first; masklay_shape_sort; masklay_shape_sort= masklay_shape_sort_new) {
- masklay_shape_sort_new= masklay_shape_sort->next;
+ for (masklay_shape_sort = sel_buffer.first; masklay_shape_sort; masklay_shape_sort = masklay_shape_sort_new) {
+ masklay_shape_sort_new = masklay_shape_sort->next;
BLI_remlink(&sel_buffer, masklay_shape_sort);
BLI_addtail(&masklay->splines_shapes, masklay_shape_sort);
@@ -2893,18 +2893,18 @@ static void posttrans_mask_clean(Mask *mask)
/* Called during special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
*/
-static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
+static void posttrans_fcurve_clean(FCurve *fcu, const short use_handle)
{
- float *selcache; /* cache for frame numbers of selected frames (fcu->totvert*sizeof(float)) */
- int len, index, i; /* number of frames in cache, item index */
+ float *selcache; /* cache for frame numbers of selected frames (fcu->totvert*sizeof(float)) */
+ int len, index, i; /* number of frames in cache, item index */
/* allocate memory for the cache */
// TODO: investigate using BezTriple columns instead?
- if (fcu->totvert == 0 || fcu->bezt==NULL)
+ if (fcu->totvert == 0 || fcu->bezt == NULL)
return;
- selcache= MEM_callocN(sizeof(float)*fcu->totvert, "FCurveSelFrameNums");
- len= 0;
- index= 0;
+ selcache = MEM_callocN(sizeof(float) * fcu->totvert, "FCurveSelFrameNums");
+ len = 0;
+ index = 0;
/* We do 2 loops, 1 for marking keyframes for deletion, one for deleting
* as there is no guarantee what order the keyframes are exactly, even though
@@ -2913,10 +2913,10 @@ static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
/* Loop 1: find selected keyframes */
for (i = 0; i < fcu->totvert; i++) {
- BezTriple *bezt= &fcu->bezt[i];
+ BezTriple *bezt = &fcu->bezt[i];
if (BEZSELECTED(bezt)) {
- selcache[index]= bezt->vec[1][0];
+ selcache[index] = bezt->vec[1][0];
index++;
len++;
}
@@ -2926,12 +2926,12 @@ static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
* (if any keyframes were found, or the whole curve wasn't affected)
*/
if ((len) && (len != fcu->totvert)) {
- for (i= fcu->totvert-1; i >= 0; i--) {
- BezTriple *bezt= &fcu->bezt[i];
+ for (i = fcu->totvert - 1; i >= 0; i--) {
+ BezTriple *bezt = &fcu->bezt[i];
if (BEZSELECTED(bezt) == 0) {
/* check beztriple should be removed according to cache */
- for (index= 0; index < len; index++) {
+ for (index = 0; index < len; index++) {
if (IS_EQF(bezt->vec[1][0], selcache[index])) {
delete_fcurve_key(fcu, i, 0);
break;
@@ -2955,21 +2955,21 @@ static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
* any other keyframes which may reside on that frame (that is not selected).
* remake_action_ipos should have already been called
*/
-static void posttrans_action_clean (bAnimContext *ac, bAction *act)
+static void posttrans_action_clean(bAnimContext *ac, bAction *act)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
/* filter data */
- filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
ANIM_animdata_filter(ac, &anim_data, filter, act, ANIMCONT_ACTION);
/* loop through relevant data, removing keyframes as appropriate
- * - all keyframes are converted in/out of global time
+ * - all keyframes are converted in/out of global time
*/
- for (ale= anim_data.first; ale; ale= ale->next) {
- AnimData *adt= ANIM_nla_mapping_get(ac, ale);
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
@@ -2977,7 +2977,7 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
- posttrans_fcurve_clean(ale->key_data, FALSE); /* only use handles in graph editor */
+ posttrans_fcurve_clean(ale->key_data, FALSE); /* only use handles in graph editor */
}
/* free temp data */
@@ -2996,7 +2996,7 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
return count;
/* only include points that occur on the right side of cfra */
- for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (bezt->f2 & SELECT) {
/* no need to adjust the handle selection since they are assumed
* selected (like graph editor with SIPO_NOHANDLES) */
@@ -3019,7 +3019,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
return count;
/* only include points that occur on the right side of cfra */
- for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
if (FrameOnMouseSide(side, (float)gpf->framenum, cfra))
count++;
@@ -3039,7 +3039,7 @@ static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra)
return count;
/* only include points that occur on the right side of cfra */
- for (masklayer_shape= masklay->splines_shapes.first; masklayer_shape; masklayer_shape= masklayer_shape->next) {
+ for (masklayer_shape = masklay->splines_shapes.first; masklayer_shape; masklayer_shape = masklayer_shape->next) {
if (masklayer_shape->flag & MASK_SHAPE_SELECT) {
if (FrameOnMouseSide(side, (float)masklayer_shape->frame, cfra))
count++;
@@ -3060,7 +3060,7 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt)
/* store the AnimData where this keyframe exists as a keyframe of the
* active action as td->extra.
*/
- td->extra= adt;
+ td->extra = adt;
}
/* This function advances the address to which td points to, so it must return
@@ -3079,7 +3079,7 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
if (ELEM(NULL, fcu, fcu->bezt))
return td;
- for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* only add selected keyframes (for now, proportional edit is not enabled) */
if (bezt->f2 & SELECT) { /* note this MUST match count_fcurve_keys(), so can't use BEZSELECTED() macro */
/* only add if on the right 'side' of the current frame */
@@ -3087,7 +3087,7 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
TimeToTransData(td, bezt->vec[1], adt);
/*set flags to move handles as necessary*/
- td->flag |= TD_MOVEHANDLE1|TD_MOVEHANDLE2;
+ td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2;
td2d->h1 = bezt->vec[0];
td2d->h2 = bezt->vec[2];
@@ -3107,8 +3107,8 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
/* helper struct for gp-frame transforms (only used here) */
typedef struct tGPFtransdata {
- float val; /* where transdata writes transform */
- int *sdata; /* pointer to gpf->framenum */
+ float val; /* where transdata writes transform */
+ int *sdata; /* pointer to gpf->framenum */
} tGPFtransdata;
/* This function helps flush transdata written to tempdata into the gp-frames */
@@ -3119,13 +3119,13 @@ void flushTransIntFrameActionData(TransInfo *t)
/* find the first one to start from */
if (t->mode == TFM_TIME_SLIDE)
- tfd= (tGPFtransdata *)((float *)(t->customData) + 2);
+ tfd = (tGPFtransdata *)((float *)(t->customData) + 2);
else
- tfd= (tGPFtransdata *)(t->customData);
+ tfd = (tGPFtransdata *)(t->customData);
/* flush data! */
for (i = 0; i < t->total; i++, tfd++) {
- *(tfd->sdata)= (int)floor(tfd->val + 0.5f);
+ *(tfd->sdata) = (int)floor(tfd->val + 0.5f);
}
}
@@ -3136,21 +3136,21 @@ void flushTransIntFrameActionData(TransInfo *t)
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
* on the named side are used.
*/
-static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
+static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
- int count= 0;
+ int count = 0;
/* check for select frames on right side of current frame */
- for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) {
/* memory is calloc'ed, so that should zero everything nicely for us */
- td->val= &tfd->val;
- td->ival= (float)gpf->framenum;
+ td->val = &tfd->val;
+ td->ival = (float)gpf->framenum;
- tfd->val= (float)gpf->framenum;
- tfd->sdata= &gpf->framenum;
+ tfd->val = (float)gpf->framenum;
+ tfd->sdata = &gpf->framenum;
/* advance td now */
td++;
@@ -3167,18 +3167,18 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
static int MaskLayerToTransData(TransData *td, tGPFtransdata *tfd, MaskLayer *masklay, char side, float cfra)
{
MaskLayerShape *masklay_shape;
- int count= 0;
+ int count = 0;
/* check for select frames on right side of current frame */
- for (masklay_shape= masklay->splines_shapes.first; masklay_shape; masklay_shape= masklay_shape->next) {
+ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
if (masklay_shape->flag & MASK_SHAPE_SELECT) {
if (FrameOnMouseSide(side, (float)masklay_shape->frame, cfra)) {
/* memory is calloc'ed, so that should zero everything nicely for us */
- td->val= &tfd->val;
- td->ival= (float)masklay_shape->frame;
+ td->val = &tfd->val;
+ td->ival = (float)masklay_shape->frame;
- tfd->val= (float)masklay_shape->frame;
- tfd->sdata= &masklay_shape->frame;
+ tfd->val = (float)masklay_shape->frame;
+ tfd->sdata = &masklay_shape->frame;
/* advance td now */
td++;
@@ -3194,7 +3194,7 @@ static int MaskLayerToTransData(TransData *td, tGPFtransdata *tfd, MaskLayer *ma
static void createTransActionData(bContext *C, TransInfo *t)
{
- Scene *scene= t->scene;
+ Scene *scene = t->scene;
TransData *td = NULL;
TransData2D *td2d = NULL;
tGPFtransdata *tfd = NULL;
@@ -3204,7 +3204,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
bAnimListElem *ale;
int filter;
- int count=0;
+ int count = 0;
float cfra;
/* determine what type of data we are operating on */
@@ -3213,9 +3213,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* filter data */
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
- filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
else
- filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* which side of the current frame should be allowed */
@@ -3232,8 +3232,8 @@ static void createTransActionData(bContext *C, TransInfo *t)
}
/* loop 1: fully select ipo-keys and count how many BezTriples are selected */
- for (ale= anim_data.first; ale; ale= ale->next) {
- AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
@@ -3261,30 +3261,30 @@ static void createTransActionData(bContext *C, TransInfo *t)
}
/* allocate memory for data */
- t->total= count;
+ t->total = count;
- t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(Action Editor)");
- t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "transdata2d");
- td= t->data;
+ t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(Action Editor)");
+ t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "transdata2d");
+ td = t->data;
td2d = t->data2d;
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
if (t->mode == TFM_TIME_SLIDE) {
- t->customData= MEM_callocN((sizeof(float)*2)+(sizeof(tGPFtransdata)*count), "TimeSlide + tGPFtransdata");
- tfd= (tGPFtransdata *)((float *)(t->customData) + 2);
+ t->customData = MEM_callocN((sizeof(float) * 2) + (sizeof(tGPFtransdata) * count), "TimeSlide + tGPFtransdata");
+ tfd = (tGPFtransdata *)((float *)(t->customData) + 2);
}
else {
- t->customData= MEM_callocN(sizeof(tGPFtransdata)*count, "tGPFtransdata");
- tfd= (tGPFtransdata *)(t->customData);
+ t->customData = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata");
+ tfd = (tGPFtransdata *)(t->customData);
}
}
else if (t->mode == TFM_TIME_SLIDE)
- t->customData= MEM_callocN(sizeof(float)*2, "TimeSlide Min/Max");
+ t->customData = MEM_callocN(sizeof(float) * 2, "TimeSlide Min/Max");
/* loop 2: build transdata array */
- for (ale= anim_data.first; ale; ale= ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
- bGPDlayer *gpl= (bGPDlayer *)ale->data;
+ bGPDlayer *gpl = (bGPDlayer *)ale->data;
int i;
i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra);
@@ -3300,8 +3300,8 @@ static void createTransActionData(bContext *C, TransInfo *t)
tfd += i;
}
else {
- AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
- FCurve *fcu= (FCurve *)ale->key_data;
+ AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+ FCurve *fcu = (FCurve *)ale->key_data;
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
@@ -3311,19 +3311,19 @@ static void createTransActionData(bContext *C, TransInfo *t)
else
cfra = (float)CFRA;
- td= ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra);
+ td = ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra);
}
}
/* check if we're supposed to be setting minx/maxx for TimeSlide */
if (t->mode == TFM_TIME_SLIDE) {
- float min=999999999.0f, max=-999999999.0f;
+ float min = 999999999.0f, max = -999999999.0f;
int i;
- td= t->data;
- for (i=0; i < count; i++, td++) {
- if (min > *(td->val)) min= *(td->val);
- if (max < *(td->val)) max= *(td->val);
+ td = t->data;
+ for (i = 0; i < count; i++, td++) {
+ if (min > *(td->val)) min = *(td->val);
+ if (max < *(td->val)) max = *(td->val);
}
if (min == max) {
@@ -3349,9 +3349,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* Helper function for createTransGraphEditData, which is responsible for associating
* source data with transform data
*/
-static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, BezTriple *bezt,
- int bi, short selected, short ishandle, short intvals,
- float mtx[3][3], float smtx[3][3])
+static void bezt_to_transdata(TransData *td, TransData2D *td2d, AnimData *adt, BezTriple *bezt,
+ int bi, short selected, short ishandle, short intvals,
+ float mtx[3][3], float smtx[3][3])
{
float *loc = bezt->vec[bi];
float *cent = bezt->vec[1];
@@ -3404,17 +3404,17 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL; td->val= NULL;
+ td->ext = NULL; td->val = NULL;
/* store AnimData info in td->extra, for applying mapping when flushing */
- td->extra= adt;
+ td->extra = adt;
if (selected) {
td->flag |= TD_SELECTED;
- td->dist= 0.0f;
+ td->dist = 0.0f;
}
else
- td->dist= MAXFLOAT;
+ td->dist = MAXFLOAT;
if (ishandle)
td->flag |= TD_NOTIMESNAP;
@@ -3429,9 +3429,9 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
static void createTransGraphEditData(bContext *C, TransInfo *t)
{
SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
- Scene *scene= t->scene;
- ARegion *ar= t->ar;
- View2D *v2d= &ar->v2d;
+ Scene *scene = t->scene;
+ ARegion *ar = t->ar;
+ View2D *v2d = &ar->v2d;
TransData *td = NULL;
TransData2D *td2d = NULL;
@@ -3442,7 +3442,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
int filter;
BezTriple *bezt;
- int count=0, i;
+ int count = 0, i;
float cfra;
float mtx[3][3], smtx[3][3];
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
@@ -3452,11 +3452,11 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
return;
/* filter data */
- filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* which side of the current frame should be allowed */
- // XXX we still want this mode, but how to get this using standard transform too?
+ // XXX we still want this mode, but how to get this using standard transform too?
if (t->mode == TFM_TIME_EXTEND) {
/* only side on which mouse is gets transformed */
float xmouse, ymouse;
@@ -3470,9 +3470,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
/* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
- for (ale= anim_data.first; ale; ale= ale->next) {
- AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
- FCurve *fcu= (FCurve *)ale->key_data;
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+ FCurve *fcu = (FCurve *)ale->key_data;
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
@@ -3487,11 +3487,11 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
continue;
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
- for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
- const char sel2= bezt->f2 & SELECT;
- const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
- const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
+ const char sel2 = bezt->f2 & SELECT;
+ const char sel1 = use_handle ? bezt->f1 & SELECT : sel2;
+ const char sel3 = use_handle ? bezt->f3 & SELECT : sel2;
if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) {
/* for 'normal' pivots - just include anything that is selected.
@@ -3531,14 +3531,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
/* allocate memory for data */
- t->total= count;
+ t->total = count;
- t->data= MEM_callocN(t->total*sizeof(TransData), "TransData (Graph Editor)");
- /* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
- t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransData2D (Graph Editor)");
+ t->data = MEM_callocN(t->total * sizeof(TransData), "TransData (Graph Editor)");
+ /* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
+ t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransData2D (Graph Editor)");
- td= t->data;
- td2d= t->data2d;
+ td = t->data;
+ td2d = t->data2d;
/* precompute space-conversion matrices for dealing with non-uniform scaling of Graph Editor */
unit_m3(mtx);
@@ -3555,15 +3555,15 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
mul_v3_fl(mtx[1], yscale);
/* smtx is global (i.e. view) to data conversion */
- if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f/xscale);
- if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f/yscale);
+ if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f / xscale);
+ if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f / yscale);
}
/* loop 2: build transdata arrays */
- for (ale= anim_data.first; ale; ale= ale->next) {
- AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
- FCurve *fcu= (FCurve *)ale->key_data;
- short intvals= (fcu->flag & FCURVE_INT_VALUES);
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+ FCurve *fcu = (FCurve *)ale->key_data;
+ short intvals = (fcu->flag & FCURVE_INT_VALUES);
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
@@ -3577,14 +3577,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (fcu->bezt == NULL)
continue;
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL|ANIM_UNITCONV_SELVERTS);
+ ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS);
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
- for (i=0, bezt= fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
- const char sel2= bezt->f2 & SELECT;
- const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
- const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
+ const char sel2 = bezt->f2 & SELECT;
+ const char sel1 = use_handle ? bezt->f1 & SELECT : sel2;
+ const char sel3 = use_handle ? bezt->f3 & SELECT : sel2;
TransDataCurveHandleFlags *hdata = NULL;
/* short h1=1, h2=1; */ /* UNUSED */
@@ -3602,7 +3602,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
if (sel3) {
- if (hdata==NULL)
+ if (hdata == NULL)
hdata = initTransDataCurveHandles(td, bezt);
bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx);
}
@@ -3639,8 +3639,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
ELEM(t->mode, TFM_ROTATION, TFM_RESIZE))
{
if (hdata && (sel1) && (sel3)) {
- bezt->h1= HD_ALIGN;
- bezt->h2= HD_ALIGN;
+ bezt->h1 = HD_ALIGN;
+ bezt->h2 = HD_ALIGN;
}
}
}
@@ -3660,64 +3660,64 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
/* struct for use in re-sorting BezTriples during Graph Editor transform */
typedef struct BeztMap {
BezTriple *bezt;
- unsigned int oldIndex; /* index of bezt in fcu->bezt array before sorting */
- unsigned int newIndex; /* index of bezt in fcu->bezt array after sorting */
- short swapHs; /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
- char pipo, cipo; /* interpolation of current and next segments */
+ unsigned int oldIndex; /* index of bezt in fcu->bezt array before sorting */
+ unsigned int newIndex; /* index of bezt in fcu->bezt array after sorting */
+ short swapHs; /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
+ char pipo, cipo; /* interpolation of current and next segments */
} BeztMap;
/* This function converts an FCurve's BezTriple array to a BeztMap array
* NOTE: this allocates memory that will need to get freed later
*/
-static BeztMap *bezt_to_beztmaps (BezTriple *bezts, int totvert, const short UNUSED(use_handle))
+static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUSED(use_handle))
{
- BezTriple *bezt= bezts;
- BezTriple *prevbezt= NULL;
+ BezTriple *bezt = bezts;
+ BezTriple *prevbezt = NULL;
BeztMap *bezm, *bezms;
int i;
/* allocate memory for this array */
- if (totvert==0 || bezts==NULL)
+ if (totvert == 0 || bezts == NULL)
return NULL;
- bezm= bezms= MEM_callocN(sizeof(BeztMap)*totvert, "BeztMaps");
+ bezm = bezms = MEM_callocN(sizeof(BeztMap) * totvert, "BeztMaps");
/* assign beztriples to beztmaps */
- for (i=0; i < totvert; i++, bezm++, prevbezt=bezt, bezt++) {
- bezm->bezt= bezt;
+ for (i = 0; i < totvert; i++, bezm++, prevbezt = bezt, bezt++) {
+ bezm->bezt = bezt;
- bezm->oldIndex= i;
- bezm->newIndex= i;
+ bezm->oldIndex = i;
+ bezm->newIndex = i;
- bezm->pipo= (prevbezt) ? prevbezt->ipo : bezt->ipo;
- bezm->cipo= bezt->ipo;
+ bezm->pipo = (prevbezt) ? prevbezt->ipo : bezt->ipo;
+ bezm->cipo = bezt->ipo;
}
return bezms;
}
/* This function copies the code of sort_time_ipocurve, but acts on BeztMap structs instead */
-static void sort_time_beztmaps (BeztMap *bezms, int totvert, const short UNUSED(use_handle))
+static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(use_handle))
{
BeztMap *bezm;
- int i, ok= 1;
+ int i, ok = 1;
/* keep repeating the process until nothing is out of place anymore */
while (ok) {
- ok= 0;
+ ok = 0;
- bezm= bezms;
- i= totvert;
+ bezm = bezms;
+ i = totvert;
while (i--) {
/* is current bezm out of order (i.e. occurs later than next)? */
if (i > 0) {
- if (bezm->bezt->vec[1][0] > (bezm+1)->bezt->vec[1][0]) {
+ if (bezm->bezt->vec[1][0] > (bezm + 1)->bezt->vec[1][0]) {
bezm->newIndex++;
- (bezm+1)->newIndex--;
+ (bezm + 1)->newIndex--;
- SWAP(BeztMap, *bezm, *(bezm+1));
+ SWAP(BeztMap, *bezm, *(bezm + 1));
- ok= 1;
+ ok = 1;
}
}
@@ -3743,7 +3743,7 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert, const short UNUSED(
}
/* This function firstly adjusts the pointers that the transdata has to each BezTriple */
-static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short UNUSED(use_handle))
+static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short UNUSED(use_handle))
{
BezTriple *bezts = fcu->bezt;
BeztMap *bezm;
@@ -3756,17 +3756,17 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
* pointers have been fixed already, so that we don't override ones that are
* already done
*/
- adjusted= MEM_callocN(t->total, "beztmap_adjusted_map");
+ adjusted = MEM_callocN(t->total, "beztmap_adjusted_map");
/* for each beztmap item, find if it is used anywhere */
- bezm= bezms;
- for (i= 0; i < totvert; i++, bezm++) {
+ bezm = bezms;
+ for (i = 0; i < totvert; i++, bezm++) {
/* loop through transdata, testing if we have a hit
* for the handles (vec[0]/vec[2]), we must also check if they need to be swapped...
*/
- td2d= t->data2d;
- td= t->data;
- for (j= 0; j < t->total; j++, td2d++, td++) {
+ td2d = t->data2d;
+ td = t->data;
+ for (j = 0; j < t->total; j++, td2d++, td++) {
/* skip item if already marked */
if (adjusted[j] != 0) continue;
@@ -3775,26 +3775,26 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
*/
if (td2d->loc2d == bezm->bezt->vec[0]) {
if (bezm->swapHs == 1)
- td2d->loc2d= (bezts + bezm->newIndex)->vec[2];
+ td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
else
- td2d->loc2d= (bezts + bezm->newIndex)->vec[0];
+ td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
adjusted[j] = 1;
}
else if (td2d->loc2d == bezm->bezt->vec[2]) {
if (bezm->swapHs == 1)
- td2d->loc2d= (bezts + bezm->newIndex)->vec[0];
+ td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
else
- td2d->loc2d= (bezts + bezm->newIndex)->vec[2];
+ td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
adjusted[j] = 1;
}
else if (td2d->loc2d == bezm->bezt->vec[1]) {
- td2d->loc2d= (bezts + bezm->newIndex)->vec[1];
+ td2d->loc2d = (bezts + bezm->newIndex)->vec[1];
/* if only control point is selected, the handle pointers need to be updated as well */
if (td2d->h1)
- td2d->h1= (bezts + bezm->newIndex)->vec[0];
+ td2d->h1 = (bezts + bezm->newIndex)->vec[0];
if (td2d->h2)
- td2d->h2= (bezts + bezm->newIndex)->vec[2];
+ td2d->h2 = (bezts + bezm->newIndex)->vec[2];
adjusted[j] = 1;
}
@@ -3832,15 +3832,15 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data)
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
/* sort and reassign verts */
- for (ale= anim_data->first; ale; ale= ale->next) {
- FCurve *fcu= (FCurve *)ale->key_data;
+ for (ale = anim_data->first; ale; ale = ale->next) {
+ FCurve *fcu = (FCurve *)ale->key_data;
if (fcu->bezt) {
BeztMap *bezm;
/* adjust transform-data pointers */
/* note, none of these functions use 'use_handle', it could be removed */
- bezm= bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle);
+ bezm = bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle);
sort_time_beztmaps(bezm, fcu->totvert, use_handle);
beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle);
@@ -3864,19 +3864,19 @@ void flushTransGraphData(TransInfo *t)
SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
TransData *td;
TransData2D *td2d;
- Scene *scene= t->scene;
- double secf= FPS;
+ Scene *scene = t->scene;
+ double secf = FPS;
int a;
/* flush to 2d vector from internally used 3d vector */
- for (a=0, td= t->data, td2d=t->data2d; a<t->total; a++, td++, td2d++) {
- AnimData *adt= (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
+ for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
+ AnimData *adt = (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
/* handle snapping for time values
* - we should still be in NLA-mapping timespace
* - only apply to keyframes (but never to handles)
*/
- if ((td->flag & TD_NOTIMESNAP)==0) {
+ if ((td->flag & TD_NOTIMESNAP) == 0) {
switch (sipo->autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame (or second if drawing seconds) */
if (sipo->flag & SIPO_DRAWTIME)
@@ -3886,22 +3886,22 @@ void flushTransGraphData(TransInfo *t)
break;
case SACTSNAP_MARKER: /* snap to nearest marker */
- td2d->loc[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]);
+ td2d->loc[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]);
break;
}
}
/* we need to unapply the nla-mapping from the time in some situations */
if (adt)
- td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
+ td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
else
- td2d->loc2d[0]= td2d->loc[0];
+ td2d->loc2d[0] = td2d->loc[0];
/* if int-values only, truncate to integers */
if (td->flag & TD_INTVALUES)
- td2d->loc2d[1]= floorf(td2d->loc[1] + 0.5f);
+ td2d->loc2d[1] = floorf(td2d->loc[1] + 0.5f);
else
- td2d->loc2d[1]= td2d->loc[1];
+ td2d->loc2d[1] = td2d->loc[1];
if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) {
td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0];
@@ -3933,9 +3933,9 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
/* *** Extend Transform *** */
Scene *scene = t->scene;
- int cfra= CFRA;
- int left= seq_tx_get_final_left(seq, 1);
- int right= seq_tx_get_final_right(seq, 1);
+ int cfra = CFRA;
+ int left = seq_tx_get_final_left(seq, 1);
+ int right = seq_tx_get_final_right(seq, 1);
if (seq->depth == 0 && ((seq->flag & SELECT) == 0 || (seq->flag & SEQ_LOCK))) {
*recursive = FALSE;
@@ -3946,34 +3946,34 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
/* for meta's we only ever need to extend their children, no matter what depth
* just check the meta's are in the bounds */
- if (t->frame_side=='R' && right <= cfra) *recursive = FALSE;
- else if (t->frame_side=='L' && left >= cfra) *recursive = FALSE;
- else *recursive = TRUE;
+ if (t->frame_side == 'R' && right <= cfra) *recursive = FALSE;
+ else if (t->frame_side == 'L' && left >= cfra) *recursive = FALSE;
+ else *recursive = TRUE;
- *count= 1;
- *flag= (seq->flag | SELECT) & ~(SEQ_LEFTSEL|SEQ_RIGHTSEL);
+ *count = 1;
+ *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
}
else {
*recursive = FALSE; /* not a meta, so no thinking here */
*count = 1; /* unless its set to 0, extend will never set 2 handles at once */
- *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL|SEQ_RIGHTSEL);
+ *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
- if (t->frame_side=='R') {
- if (right <= cfra) *count = *flag= 0; /* ignore */
+ if (t->frame_side == 'R') {
+ if (right <= cfra) *count = *flag = 0; /* ignore */
else if (left > cfra) ; /* keep the selection */
- else *flag |= SEQ_RIGHTSEL;
+ else *flag |= SEQ_RIGHTSEL;
}
else {
- if (left >= cfra) *count = *flag= 0; /* ignore */
- else if (right < cfra) ; /* keep the selection */
- else *flag |= SEQ_LEFTSEL;
+ if (left >= cfra) *count = *flag = 0; /* ignore */
+ else if (right < cfra) ; /* keep the selection */
+ else *flag |= SEQ_LEFTSEL;
}
}
}
else {
- t->frame_side= 'B';
+ t->frame_side = 'B';
/* *** Normal Transform *** */
@@ -3988,18 +3988,18 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
*flag = 0;
}
else {
- if ((seq->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL)) == (SEQ_LEFTSEL|SEQ_RIGHTSEL)) {
- *flag= seq->flag;
- *count= 2; /* we need 2 transdata's */
+ if ((seq->flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL)) == (SEQ_LEFTSEL | SEQ_RIGHTSEL)) {
+ *flag = seq->flag;
+ *count = 2; /* we need 2 transdata's */
}
else {
- *flag= seq->flag;
- *count= 1; /* selected or with a handle selected */
+ *flag = seq->flag;
+ *count = 1; /* selected or with a handle selected */
}
/* Recursive */
- if ((seq->type == SEQ_TYPE_META) && ((seq->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL)) == 0)) {
+ if ((seq->type == SEQ_TYPE_META) && ((seq->flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL)) == 0)) {
/* if any handles are selected, don't recurse */
*recursive = TRUE;
}
@@ -4012,7 +4012,7 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
/* Nested, different rules apply */
#ifdef SEQ_TX_NESTED_METAS
- *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL|SEQ_RIGHTSEL);
+ *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
*count = 1; /* ignore the selection for nested */
*recursive = (seq->type == SEQ_TYPE_META);
#else
@@ -4021,13 +4021,13 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
* don't have their start and length set directly (children affect that)
* since this Meta is nested we don't need any of its data in fact.
* calc_sequence() will update its settings when run on the toplevel meta */
- *flag= 0;
- *count= 0;
+ *flag = 0;
+ *count = 0;
*recursive = TRUE;
}
else {
- *flag= (seq->flag | SELECT) & ~(SEQ_LEFTSEL|SEQ_RIGHTSEL);
- *count= 1; /* ignore the selection for nested */
+ *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
+ *count = 1; /* ignore the selection for nested */
*recursive = FALSE;
}
#endif
@@ -4040,10 +4040,10 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
static int SeqTransCount(TransInfo *t, Sequence *parent, ListBase *seqbase, int depth)
{
Sequence *seq;
- int tot= 0, recursive, count, flag;
+ int tot = 0, recursive, count, flag;
- for (seq= seqbase->first; seq; seq= seq->next) {
- seq->depth= depth;
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ seq->depth = depth;
/* seq->tmp is used by seq_tx_get_final_{left, right} to check sequence's range and clamp to it if needed.
* it's first place where digging into sequences tree, so store link to parent here */
@@ -4053,7 +4053,7 @@ static int SeqTransCount(TransInfo *t, Sequence *parent, ListBase *seqbase, int
tot += count;
if (recursive) {
- tot += SeqTransCount(t, seq, &seq->seqbase, depth+1);
+ tot += SeqTransCount(t, seq, &seq->seqbase, depth + 1);
}
}
@@ -4066,21 +4066,21 @@ static TransData *SeqToTransData(TransData *td, TransData2D *td2d, TransDataSeq
int start_left;
switch (sel_flag) {
- case SELECT:
- /* Use seq_tx_get_final_left() and an offset here
- * so transform has the left hand location of the strip.
- * tdsq->start_offset is used when flushing the tx data back */
- start_left= seq_tx_get_final_left(seq, 0);
- td2d->loc[0]= start_left;
- tdsq->start_offset= start_left - seq->start; /* use to apply the original location */
- break;
- case SEQ_LEFTSEL:
- start_left= seq_tx_get_final_left(seq, 0);
- td2d->loc[0] = start_left;
- break;
- case SEQ_RIGHTSEL:
- td2d->loc[0] = seq_tx_get_final_right(seq, 0);
- break;
+ case SELECT:
+ /* Use seq_tx_get_final_left() and an offset here
+ * so transform has the left hand location of the strip.
+ * tdsq->start_offset is used when flushing the tx data back */
+ start_left = seq_tx_get_final_left(seq, 0);
+ td2d->loc[0] = start_left;
+ tdsq->start_offset = start_left - seq->start; /* use to apply the original location */
+ break;
+ case SEQ_LEFTSEL:
+ start_left = seq_tx_get_final_left(seq, 0);
+ td2d->loc[0] = start_left;
+ break;
+ case SEQ_RIGHTSEL:
+ td2d->loc[0] = seq_tx_get_final_right(seq, 0);
+ break;
}
td2d->loc[1] = seq->machine; /* channel - Y location */
@@ -4088,15 +4088,15 @@ static TransData *SeqToTransData(TransData *td, TransData2D *td2d, TransDataSeq
td2d->loc2d = NULL;
- tdsq->seq= seq;
+ tdsq->seq = seq;
/* Use instead of seq->flag for nested strips and other
* cases where the selection may need to be modified */
- tdsq->flag= flag;
- tdsq->sel_flag= sel_flag;
+ tdsq->flag = flag;
+ tdsq->sel_flag = sel_flag;
- td->extra= (void *)tdsq; /* allow us to update the strip from here */
+ td->extra = (void *)tdsq; /* allow us to update the strip from here */
td->flag = 0;
td->loc = td2d->loc;
@@ -4106,17 +4106,17 @@ static TransData *SeqToTransData(TransData *td, TransData2D *td2d, TransDataSeq
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL; td->val= NULL;
+ td->ext = NULL; td->val = NULL;
td->flag |= TD_SELECTED;
- td->dist= 0.0;
+ td->dist = 0.0;
unit_m3(td->mtx);
unit_m3(td->smtx);
/* Time Transform (extend) */
- td->val= td2d->loc;
- td->ival= td2d->loc[0];
+ td->val = td2d->loc;
+ td->ival = td2d->loc[0];
return td;
}
@@ -4125,26 +4125,26 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData *
{
Sequence *seq;
int recursive, count, flag;
- int tot= 0;
+ int tot = 0;
- for (seq= seqbase->first; seq; seq= seq->next) {
+ for (seq = seqbase->first; seq; seq = seq->next) {
SeqTransInfo(t, seq, &recursive, &count, &flag);
/* add children first so recalculating metastrips does nested strips first */
if (recursive) {
- int tot_children= SeqToTransData_Recursive(t, &seq->seqbase, td, td2d, tdsq);
+ int tot_children = SeqToTransData_Recursive(t, &seq->seqbase, td, td2d, tdsq);
- td= td + tot_children;
- td2d= td2d + tot_children;
- tdsq= tdsq + tot_children;
+ td = td + tot_children;
+ td2d = td2d + tot_children;
+ tdsq = tdsq + tot_children;
tot += tot_children;
}
/* use 'flag' which is derived from seq->flag but modified for special cases */
if (flag & SELECT) {
- if (flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL)) {
+ if (flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL)) {
if (flag & SEQ_LEFTSEL) {
SeqToTransData(td++, td2d++, tdsq++, seq, flag, SEQ_LEFTSEL);
tot++;
@@ -4166,83 +4166,83 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData *
static void freeSeqData(TransInfo *t)
{
- Editing *ed= BKE_sequencer_editing_get(t->scene, FALSE);
+ Editing *ed = BKE_sequencer_editing_get(t->scene, FALSE);
if (ed != NULL) {
- ListBase *seqbasep= ed->seqbasep;
- TransData *td= t->data;
+ ListBase *seqbasep = ed->seqbasep;
+ TransData *td = t->data;
int a;
/* prevent updating the same seq twice
* if the transdata order is changed this will mess up
* but so will TransDataSeq */
- Sequence *seq_prev= NULL;
+ Sequence *seq_prev = NULL;
Sequence *seq;
if (!(t->state == TRANS_CANCEL)) {
-#if 0 // default 2.4 behavior
+#if 0 // default 2.4 behavior
/* flush to 2d vector from internally used 3d vector */
- for (a=0; a<t->total; a++, td++) {
- if ((seq != seq_prev) && (seq->depth==0) && (seq->flag & SEQ_OVERLAP)) {
- seq= ((TransDataSeq *)td->extra)->seq;
+ for (a = 0; a < t->total; a++, td++) {
+ if ((seq != seq_prev) && (seq->depth == 0) && (seq->flag & SEQ_OVERLAP)) {
+ seq = ((TransDataSeq *)td->extra)->seq;
shuffle_seq(seqbasep, seq);
}
- seq_prev= seq;
+ seq_prev = seq;
}
-#else // durian hack
+#else // durian hack
{
- int overlap= 0;
+ int overlap = 0;
- for (a=0; a<t->total; a++, td++) {
- seq_prev= NULL;
- seq= ((TransDataSeq *)td->extra)->seq;
- if ((seq != seq_prev) && (seq->depth==0) && (seq->flag & SEQ_OVERLAP)) {
- overlap= 1;
+ for (a = 0; a < t->total; a++, td++) {
+ seq_prev = NULL;
+ seq = ((TransDataSeq *)td->extra)->seq;
+ if ((seq != seq_prev) && (seq->depth == 0) && (seq->flag & SEQ_OVERLAP)) {
+ overlap = 1;
break;
}
- seq_prev= seq;
+ seq_prev = seq;
}
if (overlap) {
- int has_effect= 0;
- for (seq= seqbasep->first; seq; seq= seq->next)
- seq->tmp= NULL;
-
- td= t->data;
- seq_prev= NULL;
- for (a=0; a<t->total; a++, td++) {
- seq= ((TransDataSeq *)td->extra)->seq;
+ int has_effect = 0;
+ for (seq = seqbasep->first; seq; seq = seq->next)
+ seq->tmp = NULL;
+
+ td = t->data;
+ seq_prev = NULL;
+ for (a = 0; a < t->total; a++, td++) {
+ seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
/* check effects strips, we cant change their time */
if ((seq->type & SEQ_TYPE_EFFECT) && seq->seq1) {
- has_effect= TRUE;
+ has_effect = TRUE;
}
else {
/* Tag seq with a non zero value, used by shuffle_seq_time to identify the ones to shuffle */
- seq->tmp= (void*)1;
+ seq->tmp = (void *)1;
}
}
}
-#if 1 /* (mango hack! - for Ian) this is truely bad - should _never_ be in a release :| */
+#if 1 /* (mango hack! - for Ian) this is truely bad - should _never_ be in a release :| */
if (CTX_wm_window(t->context)->eventstate->alt) {
int minframe = MAXFRAME;
- td= t->data;
- seq_prev= NULL;
- for (a=0; a<t->total; a++, td++) {
- seq= ((TransDataSeq *)td->extra)->seq;
+ td = t->data;
+ seq_prev = NULL;
+ for (a = 0; a < t->total; a++, td++) {
+ seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
minframe = MIN2(minframe, seq->startdisp);
}
}
- for (seq= seqbasep->first; seq; seq= seq->next) {
+ for (seq = seqbasep->first; seq; seq = seq->next) {
if (!(seq->flag & SELECT)) {
if (seq->startdisp >= minframe) {
seq->machine += MAXSEQ * 2;
@@ -4252,13 +4252,13 @@ static void freeSeqData(TransInfo *t)
shuffle_seq_time(seqbasep, t->scene);
- for (seq= seqbasep->first; seq; seq= seq->next) {
+ for (seq = seqbasep->first; seq; seq = seq->next) {
if (seq->machine >= MAXSEQ * 2) {
seq->machine -= MAXSEQ * 2;
- seq->tmp= (void*)1;
+ seq->tmp = (void *)1;
}
else {
- seq->tmp= NULL;
+ seq->tmp = NULL;
}
}
@@ -4273,10 +4273,10 @@ static void freeSeqData(TransInfo *t)
if (has_effect) {
/* update effects strips based on strips just moved in time */
- td= t->data;
- seq_prev= NULL;
- for (a=0; a<t->total; a++, td++) {
- seq= ((TransDataSeq *)td->extra)->seq;
+ td = t->data;
+ seq_prev = NULL;
+ for (a = 0; a < t->total; a++, td++) {
+ seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
if ((seq->type & SEQ_TYPE_EFFECT) && seq->seq1) {
calc_sequence(t->scene, seq);
@@ -4285,10 +4285,10 @@ static void freeSeqData(TransInfo *t)
}
/* now if any effects _still_ overlap, we need to move them up */
- td= t->data;
- seq_prev= NULL;
- for (a=0; a<t->total; a++, td++) {
- seq= ((TransDataSeq *)td->extra)->seq;
+ td = t->data;
+ seq_prev = NULL;
+ for (a = 0; a < t->total; a++, td++) {
+ seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
if ((seq->type & SEQ_TYPE_EFFECT) && seq->seq1) {
if (seq_test_overlap(seqbasep, seq)) {
@@ -4303,7 +4303,7 @@ static void freeSeqData(TransInfo *t)
}
#endif
- for (seq= seqbasep->first; seq; seq= seq->next) {
+ for (seq = seqbasep->first; seq; seq = seq->next) {
/* We might want to build a list of effects that need to be updated during transform */
if (seq->type & SEQ_TYPE_EFFECT) {
if (seq->seq1 && seq->seq1->flag & SELECT) calc_sequence(t->scene, seq);
@@ -4316,12 +4316,12 @@ static void freeSeqData(TransInfo *t)
}
else {
/* Cancelled, need to update the strips display */
- for (a=0; a<t->total; a++, td++) {
- seq= ((TransDataSeq *)td->extra)->seq;
- if ((seq != seq_prev) && (seq->depth==0)) {
+ for (a = 0; a < t->total; a++, td++) {
+ seq = ((TransDataSeq *)td->extra)->seq;
+ if ((seq != seq_prev) && (seq->depth == 0)) {
calc_sequence_disp(t->scene, seq);
}
- seq_prev= seq;
+ seq_prev = seq;
}
}
}
@@ -4332,7 +4332,7 @@ static void freeSeqData(TransInfo *t)
}
if (t->data) {
MEM_freeN(t->data); // XXX postTrans usually does this
- t->data= NULL;
+ t->data = NULL;
}
}
@@ -4340,21 +4340,21 @@ static void createTransSeqData(bContext *C, TransInfo *t)
{
#define XXX_DURIAN_ANIM_TX_HACK
- View2D *v2d= UI_view2d_fromcontext(C);
- Scene *scene= t->scene;
- Editing *ed= BKE_sequencer_editing_get(t->scene, FALSE);
+ View2D *v2d = UI_view2d_fromcontext(C);
+ Scene *scene = t->scene;
+ Editing *ed = BKE_sequencer_editing_get(t->scene, FALSE);
TransData *td = NULL;
- TransData2D *td2d= NULL;
- TransDataSeq *tdsq= NULL;
+ TransData2D *td2d = NULL;
+ TransDataSeq *tdsq = NULL;
- int count=0;
+ int count = 0;
- if (ed==NULL) {
- t->total= 0;
+ if (ed == NULL) {
+ t->total = 0;
return;
}
- t->customFree= freeSeqData;
+ t->customFree = freeSeqData;
/* which side of the current frame should be allowed */
if (t->mode == TFM_TIME_EXTEND) {
@@ -4372,16 +4372,16 @@ static void createTransSeqData(bContext *C, TransInfo *t)
#ifdef XXX_DURIAN_ANIM_TX_HACK
{
Sequence *seq;
- for (seq= ed->seqbasep->first; seq; seq= seq->next) {
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
/* hack */
- if ((seq->flag & SELECT)==0 && seq->type & SEQ_TYPE_EFFECT) {
+ if ((seq->flag & SELECT) == 0 && seq->type & SEQ_TYPE_EFFECT) {
Sequence *seq_user;
int i;
- for (i=0; i<3; i++) {
- seq_user= *((&seq->seq1) + i);
+ for (i = 0; i < 3; i++) {
+ seq_user = *((&seq->seq1) + i);
if (seq_user && (seq_user->flag & SELECT) &&
!(seq_user->flag & SEQ_LOCK) &&
- !(seq_user->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL)))
+ !(seq_user->flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL)))
{
seq->flag |= SELECT;
}
@@ -4394,16 +4394,16 @@ static void createTransSeqData(bContext *C, TransInfo *t)
count = SeqTransCount(t, NULL, ed->seqbasep, 0);
/* allocate memory for data */
- t->total= count;
+ t->total = count;
/* stop if trying to build list if nothing selected */
if (count == 0) {
return;
}
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransSeq TransData");
- td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransSeq TransData2D");
- tdsq = t->customData = MEM_callocN(t->total*sizeof(TransDataSeq), "TransSeq TransDataSeq");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransSeq TransData");
+ td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransSeq TransData2D");
+ tdsq = t->customData = MEM_callocN(t->total * sizeof(TransDataSeq), "TransSeq TransDataSeq");
t->flag |= T_FREE_CUSTOMDATA;
@@ -4431,17 +4431,17 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list)
* constraints needing special crazyspace corrections
*/
if (list) {
- for (con= list->first; con; con=con->next) {
+ for (con = list->first; con; con = con->next) {
/* only consider constraint if it is enabled, and has influence on result */
- if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0f)) {
+ if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) {
/* (affirmative) returns for specific constraints here... */
- /* constraints that require this regardless */
+ /* constraints that require this regardless */
if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1;
if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1;
if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1;
if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) return 1;
- /* constraints that require this only under special conditions */
+ /* constraints that require this only under special conditions */
if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
/* CopyRot constraint only does this when rotating, and offset is on */
bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data;
@@ -4469,11 +4469,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
copy_m3_m4(td->axismtx, ob->obmat);
normalize_m3(td->axismtx);
- td->con= ob->constraints.first;
+ td->con = ob->constraints.first;
/* hack: temporarily disable tracking and/or constraints when getting
* object matrix, if tracking is on, or if constraints don't need
- * inverse correction to stop it from screwing up space conversion
+ * inverse correction to stop it from screwing up space conversion
* matrix later
*/
constinv = constraints_list_needinv(t, &ob->constraints);
@@ -4484,7 +4484,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
if (skip_invert == 0 && constinv == 0) {
if (constinv == 0)
- ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
+ ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
BKE_object_where_is_calc(t->scene, ob);
@@ -4500,35 +4500,35 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
copy_v3_v3(td->iloc, td->loc);
if (ob->rotmode > 0) {
- td->ext->rot= ob->rot;
- td->ext->rotAxis= NULL;
- td->ext->rotAngle= NULL;
- td->ext->quat= NULL;
+ td->ext->rot = ob->rot;
+ td->ext->rotAxis = NULL;
+ td->ext->rotAngle = NULL;
+ td->ext->quat = NULL;
copy_v3_v3(td->ext->irot, ob->rot);
copy_v3_v3(td->ext->drot, ob->drot);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
- td->ext->rot= NULL;
- td->ext->rotAxis= ob->rotAxis;
- td->ext->rotAngle= &ob->rotAngle;
- td->ext->quat= NULL;
+ td->ext->rot = NULL;
+ td->ext->rotAxis = ob->rotAxis;
+ td->ext->rotAngle = &ob->rotAngle;
+ td->ext->quat = NULL;
- td->ext->irotAngle= ob->rotAngle;
+ td->ext->irotAngle = ob->rotAngle;
copy_v3_v3(td->ext->irotAxis, ob->rotAxis);
// td->ext->drotAngle= ob->drotAngle; // XXX, not implemented
// copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented
}
else {
- td->ext->rot= NULL;
- td->ext->rotAxis= NULL;
- td->ext->rotAngle= NULL;
- td->ext->quat= ob->quat;
+ td->ext->rot = NULL;
+ td->ext->rotAxis = NULL;
+ td->ext->rotAngle = NULL;
+ td->ext->quat = ob->quat;
copy_qt_qt(td->ext->iquat, ob->quat);
copy_qt_qt(td->ext->dquat, ob->dquat);
}
- td->ext->rotOrder=ob->rotmode;
+ td->ext->rotOrder = ob->rotmode;
td->ext->size = ob->size;
copy_v3_v3(td->ext->isize, ob->size);
@@ -4586,17 +4586,17 @@ static void set_trans_object_base_flags(TransInfo *t)
BKE_scene_base_flag_to_objects(t->scene);
/* handle pending update events, otherwise they got copied below */
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (base->object->recalc)
BKE_object_handle_update(t->scene, base->object);
}
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
base->flag &= ~BA_WAS_SEL;
if (TESTBASELIB_BGMODE(v3d, scene, base)) {
- Object *ob= base->object;
- Object *parsel= ob->parent;
+ Object *ob = base->object;
+ Object *parsel = ob->parent;
/* if parent selected, deselect */
while (parsel) {
@@ -4608,7 +4608,7 @@ static void set_trans_object_base_flags(TransInfo *t)
}
}
}
- parsel= parsel->parent;
+ parsel = parsel->parent;
}
if (parsel) {
@@ -4631,7 +4631,7 @@ static void set_trans_object_base_flags(TransInfo *t)
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (base->object->recalc & OB_RECALC_OB)
base->flag |= BA_HAS_RECALC_OB;
if (base->object->recalc & OB_RECALC_DATA)
@@ -4641,7 +4641,7 @@ static void set_trans_object_base_flags(TransInfo *t)
static int mark_children(Object *ob)
{
- if (ob->flag & (SELECT|BA_TRANSFORM_CHILD))
+ if (ob->flag & (SELECT | BA_TRANSFORM_CHILD))
return 1;
if (ob->parent) {
@@ -4664,7 +4664,7 @@ static int count_proportional_objects(TransInfo *t)
/* rotations around local centers are allowed to propagate, so we take all objects */
if (!((t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL)) {
/* mark all parents */
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (TESTBASELIB_BGMODE(v3d, scene, base)) {
Object *parent = base->object->parent;
@@ -4677,9 +4677,9 @@ static int count_proportional_objects(TransInfo *t)
}
/* mark all children */
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
/* all base not already selected or marked that is editable */
- if ((base->object->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 &&
+ if ((base->object->flag & (SELECT | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
(BASE_EDITABLE_BGMODE(v3d, scene, base)))
{
mark_children(base->object);
@@ -4687,11 +4687,11 @@ static int count_proportional_objects(TransInfo *t)
}
}
- for (base= scene->base.first; base; base= base->next) {
- Object *ob= base->object;
+ for (base = scene->base.first; base; base = base->next) {
+ Object *ob = base->object;
/* if base is not selected, not a parent of selection or not a child of selection and it is editable */
- if ((ob->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 &&
+ if ((ob->flag & (SELECT | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
(BASE_EDITABLE_BGMODE(v3d, scene, base)))
{
@@ -4708,7 +4708,7 @@ static int count_proportional_objects(TransInfo *t)
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (base->object->recalc & OB_RECALC_OB)
base->flag |= BA_HAS_RECALC_OB;
if (base->object->recalc & OB_RECALC_DATA)
@@ -4723,21 +4723,21 @@ static void clear_trans_object_base_flags(TransInfo *t)
Scene *sce = t->scene;
Base *base;
- for (base= sce->base.first; base; base = base->next) {
+ for (base = sce->base.first; base; base = base->next) {
if (base->flag & BA_WAS_SEL)
base->flag |= SELECT;
- base->flag &= ~(BA_WAS_SEL|BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA|BA_TEMP_TAG|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT);
+ base->flag &= ~(BA_WAS_SEL | BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT);
}
}
/* auto-keyframing feature - for objects
- * tmode: should be a transform mode
+ * tmode: should be a transform mode
*/
// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode)
{
- ID *id= &ob->id;
+ ID *id = &ob->id;
FCurve *fcu;
// TODO: this should probably be done per channel instead...
@@ -4745,7 +4745,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
ReportList *reports = CTX_wm_reports(C);
KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
ListBase dsources = {NULL, NULL};
- float cfra= (float)CFRA; // xxx this will do for now
+ float cfra = (float)CFRA; // xxx this will do for now
short flag = 0;
/* get flags used for inserting keyframes */
@@ -4761,11 +4761,11 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
}
else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) {
- AnimData *adt= ob->adt;
+ AnimData *adt = ob->adt;
/* only key on available channels */
if (adt && adt->action) {
- for (fcu= adt->action->curves.first; fcu; fcu= fcu->next) {
+ for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) {
fcu->flag &= ~FCURVE_SELECTED;
insert_keyframe(reports, id, adt->action,
(fcu->grp ? fcu->grp->name : NULL),
@@ -4788,7 +4788,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
else if (v3d->around == V3D_CURSOR)
do_loc = TRUE;
- if ((v3d->flag & V3D_ALIGN)==0)
+ if ((v3d->flag & V3D_ALIGN) == 0)
do_rot = TRUE;
}
else if (tmode == TFM_RESIZE) {
@@ -4799,27 +4799,27 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
else if (v3d->around == V3D_CURSOR)
do_loc = TRUE;
- if ((v3d->flag & V3D_ALIGN)==0)
+ if ((v3d->flag & V3D_ALIGN) == 0)
do_scale = TRUE;
}
/* insert keyframes for the affected sets of channels using the builtin KeyingSets found */
if (do_loc) {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
if (do_rot) {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
if (do_scale) {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
}
/* insert keyframe in all (transform) channels */
else {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
@@ -4829,16 +4829,16 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
}
/* auto-keyframing feature - for poses/pose-channels
- * tmode: should be a transform mode
+ * tmode: should be a transform mode
* targetless_ik: has targetless ik been done on any channels?
*/
// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode, short targetless_ik)
{
- ID *id= &ob->id;
- AnimData *adt= ob->adt;
- bAction *act= (adt) ? adt->action : NULL;
- bPose *pose= ob->pose;
+ ID *id = &ob->id;
+ AnimData *adt = ob->adt;
+ bAction *act = (adt) ? adt->action : NULL;
+ bPose *pose = ob->pose;
bPoseChannel *pchan;
FCurve *fcu;
@@ -4846,12 +4846,12 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
if (autokeyframe_cfra_can_key(scene, id)) {
ReportList *reports = CTX_wm_reports(C);
KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
- float cfra= (float)CFRA;
- short flag= 0;
+ float cfra = (float)CFRA;
+ short flag = 0;
/* flag is initialized from UserPref keyframing settings
* - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get
- * visual keyframes even if flag not set, as it's not that useful otherwise
+ * visual keyframes even if flag not set, as it's not that useful otherwise
* (for quick animation recording)
*/
flag = ANIM_get_keyframing_flags(scene, 1);
@@ -4859,7 +4859,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
if (targetless_ik)
flag |= INSERTKEY_MATRIX;
- for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
ListBase dsources = {NULL, NULL};
@@ -4877,16 +4877,16 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
/* only insert into available channels? */
else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) {
if (act) {
- for (fcu= act->curves.first; fcu; fcu= fcu->next) {
+ for (fcu = act->curves.first; fcu; fcu = fcu->next) {
/* only insert keyframes for this F-Curve if it affects the current bone */
if (strstr(fcu->rna_path, "bones")) {
- char *pchanName= BLI_getQuotedStr(fcu->rna_path, "bones[");
+ char *pchanName = BLI_getQuotedStr(fcu->rna_path, "bones[");
/* only if bone name matches too...
* NOTE: this will do constraints too, but those are ok to do here too?
*/
if (pchanName && strcmp(pchanName, pchan->name) == 0)
- insert_keyframe(reports, id, act, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+ insert_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
if (pchanName) MEM_freeN(pchanName);
}
@@ -4908,33 +4908,33 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
if (ELEM(v3d->around, V3D_CURSOR, V3D_ACTIVE))
do_loc = TRUE;
- if ((v3d->flag & V3D_ALIGN)==0)
+ if ((v3d->flag & V3D_ALIGN) == 0)
do_rot = TRUE;
}
else if (tmode == TFM_RESIZE) {
if (ELEM(v3d->around, V3D_CURSOR, V3D_ACTIVE))
do_loc = TRUE;
- if ((v3d->flag & V3D_ALIGN)==0)
+ if ((v3d->flag & V3D_ALIGN) == 0)
do_scale = TRUE;
}
if (do_loc) {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
if (do_rot) {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
if (do_scale) {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
}
/* insert keyframe in all (transform) channels */
else {
- KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
+ KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
}
@@ -4944,7 +4944,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
}
/* do the bone paths
- * - only do this when there is context info, since we need that to resolve
+ * - only do this when there is context info, since we need that to resolve
* how to do the updates and so on...
* - do not calculate unless there are paths already to update...
*/
@@ -4955,7 +4955,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
}
else {
/* tag channels that should have unkeyed data */
- for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
/* tag this channel */
pchan->bone->flag |= BONE_UNKEYED;
@@ -4968,22 +4968,22 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
/* inserting keys, pointcache, redraw events... */
/*
* note: sequencer freeing has its own function now because of a conflict with transform's order of freeing (campbell)
- * Order changed, the sequencer stuff should go back in here
+ * Order changed, the sequencer stuff should go back in here
* */
void special_aftertrans_update(bContext *C, TransInfo *t)
{
Object *ob;
// short redrawipo=0, resetslowpar=1;
- int canceled= (t->state == TRANS_CANCEL);
- short duplicate= (t->mode == TFM_TIME_DUPLICATE);
+ int canceled = (t->state == TRANS_CANCEL);
+ short duplicate = (t->mode == TFM_TIME_DUPLICATE);
/* early out when nothing happened */
if (t->total == 0 || t->mode == TFM_DUMMY)
return;
- if (t->spacetype==SPACE_VIEW3D) {
+ if (t->spacetype == SPACE_VIEW3D) {
if (t->obedit) {
- if (canceled==0) {
+ if (canceled == 0) {
/* we need to delete the temporary faces before automerging */
if (t->mode == TFM_EDGE_SLIDE) {
SlideData *sld = t->customData;
@@ -5014,7 +5014,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* freeSeqData in transform_conversions.c does this
* keep here so the else at the end wont run... */
- SpaceSeq *sseq= (SpaceSeq *)t->sa->spacedata.first;
+ SpaceSeq *sseq = (SpaceSeq *)t->sa->spacedata.first;
/* marker transform, not especially nice but we may want to move markers
* at the same time as keyframes in the dope sheet. */
@@ -5033,7 +5033,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_NODE) {
- SpaceNode *snode= (SpaceNode *)t->sa->spacedata.first;
+ SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first;
if (canceled == 0) {
ED_node_post_apply_transform(C, snode->edittree);
@@ -5052,7 +5052,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
nodeUpdateID(t->scene->nodetree, &clip->id);
- WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
+ WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
}
}
else if (t->options & CTX_MASK) {
@@ -5063,7 +5063,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
nodeUpdateID(t->scene->nodetree, &mask->id);
- WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
+ WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
}
/* TODO - dont key all masks... */
@@ -5075,7 +5075,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
}
else if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
bAnimContext ac;
/* initialize relevant anim-context 'context' data */
@@ -5087,22 +5087,22 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
+ short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* these should all be F-Curves */
- for (ale= anim_data.first; ale; ale= ale->next) {
- AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
- FCurve *fcu= (FCurve *)ale->key_data;
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+ FCurve *fcu = (FCurve *)ale->key_data;
/* 3 cases here for curve cleanups:
* 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
* 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
* 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
*/
- if ((saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+ if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 &&
((canceled == 0) || (duplicate)) )
{
if (adt) {
@@ -5111,7 +5111,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
else
- posttrans_fcurve_clean(fcu, FALSE); /* only use handles in graph editor */
+ posttrans_fcurve_clean(fcu, FALSE); /* only use handles in graph editor */
}
}
@@ -5123,7 +5123,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// fixme... some of this stuff is not good
if (ob) {
if (ob->pose || ob_get_key(ob))
- DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME);
+ DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
else
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
@@ -5133,7 +5133,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
* 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
*/
- if ((saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+ if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 &&
((canceled == 0) || (duplicate)))
{
posttrans_action_clean(&ac, (bAction *)ac.data);
@@ -5141,13 +5141,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
else if (ac.datatype == ANIMCONT_GPENCIL) {
/* remove duplicate frames and also make sure points are in order! */
- /* 3 cases here for curve cleanups:
- * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
- * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
- * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
- */
- if ((saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
- ((canceled == 0) || (duplicate)))
+ /* 3 cases here for curve cleanups:
+ * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
+ * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
+ * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
+ */
+ if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 &&
+ ((canceled == 0) || (duplicate)))
{
bGPdata *gpd;
@@ -5161,13 +5161,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
else if (ac.datatype == ANIMCONT_MASK) {
/* remove duplicate frames and also make sure points are in order! */
- /* 3 cases here for curve cleanups:
- * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
- * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
- * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
- */
- if ((saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
- ((canceled == 0) || (duplicate)))
+ /* 3 cases here for curve cleanups:
+ * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
+ * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
+ * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
+ */
+ if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 &&
+ ((canceled == 0) || (duplicate)))
{
Mask *mask;
@@ -5209,7 +5209,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
saction->flag &= ~SACTION_MOVING;
}
else if (t->spacetype == SPACE_IPO) {
- SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+ SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
bAnimContext ac;
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
@@ -5220,21 +5220,21 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
+ short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (ale= anim_data.first; ale; ale= ale->next) {
- AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
- FCurve *fcu= (FCurve *)ale->key_data;
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+ FCurve *fcu = (FCurve *)ale->key_data;
/* 3 cases here for curve cleanups:
* 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
* 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
* 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
*/
- if ((sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
+ if ((sipo->flag & SIPO_NOTRANSKEYCULL) == 0 &&
((canceled == 0) || (duplicate)))
{
if (adt) {
@@ -5269,13 +5269,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
+ short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (ale= anim_data.first; ale; ale= ale->next) {
- NlaTrack *nlt= (NlaTrack *)ale->data;
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ NlaTrack *nlt = (NlaTrack *)ale->data;
/* make sure strips are in order again */
BKE_nlatrack_sort_strips(nlt);
@@ -5301,16 +5301,16 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if ((t->flag & T_POSE) && (t->poseobj)) {
bArmature *arm;
bPoseChannel *pchan;
- short targetless_ik= 0;
+ short targetless_ik = 0;
- ob= t->poseobj;
- arm= ob->data;
+ ob = t->poseobj;
+ arm = ob->data;
if ((t->flag & T_AUTOIK) && (t->options & CTX_AUTOCONFIRM)) {
/* when running transform non-interactively (operator exec),
* we need to update the pose otherwise no updates get called during
* transform and the auto-ik is not applied. see [#26164] */
- struct Object *pose_ob=t->poseobj;
+ struct Object *pose_ob = t->poseobj;
BKE_pose_where_is(t->scene, pose_ob);
}
@@ -5319,17 +5319,17 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
count_set_pose_transflags(&t->mode, t->around, ob);
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
- if (!canceled && t->mode==TFM_TRANSLATION)
- targetless_ik= apply_targetless_ik(ob);
+ if (!canceled && t->mode == TFM_TRANSLATION)
+ targetless_ik = apply_targetless_ik(ob);
else {
/* not forget to clear the auto flag */
- for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- bKinematicConstraint *data= has_targetless_ik(pchan);
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bKinematicConstraint *data = has_targetless_ik(pchan);
if (data) data->flag &= ~CONSTRAINT_IK_AUTO;
}
}
- if (t->mode==TFM_TRANSLATION)
+ if (t->mode == TFM_TRANSLATION)
pose_grab_with_ik_clear(ob);
/* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */
@@ -5340,7 +5340,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (arm->flag & ARM_DELAYDEFORM) {
/* old optimize trick... this enforces to bypass the depgraph */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- ob->recalc= 0; // is set on OK position already by recalcData()
+ ob->recalc = 0; // is set on OK position already by recalcData()
}
else
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -5354,7 +5354,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* do nothing */
}
else { /* Objects */
- int i, recalcObPaths=0;
+ int i, recalcObPaths = 0;
for (i = 0; i < t->total; i++) {
TransData *td = t->data + i;
@@ -5370,7 +5370,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* flag object caches as outdated */
BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR);
- for (pid=pidlist.first; pid; pid=pid->next) {
+ for (pid = pidlist.first; pid; pid = pid->next) {
if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */
pid->cache->flag |= PTCACHE_OUTDATED;
}
@@ -5392,7 +5392,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* only calculate paths if there are paths to be recalculated */
if (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)
- recalcObPaths= 1;
+ recalcObPaths = 1;
}
}
@@ -5434,7 +5434,7 @@ static void createTransObject(bContext *C, TransInfo *t)
set_trans_object_base_flags(t);
/* count */
- t->total= CTX_DATA_COUNT(C, selected_objects);
+ t->total = CTX_DATA_COUNT(C, selected_objects);
if (!t->total) {
/* clear here, main transform function escapes too */
@@ -5446,17 +5446,17 @@ static void createTransObject(bContext *C, TransInfo *t)
t->total += count_proportional_objects(t);
}
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransOb");
- tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransObExtension");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransOb");
+ tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "TransObExtension");
- CTX_DATA_BEGIN (C, Base*, base, selected_bases)
+ CTX_DATA_BEGIN(C, Base *, base, selected_bases)
{
- Object *ob= base->object;
+ Object *ob = base->object;
td->flag = TD_SELECTED;
- td->protectflag= ob->protectflag;
+ td->protectflag = ob->protectflag;
td->ext = tx;
- td->ext->rotOrder= ob->rotmode;
+ td->ext->rotOrder = ob->rotmode;
if (base->flag & BA_TRANSFORM_CHILD) {
td->flag |= TD_NOCENTER;
@@ -5480,16 +5480,16 @@ static void createTransObject(bContext *C, TransInfo *t)
View3D *v3d = t->view;
Base *base;
- for (base= scene->base.first; base; base= base->next) {
- Object *ob= base->object;
+ for (base = scene->base.first; base; base = base->next) {
+ Object *ob = base->object;
/* if base is not selected, not a parent of selection or not a child of selection and it is editable */
if ((ob->flag & (SELECT | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
BASE_EDITABLE_BGMODE(v3d, scene, base))
{
- td->protectflag= ob->protectflag;
+ td->protectflag = ob->protectflag;
td->ext = tx;
- td->ext->rotOrder= ob->rotmode;
+ td->ext->rotOrder = ob->rotmode;
ObjectToTransData(t, td, ob);
td->val = NULL;
@@ -5522,10 +5522,10 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL; td->val= NULL;
+ td->ext = NULL; td->val = NULL;
td->flag |= TD_SELECTED;
- td->dist= 0.0;
+ td->dist = 0.0;
unit_m3(td->mtx);
unit_m3(td->smtx);
@@ -5535,29 +5535,29 @@ static void createTransNodeData(bContext *C, TransInfo *t)
{
TransData *td;
TransData2D *td2d;
- SpaceNode *snode= t->sa->spacedata.first;
+ SpaceNode *snode = t->sa->spacedata.first;
bNode *node;
if (!snode->edittree) {
- t->total= 0;
+ t->total = 0;
return;
}
/* set transform flags on nodes */
- for (node=snode->edittree->nodes.first; node; node=node->next) {
+ for (node = snode->edittree->nodes.first; node; node = node->next) {
if ((node->flag & NODE_SELECT) || (node->parent && (node->parent->flag & NODE_TRANSFORM)))
node->flag |= NODE_TRANSFORM;
else
node->flag &= ~NODE_TRANSFORM;
}
- t->total= CTX_DATA_COUNT(C, selected_nodes);
+ t->total = CTX_DATA_COUNT(C, selected_nodes);
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransNode TransData");
- td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransNode TransData2D");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransNode TransData");
+ td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransNode TransData2D");
- CTX_DATA_BEGIN (C, bNode *, selnode, selected_nodes)
- NodeToTransData(td++, td2d++, selnode);
+ CTX_DATA_BEGIN(C, bNode *, selnode, selected_nodes)
+ NodeToTransData(td++, td2d++, selnode);
CTX_DATA_END
}
@@ -5600,7 +5600,7 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra
td2d->loc[0] = rel[0] * aspx; /* hold original location */
td2d->loc[1] = rel[1] * aspy;
- tdt->loc= loc;
+ tdt->loc = loc;
td2d->loc2d = loc; /* current location */
}
else {
@@ -5640,8 +5640,8 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL;
- td->val= NULL;
+ td->ext = NULL;
+ td->val = NULL;
td->flag |= TD_SELECTED;
td->dist = 0.0;
@@ -5654,7 +5654,7 @@ static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy)
{
int framenr = ED_space_clip_clip_framenr(sc);
- MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
tdt->flag = marker->flag;
marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
@@ -5703,7 +5703,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
TransData2D *td2d;
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
TransDataTracking *tdt;
@@ -5715,19 +5715,19 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
- marker = BKE_tracking_get_marker(track, framenr);
+ if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
+ marker = BKE_tracking_marker_get(track, framenr);
- t->total++; /* offset */
+ t->total++; /* offset */
if (track->flag & SELECT)
t->total++;
if (track->pat_flag & SELECT)
- t->total+= 4;
+ t->total += 4;
if (track->search_flag & SELECT)
- t->total+= 2;
+ t->total += 2;
}
track = track->next;
@@ -5738,9 +5738,9 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy);
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData");
- td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransTracking TransData2D");
- tdt = t->customData = MEM_callocN(t->total*sizeof(TransDataTracking), "TransTracking TransDataTracking");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransTracking TransData");
+ td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransTracking TransData2D");
+ tdt = t->customData = MEM_callocN(t->total * sizeof(TransDataTracking), "TransTracking TransDataTracking");
t->customFree = transDataTrackingFree;
@@ -5748,7 +5748,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- marker = BKE_tracking_get_marker(track, framenr);
+ marker = BKE_tracking_marker_get(track, framenr);
trackToTransData(sc, td, td2d, tdt, track, aspx, aspy);
@@ -5815,8 +5815,8 @@ static void markerToTransCurveDataInit(TransData *td, TransData2D *td2d, TransDa
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL;
- td->val= NULL;
+ td->ext = NULL;
+ td->val = NULL;
td->flag |= TD_SELECTED;
td->dist = 0.0;
@@ -5831,7 +5831,7 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
TransData2D *td2d;
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
- ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
MovieTrackingMarker *marker, *prev_marker;
TransDataTracking *tdt;
@@ -5844,10 +5844,10 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
+ if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
for (i = 1; i < track->markersnr; i++) {
marker = &track->markers[i];
- prev_marker = &track->markers[i-1];
+ prev_marker = &track->markers[i - 1];
if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
continue;
@@ -5866,32 +5866,32 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
if (t->total == 0)
return;
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData");
- td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransTracking TransData2D");
- tdt = t->customData = MEM_callocN(t->total*sizeof(TransDataTracking), "TransTracking TransDataTracking");
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransTracking TransData");
+ td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransTracking TransData2D");
+ tdt = t->customData = MEM_callocN(t->total * sizeof(TransDataTracking), "TransTracking TransDataTracking");
t->customFree = transDataTrackingFree;
/* create actual data */
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
+ if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
for (i = 1; i < track->markersnr; i++) {
marker = &track->markers[i];
- prev_marker = &track->markers[i-1];
+ prev_marker = &track->markers[i - 1];
if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
continue;
if (marker->flag & MARKER_GRAPH_SEL_X) {
- markerToTransCurveDataInit(td, td2d, tdt, marker, &track->markers[i-1], 0, width);
+ markerToTransCurveDataInit(td, td2d, tdt, marker, &track->markers[i - 1], 0, width);
td += 1;
td2d += 1;
tdt += 1;
}
if (marker->flag & MARKER_GRAPH_SEL_Y) {
- markerToTransCurveDataInit(td, td2d, tdt, marker, &track->markers[i-1], 1, height);
+ markerToTransCurveDataInit(td, td2d, tdt, marker, &track->markers[i - 1], 1, height);
td += 1;
td2d += 1;
@@ -5932,7 +5932,7 @@ static void cancelTransTracking(TransInfo *t)
TransDataTracking *tdt = t->customData;
SpaceClip *sc = t->sa->spacedata.first;
MovieClip *clip = ED_space_clip(sc);
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
int a, framenr = ED_space_clip_clip_framenr(sc);
@@ -5940,8 +5940,8 @@ static void cancelTransTracking(TransInfo *t)
if (tdt->mode == transDataTracking_ModeTracks) {
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
- marker = BKE_tracking_get_marker(track, framenr);
+ if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
+ marker = BKE_tracking_marker_get(track, framenr);
marker->flag = tdt->flag;
tdt++;
@@ -5964,15 +5964,15 @@ static void cancelTransTracking(TransInfo *t)
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
+ if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
for (a = 1; a < track->markersnr; a++) {
marker = &track->markers[a];
- prev_marker = &track->markers[a-1];
+ prev_marker = &track->markers[a - 1];
if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
continue;
- if (marker->flag & (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y)) {
+ if (marker->flag & (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)) {
marker->flag = tdt->flag;
}
}
@@ -5998,7 +5998,7 @@ void flushTransTracking(TransInfo *t)
cancelTransTracking(t);
/* flush to 2d vector from internally used 3d vector */
- for (a=0, td= t->data, td2d= t->data2d, tdt= t->customData; a<t->total; a++, td2d++, td++, tdt++) {
+ for (a = 0, td = t->data, td2d = t->data2d, tdt = t->customData; a < t->total; a++, td2d++, td++, tdt++) {
if (tdt->mode == transDataTracking_ModeTracks) {
float loc2d[2];
@@ -6019,7 +6019,7 @@ void flushTransTracking(TransInfo *t)
float d[2], d2[2];
if (!tdt->smarkers) {
- tdt->smarkers = MEM_callocN(sizeof(*tdt->smarkers)*tdt->markersnr, "flushTransTracking markers");
+ tdt->smarkers = MEM_callocN(sizeof(*tdt->smarkers) * tdt->markersnr, "flushTransTracking markers");
for (a = 0; a < tdt->markersnr; a++)
copy_v2_v2(tdt->smarkers[a], tdt->markers[a].pos);
}
@@ -6029,7 +6029,7 @@ void flushTransTracking(TransInfo *t)
sub_v2_v2v2(d2, loc2d, tdt->srelative);
- for (a= 0; a<tdt->markersnr; a++)
+ for (a = 0; a < tdt->markersnr; a++)
add_v2_v2v2(tdt->markers[a].pos, tdt->smarkers[a], d2);
negate_v2_v2(td2d->loc2d, d);
@@ -6037,7 +6037,7 @@ void flushTransTracking(TransInfo *t)
}
}
- if (tdt->area!=TRACK_AREA_POINT || tdt->relative==0) {
+ if (tdt->area != TRACK_AREA_POINT || tdt->relative == 0) {
td2d->loc2d[0] = loc2d[0];
td2d->loc2d[1] = loc2d[1];
@@ -6054,7 +6054,7 @@ void flushTransTracking(TransInfo *t)
/* * masking * */
typedef struct TransDataMasking {
- int is_handle;
+ int is_handle;
float handle[2], orig_handle[2];
float vec[3][3];
@@ -6081,8 +6081,8 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
* proportional editing to be consistent with the stretched CV coords
* that are displayed. this also means that for display and numinput,
* and when the the CV coords are flushed, these are converted each time */
- td2d->loc[0] = bezt->vec[i][0]*aspx;
- td2d->loc[1] = bezt->vec[i][1]*aspy;
+ td2d->loc[0] = bezt->vec[i][0] * aspx;
+ td2d->loc[1] = bezt->vec[i][1] * aspy;
td2d->loc[2] = 0.0f;
td2d->loc2d = bezt->vec[i];
@@ -6108,7 +6108,7 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
if (is_sel_any) {
td->flag |= TD_SELECTED;
}
- td->dist= 0.0;
+ td->dist = 0.0;
unit_m3(td->mtx);
unit_m3(td->smtx);
@@ -6124,8 +6124,8 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
copy_v2_v2(tdm->orig_handle, tdm->handle);
- td2d->loc[0] = tdm->handle[0]*aspx;
- td2d->loc[1] = tdm->handle[1]*aspy;
+ td2d->loc[0] = tdm->handle[0] * aspx;
+ td2d->loc[1] = tdm->handle[1] * aspy;
td2d->loc[2] = 0.0f;
td2d->loc2d = tdm->handle;
@@ -6137,14 +6137,14 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
- td->ext= NULL;
- td->val= NULL;
+ td->ext = NULL;
+ td->val = NULL;
if (is_sel_any) {
td->flag |= TD_SELECTED;
}
- td->dist= 0.0;
+ td->dist = 0.0;
unit_m3(td->mtx);
unit_m3(td->smtx);
@@ -6200,12 +6200,12 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
/* note: in prop mode we need at least 1 selected */
if (countsel == 0) return;
- t->total = (propmode) ? count: countsel;
- td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransObData(Mask Editing)");
+ t->total = (propmode) ? count : countsel;
+ td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mask Editing)");
/* for each 2d uv coord a 3d vector is allocated, so that they can be
* treated just as if they were 3d verts */
- td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransObData2D(Mask Editing)");
- tdm = t->customData = MEM_callocN(t->total*sizeof(TransDataMasking), "TransDataMasking(Mask Editing)");
+ td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransObData2D(Mask Editing)");
+ tdm = t->customData = MEM_callocN(t->total * sizeof(TransDataMasking), "TransDataMasking(Mask Editing)");
t->flag |= T_FREE_CUSTOMDATA;
@@ -6251,13 +6251,13 @@ void flushTransMasking(TransInfo *t)
float aspx, aspy, invx, invy;
ED_space_clip_mask_aspect(sc, &aspx, &aspy);
- invx = 1.0f/aspx;
- invy = 1.0f/aspy;
+ invx = 1.0f / aspx;
+ invy = 1.0f / aspy;
/* flush to 2d vector from internally used 3d vector */
- for (a=0, td = t->data2d, tdm = t->customData; a<t->total; a++, td++, tdm++) {
- td->loc2d[0]= td->loc[0]*invx;
- td->loc2d[1]= td->loc[1]*invy;
+ for (a = 0, td = t->data2d, tdm = t->customData; a < t->total; a++, td++, tdm++) {
+ td->loc2d[0] = td->loc[0] * invx;
+ td->loc2d[1] = td->loc[1] * invy;
if (tdm->is_handle)
BKE_mask_point_set_handle(tdm->point, td->loc2d, t->flag & T_ALT_TRANSFORM, tdm->orig_handle, tdm->vec);
@@ -6278,7 +6278,7 @@ void createTransData(bContext *C, TransInfo *t)
t->flag |= T_EDIT;
createTransEdge(t);
if (t->data && t->flag & T_PROP_EDIT) {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
@@ -6288,56 +6288,56 @@ void createTransData(bContext *C, TransInfo *t)
//createTransBMeshVerts(t, G.editBMesh->bm, G.editBMesh->td);
}
else if (t->spacetype == SPACE_IMAGE) {
- t->flag |= T_POINTS|T_2D_EDIT;
+ t->flag |= T_POINTS | T_2D_EDIT;
createTransUVs(C, t);
if (t->data && (t->flag & T_PROP_EDIT)) {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
}
else if (t->spacetype == SPACE_ACTION) {
- t->flag |= T_POINTS|T_2D_EDIT;
+ t->flag |= T_POINTS | T_2D_EDIT;
createTransActionData(C, t);
}
else if (t->spacetype == SPACE_NLA) {
- t->flag |= T_POINTS|T_2D_EDIT;
+ t->flag |= T_POINTS | T_2D_EDIT;
createTransNlaData(C, t);
}
else if (t->spacetype == SPACE_SEQ) {
- t->flag |= T_POINTS|T_2D_EDIT;
+ t->flag |= T_POINTS | T_2D_EDIT;
t->num.flag |= NUM_NO_FRACTION; /* sequencer has no use for floating point transformations */
createTransSeqData(C, t);
}
else if (t->spacetype == SPACE_IPO) {
- t->flag |= T_POINTS|T_2D_EDIT;
+ t->flag |= T_POINTS | T_2D_EDIT;
createTransGraphEditData(C, t);
#if 0
if (t->data && (t->flag & T_PROP_EDIT)) {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
#endif
}
else if (t->spacetype == SPACE_NODE) {
- t->flag |= T_2D_EDIT|T_POINTS;
+ t->flag |= T_2D_EDIT | T_POINTS;
createTransNodeData(C, t);
if (t->data && (t->flag & T_PROP_EDIT)) {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
}
else if (t->spacetype == SPACE_CLIP) {
- t->flag |= T_POINTS|T_2D_EDIT;
+ t->flag |= T_POINTS | T_2D_EDIT;
if (t->options & CTX_MOVIECLIP)
createTransTrackingData(C, t);
else if (t->options & CTX_MASK) {
createTransMaskingData(C, t);
if (t->data && (t->flag & T_PROP_EDIT)) {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, TRUE);
sort_trans_data_dist(t);
}
@@ -6351,13 +6351,13 @@ void createTransData(bContext *C, TransInfo *t)
else if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
createTransCurveVerts(C, t);
}
- else if (t->obedit->type==OB_LATTICE) {
+ else if (t->obedit->type == OB_LATTICE) {
createTransLatticeVerts(t);
}
- else if (t->obedit->type==OB_MBALL) {
+ else if (t->obedit->type == OB_MBALL) {
createTransMBallVerts(t);
}
- else if (t->obedit->type==OB_ARMATURE) {
+ else if (t->obedit->type == OB_ARMATURE) {
t->flag &= ~T_PROP_EDIT;
createTransArmatureVerts(t);
}
@@ -6365,26 +6365,26 @@ void createTransData(bContext *C, TransInfo *t)
printf("edit type not implemented!\n");
}
- t->flag |= T_EDIT|T_POINTS;
+ t->flag |= T_EDIT | T_POINTS;
if (t->data && t->flag & T_PROP_EDIT) {
if (ELEM(t->obedit->type, OB_CURVE, OB_MESH)) {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 0);
sort_trans_data_dist(t);
}
else {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
}
/* exception... hackish, we want bonesize to use bone orientation matrix (ton) */
- if (t->mode==TFM_BONESIZE) {
- t->flag &= ~(T_EDIT|T_POINTS);
+ if (t->mode == TFM_BONESIZE) {
+ t->flag &= ~(T_EDIT | T_POINTS);
t->flag |= T_POSE;
- t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */
+ t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
@@ -6395,9 +6395,9 @@ void createTransData(bContext *C, TransInfo *t)
else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) {
/* important that ob_armature can be set even when its not selected [#23412]
* lines below just check is also visible */
- Object *ob_armature= modifiers_isDeformedByArmature(ob);
+ Object *ob_armature = modifiers_isDeformedByArmature(ob);
if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
- Base *base_arm= BKE_scene_base_find(t->scene, ob_armature);
+ Base *base_arm = BKE_scene_base_find(t->scene, ob_armature);
if (base_arm) {
View3D *v3d = t->view;
if (BASE_VISIBLE(v3d, base_arm)) {
@@ -6412,12 +6412,12 @@ void createTransData(bContext *C, TransInfo *t)
t->flag |= T_POINTS;
if (t->data && t->flag & T_PROP_EDIT) {
- sort_trans_data(t); // makes selected become first in array
+ sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
}
- else if (ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_TEXTURE_PAINT))) {
+ else if (ob && (ob->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT))) {
/* sculpt mode and project paint have own undo stack
* transform ops redo clears sculpt/project undo stack.
*
@@ -6437,7 +6437,7 @@ void createTransData(bContext *C, TransInfo *t)
if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) {
View3D *v3d = t->view;
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- if (rv3d && (t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==RV3D_CAMOB) {
+ if (rv3d && (t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp == RV3D_CAMOB) {
t->flag |= T_CAMERA;
}
}
@@ -6447,7 +6447,3 @@ void createTransData(bContext *C, TransInfo *t)
// /* temporal...? */
// t->scene->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */
}
-
-
-
-
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 1b8cc14ecac..b7857be5afb 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -140,13 +140,13 @@ void getViewVector(TransInfo *t, float coord[3], float vec[3])
static void clipMirrorModifier(TransInfo *t, Object *ob)
{
- ModifierData *md= ob->modifiers.first;
+ ModifierData *md = ob->modifiers.first;
float tolerance[3] = {0.0f, 0.0f, 0.0f};
int axis = 0;
- for (; md; md=md->next) {
- if ((md->type==eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) {
- MirrorModifierData *mmd = (MirrorModifierData*) md;
+ for (; md; md = md->next) {
+ if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) {
+ MirrorModifierData *mmd = (MirrorModifierData *) md;
if (mmd->flag & MOD_MIR_CLIPPING) {
axis = 0;
@@ -175,13 +175,13 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
invert_m4_m4(imtx, mtx);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
int clip;
float loc[3], iloc[3];
if (td->flag & TD_NOACTION)
break;
- if (td->loc==NULL)
+ if (td->loc == NULL)
break;
if (td->flag & TD_SKIP)
@@ -197,27 +197,27 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
clip = 0;
if (axis & 1) {
- if (fabsf(iloc[0])<=tolerance[0] ||
- loc[0]*iloc[0]<0.0f)
+ if (fabsf(iloc[0]) <= tolerance[0] ||
+ loc[0] * iloc[0] < 0.0f)
{
- loc[0]= 0.0f;
+ loc[0] = 0.0f;
clip = 1;
}
}
if (axis & 2) {
if (fabsf(iloc[1]) <= tolerance[1] ||
- loc[1] * iloc[1]<0.0f)
+ loc[1] * iloc[1] < 0.0f)
{
- loc[1]= 0.0f;
+ loc[1] = 0.0f;
clip = 1;
}
}
if (axis & 4) {
if (fabsf(iloc[2]) <= tolerance[2] ||
- loc[2] * iloc[2] < 0.0f)
+ loc[2] * iloc[2] < 0.0f)
{
- loc[2]= 0.0f;
+ loc[2] = 0.0f;
clip = 1;
}
}
@@ -242,19 +242,19 @@ static void editbmesh_apply_to_mirror(TransInfo *t)
BMVert *eve;
int i;
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
- if (td->loc==NULL)
+ if (td->loc == NULL)
break;
if (td->flag & TD_SKIP)
continue;
eve = td->extra;
if (eve) {
- eve->co[0]= -td->loc[0];
- eve->co[1]= td->loc[1];
- eve->co[2]= td->loc[2];
+ eve->co[0] = -td->loc[0];
+ eve->co[1] = td->loc[1];
+ eve->co[2] = td->loc[2];
}
if (td->flag & TD_MIRROR_EDGE) {
@@ -264,23 +264,23 @@ static void editbmesh_apply_to_mirror(TransInfo *t)
}
/* for the realtime animation recording feature, handle overlapping data */
-static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer)
+static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer)
{
- ScreenAnimData *sad= (animtimer) ? animtimer->customdata : NULL;
+ ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL;
/* sanity checks */
if (ELEM3(NULL, scene, id, sad))
return;
/* check if we need a new strip if:
- * - if animtimer is running
+ * - if animtimer is running
* - we're not only keying for available channels
* - the option to add new actions for each round is not enabled
*/
- if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)==0 && (scene->toolsettings->autokey_flag & ANIMRECORD_FLAG_WITHNLA)) {
+ if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL) == 0 && (scene->toolsettings->autokey_flag & ANIMRECORD_FLAG_WITHNLA)) {
/* if playback has just looped around, we need to add a new NLA track+strip to allow a clean pass to occur */
if ((sad) && (sad->flag & ANIMPLAY_FLAG_JUMPED)) {
- AnimData *adt= BKE_animdata_from_id(id);
+ AnimData *adt = BKE_animdata_from_id(id);
/* perform push-down manually with some differences
* NOTE: BKE_nla_action_pushdown() sync warning...
@@ -290,21 +290,21 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer)
/* only push down if action is more than 1-2 frames long */
calc_action_range(adt->action, &astart, &aend, 1);
- if (aend > astart+2.0f) {
- NlaStrip *strip= add_nlastrip_to_stack(adt, adt->action);
+ if (aend > astart + 2.0f) {
+ NlaStrip *strip = add_nlastrip_to_stack(adt, adt->action);
/* clear reference to action now that we've pushed it onto the stack */
adt->action->id.us--;
- adt->action= NULL;
+ adt->action = NULL;
/* adjust blending + extend so that they will behave correctly */
- strip->extendmode= NLASTRIP_EXTEND_NOTHING;
- strip->flag &= ~(NLASTRIP_FLAG_AUTO_BLENDS|NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE);
+ strip->extendmode = NLASTRIP_EXTEND_NOTHING;
+ strip->flag &= ~(NLASTRIP_FLAG_AUTO_BLENDS | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE);
/* also, adjust the AnimData's action extend mode to be on
* 'nothing' so that previous result still play
*/
- adt->act_extendmode= NLASTRIP_EXTEND_NOTHING;
+ adt->act_extendmode = NLASTRIP_EXTEND_NOTHING;
}
}
}
@@ -313,13 +313,13 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer)
static int fcu_test_selected(FCurve *fcu)
{
- BezTriple *bezt= fcu->bezt;
+ BezTriple *bezt = fcu->bezt;
unsigned int i;
- if (bezt==NULL) /* ignore baked */
+ if (bezt == NULL) /* ignore baked */
return 0;
- for (i=0; i < fcu->totvert; i++, bezt++) {
+ for (i = 0; i < fcu->totvert; i++, bezt++) {
if (BEZSELECTED(bezt)) return 1;
}
@@ -329,23 +329,23 @@ static int fcu_test_selected(FCurve *fcu)
/* helper for recalcData() - for Action Editor transforms */
static void recalcData_actedit(TransInfo *t)
{
- Scene *scene= t->scene;
- SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+ Scene *scene = t->scene;
+ SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
- bAnimContext ac= {NULL};
+ bAnimContext ac = {NULL};
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
/* initialize relevant anim-context 'context' data from TransInfo data */
- /* NOTE: sync this with the code in ANIM_animdata_get_context() */
- ac.scene= t->scene;
- ac.obact= OBACT;
- ac.sa= t->sa;
- ac.ar= t->ar;
- ac.sl= (t->sa)? t->sa->spacedata.first : NULL;
- ac.spacetype= (t->sa)? t->sa->spacetype : 0;
- ac.regiontype= (t->ar)? t->ar->regiontype : 0;
+ /* NOTE: sync this with the code in ANIM_animdata_get_context() */
+ ac.scene = t->scene;
+ ac.obact = OBACT;
+ ac.sa = t->sa;
+ ac.ar = t->ar;
+ ac.sl = (t->sa) ? t->sa->spacedata.first : NULL;
+ ac.spacetype = (t->sa) ? t->sa->spacetype : 0;
+ ac.regiontype = (t->ar) ? t->ar->regiontype : 0;
ANIM_animdata_context_getdata(&ac);
@@ -356,14 +356,14 @@ static void recalcData_actedit(TransInfo *t)
}
else {
/* get animdata blocks visible in editor, assuming that these will be the ones where things changed */
- filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* just tag these animdata-blocks to recalc, assuming that some data there changed
* BUT only do this if realtime updates are enabled
*/
if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
- for (ale= anim_data.first; ale; ale= ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next) {
/* set refresh tags for objects using this animation */
ANIM_list_elem_update(t->scene, ale);
}
@@ -376,11 +376,11 @@ static void recalcData_actedit(TransInfo *t)
/* helper for recalcData() - for Graph Editor transforms */
static void recalcData_graphedit(TransInfo *t)
{
- SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+ SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
Scene *scene;
ListBase anim_data = {NULL, NULL};
- bAnimContext ac= {NULL};
+ bAnimContext ac = {NULL};
int filter;
bAnimListElem *ale;
@@ -388,14 +388,14 @@ static void recalcData_graphedit(TransInfo *t)
/* initialize relevant anim-context 'context' data from TransInfo data */
- /* NOTE: sync this with the code in ANIM_animdata_get_context() */
- scene= ac.scene= t->scene;
- ac.obact= OBACT;
- ac.sa= t->sa;
- ac.ar= t->ar;
- ac.sl= (t->sa)? t->sa->spacedata.first : NULL;
- ac.spacetype= (t->sa)? t->sa->spacetype : 0;
- ac.regiontype= (t->ar)? t->ar->regiontype : 0;
+ /* NOTE: sync this with the code in ANIM_animdata_get_context() */
+ scene = ac.scene = t->scene;
+ ac.obact = OBACT;
+ ac.sa = t->sa;
+ ac.ar = t->ar;
+ ac.sl = (t->sa) ? t->sa->spacedata.first : NULL;
+ ac.spacetype = (t->sa) ? t->sa->spacetype : 0;
+ ac.regiontype = (t->ar) ? t->ar->regiontype : 0;
ANIM_animdata_context_getdata(&ac);
@@ -403,19 +403,19 @@ static void recalcData_graphedit(TransInfo *t)
flushTransGraphData(t);
/* get curves to check if a re-sort is needed */
- filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* now test if there is a need to re-sort */
- for (ale= anim_data.first; ale; ale= ale->next) {
- FCurve *fcu= (FCurve *)ale->key_data;
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ FCurve *fcu = (FCurve *)ale->key_data;
/* ignore unselected fcurves */
if (!fcu_test_selected(fcu))
continue;
// fixme: only do this for selected verts...
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL|ANIM_UNITCONV_SELVERTS|ANIM_UNITCONV_RESTORE);
+ ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS | ANIM_UNITCONV_RESTORE);
/* watch it: if the time is wrong: do not correct handles yet */
@@ -441,10 +441,10 @@ static void recalcData_graphedit(TransInfo *t)
/* helper for recalcData() - for NLA Editor transforms */
static void recalcData_nla(TransInfo *t)
{
- TransDataNla *tdn= (TransDataNla *)t->customData;
- SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
- Scene *scene= t->scene;
- double secf= FPS;
+ TransDataNla *tdn = (TransDataNla *)t->customData;
+ SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
+ Scene *scene = t->scene;
+ double secf = FPS;
int i;
/* for each strip we've got, perform some additional validation of the values that got set before
@@ -452,7 +452,7 @@ static void recalcData_nla(TransInfo *t)
* sure that everything works ok)
*/
for (i = 0; i < t->total; i++, tdn++) {
- NlaStrip *strip= tdn->strip;
+ NlaStrip *strip = tdn->strip;
PointerRNA strip_ptr;
short pExceeded, nExceeded, iter;
int delta_y1, delta_y2;
@@ -474,16 +474,16 @@ static void recalcData_nla(TransInfo *t)
*/
/* start */
- strip->start= tdn->h1[0];
+ strip->start = tdn->h1[0];
if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
- strip->prev->end= tdn->h1[0];
+ strip->prev->end = tdn->h1[0];
/* end */
- strip->end= tdn->h2[0];
+ strip->end = tdn->h2[0];
if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
- strip->next->start= tdn->h2[0];
+ strip->next->start = tdn->h2[0];
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
@@ -503,9 +503,9 @@ static void recalcData_nla(TransInfo *t)
*
* this is done as a iterative procedure (done 5 times max for now)
*/
- for (iter=0; iter < 5; iter++) {
- pExceeded= ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h1[0] < strip->prev->end));
- nExceeded= ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h2[0] > strip->next->start));
+ for (iter = 0; iter < 5; iter++) {
+ pExceeded = ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h1[0] < strip->prev->end));
+ nExceeded = ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h2[0] > strip->next->start));
if ((pExceeded && nExceeded) || (iter == 4) ) {
/* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
@@ -513,24 +513,24 @@ static void recalcData_nla(TransInfo *t)
* - if there were no neighbors, clear the transforms (make it default to the strip's current values)
*/
if (strip->prev && strip->next) {
- tdn->h1[0]= strip->prev->end;
- tdn->h2[0]= strip->next->start;
+ tdn->h1[0] = strip->prev->end;
+ tdn->h2[0] = strip->next->start;
}
else {
- tdn->h1[0]= strip->start;
- tdn->h2[0]= strip->end;
+ tdn->h1[0] = strip->start;
+ tdn->h2[0] = strip->end;
}
}
else if (nExceeded) {
/* move backwards */
- float offset= tdn->h2[0] - strip->next->start;
+ float offset = tdn->h2[0] - strip->next->start;
tdn->h1[0] -= offset;
tdn->h2[0] -= offset;
}
else if (pExceeded) {
/* more forwards */
- float offset= strip->prev->end - tdn->h1[0];
+ float offset = strip->prev->end - tdn->h1[0];
tdn->h1[0] += offset;
tdn->h2[0] += offset;
@@ -553,8 +553,8 @@ static void recalcData_nla(TransInfo *t)
break;
case SACTSNAP_MARKER: /* snap to nearest marker */
- tdn->h1[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
- tdn->h2[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
+ tdn->h1[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
+ tdn->h2[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
break;
}
@@ -572,8 +572,8 @@ static void recalcData_nla(TransInfo *t)
/* now, check if we need to try and move track
* - we need to calculate both, as only one may have been altered by transform if only 1 handle moved
*/
- delta_y1= ((int)tdn->h1[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
- delta_y2= ((int)tdn->h2[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
+ delta_y1 = ((int)tdn->h1[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
+ delta_y2 = ((int)tdn->h2[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
if (delta_y1 || delta_y2) {
NlaTrack *track;
@@ -584,14 +584,14 @@ static void recalcData_nla(TransInfo *t)
* stopping on the last track available or that we're able to fit in
*/
if (delta > 0) {
- for (track=tdn->nlt->next, n=0; (track) && (n < delta); track=track->next, n++) {
+ for (track = tdn->nlt->next, n = 0; (track) && (n < delta); track = track->next, n++) {
/* check if space in this track for the strip */
if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
/* move strip to this track */
BLI_remlink(&tdn->nlt->strips, strip);
BKE_nlatrack_add_strip(track, strip);
- tdn->nlt= track;
+ tdn->nlt = track;
tdn->trackIndex++;
}
else /* can't move any further */
@@ -600,16 +600,16 @@ static void recalcData_nla(TransInfo *t)
}
else {
/* make delta 'positive' before using it, since we now know to go backwards */
- delta= -delta;
+ delta = -delta;
- for (track=tdn->nlt->prev, n=0; (track) && (n < delta); track=track->prev, n++) {
+ for (track = tdn->nlt->prev, n = 0; (track) && (n < delta); track = track->prev, n++) {
/* check if space in this track for the strip */
if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
/* move strip to this track */
BLI_remlink(&tdn->nlt->strips, strip);
BKE_nlatrack_add_strip(track, strip);
- tdn->nlt= track;
+ tdn->nlt = track;
tdn->trackIndex--;
}
else /* can't move any further */
@@ -624,7 +624,7 @@ static void recalcData_nla(TransInfo *t)
static void recalcData_image(TransInfo *t)
{
if (t->obedit && t->obedit->type == OB_MESH) {
- SpaceImage *sima= t->sa->spacedata.first;
+ SpaceImage *sima = t->sa->spacedata.first;
flushTransUVs(t);
if (sima->flag & SI_LIVE_UNWRAP)
@@ -641,7 +641,7 @@ static void recalcData_spaceclip(TransInfo *t)
if (ED_space_clip_show_trackedit(sc)) {
MovieClip *clip = ED_space_clip(sc);
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
int framenr = sc->user.framenr;
@@ -649,24 +649,24 @@ static void recalcData_spaceclip(TransInfo *t)
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
- MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
+ if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (t->mode == TFM_TRANSLATION) {
if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
- BKE_tracking_clamp_marker(marker, CLAMP_PAT_POS);
+ BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS);
if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
- BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_POS);
+ BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_POS);
}
else if (t->mode == TFM_RESIZE) {
if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
- BKE_tracking_clamp_marker(marker, CLAMP_PAT_DIM);
+ BKE_tracking_marker_clamp(marker, CLAMP_PAT_DIM);
if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
- BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_DIM);
+ BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_DIM);
}
else if (t->mode == TFM_ROTATION) {
if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
- BKE_tracking_clamp_marker(marker, CLAMP_PAT_POS);
+ BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS);
}
}
@@ -691,9 +691,9 @@ static void recalcData_view3d(TransInfo *t)
if (t->obedit) {
if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
- Curve *cu= t->obedit->data;
- ListBase *nurbs= BKE_curve_editNurbs_get(cu);
- Nurb *nu= nurbs->first;
+ Curve *cu = t->obedit->data;
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+ Nurb *nu = nurbs->first;
if (t->state != TRANS_CANCEL) {
clipMirrorModifier(t, t->obedit);
@@ -705,7 +705,7 @@ static void recalcData_view3d(TransInfo *t)
if (t->state == TRANS_CANCEL) {
while (nu) {
BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
- nu= nu->next;
+ nu = nu->next;
}
}
else {
@@ -713,12 +713,12 @@ static void recalcData_view3d(TransInfo *t)
while (nu) {
BKE_nurb_test2D(nu);
BKE_nurb_handles_calc(nu);
- nu= nu->next;
+ nu = nu->next;
}
}
}
- else if (t->obedit->type==OB_LATTICE) {
- Lattice *la= t->obedit->data;
+ else if (t->obedit->type == OB_LATTICE) {
+ Lattice *la = t->obedit->data;
if (t->state != TRANS_CANCEL) {
applyProject(t);
@@ -744,8 +744,8 @@ static void recalcData_view3d(TransInfo *t)
EDBM_mesh_normals_update(em);
BMEdit_RecalcTessellation(em);
}
- else if (t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */
- bArmature *arm= t->obedit->data;
+ else if (t->obedit->type == OB_ARMATURE) { /* no recalc flag, does pose */
+ bArmature *arm = t->obedit->data;
ListBase *edbo = arm->edbo;
EditBone *ebo;
TransData *td = t->data;
@@ -761,33 +761,33 @@ static void recalcData_view3d(TransInfo *t)
if ((ebo->flag & BONE_CONNECTED) && ebo->parent) {
/* If this bone has a parent tip that has been moved */
if (ebo->parent->flag & BONE_TIPSEL) {
- copy_v3_v3 (ebo->head, ebo->parent->tail);
- if (t->mode==TFM_BONE_ENVELOPE) ebo->rad_head= ebo->parent->rad_tail;
+ copy_v3_v3(ebo->head, ebo->parent->tail);
+ if (t->mode == TFM_BONE_ENVELOPE) ebo->rad_head = ebo->parent->rad_tail;
}
/* If this bone has a parent tip that has NOT been moved */
else {
- copy_v3_v3 (ebo->parent->tail, ebo->head);
- if (t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head;
+ copy_v3_v3(ebo->parent->tail, ebo->head);
+ if (t->mode == TFM_BONE_ENVELOPE) ebo->parent->rad_tail = ebo->rad_head;
}
}
/* on extrude bones, oldlength==0.0f, so we scale radius of points */
- ebo->length= len_v3v3(ebo->head, ebo->tail);
- if (ebo->oldlength==0.0f) {
- ebo->rad_head= 0.25f*ebo->length;
- ebo->rad_tail= 0.10f*ebo->length;
- ebo->dist= 0.25f*ebo->length;
+ ebo->length = len_v3v3(ebo->head, ebo->tail);
+ if (ebo->oldlength == 0.0f) {
+ ebo->rad_head = 0.25f * ebo->length;
+ ebo->rad_tail = 0.10f * ebo->length;
+ ebo->dist = 0.25f * ebo->length;
if (ebo->parent) {
if (ebo->rad_head > ebo->parent->rad_tail)
- ebo->rad_head= ebo->parent->rad_tail;
+ ebo->rad_head = ebo->parent->rad_tail;
}
}
- else if (t->mode!=TFM_BONE_ENVELOPE) {
+ else if (t->mode != TFM_BONE_ENVELOPE) {
/* if bones change length, lets do that for the deform distance as well */
- ebo->dist*= ebo->length/ebo->oldlength;
- ebo->rad_head*= ebo->length/ebo->oldlength;
- ebo->rad_tail*= ebo->length/ebo->oldlength;
- ebo->oldlength= ebo->length;
+ ebo->dist *= ebo->length / ebo->oldlength;
+ ebo->rad_head *= ebo->length / ebo->oldlength;
+ ebo->rad_tail *= ebo->length / ebo->oldlength;
+ ebo->oldlength = ebo->length;
}
}
@@ -828,9 +828,9 @@ static void recalcData_view3d(TransInfo *t)
DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */
}
}
- else if ( (t->flag & T_POSE) && t->poseobj) {
- Object *ob= t->poseobj;
- bArmature *arm= ob->data;
+ else if ((t->flag & T_POSE) && t->poseobj) {
+ Object *ob = t->poseobj;
+ bArmature *arm = ob->data;
/* if animtimer is running, and the object already has animation data,
* check if the auto-record feature means that we should record 'samples'
@@ -840,7 +840,7 @@ static void recalcData_view3d(TransInfo *t)
*/
// TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) {
- int targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
+ int targetless_ik = (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
animrecord_check_state(t->scene, &ob->id, t->animtimer);
autokeyframe_pose_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
@@ -897,10 +897,10 @@ static void recalcData_view3d(TransInfo *t)
/* called for updating while transform acts, once per redraw */
void recalcData(TransInfo *t)
{
- if (t->spacetype==SPACE_NODE) {
+ if (t->spacetype == SPACE_NODE) {
flushTransNodes(t);
}
- else if (t->spacetype==SPACE_SEQ) {
+ else if (t->spacetype == SPACE_SEQ) {
flushTransSeq(t);
}
else if (t->spacetype == SPACE_ACTION) {
@@ -953,8 +953,8 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
setlinestyle(0);
glBegin(GL_LINE_STRIP);
- glVertex3fv(v1);
- glVertex3fv(v2);
+ glVertex3fv(v1);
+ glVertex3fv(v2);
glEnd();
glPopMatrix();
@@ -1011,20 +1011,20 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->mval[0] = t->imval[0];
t->mval[1] = t->imval[1];
- t->transform = NULL;
- t->handleEvent = NULL;
+ t->transform = NULL;
+ t->handleEvent = NULL;
- t->total = 0;
+ t->total = 0;
t->val = 0.0f;
- t->vec[0] =
- t->vec[1] =
- t->vec[2] = 0.0f;
-
- t->center[0] =
- t->center[1] =
- t->center[2] = 0.0f;
+ t->vec[0] =
+ t->vec[1] =
+ t->vec[2] = 0.0f;
+
+ t->center[0] =
+ t->center[1] =
+ t->center[2] = 0.0f;
unit_m3(t->mat);
@@ -1042,15 +1042,15 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
/* Assign the space type, some exceptions for running in different mode */
if (sa == NULL) {
/* background mode */
- t->spacetype= SPACE_EMPTY;
+ t->spacetype = SPACE_EMPTY;
}
else if ((ar == NULL) && (sa->spacetype == SPACE_VIEW3D)) {
/* running in the text editor */
- t->spacetype= SPACE_EMPTY;
+ t->spacetype = SPACE_EMPTY;
}
else {
/* normal operation */
- t->spacetype= sa->spacetype;
+ t->spacetype = sa->spacetype;
}
@@ -1059,7 +1059,7 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
bScreen *animscreen = ED_screen_animation_playing(CTX_wm_manager(C));
t->view = v3d;
- t->animtimer= (animscreen)? animscreen->animtimer: NULL;
+ t->animtimer = (animscreen) ? animscreen->animtimer : NULL;
/* turn manipulator off during transform */
// FIXME: but don't do this when USING the manipulator...
@@ -1085,7 +1085,7 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
/* exceptional case */
- if (t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
+ if (t->around == V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
if (ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
t->options |= CTX_NO_PET;
}
@@ -1107,23 +1107,23 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
}
- else if (t->spacetype==SPACE_IMAGE) {
+ else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = sa->spacedata.first;
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
t->around = sima->around;
}
- else if (t->spacetype==SPACE_NODE) {
+ else if (t->spacetype == SPACE_NODE) {
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
t->around = V3D_CENTER;
}
- else if (t->spacetype==SPACE_IPO) {
- SpaceIpo *sipo= sa->spacedata.first;
+ else if (t->spacetype == SPACE_IPO) {
+ SpaceIpo *sipo = sa->spacedata.first;
t->view = &ar->v2d;
t->around = sipo->around;
}
- else if (t->spacetype==SPACE_CLIP) {
+ else if (t->spacetype == SPACE_CLIP) {
SpaceClip *sclip = sa->spacedata.first;
t->view = &ar->v2d;
t->around = sclip->around;
@@ -1140,7 +1140,7 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
// XXX for now, the center point is the midpoint of the data
}
else {
- t->view= NULL;
+ t->view = NULL;
}
t->around = V3D_CENTER;
}
@@ -1277,7 +1277,7 @@ void postTrans(bContext *C, TransInfo *t)
int a;
/* free data malloced per trans-data */
- for (a=0, td= t->data; a<t->total; a++, td++) {
+ for (a = 0, td = t->data; a < t->total; a++, td++) {
if (td->flag & TD_BEZTRIPLE)
MEM_freeN(td->hdata);
}
@@ -1289,15 +1289,15 @@ void postTrans(bContext *C, TransInfo *t)
if (t->ext) MEM_freeN(t->ext);
if (t->data2d) {
MEM_freeN(t->data2d);
- t->data2d= NULL;
+ t->data2d = NULL;
}
- if (t->spacetype==SPACE_IMAGE) {
- SpaceImage *sima= t->sa->spacedata.first;
+ if (t->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = t->sa->spacedata.first;
if (sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
}
- else if (t->spacetype==SPACE_VIEW3D) {
+ else if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = t->sa->spacedata.first;
/* restore manipulator */
if (t->flag & T_MODAL) {
@@ -1336,12 +1336,12 @@ static void restoreElement(TransData *td)
*td->val = td->ival;
}
- if (td->ext && (td->flag&TD_NO_EXT)==0) {
+ if (td->ext && (td->flag & TD_NO_EXT) == 0) {
if (td->ext->rot) {
copy_v3_v3(td->ext->rot, td->ext->irot);
}
if (td->ext->rotAngle) {
- *td->ext->rotAngle= td->ext->irotAngle;
+ *td->ext->rotAngle = td->ext->irotAngle;
}
if (td->ext->rotAxis) {
copy_v3_v3(td->ext->rotAxis, td->ext->irotAxis);
@@ -1370,7 +1370,7 @@ void restoreTransObjects(TransInfo *t)
restoreElement(td);
}
- for (td2d=t->data2d; t->data2d && td2d < t->data2d + t->total; td2d++) {
+ for (td2d = t->data2d; t->data2d && td2d < t->data2d + t->total; td2d++) {
if (td2d->h1) {
td2d->h1[0] = td2d->ih1[0];
td2d->h1[1] = td2d->ih1[1];
@@ -1388,8 +1388,8 @@ void restoreTransObjects(TransInfo *t)
void calculateCenter2D(TransInfo *t)
{
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
float vec[3];
copy_v3_v3(vec, t->center);
@@ -1409,8 +1409,8 @@ void calculateCenterCursor(TransInfo *t)
copy_v3_v3(t->center, cursor);
/* If edit or pose mode, move cursor in local space */
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob = t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
float mat[3][3], imat[3][3];
sub_v3_v3v3(t->center, t->center, ob->obmat[3]);
@@ -1424,11 +1424,11 @@ void calculateCenterCursor(TransInfo *t)
void calculateCenterCursor2D(TransInfo *t)
{
- float aspx=1.0, aspy=1.0;
- float *cursor= NULL;
+ float aspx = 1.0, aspy = 1.0;
+ float *cursor = NULL;
- if (t->spacetype==SPACE_IMAGE) {
- SpaceImage *sima= (SpaceImage *)t->sa->spacedata.first;
+ if (t->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
/* only space supported right now but may change */
ED_space_image_uv_aspect(sima, &aspx, &aspy);
cursor = sima->cursor;
@@ -1444,12 +1444,12 @@ void calculateCenterCursor2D(TransInfo *t)
static void calculateCenterCursorGraph2D(TransInfo *t)
{
- SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
- Scene *scene= t->scene;
+ SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
+ Scene *scene = t->scene;
/* cursor is combination of current frame, and graph-editor cursor value */
- t->center[0]= (float)(scene->r.cfra);
- t->center[1]= sipo->cursorVal;
+ t->center[0] = (float)(scene->r.cfra);
+ t->center[1] = sipo->cursorVal;
calculateCenter2D(t);
}
@@ -1515,95 +1515,95 @@ void calculateCenterBound(TransInfo *t)
void calculateCenter(TransInfo *t)
{
switch (t->around) {
- case V3D_CENTER:
- calculateCenterBound(t);
- break;
- case V3D_CENTROID:
- calculateCenterMedian(t);
- break;
- case V3D_CURSOR:
- if (t->spacetype==SPACE_IMAGE)
- calculateCenterCursor2D(t);
- else if (t->spacetype==SPACE_IPO)
- calculateCenterCursorGraph2D(t);
- else
- calculateCenterCursor(t);
- break;
- case V3D_LOCAL:
- /* Individual element center uses median center for helpline and such */
- calculateCenterMedian(t);
- break;
- case V3D_ACTIVE:
+ case V3D_CENTER:
+ calculateCenterBound(t);
+ break;
+ case V3D_CENTROID:
+ calculateCenterMedian(t);
+ break;
+ case V3D_CURSOR:
+ if (t->spacetype == SPACE_IMAGE)
+ calculateCenterCursor2D(t);
+ else if (t->spacetype == SPACE_IPO)
+ calculateCenterCursorGraph2D(t);
+ else
+ calculateCenterCursor(t);
+ break;
+ case V3D_LOCAL:
+ /* Individual element center uses median center for helpline and such */
+ calculateCenterMedian(t);
+ break;
+ case V3D_ACTIVE:
{
- /* set median, and if if if... do object center */
+ /* set median, and if if if... do object center */
- /* EDIT MODE ACTIVE EDITMODE ELEMENT */
+ /* EDIT MODE ACTIVE EDITMODE ELEMENT */
- if (t->obedit) {
- if (t->obedit && t->obedit->type == OB_MESH) {
- BMEditSelection ese;
- BMEditMesh *em = BMEdit_FromObject(t->obedit);
+ if (t->obedit) {
+ if (t->obedit && t->obedit->type == OB_MESH) {
+ BMEditSelection ese;
+ BMEditMesh *em = BMEdit_FromObject(t->obedit);
- if (BM_select_history_active_get(em->bm, &ese)) {
- BM_editselection_center(&ese, t->center);
- calculateCenter2D(t);
- break;
+ if (BM_select_history_active_get(em->bm, &ese)) {
+ BM_editselection_center(&ese, t->center);
+ calculateCenter2D(t);
+ break;
+ }
}
- }
- else if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
- float center[3];
- Curve *cu= (Curve *)t->obedit->data;
+ else if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
+ float center[3];
+ Curve *cu = (Curve *)t->obedit->data;
- if (ED_curve_actSelection(cu, center)) {
- copy_v3_v3(t->center, center);
- calculateCenter2D(t);
- break;
+ if (ED_curve_actSelection(cu, center)) {
+ copy_v3_v3(t->center, center);
+ calculateCenter2D(t);
+ break;
+ }
+ }
+ } /* END EDIT MODE ACTIVE ELEMENT */
+
+ calculateCenterMedian(t);
+ if ((t->flag & (T_EDIT | T_POSE)) == 0) {
+ Scene *scene = t->scene;
+ Object *ob = OBACT;
+ if (ob) {
+ copy_v3_v3(t->center, ob->obmat[3]);
+ projectIntView(t, t->center, t->center2d);
}
}
- } /* END EDIT MODE ACTIVE ELEMENT */
-
- calculateCenterMedian(t);
- if ((t->flag & (T_EDIT|T_POSE))==0) {
- Scene *scene = t->scene;
- Object *ob= OBACT;
- if (ob) {
- copy_v3_v3(t->center, ob->obmat[3]);
- projectIntView(t, t->center, t->center2d);
- }
- }
}
}
/* setting constraint center */
copy_v3_v3(t->con.center, t->center);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->con.center);
}
/* for panning from cameraview */
if (t->flag & T_OBJECT) {
- if (t->spacetype==SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
+ if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
View3D *v3d = t->view;
Scene *scene = t->scene;
RegionView3D *rv3d = t->ar->regiondata;
- if (v3d->camera == OBACT && rv3d->persp==RV3D_CAMOB) {
+ if (v3d->camera == OBACT && rv3d->persp == RV3D_CAMOB) {
float axis[3];
/* persinv is nasty, use viewinv instead, always right */
copy_v3_v3(axis, t->viewinv[2]);
normalize_v3(axis);
/* 6.0 = 6 grid units */
- axis[0]= t->center[0]- 6.0f*axis[0];
- axis[1]= t->center[1]- 6.0f*axis[1];
- axis[2]= t->center[2]- 6.0f*axis[2];
+ axis[0] = t->center[0] - 6.0f * axis[0];
+ axis[1] = t->center[1] - 6.0f * axis[1];
+ axis[2] = t->center[2] - 6.0f * axis[2];
projectIntView(t, axis, t->center2d);
/* rotate only needs correct 2d center, grab needs initgrabz() value */
- if (t->mode==TFM_TRANSLATION) {
+ if (t->mode == TFM_TRANSLATION) {
copy_v3_v3(t->center, axis);
copy_v3_v3(t->con.center, t->center);
}
@@ -1611,10 +1611,10 @@ void calculateCenter(TransInfo *t)
}
}
- if (t->spacetype==SPACE_VIEW3D) {
+ if (t->spacetype == SPACE_VIEW3D) {
/* initgrabz() defines a factor for perspective depth correction, used in window_to_3d_delta() */
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
float vec[3];
copy_v3_v3(vec, t->center);
@@ -1635,7 +1635,7 @@ void calculatePropRatio(TransInfo *t)
short connected = t->flag & T_PROP_CONNECTED;
if (t->flag & T_PROP_EDIT) {
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_SELECTED) {
td->factor = 1.0f;
}
@@ -1660,9 +1660,9 @@ void calculatePropRatio(TransInfo *t)
td->flag &= ~TD_NOACTION;
if (connected)
- dist= (t->prop_size-td->dist)/t->prop_size;
+ dist = (t->prop_size - td->dist) / t->prop_size;
else
- dist= (t->prop_size-td->rdist)/t->prop_size;
+ dist = (t->prop_size - td->rdist) / t->prop_size;
/*
* Clamp to positive numbers.
@@ -1673,63 +1673,63 @@ void calculatePropRatio(TransInfo *t)
dist = 0.0f;
switch (t->prop_mode) {
- case PROP_SHARP:
- td->factor= dist*dist;
- break;
- case PROP_SMOOTH:
- td->factor= 3.0f*dist*dist - 2.0f*dist*dist*dist;
- break;
- case PROP_ROOT:
- td->factor = (float)sqrt(dist);
- break;
- case PROP_LIN:
- td->factor = dist;
- break;
- case PROP_CONST:
- td->factor = 1.0f;
- break;
- case PROP_SPHERE:
- td->factor = (float)sqrt(2*dist - dist * dist);
- break;
- case PROP_RANDOM:
- BLI_srand(BLI_rand()); /* random seed */
- td->factor = BLI_frand()*dist;
- break;
- default:
- td->factor = 1;
+ case PROP_SHARP:
+ td->factor = dist * dist;
+ break;
+ case PROP_SMOOTH:
+ td->factor = 3.0f * dist * dist - 2.0f * dist * dist * dist;
+ break;
+ case PROP_ROOT:
+ td->factor = (float)sqrt(dist);
+ break;
+ case PROP_LIN:
+ td->factor = dist;
+ break;
+ case PROP_CONST:
+ td->factor = 1.0f;
+ break;
+ case PROP_SPHERE:
+ td->factor = (float)sqrt(2 * dist - dist * dist);
+ break;
+ case PROP_RANDOM:
+ BLI_srand(BLI_rand()); /* random seed */
+ td->factor = BLI_frand() * dist;
+ break;
+ default:
+ td->factor = 1;
}
}
}
switch (t->prop_mode) {
- case PROP_SHARP:
- strcpy(t->proptext, "(Sharp)");
- break;
- case PROP_SMOOTH:
- strcpy(t->proptext, "(Smooth)");
- break;
- case PROP_ROOT:
- strcpy(t->proptext, "(Root)");
- break;
- case PROP_LIN:
- strcpy(t->proptext, "(Linear)");
- break;
- case PROP_CONST:
- strcpy(t->proptext, "(Constant)");
- break;
- case PROP_SPHERE:
- strcpy(t->proptext, "(Sphere)");
- break;
- case PROP_RANDOM:
- strcpy(t->proptext, "(Random)");
- break;
- default:
- t->proptext[0]= '\0';
+ case PROP_SHARP:
+ strcpy(t->proptext, "(Sharp)");
+ break;
+ case PROP_SMOOTH:
+ strcpy(t->proptext, "(Smooth)");
+ break;
+ case PROP_ROOT:
+ strcpy(t->proptext, "(Root)");
+ break;
+ case PROP_LIN:
+ strcpy(t->proptext, "(Linear)");
+ break;
+ case PROP_CONST:
+ strcpy(t->proptext, "(Constant)");
+ break;
+ case PROP_SPHERE:
+ strcpy(t->proptext, "(Sphere)");
+ break;
+ case PROP_RANDOM:
+ strcpy(t->proptext, "(Random)");
+ break;
+ default:
+ t->proptext[0] = '\0';
}
}
else {
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
td->factor = 1.0;
}
- t->proptext[0]= '\0';
+ t->proptext[0] = '\0';
}
}
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 9c485e17dc7..7e05fdae364 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -64,18 +64,18 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
dx = (float)(mi->center[0] - mi->precision_mval[0]);
dy = (float)(mi->center[1] - mi->precision_mval[1]);
- ratio = (float)sqrt( dx*dx + dy*dy);
+ ratio = sqrtf(dx * dx + dy * dy);
- dx= (float)(mi->center[0] - mval[0]);
- dy= (float)(mi->center[1] - mval[1]);
- precise_ratio = (float)sqrt( dx*dx + dy*dy);
+ dx = (float)(mi->center[0] - mval[0]);
+ dy = (float)(mi->center[1] - mval[1]);
+ precise_ratio = (float)sqrt(dx * dx + dy * dy);
ratio = (ratio + (precise_ratio - ratio) / 10.0f) / mi->factor;
}
else {
dx = (float)(mi->center[0] - mval[0]);
dy = (float)(mi->center[1] - mval[1]);
- ratio = (float)sqrt( dx*dx + dy*dy) / mi->factor;
+ ratio = sqrtf(dx * dx + dy * dy) / mi->factor;
}
output[0] = ratio;
@@ -98,12 +98,12 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const int mval[
{
if (mi->precision) {
- output[0] = ( mi->imval[1] - mi->precision_mval[1] ) + ( mi->precision_mval[1] - mval[1] ) * 0.1f;
- output[1] = ( mi->precision_mval[0] - mi->imval[0] ) + ( mval[0] - mi->precision_mval[0] ) * 0.1f;
+ output[0] = (mi->imval[1] - mi->precision_mval[1]) + (mi->precision_mval[1] - mval[1]) * 0.1f;
+ output[1] = (mi->precision_mval[0] - mi->imval[0]) + (mval[0] - mi->precision_mval[0]) * 0.1f;
}
else {
- output[0] = (float)( mi->imval[1] - mval[1] );
- output[1] = (float)( mval[0] - mi->imval[0] );
+ output[0] = (float)(mi->imval[1] - mval[1]);
+ output[1] = (float)(mval[0] - mi->imval[0]);
}
output[0] *= mi->factor;
@@ -191,7 +191,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva
dx = data[2] - data[0];
dy = data[3] - data[1];
- length = sqrt(dx*dx + dy*dy);
+ length = sqrt(dx * dx + dy * dy);
if (mi->precision) {
/* deal with Shift key by adding motion / 10 to motion before shift press */
@@ -199,7 +199,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva
mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2];
mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3];
- distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length: 0.0;
+ distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length : 0.0;
}
else {
int mdx, mdy;
@@ -217,11 +217,11 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
{
double dx2 = mval[0] - mi->center[0];
double dy2 = mval[1] - mi->center[1];
- double B = sqrt(dx2*dx2+dy2*dy2);
+ double B = sqrt(dx2 * dx2 + dy2 * dy2);
double dx1 = mi->imval[0] - mi->center[0];
double dy1 = mi->imval[1] - mi->center[1];
- double A = sqrt(dx1*dx1+dy1*dy1);
+ double A = sqrt(dx1 * dx1 + dy1 * dy1);
double dx3 = mval[0] - mi->imval[0];
double dy3 = mval[1] - mi->imval[1];
@@ -237,7 +237,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
float dphi;
dphi = saacos((float)deler);
- if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
+ if ((dx1 * dy2 - dx2 * dy1) > 0.0) dphi = -dphi;
/* If the angle is zero, because of lack of precision close to the 1.0 value in acos
* approximate the angle with the opposite side of the normalized triangle
@@ -256,12 +256,12 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
dx = dx1 - dx2;
dy = dy1 - dy2;
- dphi = sqrt(dx*dx + dy*dy);
- if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
+ dphi = sqrt(dx * dx + dy * dy);
+ if ((dx1 * dy2 - dx2 * dy1) > 0.0) dphi = -dphi;
}
if (mi->precision) {
- dphi = dphi/30.0f;
+ dphi = dphi / 30.0f;
}
/* if no delta angle, don't update initial position */
@@ -295,7 +295,7 @@ static void calcSpringFactor(MouseInput *mi)
((float)(mi->center[0] - mi->imval[0])) * ((float)(mi->center[0] - mi->imval[0])));
if (mi->factor == 0.0f) {
- mi->factor= 1.0f; /* prevent Inf */
+ mi->factor = 1.0f; /* prevent Inf */
}
}
@@ -307,68 +307,68 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#if 0
if (mi->data) {
MEM_freeN(mi->data);
- mi->data= NULL;
+ mi->data = NULL;
}
#endif
switch (mode) {
- case INPUT_VECTOR:
- mi->apply = InputVector;
- t->helpline = HLP_NONE;
- break;
- case INPUT_SPRING:
- calcSpringFactor(mi);
- mi->apply = InputSpring;
- t->helpline = HLP_SPRING;
- break;
- case INPUT_SPRING_FLIP:
- calcSpringFactor(mi);
- mi->apply = InputSpringFlip;
- t->helpline = HLP_SPRING;
- break;
- case INPUT_ANGLE:
- mi->data = MEM_callocN(sizeof(double), "angle accumulator");
- mi->apply = InputAngle;
- t->helpline = HLP_ANGLE;
- break;
- case INPUT_TRACKBALL:
- /* factor has to become setting or so */
- mi->factor = 0.01f;
- mi->apply = InputTrackBall;
- t->helpline = HLP_TRACKBALL;
- break;
- case INPUT_HORIZONTAL_RATIO:
- mi->factor = (float)(mi->center[0] - mi->imval[0]);
- mi->apply = InputHorizontalRatio;
- t->helpline = HLP_HARROW;
- break;
- case INPUT_HORIZONTAL_ABSOLUTE:
- mi->apply = InputHorizontalAbsolute;
- t->helpline = HLP_HARROW;
- break;
- case INPUT_VERTICAL_RATIO:
- mi->apply = InputVerticalRatio;
- t->helpline = HLP_VARROW;
- break;
- case INPUT_VERTICAL_ABSOLUTE:
- mi->apply = InputVerticalAbsolute;
- t->helpline = HLP_VARROW;
- break;
- case INPUT_CUSTOM_RATIO:
- mi->apply = InputCustomRatio;
- t->helpline = HLP_NONE;
- break;
- case INPUT_NONE:
- default:
- mi->apply = NULL;
- break;
+ case INPUT_VECTOR:
+ mi->apply = InputVector;
+ t->helpline = HLP_NONE;
+ break;
+ case INPUT_SPRING:
+ calcSpringFactor(mi);
+ mi->apply = InputSpring;
+ t->helpline = HLP_SPRING;
+ break;
+ case INPUT_SPRING_FLIP:
+ calcSpringFactor(mi);
+ mi->apply = InputSpringFlip;
+ t->helpline = HLP_SPRING;
+ break;
+ case INPUT_ANGLE:
+ mi->data = MEM_callocN(sizeof(double), "angle accumulator");
+ mi->apply = InputAngle;
+ t->helpline = HLP_ANGLE;
+ break;
+ case INPUT_TRACKBALL:
+ /* factor has to become setting or so */
+ mi->factor = 0.01f;
+ mi->apply = InputTrackBall;
+ t->helpline = HLP_TRACKBALL;
+ break;
+ case INPUT_HORIZONTAL_RATIO:
+ mi->factor = (float)(mi->center[0] - mi->imval[0]);
+ mi->apply = InputHorizontalRatio;
+ t->helpline = HLP_HARROW;
+ break;
+ case INPUT_HORIZONTAL_ABSOLUTE:
+ mi->apply = InputHorizontalAbsolute;
+ t->helpline = HLP_HARROW;
+ break;
+ case INPUT_VERTICAL_RATIO:
+ mi->apply = InputVerticalRatio;
+ t->helpline = HLP_VARROW;
+ break;
+ case INPUT_VERTICAL_ABSOLUTE:
+ mi->apply = InputVerticalAbsolute;
+ t->helpline = HLP_VARROW;
+ break;
+ case INPUT_CUSTOM_RATIO:
+ mi->apply = InputCustomRatio;
+ t->helpline = HLP_NONE;
+ break;
+ case INPUT_NONE:
+ default:
+ mi->apply = NULL;
+ break;
}
/* bootstrap mouse input with initial values */
applyMouseInput(t, mi, mi->imval, t->values);
}
-void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3]))
+void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float[3]))
{
mi->post = post;
}
@@ -389,21 +389,21 @@ int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event)
int redraw = TREDRAW_NOTHING;
switch (event->type) {
- case LEFTSHIFTKEY:
- case RIGHTSHIFTKEY:
- if (event->val == KM_PRESS) {
- t->modifiers |= MOD_PRECISION;
- /* shift is modifier for higher precision transform
- * store the mouse position where the normal movement ended */
- copy_v2_v2_int(mi->precision_mval, event->mval);
- mi->precision = 1;
- }
- else {
- t->modifiers &= ~MOD_PRECISION;
- mi->precision = 0;
- }
- redraw = TREDRAW_HARD;
- break;
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY:
+ if (event->val == KM_PRESS) {
+ t->modifiers |= MOD_PRECISION;
+ /* shift is modifier for higher precision transform
+ * store the mouse position where the normal movement ended */
+ copy_v2_v2_int(mi->precision_mval, event->mval);
+ mi->precision = 1;
+ }
+ else {
+ t->modifiers &= ~MOD_PRECISION;
+ mi->precision = 0;
+ }
+ redraw = TREDRAW_HARD;
+ break;
}
return redraw;
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 7d0e9dd6005..b3ccf004810 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -84,35 +84,35 @@
/* return codes for select, and drawing flags */
-#define MAN_TRANS_X 1
-#define MAN_TRANS_Y 2
-#define MAN_TRANS_Z 4
-#define MAN_TRANS_C 7
-
-#define MAN_ROT_X 8
-#define MAN_ROT_Y 16
-#define MAN_ROT_Z 32
-#define MAN_ROT_V 64
-#define MAN_ROT_T 128
-#define MAN_ROT_C 248
-
-#define MAN_SCALE_X 256
-#define MAN_SCALE_Y 512
-#define MAN_SCALE_Z 1024
-#define MAN_SCALE_C 1792
+#define MAN_TRANS_X 1
+#define MAN_TRANS_Y 2
+#define MAN_TRANS_Z 4
+#define MAN_TRANS_C 7
+
+#define MAN_ROT_X 8
+#define MAN_ROT_Y 16
+#define MAN_ROT_Z 32
+#define MAN_ROT_V 64
+#define MAN_ROT_T 128
+#define MAN_ROT_C 248
+
+#define MAN_SCALE_X 256
+#define MAN_SCALE_Y 512
+#define MAN_SCALE_Z 1024
+#define MAN_SCALE_C 1792
/* color codes */
-#define MAN_RGB 0
-#define MAN_GHOST 1
-#define MAN_MOVECOL 2
+#define MAN_RGB 0
+#define MAN_GHOST 1
+#define MAN_MOVECOL 2
/* transform widget center calc helper for below */
-static void calc_tw_center(Scene *scene, float *co)
+static void calc_tw_center(Scene *scene, const float co[3])
{
- float *twcent= scene->twcent;
- float *min= scene->twmin;
- float *max= scene->twmax;
+ float *twcent = scene->twcent;
+ float *min = scene->twmin;
+ float *max = scene->twmax;
minmax_v3v3_v3(min, max, co);
add_v3_v3(twcent, co);
@@ -145,7 +145,7 @@ static void protectflag_to_drawflags(short protectflag, short *drawflags)
/* for pose mode */
static void stats_pose(Scene *scene, RegionView3D *rv3d, bPoseChannel *pchan)
{
- Bone *bone= pchan->bone;
+ Bone *bone = pchan->bone;
if (bone) {
if (bone->flag & BONE_TRANSFORM) {
@@ -159,7 +159,7 @@ static void stats_pose(Scene *scene, RegionView3D *rv3d, bPoseChannel *pchan)
static void stats_editbone(RegionView3D *rv3d, EditBone *ebo)
{
if (ebo->flag & BONE_EDITMODE_LOCKED)
- protectflag_to_drawflags(OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE, &rv3d->twdrawflag);
+ protectflag_to_drawflags(OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE, &rv3d->twdrawflag);
}
/* could move into BLI_math however this is only useful for display/editing purposes */
@@ -172,9 +172,9 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], float axis[3], float ang
/* this is an un-scientific method to get a vector to cross with
* XYZ intentionally YZX */
- cross_vec[0]= axis[1];
- cross_vec[1]= axis[2];
- cross_vec[2]= axis[0];
+ cross_vec[0] = axis[1];
+ cross_vec[1] = axis[2];
+ cross_vec[2] = axis[0];
/* X-axis */
cross_v3_v3v3(gmat[0], cross_vec, axis);
@@ -183,7 +183,7 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], float axis[3], float ang
mul_qt_v3(quat, gmat[0]);
/* Y-axis */
- axis_angle_to_quat(quat, axis, M_PI/2.0);
+ axis_angle_to_quat(quat, axis, M_PI / 2.0);
copy_v3_v3(gmat[1], gmat[0]);
mul_qt_v3(quat, gmat[1]);
@@ -196,14 +196,14 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], float axis[3], float ang
static int test_rotmode_euler(short rotmode)
{
- return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0:1;
+ return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1;
}
int gimbal_axis(Object *ob, float gmat[][3])
{
if (ob) {
if (ob->mode & OB_MODE_POSE) {
- bPoseChannel *pchan= BKE_pose_channel_active(ob);
+ bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan) {
float mat[3][3], tmat[3][3], obmat[3][3];
@@ -270,40 +270,40 @@ int gimbal_axis(Object *ob, float gmat[][3])
/* returns total items selected */
int calc_manipulator_stats(const bContext *C)
{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= CTX_wm_region(C);
- Scene *scene= CTX_data_scene(C);
- Object *obedit= CTX_data_edit_object(C);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *obedit = CTX_data_edit_object(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- View3D *v3d= sa->spacedata.first;
- RegionView3D *rv3d= ar->regiondata;
+ View3D *v3d = sa->spacedata.first;
+ RegionView3D *rv3d = ar->regiondata;
Base *base;
- Object *ob= OBACT;
- int a, totsel= 0;
+ Object *ob = OBACT;
+ int a, totsel = 0;
/* transform widget matrix */
unit_m4(rv3d->twmat);
- rv3d->twdrawflag= 0xFFFF;
+ rv3d->twdrawflag = 0xFFFF;
/* transform widget centroid/center */
INIT_MINMAX(scene->twmin, scene->twmax);
zero_v3(scene->twcent);
if (obedit) {
- ob= obedit;
- if ((ob->lay & v3d->lay)==0) return 0;
+ ob = obedit;
+ if ((ob->lay & v3d->lay) == 0) return 0;
- if (obedit->type==OB_MESH) {
+ if (obedit->type == OB_MESH) {
BMEditMesh *em = BMEdit_FromObject(obedit);
BMEditSelection ese;
- float vec[3]= {0, 0, 0};
+ float vec[3] = {0, 0, 0};
/* USE LAST SELECTE WITH ACTIVE */
if ((v3d->around == V3D_ACTIVE) && BM_select_history_active_get(em->bm, &ese)) {
BM_editselection_center(&ese, vec);
calc_tw_center(scene, vec);
- totsel= 1;
+ totsel = 1;
}
else {
BMesh *bm = em->bm;
@@ -358,10 +358,10 @@ int calc_manipulator_stats(const bContext *C)
}
}
} /* end editmesh */
- else if (obedit->type==OB_ARMATURE) {
- bArmature *arm= obedit->data;
+ else if (obedit->type == OB_ARMATURE) {
+ bArmature *arm = obedit->data;
EditBone *ebo;
- for (ebo= arm->edbo->first; ebo; ebo=ebo->next) {
+ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
if (EBONE_VISIBLE(arm, ebo)) {
if (ebo->flag & BONE_TIPSEL) {
calc_tw_center(scene, ebo->tail);
@@ -378,24 +378,24 @@ int calc_manipulator_stats(const bContext *C)
}
}
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
- Curve *cu= obedit->data;
+ Curve *cu = obedit->data;
float center[3];
- if (v3d->around==V3D_ACTIVE && ED_curve_actSelection(cu, center)) {
- calc_tw_center(scene, center);
+ if (v3d->around == V3D_ACTIVE && ED_curve_actSelection(cu, center)) {
+ calc_tw_center(scene, center);
totsel++;
}
else {
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
- ListBase *nurbs= BKE_curve_editNurbs_get(cu);
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- nu= nurbs->first;
+ nu = nurbs->first;
while (nu) {
if (nu->type == CU_BEZIER) {
- bezt= nu->bezt;
- a= nu->pntsu;
+ bezt = nu->bezt;
+ a = nu->pntsu;
while (a--) {
/* exceptions
* if handles are hidden then only check the center points.
@@ -425,8 +425,8 @@ int calc_manipulator_stats(const bContext *C)
}
}
else {
- bp= nu->bp;
- a= nu->pntsu*nu->pntsv;
+ bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
calc_tw_center(scene, bp->vec);
@@ -435,31 +435,31 @@ int calc_manipulator_stats(const bContext *C)
bp++;
}
}
- nu= nu->next;
+ nu = nu->next;
}
}
}
- else if (obedit->type==OB_MBALL) {
- MetaBall *mb = (MetaBall*)obedit->data;
+ else if (obedit->type == OB_MBALL) {
+ MetaBall *mb = (MetaBall *)obedit->data;
MetaElem *ml /* , *ml_sel=NULL */ /* UNUSED */;
- ml= mb->editelems->first;
+ ml = mb->editelems->first;
while (ml) {
if (ml->flag & SELECT) {
calc_tw_center(scene, &ml->x);
/* ml_sel = ml; */ /* UNUSED */
totsel++;
}
- ml= ml->next;
+ ml = ml->next;
}
}
- else if (obedit->type==OB_LATTICE) {
+ else if (obedit->type == OB_LATTICE) {
BPoint *bp;
- Lattice *lt= obedit->data;
+ Lattice *lt = obedit->data;
- bp= lt->editlatt->latt->def;
+ bp = lt->editlatt->latt->def;
- a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
+ a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
while (a--) {
if (bp->f1 & SELECT) {
calc_tw_center(scene, bp->vec);
@@ -471,7 +471,7 @@ int calc_manipulator_stats(const bContext *C)
/* selection center */
if (totsel) {
- mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid!
+ mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
mul_m4_v3(obedit->obmat, scene->twcent);
mul_m4_v3(obedit->obmat, scene->twmin);
mul_m4_v3(obedit->obmat, scene->twmax);
@@ -481,17 +481,17 @@ int calc_manipulator_stats(const bContext *C)
bPoseChannel *pchan;
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
- if ((ob->lay & v3d->lay)==0) return 0;
+ if ((ob->lay & v3d->lay) == 0) return 0;
totsel = count_set_pose_transflags(&mode, 0, ob);
if (totsel) {
/* use channels to get stats */
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
stats_pose(scene, rv3d, pchan);
}
- mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid!
+ mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
mul_m4_v3(ob->obmat, scene->twcent);
mul_m4_v3(ob->obmat, scene->twmin);
mul_m4_v3(ob->obmat, scene->twmax);
@@ -501,17 +501,17 @@ int calc_manipulator_stats(const bContext *C)
;
}
else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
- PTCacheEdit *edit= PE_get_current(scene, ob);
+ PTCacheEdit *edit = PE_get_current(scene, ob);
PTCacheEditPoint *point;
PTCacheEditKey *ek;
int k;
if (edit) {
point = edit->points;
- for (a=0; a<edit->totpoint; a++, point++) {
+ for (a = 0; a < edit->totpoint; a++, point++) {
if (point->flag & PEP_HIDE) continue;
- for (k=0, ek=point->keys; k<point->totkey; k++, ek++) {
+ for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) {
if (ek->flag & PEK_SELECT) {
calc_tw_center(scene, ek->flag & PEK_USE_WCO ? ek->world_co : ek->co);
totsel++;
@@ -521,19 +521,19 @@ int calc_manipulator_stats(const bContext *C)
/* selection center */
if (totsel)
- mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid!
+ mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
}
}
else {
/* we need the one selected object, if its not active */
- ob= OBACT;
- if (ob && !(ob->flag & SELECT)) ob= NULL;
+ ob = OBACT;
+ if (ob && !(ob->flag & SELECT)) ob = NULL;
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (TESTBASELIB(v3d, base)) {
- if (ob==NULL)
- ob= base->object;
+ if (ob == NULL)
+ ob = base->object;
calc_tw_center(scene, base->object->obmat[3]);
protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag);
totsel++;
@@ -542,7 +542,7 @@ int calc_manipulator_stats(const bContext *C)
/* selection center */
if (totsel) {
- mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid!
+ mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
}
}
@@ -551,32 +551,32 @@ int calc_manipulator_stats(const bContext *C)
switch (v3d->twmode) {
- case V3D_MANIP_GLOBAL:
- break; /* nothing to do */
+ case V3D_MANIP_GLOBAL:
+ break; /* nothing to do */
- case V3D_MANIP_GIMBAL:
- {
- float mat[3][3];
- if (gimbal_axis(ob, mat)) {
- copy_m4_m3(rv3d->twmat, mat);
- break;
- }
- /* if not gimbal, fall through to normal */
- }
- case V3D_MANIP_NORMAL:
- if (obedit || ob->mode & OB_MODE_POSE) {
+ case V3D_MANIP_GIMBAL:
+ {
float mat[3][3];
- ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE));
- copy_m4_m3(rv3d->twmat, mat);
- break;
+ if (gimbal_axis(ob, mat)) {
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
+ /* if not gimbal, fall through to normal */
}
+ case V3D_MANIP_NORMAL:
+ if (obedit || ob->mode & OB_MODE_POSE) {
+ float mat[3][3];
+ ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE));
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
/* no break we define 'normal' as 'local' in Object mode */
- case V3D_MANIP_LOCAL:
- copy_m4_m4(rv3d->twmat, ob->obmat);
- normalize_m4(rv3d->twmat);
- break;
+ case V3D_MANIP_LOCAL:
+ copy_m4_m4(rv3d->twmat, ob->obmat);
+ normalize_m4(rv3d->twmat);
+ break;
- case V3D_MANIP_VIEW:
+ case V3D_MANIP_VIEW:
{
float mat[3][3];
copy_m3_m4(mat, rv3d->viewinv);
@@ -584,7 +584,7 @@ int calc_manipulator_stats(const bContext *C)
copy_m4_m3(rv3d->twmat, mat);
}
break;
- default: /* V3D_MANIP_CUSTOM */
+ default: /* V3D_MANIP_CUSTOM */
{
float mat[3][3];
applyTransformOrientation(C, mat, NULL);
@@ -601,7 +601,7 @@ int calc_manipulator_stats(const bContext *C)
/* don't draw axis perpendicular to the view */
static void test_manipulator_axis(const bContext *C)
{
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
float angle;
float vec[3];
@@ -613,7 +613,7 @@ static void test_manipulator_axis(const bContext *C)
}
angle = rv3d->twangle[0] = RAD2DEGF(angle);
if (angle < 5.0f) {
- rv3d->twdrawflag &= ~(MAN_TRANS_X|MAN_SCALE_X);
+ rv3d->twdrawflag &= ~(MAN_TRANS_X | MAN_SCALE_X);
}
angle = fabs(angle_v3v3(rv3d->twmat[1], vec));
@@ -622,7 +622,7 @@ static void test_manipulator_axis(const bContext *C)
}
angle = rv3d->twangle[1] = RAD2DEGF(angle);
if (angle < 5.0f) {
- rv3d->twdrawflag &= ~(MAN_TRANS_Y|MAN_SCALE_Y);
+ rv3d->twdrawflag &= ~(MAN_TRANS_Y | MAN_SCALE_Y);
}
angle = fabs(angle_v3v3(rv3d->twmat[2], vec));
@@ -631,7 +631,7 @@ static void test_manipulator_axis(const bContext *C)
}
angle = rv3d->twangle[2] = RAD2DEGF(angle);
if (angle < 5.0f) {
- rv3d->twdrawflag &= ~(MAN_TRANS_Z|MAN_SCALE_Z);
+ rv3d->twdrawflag &= ~(MAN_TRANS_Z | MAN_SCALE_Z);
}
}
@@ -643,7 +643,7 @@ static float screen_aligned(RegionView3D *rv3d, float mat[][4])
glTranslatef(mat[3][0], mat[3][1], mat[3][2]);
/* sets view screen aligned */
- glRotatef(-360.0f*saacos(rv3d->viewquat[0])/(float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]);
+ glRotatef(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]);
return len_v3(mat[0]); /* draw scale */
}
@@ -666,43 +666,43 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
if (start == 0 && end == nrings) do_caps = FALSE;
- ring_delta= 2.0f*(float)M_PI/(float)nrings;
- side_delta= 2.0f*(float)M_PI/(float)nsides;
+ ring_delta = 2.0f * (float)M_PI / (float)nrings;
+ side_delta = 2.0f * (float)M_PI / (float)nsides;
- theta= (float)M_PI+0.5f*ring_delta;
- cos_theta= (float)cos(theta);
- sin_theta= (float)sin(theta);
+ theta = (float)M_PI + 0.5f * ring_delta;
+ cos_theta = (float)cos(theta);
+ sin_theta = (float)sin(theta);
- for (i= nrings - 1; i >= 0; i--) {
- theta1= theta + ring_delta;
- cos_theta1= (float)cos(theta1);
- sin_theta1= (float)sin(theta1);
+ for (i = nrings - 1; i >= 0; i--) {
+ theta1 = theta + ring_delta;
+ cos_theta1 = (float)cos(theta1);
+ sin_theta1 = (float)sin(theta1);
- if (do_caps && i==start) { // cap
+ if (do_caps && i == start) { // cap
glBegin(GL_POLYGON);
- phi= 0.0;
- for (j= nsides; j >= 0; j--) {
+ phi = 0.0;
+ for (j = nsides; j >= 0; j--) {
float cos_phi, sin_phi, dist;
phi += side_delta;
- cos_phi= (float)cos(phi);
- sin_phi= (float)sin(phi);
- dist= radhole + radring * cos_phi;
+ cos_phi = (float)cos(phi);
+ sin_phi = (float)sin(phi);
+ dist = radhole + radring * cos_phi;
glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
}
glEnd();
}
- if (i>=start && i<=end) {
+ if (i >= start && i <= end) {
glBegin(GL_QUAD_STRIP);
- phi= 0.0;
- for (j= nsides; j >= 0; j--) {
+ phi = 0.0;
+ for (j = nsides; j >= 0; j--) {
float cos_phi, sin_phi, dist;
phi += side_delta;
- cos_phi= (float)cos(phi);
- sin_phi= (float)sin(phi);
- dist= radhole + radring * cos_phi;
+ cos_phi = (float)cos(phi);
+ sin_phi = (float)sin(phi);
+ dist = radhole + radring * cos_phi;
glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
@@ -710,16 +710,16 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
glEnd();
}
- if (do_caps && i==end) { // cap
+ if (do_caps && i == end) { // cap
glBegin(GL_POLYGON);
- phi= 0.0;
- for (j= nsides; j >= 0; j--) {
+ phi = 0.0;
+ for (j = nsides; j >= 0; j--) {
float cos_phi, sin_phi, dist;
phi -= side_delta;
- cos_phi= (float)cos(phi);
- sin_phi= (float)sin(phi);
- dist= radhole + radring * cos_phi;
+ cos_phi = (float)cos(phi);
+ sin_phi = (float)sin(phi);
+ dist = radhole + radring * cos_phi;
glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
}
@@ -727,9 +727,9 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
}
- theta= theta1;
- cos_theta= cos_theta1;
- sin_theta= sin_theta1;
+ theta = theta1;
+ cos_theta = cos_theta1;
+ sin_theta = sin_theta1;
}
}
@@ -751,43 +751,43 @@ static char axisBlendAngle(float angle)
*/
static void manipulator_setcolor(View3D *v3d, char axis, int colcode, unsigned char alpha)
{
- unsigned char col[4]= {0};
- col[3]= alpha;
+ unsigned char col[4] = {0};
+ col[3] = alpha;
- if (colcode==MAN_GHOST) {
- col[3]= 70;
+ if (colcode == MAN_GHOST) {
+ col[3] = 70;
}
- else if (colcode==MAN_MOVECOL) {
+ else if (colcode == MAN_MOVECOL) {
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
}
else {
switch (axis) {
- case 'C':
- UI_GetThemeColor3ubv(TH_TRANSFORM, col);
- if (v3d->twmode == V3D_MANIP_LOCAL) {
- col[0]= col[0]>200?255:col[0]+55;
- col[1]= col[1]>200?255:col[1]+55;
- col[2]= col[2]>200?255:col[2]+55;
- }
- else if (v3d->twmode == V3D_MANIP_NORMAL) {
- col[0]= col[0]<55?0:col[0]-55;
- col[1]= col[1]<55?0:col[1]-55;
- col[2]= col[2]<55?0:col[2]-55;
- }
- break;
- case 'X':
- col[0]= 220;
- break;
- case 'Y':
- col[1]= 220;
- break;
- case 'Z':
- col[0]= 30;
- col[1]= 30;
- col[2]= 220;
- break;
- default:
- BLI_assert(!"invalid axis arg");
+ case 'C':
+ UI_GetThemeColor3ubv(TH_TRANSFORM, col);
+ if (v3d->twmode == V3D_MANIP_LOCAL) {
+ col[0] = col[0] > 200 ? 255 : col[0] + 55;
+ col[1] = col[1] > 200 ? 255 : col[1] + 55;
+ col[2] = col[2] > 200 ? 255 : col[2] + 55;
+ }
+ else if (v3d->twmode == V3D_MANIP_NORMAL) {
+ col[0] = col[0] < 55 ? 0 : col[0] - 55;
+ col[1] = col[1] < 55 ? 0 : col[1] - 55;
+ col[2] = col[2] < 55 ? 0 : col[2] - 55;
+ }
+ break;
+ case 'X':
+ col[0] = 220;
+ break;
+ case 'Y':
+ col[1] = 220;
+ break;
+ case 'Z':
+ col[0] = 30;
+ col[1] = 30;
+ col[2] = 220;
+ break;
+ default:
+ BLI_assert(!"invalid axis arg");
}
}
@@ -836,7 +836,7 @@ static void preOrthoFront(int ortho, float twmat[][4], int axis)
orthogonalize_m4(omat, axis);
glPushMatrix();
glMultMatrixf(omat);
- glFrontFace(is_negative_m4(omat) ? GL_CW:GL_CCW);
+ glFrontFace(is_negative_m4(omat) ? GL_CW : GL_CCW);
}
}
@@ -853,42 +853,42 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
double plane[4];
float matt[4][4];
float size, unitmat[4][4];
- float cywid= 0.33f*0.01f*(float)U.tw_handlesize;
- float cusize= cywid*0.65f;
- int arcs= (G.rt!=2);
+ float cywid = 0.33f * 0.01f * (float)U.tw_handlesize;
+ float cusize = cywid * 0.65f;
+ int arcs = (G.rt != 2);
int colcode;
int ortho;
- if (moving) colcode= MAN_MOVECOL;
- else colcode= MAN_RGB;
+ if (moving) colcode = MAN_MOVECOL;
+ else colcode = MAN_RGB;
/* when called while moving in mixed mode, do not draw when... */
- if ((drawflags & MAN_ROT_C)==0) return;
+ if ((drawflags & MAN_ROT_C) == 0) return;
/* Init stuff */
glDisable(GL_DEPTH_TEST);
unit_m4(unitmat);
- qobj= gluNewQuadric();
+ qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL);
/* prepare for screen aligned draw */
- size= len_v3(rv3d->twmat[0]);
+ size = len_v3(rv3d->twmat[0]);
glPushMatrix();
glTranslatef(rv3d->twmat[3][0], rv3d->twmat[3][1], rv3d->twmat[3][2]);
if (arcs) {
/* clipplane makes nice handles, calc here because of multmatrix but with translate! */
copy_v3db_v3fl(plane, rv3d->viewinv[2]);
- plane[3]= -0.02f*size; // clip just a bit more
+ plane[3] = -0.02f * size; // clip just a bit more
glClipPlane(GL_CLIP_PLANE0, plane);
}
/* sets view screen aligned */
- glRotatef(-360.0f*saacos(rv3d->viewquat[0])/(float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]);
+ glRotatef(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]);
/* Screen aligned help circle */
if (arcs) {
- if ((G.f & G_PICKSEL)==0) {
+ if ((G.f & G_PICKSEL) == 0) {
UI_ThemeColorShade(TH_BACK, -30);
drawcircball(GL_LINE_LOOP, unitmat[3], size, unitmat);
}
@@ -899,22 +899,22 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if (G.f & G_PICKSEL) glLoadName(MAN_ROT_T);
UI_ThemeColor(TH_TRANSFORM);
- drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat);
+ drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
}
/* Screen aligned view rot circle */
if (drawflags & MAN_ROT_V) {
if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V);
UI_ThemeColor(TH_TRANSFORM);
- drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f*size, unitmat);
+ drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat);
if (moving) {
float vec[3];
- vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]);
- vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]);
- vec[2]= 0.0f;
+ vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]);
+ vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]);
+ vec[2] = 0.0f;
normalize_v3(vec);
- mul_v3_fl(vec, 1.2f*size);
+ mul_v3_fl(vec, 1.2f * size);
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3fv(vec);
@@ -932,22 +932,22 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
// XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
if (ortho) {
glMultMatrixf(matt);
- glFrontFace(is_negative_m4(matt) ? GL_CW:GL_CCW);
+ glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW);
}
}
else {
if (ortho) {
- glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW);
+ glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW);
glMultMatrixf(rv3d->twmat);
}
}
/* axes */
- if (arcs==0) {
+ if (arcs == 0) {
if (!(G.f & G_PICKSEL)) {
- if ( (combo & V3D_MANIP_SCALE)==0) {
+ if ((combo & V3D_MANIP_SCALE) == 0) {
/* axis */
- if ( (drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z)) ) {
+ if ((drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z))) {
preOrthoFront(ortho, rv3d->twmat, 2);
manipulator_setcolor(v3d, 'X', colcode, 255);
glBegin(GL_LINES);
@@ -956,7 +956,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glEnd();
postOrtho(ortho);
}
- if ( (drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X)) ) {
+ if ((drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X))) {
preOrthoFront(ortho, rv3d->twmat, 0);
manipulator_setcolor(v3d, 'Y', colcode, 255);
glBegin(GL_LINES);
@@ -965,7 +965,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glEnd();
postOrtho(ortho);
}
- if ( (drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y)) ) {
+ if ((drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y))) {
preOrthoFront(ortho, rv3d->twmat, 1);
manipulator_setcolor(v3d, 'Z', colcode, 255);
glBegin(GL_LINES);
@@ -978,7 +978,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
}
}
- if (arcs==0 && moving) {
+ if (arcs == 0 && moving) {
/* Z circle */
if (drawflags & MAN_ROT_Z) {
@@ -1020,7 +1020,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
preOrthoFront(ortho, rv3d->twmat, 2);
if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
manipulator_setcolor(v3d, 'Z', colcode, 255);
- partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48);
+ partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
postOrtho(ortho);
}
/* X circle */
@@ -1029,7 +1029,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
glRotatef(90.0, 0.0, 1.0, 0.0);
manipulator_setcolor(v3d, 'X', colcode, 255);
- partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48);
+ partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
glRotatef(-90.0, 0.0, 1.0, 0.0);
postOrtho(ortho);
}
@@ -1039,7 +1039,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
glRotatef(-90.0, 1.0, 0.0, 0.0);
manipulator_setcolor(v3d, 'Y', colcode, 255);
- partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48);
+ partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
glRotatef(90.0, 1.0, 0.0, 0.0);
postOrtho(ortho);
}
@@ -1047,7 +1047,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glDisable(GL_CLIP_PLANE0);
}
- if (arcs==0) {
+ if (arcs == 0) {
/* Z handle on X axis */
if (drawflags & MAN_ROT_Z) {
@@ -1056,7 +1056,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
manipulator_setcolor(v3d, 'Z', colcode, 255);
- partial_doughnut(0.7f*cusize, 1.0f, 31, 33, 8, 64);
+ partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
glPopMatrix();
postOrtho(ortho);
@@ -1071,7 +1071,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glRotatef(90.0, 1.0, 0.0, 0.0);
glRotatef(90.0, 0.0, 0.0, 1.0);
- partial_doughnut(0.7f*cusize, 1.0f, 31, 33, 8, 64);
+ partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
glPopMatrix();
postOrtho(ortho);
@@ -1086,7 +1086,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glRotatef(-90.0, 0.0, 1.0, 0.0);
glRotatef(90.0, 0.0, 0.0, 1.0);
- partial_doughnut(0.7f*cusize, 1.0f, 31, 33, 8, 64);
+ partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
glPopMatrix();
postOrtho(ortho);
@@ -1104,56 +1104,57 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
static void drawsolidcube(float size)
{
static float cube[8][3] = {
- {-1.0, -1.0, -1.0},
- {-1.0, -1.0, 1.0},
- {-1.0, 1.0, 1.0},
- {-1.0, 1.0, -1.0},
- { 1.0, -1.0, -1.0},
- { 1.0, -1.0, 1.0},
- { 1.0, 1.0, 1.0},
- { 1.0, 1.0, -1.0}, };
+ {-1.0, -1.0, -1.0},
+ {-1.0, -1.0, 1.0},
+ {-1.0, 1.0, 1.0},
+ {-1.0, 1.0, -1.0},
+ { 1.0, -1.0, -1.0},
+ { 1.0, -1.0, 1.0},
+ { 1.0, 1.0, 1.0},
+ { 1.0, 1.0, -1.0},
+ };
float n[3] = {0.0f};
glPushMatrix();
glScalef(size, size, size);
glBegin(GL_QUADS);
- n[0]= -1.0;
+ n[0] = -1.0;
glNormal3fv(n);
glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
- n[0]=0;
+ n[0] = 0;
glEnd();
glBegin(GL_QUADS);
- n[1]= -1.0;
+ n[1] = -1.0;
glNormal3fv(n);
glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]);
- n[1]=0;
+ n[1] = 0;
glEnd();
glBegin(GL_QUADS);
- n[0]= 1.0;
+ n[0] = 1.0;
glNormal3fv(n);
glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]);
- n[0]=0;
+ n[0] = 0;
glEnd();
glBegin(GL_QUADS);
- n[1]= 1.0;
+ n[1] = 1.0;
glNormal3fv(n);
glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]);
- n[1]=0;
+ n[1] = 0;
glEnd();
glBegin(GL_QUADS);
- n[2]= 1.0;
+ n[2] = 1.0;
glNormal3fv(n);
glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]);
- n[2]=0;
+ n[2] = 0;
glEnd();
glBegin(GL_QUADS);
- n[2]= -1.0;
+ n[2] = -1.0;
glNormal3fv(n);
glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]);
glEnd();
@@ -1164,32 +1165,32 @@ static void drawsolidcube(float size)
static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
{
- float cywid= 0.25f*0.01f*(float)U.tw_handlesize;
- float cusize= cywid*0.75f, dz;
+ float cywid = 0.25f * 0.01f * (float)U.tw_handlesize;
+ float cusize = cywid * 0.75f, dz;
/* when called while moving in mixed mode, do not draw when... */
- if ((drawflags & MAN_SCALE_C)==0) return;
+ if ((drawflags & MAN_SCALE_C) == 0) return;
glDisable(GL_DEPTH_TEST);
/* not in combo mode */
- if ( (combo & (V3D_MANIP_TRANSLATE|V3D_MANIP_ROTATE))==0) {
+ if ((combo & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) == 0) {
float size, unitmat[4][4];
- int shift= 0; // XXX
+ int shift = 0; // XXX
/* center circle, do not add to selection when shift is pressed (planar constraint) */
- if ( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_SCALE_C);
+ if ((G.f & G_PICKSEL) && shift == 0) glLoadName(MAN_SCALE_C);
manipulator_setcolor(v3d, 'C', colcode, 255);
glPushMatrix();
- size= screen_aligned(rv3d, rv3d->twmat);
+ size = screen_aligned(rv3d, rv3d->twmat);
unit_m4(unitmat);
- drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat);
+ drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
glPopMatrix();
- dz= 1.0;
+ dz = 1.0;
}
- else dz= 1.0f-4.0f*cusize;
+ else dz = 1.0f - 4.0f * cusize;
if (moving) {
float matt[4][4];
@@ -1197,11 +1198,11 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
// XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
glMultMatrixf(matt);
- glFrontFace(is_negative_m4(matt) ? GL_CW:GL_CCW);
+ glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW);
}
else {
glMultMatrixf(rv3d->twmat);
- glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW);
+ glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW);
}
/* axis */
@@ -1233,7 +1234,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
/* if shiftkey, center point as last, for selectbuffer order */
if (G.f & G_PICKSEL) {
- int shift= 0; // XXX
+ int shift = 0; // XXX
if (shift) {
glTranslatef(0.0, -dz, 0.0);
@@ -1254,55 +1255,55 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
static void draw_cone(GLUquadricObj *qobj, float len, float width)
{
- glTranslatef(0.0, 0.0, -0.5f*len);
+ glTranslatef(0.0, 0.0, -0.5f * len);
gluCylinder(qobj, width, 0.0, len, 8, 1);
gluQuadricOrientation(qobj, GLU_INSIDE);
gluDisk(qobj, 0.0, width, 8, 1);
gluQuadricOrientation(qobj, GLU_OUTSIDE);
- glTranslatef(0.0, 0.0, 0.5f*len);
+ glTranslatef(0.0, 0.0, 0.5f * len);
}
static void draw_cylinder(GLUquadricObj *qobj, float len, float width)
{
- width*= 0.8f; // just for beauty
+ width *= 0.8f; // just for beauty
- glTranslatef(0.0, 0.0, -0.5f*len);
+ glTranslatef(0.0, 0.0, -0.5f * len);
gluCylinder(qobj, width, width, len, 8, 1);
gluQuadricOrientation(qobj, GLU_INSIDE);
gluDisk(qobj, 0.0, width, 8, 1);
gluQuadricOrientation(qobj, GLU_OUTSIDE);
glTranslatef(0.0, 0.0, len);
gluDisk(qobj, 0.0, width, 8, 1);
- glTranslatef(0.0, 0.0, -0.5f*len);
+ glTranslatef(0.0, 0.0, -0.5f * len);
}
static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUSED(moving), int drawflags, int combo, int colcode)
{
GLUquadricObj *qobj;
- float cylen= 0.01f*(float)U.tw_handlesize;
- float cywid= 0.25f*cylen, dz, size;
+ float cylen = 0.01f * (float)U.tw_handlesize;
+ float cywid = 0.25f * cylen, dz, size;
float unitmat[4][4];
- int shift= 0; // XXX
+ int shift = 0; // XXX
/* when called while moving in mixed mode, do not draw when... */
- if ((drawflags & MAN_TRANS_C)==0) return;
+ if ((drawflags & MAN_TRANS_C) == 0) return;
// XXX if (moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]);
glDisable(GL_DEPTH_TEST);
- qobj= gluNewQuadric();
+ qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL);
/* center circle, do not add to selection when shift is pressed (planar constraint) */
- if ( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_TRANS_C);
+ if ((G.f & G_PICKSEL) && shift == 0) glLoadName(MAN_TRANS_C);
manipulator_setcolor(v3d, 'C', colcode, 255);
glPushMatrix();
- size= screen_aligned(rv3d, rv3d->twmat);
+ size = screen_aligned(rv3d, rv3d->twmat);
unit_m4(unitmat);
- drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat);
+ drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
glPopMatrix();
/* and now apply matrix, we move to local matrix drawing */
@@ -1312,14 +1313,14 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS
glLoadName(-1);
// translate drawn as last, only axis when no combo with scale, or for ghosting
- if ((combo & V3D_MANIP_SCALE)==0 || colcode==MAN_GHOST)
+ if ((combo & V3D_MANIP_SCALE) == 0 || colcode == MAN_GHOST)
draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_TRANS_X, drawflags & MAN_TRANS_Y, drawflags & MAN_TRANS_Z);
/* offset in combo mode, for rotate a bit more */
- if (combo & (V3D_MANIP_ROTATE)) dz= 1.0f+2.0f*cylen;
- else if (combo & (V3D_MANIP_SCALE)) dz= 1.0f+0.5f*cylen;
- else dz= 1.0f;
+ if (combo & (V3D_MANIP_ROTATE)) dz = 1.0f + 2.0f * cylen;
+ else if (combo & (V3D_MANIP_SCALE)) dz = 1.0f + 0.5f * cylen;
+ else dz = 1.0f;
/* Z Cone */
glTranslatef(0.0, 0.0, dz);
@@ -1357,35 +1358,35 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
{
GLUquadricObj *qobj;
float size;
- float cylen= 0.01f*(float)U.tw_handlesize;
- float cywid= 0.25f*cylen;
+ float cylen = 0.01f * (float)U.tw_handlesize;
+ float cywid = 0.25f * cylen;
/* when called while moving in mixed mode, do not draw when... */
- if ((drawflags & MAN_ROT_C)==0) return;
+ if ((drawflags & MAN_ROT_C) == 0) return;
/* prepare for screen aligned draw */
glPushMatrix();
- size= screen_aligned(rv3d, rv3d->twmat);
+ size = screen_aligned(rv3d, rv3d->twmat);
glDisable(GL_DEPTH_TEST);
- qobj= gluNewQuadric();
+ qobj = gluNewQuadric();
/* Screen aligned view rot circle */
if (drawflags & MAN_ROT_V) {
- float unitmat[4][4]= MAT4_UNITY;
+ float unitmat[4][4] = MAT4_UNITY;
if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V);
UI_ThemeColor(TH_TRANSFORM);
- drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f*size, unitmat);
+ drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat);
if (moving) {
float vec[3];
- vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]);
- vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]);
- vec[2]= 0.0f;
+ vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]);
+ vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]);
+ vec[2] = 0.0f;
normalize_v3(vec);
- mul_v3_fl(vec, 1.2f*size);
+ mul_v3_fl(vec, 1.2f * size);
glBegin(GL_LINES);
glVertex3f(0.0, 0.0, 0.0);
glVertex3fv(vec);
@@ -1398,8 +1399,8 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
if (moving) {
float matt[4][4];
copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
- // XXX if (t->flag & T_USES_MANIPULATOR) {
- // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
+ // XXX if (t->flag & T_USES_MANIPULATOR) {
+ // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
// XXX }
glMultMatrixf(matt);
}
@@ -1407,13 +1408,13 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
glMultMatrixf(rv3d->twmat);
}
- glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW);
+ glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW);
/* axis */
- if ( (G.f & G_PICKSEL)==0 ) {
+ if ((G.f & G_PICKSEL) == 0) {
// only draw axis when combo didn't draw scale axes
- if ((combo & V3D_MANIP_SCALE)==0)
+ if ((combo & V3D_MANIP_SCALE) == 0)
draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_ROT_X, drawflags & MAN_ROT_Y, drawflags & MAN_ROT_Z);
/* only has to be set when not in picking */
@@ -1459,15 +1460,15 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
/* main call, does calc centers & orientation too */
/* uses global G.moving */
-static int drawflags= 0xFFFF; // only for the calls below, belongs in scene...?
+static int drawflags = 0xFFFF; // only for the calls below, belongs in scene...?
void BIF_draw_manipulator(const bContext *C)
{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= CTX_wm_region(C);
- Scene *scene= CTX_data_scene(C);
- View3D *v3d= sa->spacedata.first;
- RegionView3D *rv3d= ar->regiondata;
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = sa->spacedata.first;
+ RegionView3D *rv3d = ar->regiondata;
int totsel;
if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return;
@@ -1477,38 +1478,38 @@ void BIF_draw_manipulator(const bContext *C)
{
v3d->twflag &= ~V3D_DRAW_MANIPULATOR;
- totsel= calc_manipulator_stats(C);
- if (totsel==0) return;
+ totsel = calc_manipulator_stats(C);
+ if (totsel == 0) return;
v3d->twflag |= V3D_DRAW_MANIPULATOR;
/* now we can define center */
switch (v3d->around) {
- case V3D_CENTER:
- case V3D_ACTIVE:
- rv3d->twmat[3][0]= (scene->twmin[0] + scene->twmax[0])/2.0f;
- rv3d->twmat[3][1]= (scene->twmin[1] + scene->twmax[1])/2.0f;
- rv3d->twmat[3][2]= (scene->twmin[2] + scene->twmax[2])/2.0f;
- if (v3d->around==V3D_ACTIVE && scene->obedit==NULL) {
- Object *ob= OBACT;
- if (ob && !(ob->mode & OB_MODE_POSE))
- copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
- }
- break;
- case V3D_LOCAL:
- case V3D_CENTROID:
- copy_v3_v3(rv3d->twmat[3], scene->twcent);
- break;
- case V3D_CURSOR:
- copy_v3_v3(rv3d->twmat[3], give_cursor(scene, v3d));
- break;
+ case V3D_CENTER:
+ case V3D_ACTIVE:
+ rv3d->twmat[3][0] = (scene->twmin[0] + scene->twmax[0]) / 2.0f;
+ rv3d->twmat[3][1] = (scene->twmin[1] + scene->twmax[1]) / 2.0f;
+ rv3d->twmat[3][2] = (scene->twmin[2] + scene->twmax[2]) / 2.0f;
+ if (v3d->around == V3D_ACTIVE && scene->obedit == NULL) {
+ Object *ob = OBACT;
+ if (ob && !(ob->mode & OB_MODE_POSE))
+ copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
+ }
+ break;
+ case V3D_LOCAL:
+ case V3D_CENTROID:
+ copy_v3_v3(rv3d->twmat[3], scene->twcent);
+ break;
+ case V3D_CURSOR:
+ copy_v3_v3(rv3d->twmat[3], give_cursor(scene, v3d));
+ break;
}
mul_mat3_m4_fl(rv3d->twmat, ED_view3d_pixel_size(rv3d, rv3d->twmat[3]) * U.tw_size * 5.0f);
}
test_manipulator_axis(C);
- drawflags= rv3d->twdrawflag; /* set in calc_manipulator_stats */
+ drawflags = rv3d->twdrawflag; /* set in calc_manipulator_stats */
if (v3d->twflag & V3D_DRAW_MANIPULATOR) {
@@ -1516,7 +1517,7 @@ void BIF_draw_manipulator(const bContext *C)
glEnable(GL_BLEND);
if (v3d->twtype & V3D_MANIP_ROTATE) {
- if (G.rt==3) {
+ if (G.rt == 3) {
if (G.moving) draw_manipulator_rotate_cyl(v3d, rv3d, 1, drawflags, v3d->twtype, MAN_MOVECOL);
else draw_manipulator_rotate_cyl(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB);
}
@@ -1536,31 +1537,31 @@ void BIF_draw_manipulator(const bContext *C)
static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot)
{
- View3D *v3d= sa->spacedata.first;
- RegionView3D *rv3d= ar->regiondata;
+ View3D *v3d = sa->spacedata.first;
+ RegionView3D *rv3d = ar->regiondata;
rctf rect;
- GLuint buffer[64]; // max 4 items per select, so large enuf
+ GLuint buffer[64]; // max 4 items per select, so large enuf
short hits;
extern void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); // XXX check a bit later on this... (ton)
G.f |= G_PICKSEL;
- rect.xmin = mval[0]-hotspot;
- rect.xmax = mval[0]+hotspot;
- rect.ymin = mval[1]-hotspot;
- rect.ymax = mval[1]+hotspot;
+ rect.xmin = mval[0] - hotspot;
+ rect.xmax = mval[0] + hotspot;
+ rect.ymin = mval[1] - hotspot;
+ rect.ymax = mval[1] + hotspot;
setwinmatrixview3d(ar, v3d, &rect);
mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
glSelectBuffer(64, buffer);
glRenderMode(GL_SELECT);
- glInitNames(); /* these two calls whatfor? It doesnt work otherwise */
+ glInitNames(); /* these two calls whatfor? It doesnt work otherwise */
glPushName(-2);
/* do the drawing */
if (v3d->twtype & V3D_MANIP_ROTATE) {
- if (G.rt==3) draw_manipulator_rotate_cyl(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB);
+ if (G.rt == 3) draw_manipulator_rotate_cyl(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB);
else draw_manipulator_rotate(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype);
}
if (v3d->twtype & V3D_MANIP_SCALE)
@@ -1569,37 +1570,37 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
draw_manipulator_translate(v3d, rv3d, 0, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB);
glPopName();
- hits= glRenderMode(GL_RENDER);
+ hits = glRenderMode(GL_RENDER);
G.f &= ~G_PICKSEL;
setwinmatrixview3d(ar, v3d, NULL);
mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
- if (hits==1) return buffer[3];
- else if (hits>1) {
- GLuint val, dep, mindep=0, mindeprot=0, minval=0, minvalrot=0;
+ if (hits == 1) return buffer[3];
+ else if (hits > 1) {
+ GLuint val, dep, mindep = 0, mindeprot = 0, minval = 0, minvalrot = 0;
int a;
/* we compare the hits in buffer, but value centers highest */
/* we also store the rotation hits separate (because of arcs) and return hits on other widgets if there are */
- for (a=0; a<hits; a++) {
- dep= buffer[4*a + 1];
- val= buffer[4*a + 3];
+ for (a = 0; a < hits; a++) {
+ dep = buffer[4 * a + 1];
+ val = buffer[4 * a + 3];
- if (val==MAN_TRANS_C) return MAN_TRANS_C;
- else if (val==MAN_SCALE_C) return MAN_SCALE_C;
+ if (val == MAN_TRANS_C) return MAN_TRANS_C;
+ else if (val == MAN_SCALE_C) return MAN_SCALE_C;
else {
if (val & MAN_ROT_C) {
- if (minvalrot==0 || dep<mindeprot) {
- mindeprot= dep;
- minvalrot= val;
+ if (minvalrot == 0 || dep < mindeprot) {
+ mindeprot = dep;
+ minvalrot = val;
}
}
else {
- if (minval==0 || dep<mindep) {
- mindep= dep;
- minval= val;
+ if (minval == 0 || dep < mindep) {
+ mindep = dep;
+ minval = val;
}
}
}
@@ -1617,9 +1618,9 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
/* return 0; nothing happened */
int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
{
- ScrArea *sa= CTX_wm_area(C);
- View3D *v3d= sa->spacedata.first;
- ARegion *ar= CTX_wm_region(C);
+ ScrArea *sa = CTX_wm_area(C);
+ View3D *v3d = sa->spacedata.first;
+ ARegion *ar = CTX_wm_region(C);
int constraint_axis[3] = {0, 0, 0};
int val;
int shift = event->shift;
@@ -1631,41 +1632,41 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
RNA_enum_set(op->ptr, "constraint_orientation", v3d->twmode);
// find the hotspots first test narrow hotspot
- val= manipulator_selectbuf(sa, ar, event->mval, 0.5f*(float)U.tw_hotspot);
+ val = manipulator_selectbuf(sa, ar, event->mval, 0.5f * (float)U.tw_hotspot);
if (val) {
// drawflags still global, for drawing call above
- drawflags= manipulator_selectbuf(sa, ar, event->mval, 0.2f*(float)U.tw_hotspot);
- if (drawflags==0) drawflags= val;
+ drawflags = manipulator_selectbuf(sa, ar, event->mval, 0.2f * (float)U.tw_hotspot);
+ if (drawflags == 0) drawflags = val;
if (drawflags & MAN_TRANS_C) {
switch (drawflags) {
- case MAN_TRANS_C:
- break;
- case MAN_TRANS_X:
- if (shift) {
- constraint_axis[1] = 1;
- constraint_axis[2] = 1;
- }
- else
- constraint_axis[0] = 1;
- break;
- case MAN_TRANS_Y:
- if (shift) {
- constraint_axis[0] = 1;
- constraint_axis[2] = 1;
- }
- else
- constraint_axis[1] = 1;
- break;
- case MAN_TRANS_Z:
- if (shift) {
- constraint_axis[0] = 1;
- constraint_axis[1] = 1;
- }
- else
- constraint_axis[2] = 1;
- break;
+ case MAN_TRANS_C:
+ break;
+ case MAN_TRANS_X:
+ if (shift) {
+ constraint_axis[1] = 1;
+ constraint_axis[2] = 1;
+ }
+ else
+ constraint_axis[0] = 1;
+ break;
+ case MAN_TRANS_Y:
+ if (shift) {
+ constraint_axis[0] = 1;
+ constraint_axis[2] = 1;
+ }
+ else
+ constraint_axis[1] = 1;
+ break;
+ case MAN_TRANS_Z:
+ if (shift) {
+ constraint_axis[0] = 1;
+ constraint_axis[1] = 1;
+ }
+ else
+ constraint_axis[2] = 1;
+ break;
}
RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr);
@@ -1673,30 +1674,30 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
}
else if (drawflags & MAN_SCALE_C) {
switch (drawflags) {
- case MAN_SCALE_X:
- if (shift) {
- constraint_axis[1] = 1;
- constraint_axis[2] = 1;
- }
- else
- constraint_axis[0] = 1;
- break;
- case MAN_SCALE_Y:
- if (shift) {
- constraint_axis[0] = 1;
- constraint_axis[2] = 1;
- }
- else
- constraint_axis[1] = 1;
- break;
- case MAN_SCALE_Z:
- if (shift) {
- constraint_axis[0] = 1;
- constraint_axis[1] = 1;
- }
- else
- constraint_axis[2] = 1;
- break;
+ case MAN_SCALE_X:
+ if (shift) {
+ constraint_axis[1] = 1;
+ constraint_axis[2] = 1;
+ }
+ else
+ constraint_axis[0] = 1;
+ break;
+ case MAN_SCALE_Y:
+ if (shift) {
+ constraint_axis[0] = 1;
+ constraint_axis[2] = 1;
+ }
+ else
+ constraint_axis[1] = 1;
+ break;
+ case MAN_SCALE_Z:
+ if (shift) {
+ constraint_axis[0] = 1;
+ constraint_axis[1] = 1;
+ }
+ else
+ constraint_axis[2] = 1;
+ break;
}
RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr);
@@ -1708,15 +1709,15 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
}
else if (drawflags & MAN_ROT_C) {
switch (drawflags) {
- case MAN_ROT_X:
- constraint_axis[0] = 1;
- break;
- case MAN_ROT_Y:
- constraint_axis[1] = 1;
- break;
- case MAN_ROT_Z:
- constraint_axis[2] = 1;
- break;
+ case MAN_ROT_X:
+ constraint_axis[0] = 1;
+ break;
+ case MAN_ROT_Y:
+ constraint_axis[1] = 1;
+ break;
+ case MAN_ROT_Z:
+ constraint_axis[2] = 1;
+ break;
}
RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
WM_operator_name_call(C, "TRANSFORM_OT_rotate", WM_OP_INVOKE_DEFAULT, op->ptr);
@@ -1724,7 +1725,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
}
}
/* after transform, restore drawflags */
- drawflags= 0xFFFF;
+ drawflags = 0xFFFF;
return val;
}
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 52b32ae66fc..81a4c082dcc 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -40,6 +40,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_armature.h"
+#include "BKE_report.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -53,8 +54,8 @@
typedef struct TransformModeItem {
char *idname;
- int mode;
- void (*opfunc)(wmOperatorType*);
+ int mode;
+ void (*opfunc)(wmOperatorType *);
} TransformModeItem;
static float VecOne[3] = {1, 1, 1};
@@ -151,11 +152,11 @@ EnumPropertyItem transform_mode_types[] =
static int snap_type_exec(bContext *C, wmOperator *op)
{
- ToolSettings *ts= CTX_data_tool_settings(C);
+ ToolSettings *ts = CTX_data_tool_settings(C);
ts->snap_mode = RNA_enum_get(op->ptr, "type");
- WM_event_add_notifier(C, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */
+ WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
return OPERATOR_FINISHED;
}
@@ -187,7 +188,7 @@ static int select_orientation_exec(bContext *C, wmOperator *op)
BIF_selectTransformOrientationValue(C, orientation);
- WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
return OPERATOR_FINISHED;
}
@@ -197,8 +198,8 @@ static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), wmEven
uiPopupMenu *pup;
uiLayout *layout;
- pup= uiPupMenuBegin(C, "Orientation", ICON_NONE);
- layout= uiPupMenuLayout(pup);
+ pup = uiPupMenuBegin(C, "Orientation", ICON_NONE);
+ layout = uiPupMenuLayout(pup);
uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation");
uiPupMenuEnd(C, pup);
@@ -220,7 +221,7 @@ static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot)
ot->exec = select_orientation_exec;
ot->poll = ED_operator_view3d_active;
- prop= RNA_def_property(ot->srna, "orientation", PROP_ENUM, PROP_NONE);
+ prop = RNA_def_property(ot->srna, "orientation", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
}
@@ -233,8 +234,8 @@ static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
BIF_removeTransformOrientationIndex(C, selected_index);
- WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
- WM_event_add_notifier(C, NC_SCENE|NA_EDITED, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+ WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -282,10 +283,15 @@ static int create_orientation_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
+ if (use && !CTX_wm_view3d(C)) {
+ BKE_report(op->reports, RPT_ERROR, "Create Orientation \"use\" parameter only valid in a 3dView context");
+ return OPERATOR_CANCELLED;
+ }
+
BIF_createTransformOrientation(C, op->reports, name, use, overwrite);
- WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
- WM_event_add_notifier(C, NC_SCENE|NA_EDITED, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+ WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -301,13 +307,13 @@ static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot)
ot->name = "Create Orientation";
ot->description = "Create transformation orientation from selection";
ot->idname = "TRANSFORM_OT_create_orientation";
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* api callbacks */
ot->invoke = create_orientation_invoke;
ot->exec = create_orientation_exec;
ot->poll = ED_operator_areaactive;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Text to insert at the cursor position");
RNA_def_boolean(ot->srna, "use", 0, "Use after creation", "Select orientation after its creation");
@@ -372,9 +378,9 @@ static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
#endif
/* XXX insert keys are called here, and require context */
- t->context= C;
+ t->context = C;
exit_code = transformEvent(t, event);
- t->context= NULL;
+ t->context = NULL;
transformApply(C, t);
@@ -418,7 +424,7 @@ static int transform_exec(bContext *C, wmOperator *op)
transformops_exit(C, op);
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
@@ -447,7 +453,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
PropertyRNA *prop;
if (flags & P_AXIS) {
- prop= RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
+ prop = RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_array(prop, 3);
/* Make this not hidden when there's a nice axis selection widget */
RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -457,7 +463,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
if (flags & P_CONSTRAINT) {
RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
- prop= RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE);
+ prop = RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
@@ -476,19 +482,19 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
if (flags & P_SNAP) {
- prop= RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
+ prop = RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
if (flags & P_GEO_SNAP) {
- prop= RNA_def_enum(ot->srna, "snap_target", snap_target_items, 0, "Target", "");
+ prop = RNA_def_enum(ot->srna, "snap_target", snap_target_items, 0, "Target", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
- prop= RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
+ prop = RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
if (flags & P_ALIGN_SNAP) {
- prop= RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
+ prop = RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
- prop= RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX);
+ prop = RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
}
}
@@ -513,7 +519,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
ot->name = "Translate";
ot->description = "Translate (move) selected items";
ot->idname = OP_TRANSLATION;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -524,7 +530,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_ALIGN_SNAP|P_OPTIONS);
+ Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS);
}
static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
@@ -533,7 +539,7 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
ot->name = "Resize";
ot->description = "Scale (resize) selected items";
ot->idname = OP_RESIZE;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -544,7 +550,7 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_GEO_SNAP|P_OPTIONS);
+ Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS);
}
static int skin_resize_poll(bContext *C)
@@ -563,7 +569,7 @@ static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)
ot->name = "Skin Resize";
ot->description = "Scale selected vertices' skin radii";
ot->idname = OP_SKIN_RESIZE;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -574,7 +580,7 @@ static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)
RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_GEO_SNAP|P_OPTIONS);
+ Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS);
}
static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
@@ -583,7 +589,7 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
ot->name = "Trackball";
ot->description = "Trackball style rotation of selected items";
ot->idname = OP_TRACKBALL;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -594,7 +600,7 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
@@ -603,7 +609,7 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
ot->name = "Rotate";
ot->description = "Rotate selected items";
ot->idname = OP_ROTATION;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -612,9 +618,9 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
- RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
+ RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
- Transform_Properties(ot, P_AXIS|P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_GEO_SNAP);
+ Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP);
}
static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
@@ -626,7 +632,7 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
* "Specify an extra axis rotation for selected vertices of 3d curve" */
ot->description = "Tilt selected control vertices of 3d curve";
ot->idname = OP_TILT;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -635,9 +641,9 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_editcurve_3d;
- RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
+ RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
- Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_SNAP);
+ Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
@@ -646,7 +652,7 @@ static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
ot->name = "Warp";
ot->description = "Warp selected items around the cursor";
ot->idname = OP_WARP;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -655,9 +661,9 @@ static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
- RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
+ RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
- Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
// XXX Warp axis?
}
@@ -667,7 +673,7 @@ static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
ot->name = "Shear";
ot->description = "Shear selected items along the horizontal screen axis";
ot->idname = OP_SHEAR;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -678,7 +684,7 @@ static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
// XXX Shear axis?
}
@@ -688,7 +694,7 @@ static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
ot->name = "Push/Pull";
ot->description = "Push/Pull selected items";
ot->idname = OP_PUSH_PULL;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -699,7 +705,7 @@ static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
@@ -708,7 +714,7 @@ static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
ot->name = "Shrink/Fatten";
ot->description = "Shrink/fatten selected vertices along normals";
ot->idname = OP_SHRINK_FATTEN;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -719,7 +725,7 @@ static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
@@ -729,7 +735,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
//added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()"
ot->description = "Move selected vertices outward in a spherical shape around mesh center";
ot->idname = OP_TOSPHERE;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -740,7 +746,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
- Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
@@ -749,7 +755,7 @@ static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
ot->name = "Mirror";
ot->description = "Mirror selected vertices around one or more axes";
ot->idname = OP_MIRROR;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -758,7 +764,7 @@ static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
- Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL);
+ Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL);
}
static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
@@ -767,7 +773,7 @@ static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
ot->name = "Edge Slide";
ot->description = "Slide an edge loop along a mesh";
ot->idname = OP_EDGE_SLIDE;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -778,7 +784,7 @@ static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
- Transform_Properties(ot, P_MIRROR|P_SNAP|P_CORRECT_UV);
+ Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV);
}
static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)
@@ -787,7 +793,7 @@ static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)
ot->name = "Edge Crease";
ot->description = "Change the crease of edges";
ot->idname = OP_EDGE_CREASE;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -807,7 +813,7 @@ static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot)
ot->name = "Edge Bevel Weight";
ot->description = "Change the bevel weight of edges";
ot->idname = OP_EDGE_BWEIGHT;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -827,7 +833,7 @@ static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
ot->name = "Sequence Slide";
ot->description = "Slide a sequence strip in time";
ot->idname = OP_SEQ_SLIDE;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -849,7 +855,7 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
ot->name = "Transform";
ot->description = "Transform selected items by mode type";
ot->idname = "TRANSFORM_OT_transform";
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
@@ -858,12 +864,12 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
- prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
+ prop = RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_AXIS|P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_ALIGN_SNAP);
+ Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP);
}
void transform_operatortypes(void)
@@ -913,13 +919,13 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac
WM_keymap_add_item(keymap, OP_WARP, WKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, OP_TOSPHERE, SKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, OP_TOSPHERE, SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
- WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT|KM_CTRL|KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
- kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+ kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "use", TRUE);
WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0);
@@ -927,12 +933,12 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
- WM_keymap_add_item(keymap, "TRANSFORM_OT_snap_type", TABKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "TRANSFORM_OT_snap_type", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "texture_space", TRUE);
- kmi = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
+ kmi = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "texture_space", TRUE);
WM_keymap_add_item(keymap, OP_SKIN_RESIZE, AKEY, KM_PRESS, KM_CTRL, 0);
@@ -1014,7 +1020,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac
WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT|KM_CTRL|KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index e4ba9b94ff7..97fc173f9a1 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -75,16 +75,16 @@ void BIF_clearTransformOrientation(bContext *C)
// Need to loop over all view3d
if (v3d && v3d->twmode >= V3D_MANIP_CUSTOM) {
- v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
+ v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
}
}
-static TransformOrientation* findOrientationName(ListBase *lb, const char *name)
+static TransformOrientation *findOrientationName(ListBase *lb, const char *name)
{
- TransformOrientation *ts= NULL;
+ TransformOrientation *ts = NULL;
- for (ts= lb->first; ts; ts = ts->next) {
- if (strncmp(ts->name, name, sizeof(ts->name)-1) == 0) {
+ for (ts = lb->first; ts; ts = ts->next) {
+ if (strncmp(ts->name, name, sizeof(ts->name) - 1) == 0) {
return ts;
}
}
@@ -115,7 +115,7 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, char *name
ts = createBoneSpace(C, reports, name, overwrite);
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- ts = createBoneSpace(C, reports, name, overwrite);
+ ts = createBoneSpace(C, reports, name, overwrite);
}
else {
ts = createObjectSpace(C, reports, name, overwrite);
@@ -143,7 +143,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports)
/* use object name if no name is given */
if (name[0] == 0) {
- strncpy(name, ob->id.name+2, MAX_ID_NAME-2);
+ strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2);
}
return addMatrixSpace(C, mat, name, overwrite);
@@ -262,7 +262,7 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
return 1;
}
-TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite)
+TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite)
{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts = NULL;
@@ -301,7 +301,7 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target)
// Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D
if (selected_index == i) {
- v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
+ v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
}
else if (selected_index > i) {
v3d->twmode--;
@@ -318,7 +318,7 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target)
void BIF_removeTransformOrientationIndex(bContext *C, int index)
{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
- TransformOrientation *ts= BLI_findlink(transform_spaces, index);
+ TransformOrientation *ts = BLI_findlink(transform_spaces, index);
if (ts) {
View3D *v3d = CTX_wm_view3d(C);
@@ -327,7 +327,7 @@ void BIF_removeTransformOrientationIndex(bContext *C, int index)
// Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D
if (selected_index == index) {
- v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
+ v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
}
else if (selected_index > index) {
v3d->twmode--;
@@ -365,15 +365,15 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
{
Scene *scene;
ListBase *transform_spaces;
- TransformOrientation *ts= NULL;
+ TransformOrientation *ts = NULL;
- EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""};
+ EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""};
EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""};
EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""};
EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""};
EnumPropertyItem tmp = {0, "", 0, "", ""};
- EnumPropertyItem *item= NULL;
- int i = V3D_MANIP_CUSTOM, totitem= 0;
+ EnumPropertyItem *item = NULL;
+ int i = V3D_MANIP_CUSTOM, totitem = 0;
RNA_enum_item_add(&item, &totitem, &global);
RNA_enum_item_add(&item, &totitem, &normal);
@@ -381,7 +381,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
RNA_enum_item_add(&item, &totitem, &view);
if (C) {
- scene= CTX_data_scene(C);
+ scene = CTX_data_scene(C);
if (scene) {
transform_spaces = &scene->transform_spaces;
@@ -394,7 +394,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
for (; ts; ts = ts->next) {
tmp.identifier = "CUSTOM";
- tmp.name= ts->name;
+ tmp.name = ts->name;
tmp.value = i++;
RNA_enum_item_add(&item, &totitem, &tmp);
}
@@ -404,9 +404,9 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
return item;
}
-const char * BIF_menustringTransformOrientation(const bContext *C, const char *title)
+const char *BIF_menustringTransformOrientation(const bContext *C, const char *title)
{
- const char* menu = IFACE_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3");
+ const char *menu = IFACE_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3");
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int i = V3D_MANIP_CUSTOM;
@@ -459,7 +459,7 @@ void applyTransformOrientation(const bContext *C, float mat[3][3], char *name)
break;
}
}
- }
+ }
}
static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
@@ -468,7 +468,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
int do_next;
int total = 0;
- for (bone= lb->first; bone; bone= bone->next) {
+ for (bone = lb->first; bone; bone = bone->next) {
bone->flag &= ~BONE_TRANSFORM;
do_next = do_it;
if (do_it) {
@@ -476,7 +476,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
if (bone->flag & BONE_SELECTED) {
bone->flag |= BONE_TRANSFORM;
total++;
- do_next = FALSE; // no transform on children if one parent bone is selected
+ do_next = FALSE; // no transform on children if one parent bone is selected
}
}
}
@@ -493,54 +493,55 @@ void initTransformOrientation(bContext *C, TransInfo *t)
Object *obedit = CTX_data_active_object(C);
switch (t->current_orientation) {
- case V3D_MANIP_GLOBAL:
- strcpy(t->spacename, "global");
- break;
-
- case V3D_MANIP_GIMBAL:
- unit_m3(t->spacemtx);
- if (gimbal_axis(ob, t->spacemtx)) {
- strcpy(t->spacename, "gimbal");
+ case V3D_MANIP_GLOBAL:
+ unit_m3(t->spacemtx);
+ strcpy(t->spacename, "global");
break;
- }
+
+ case V3D_MANIP_GIMBAL:
+ unit_m3(t->spacemtx);
+ if (gimbal_axis(ob, t->spacemtx)) {
+ strcpy(t->spacename, "gimbal");
+ break;
+ }
/* no gimbal fallthrough to normal */
- case V3D_MANIP_NORMAL:
- if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
- strcpy(t->spacename, "normal");
- ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE));
- break;
- }
+ case V3D_MANIP_NORMAL:
+ if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
+ strcpy(t->spacename, "normal");
+ ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE));
+ break;
+ }
/* no break we define 'normal' as 'local' in Object mode */
- case V3D_MANIP_LOCAL:
- strcpy(t->spacename, "local");
+ case V3D_MANIP_LOCAL:
+ strcpy(t->spacename, "local");
- if (ob) {
- copy_m3_m4(t->spacemtx, ob->obmat);
- normalize_m3(t->spacemtx);
- }
- else {
- unit_m3(t->spacemtx);
- }
+ if (ob) {
+ copy_m3_m4(t->spacemtx, ob->obmat);
+ normalize_m3(t->spacemtx);
+ }
+ else {
+ unit_m3(t->spacemtx);
+ }
- break;
+ break;
- case V3D_MANIP_VIEW:
- if (t->ar->regiontype == RGN_TYPE_WINDOW) {
- RegionView3D *rv3d = t->ar->regiondata;
- float mat[3][3];
-
- strcpy(t->spacename, "view");
- copy_m3_m4(mat, rv3d->viewinv);
- normalize_m3(mat);
- copy_m3_m3(t->spacemtx, mat);
- }
- else {
- unit_m3(t->spacemtx);
- }
- break;
- default: /* V3D_MANIP_CUSTOM */
- applyTransformOrientation(C, t->spacemtx, t->spacename);
- break;
+ case V3D_MANIP_VIEW:
+ if (t->ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = t->ar->regiondata;
+ float mat[3][3];
+
+ strcpy(t->spacename, "view");
+ copy_m3_m4(mat, rv3d->viewinv);
+ normalize_m3(mat);
+ copy_m3_m3(t->spacemtx, mat);
+ }
+ else {
+ unit_m3(t->spacemtx);
+ }
+ break;
+ default: /* V3D_MANIP_CUSTOM */
+ applyTransformOrientation(C, t->spacemtx, t->spacename);
+ break;
}
}
@@ -548,7 +549,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- Object *obedit= CTX_data_edit_object(C);
+ Object *obedit = CTX_data_edit_object(C);
Base *base;
Object *ob = OBACT;
int result = ORIENTATION_NONE;
@@ -565,14 +566,14 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
invert_m3_m3(mat, imat);
transpose_m3(mat);
- ob= obedit;
+ ob = obedit;
- if (ob->type==OB_MESH) {
- Mesh *me= ob->data;
+ if (ob->type == OB_MESH) {
+ Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
BMVert *eve;
BMEditSelection ese;
- float vec[3]= {0, 0, 0};
+ float vec[3] = {0, 0, 0};
/* USE LAST SELECTED WITH ACTIVE */
if (activeOnly && BM_select_history_active_get(em->bm, &ese)) {
@@ -710,17 +711,17 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
}
} /* end editmesh */
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
- Curve *cu= obedit->data;
+ Curve *cu = obedit->data;
Nurb *nu;
BezTriple *bezt;
int a;
- ListBase *nurbs= BKE_curve_editNurbs_get(cu);
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
for (nu = nurbs->first; nu; nu = nu->next) {
/* only bezier has a normal */
if (nu->type == CU_BEZIER) {
- bezt= nu->bezt;
- a= nu->pntsu;
+ bezt = nu->bezt;
+ a = nu->pntsu;
while (a--) {
/* exception */
if ((bezt->f1 & SELECT) + (bezt->f2 & SELECT) + (bezt->f3 & SELECT) > SELECT) {
@@ -746,7 +747,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
result = ORIENTATION_NORMAL;
}
}
- else if (obedit->type==OB_MBALL) {
+ else if (obedit->type == OB_MBALL) {
#if 0 // XXX
/* editmball.c */
MetaElem *ml, *ml_sel = NULL;
@@ -783,7 +784,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
bArmature *arm = obedit->data;
EditBone *ebone;
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_SELECTED) {
float tmat[3][3];
@@ -818,7 +819,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
bPoseChannel *pchan;
int totsel;
@@ -827,7 +828,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
float imat[3][3], mat[3][3];
/* use channels to get stats */
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
@@ -846,7 +847,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
result = ORIENTATION_EDGE;
}
}
- else if (ob && (ob->mode & (OB_MODE_ALL_PAINT|OB_MODE_PARTICLE_EDIT))) {
+ else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
/* pass */
}
else {
@@ -854,10 +855,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
ob = OBACT;
if (ob && !(ob->flag & SELECT)) ob = NULL;
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (TESTBASELIB(v3d, base)) {
if (ob == NULL) {
- ob= base->object;
+ ob = base->object;
break;
}
}
@@ -875,8 +876,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[][3], int activeOnly)
{
- float normal[3]={0.0, 0.0, 0.0};
- float plane[3]={0.0, 0.0, 0.0};
+ float normal[3] = {0.0, 0.0, 0.0};
+ float plane[3] = {0.0, 0.0, 0.0};
int type;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index a04ce1ca213..9ebd43cd0d1 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -129,13 +129,13 @@ int BIF_snappingSupported(Object *obedit)
int validSnap(TransInfo *t)
{
- return (t->tsnap.status & (POINT_INIT|TARGET_INIT)) == (POINT_INIT|TARGET_INIT) ||
- (t->tsnap.status & (MULTI_POINTS|TARGET_INIT)) == (MULTI_POINTS|TARGET_INIT);
+ return (t->tsnap.status & (POINT_INIT | TARGET_INIT)) == (POINT_INIT | TARGET_INIT) ||
+ (t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT);
}
int activeSnap(TransInfo *t)
{
- return (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP_INVERT;
+ return (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT;
}
void drawSnapping(const struct bContext *C, TransInfo *t)
@@ -144,13 +144,13 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
unsigned char col[4], selectedCol[4], activeCol[4];
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
- col[3]= 128;
+ col[3] = 128;
UI_GetThemeColor3ubv(TH_SELECT, selectedCol);
- selectedCol[3]= 128;
+ selectedCol[3] = 128;
UI_GetThemeColor3ubv(TH_ACTIVE, activeCol);
- activeCol[3]= 192;
+ activeCol[3] = 192;
if (t->spacetype == SPACE_VIEW3D) {
TransSnapPoint *p;
@@ -187,31 +187,31 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
glColor4ubv(activeCol);
glBegin(GL_LINES);
- glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
- glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
- t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
- t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]);
- glEnd();
+ glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
+ glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
+ t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
+ t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]);
+ glEnd();
}
if (v3d->zbuf)
glEnable(GL_DEPTH_TEST);
}
- else if (t->spacetype==SPACE_IMAGE) {
+ else if (t->spacetype == SPACE_IMAGE) {
/* This will not draw, and Im nor sure why - campbell */
#if 0
float xuser_asp, yuser_asp;
int wi, hi;
float w, h;
- calc_image_view(G.sima, 'f'); // float
+ calc_image_view(G.sima, 'f'); // float
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
glLoadIdentity();
ED_space_image_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
- w = (((float)wi)/256.0f)*G.sima->zoom * xuser_asp;
- h = (((float)hi)/256.0f)*G.sima->zoom * yuser_asp;
+ w = (((float)wi) / 256.0f) * G.sima->zoom * xuser_asp;
+ h = (((float)hi) / 256.0f) * G.sima->zoom * yuser_asp;
cpack(0xFFFFFF);
glTranslatef(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f);
@@ -220,10 +220,10 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
setlinestyle(0);
cpack(0x0);
- fdrawline(-0.020/w, 0, -0.1/w, 0);
- fdrawline(0.1/w, 0, .020/w, 0);
- fdrawline(0, -0.020/h, 0, -0.1/h);
- fdrawline(0, 0.1/h, 0, 0.020/h);
+ fdrawline(-0.020 / w, 0, -0.1 / w, 0);
+ fdrawline(0.1 / w, 0, .020 / w, 0);
+ fdrawline(0, -0.020 / h, 0, -0.1 / h);
+ fdrawline(0, 0.1 / h, 0, 0.020 / h);
glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f);
setlinestyle(0);
@@ -261,12 +261,12 @@ void applyProject(TransInfo *t)
float imat[4][4];
int i;
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob = t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
invert_m4_m4(imat, ob->obmat);
}
- for (i = 0 ; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
float iloc[3], loc[3], no[3];
float mval[2];
int dist = 1000;
@@ -278,12 +278,12 @@ void applyProject(TransInfo *t)
continue;
copy_v3_v3(iloc, td->loc);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob = t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, iloc);
}
else if (t->flag & T_OBJECT) {
- td->ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
BKE_object_handle_update(t->scene, td->ob);
copy_v3_v3(iloc, td->ob->obmat[3]);
}
@@ -387,7 +387,7 @@ static void initSnappingMode(TransInfo *t)
/* Edit mode */
if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves
+ (obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves
{
/* Exclude editmesh if using proportional edit */
if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) {
@@ -399,13 +399,13 @@ static void initSnappingMode(TransInfo *t)
}
/* Particles edit mode*/
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT ))
+ (obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT))
{
t->tsnap.modeSelect = SNAP_ALL;
}
/* Object mode */
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit == NULL) ) // Object Mode
+ (obedit == NULL) ) // Object Mode
{
t->tsnap.modeSelect = SNAP_NOT_SELECTED;
}
@@ -438,7 +438,7 @@ void initSnapping(TransInfo *t, wmOperator *op)
if (RNA_struct_property_is_set(op->ptr, "snap_point")) {
RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint);
- t->tsnap.status |= SNAP_FORCED|POINT_INIT;
+ t->tsnap.status |= SNAP_FORCED | POINT_INIT;
}
/* snap align only defined in specific cases */
@@ -497,33 +497,33 @@ static void setSnappingCallback(TransInfo *t)
}
switch (t->mode) {
- case TFM_TRANSLATION:
- t->tsnap.applySnap = ApplySnapTranslation;
- t->tsnap.distance = TranslationBetween;
- break;
- case TFM_ROTATION:
- t->tsnap.applySnap = ApplySnapRotation;
- t->tsnap.distance = RotationBetween;
-
- // Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead
- if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
- t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
- t->tsnap.targetSnap = TargetSnapMedian;
- }
- break;
- case TFM_RESIZE:
- t->tsnap.applySnap = ApplySnapResize;
- t->tsnap.distance = ResizeBetween;
-
- // Can't do TARGET_CENTER with resize, use TARGET_MEDIAN instead
- if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
- t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
- t->tsnap.targetSnap = TargetSnapMedian;
- }
- break;
- default:
- t->tsnap.applySnap = NULL;
- break;
+ case TFM_TRANSLATION:
+ t->tsnap.applySnap = ApplySnapTranslation;
+ t->tsnap.distance = TranslationBetween;
+ break;
+ case TFM_ROTATION:
+ t->tsnap.applySnap = ApplySnapRotation;
+ t->tsnap.distance = RotationBetween;
+
+ // Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead
+ if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
+ t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
+ t->tsnap.targetSnap = TargetSnapMedian;
+ }
+ break;
+ case TFM_RESIZE:
+ t->tsnap.applySnap = ApplySnapResize;
+ t->tsnap.distance = ResizeBetween;
+
+ // Can't do TARGET_CENTER with resize, use TARGET_MEDIAN instead
+ if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
+ t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
+ t->tsnap.targetSnap = TargetSnapMedian;
+ }
+ break;
+ default:
+ t->tsnap.applySnap = NULL;
+ break;
}
}
@@ -550,7 +550,7 @@ int updateSelectedSnapPoint(TransInfo *t)
int closest_dist = 0;
int screen_loc[2];
- for ( p = t->tsnap.points.first; p; p = p->next ) {
+ for (p = t->tsnap.points.first; p; p = p->next) {
int dx, dy;
int dist;
@@ -663,8 +663,8 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3])
float angle, start[3], end[3], center[3];
copy_v3_v3(center, t->center);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, center);
}
@@ -719,8 +719,8 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
float d1[3], d2[3], center[3], len_d1;
copy_v3_v3(center, t->center);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, center);
}
@@ -739,7 +739,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
/********************** CALC **************************/
-static void UNUSED_FUNCTION(CalcSnapGrid)(TransInfo *t, float *UNUSED(vec))
+static void UNUSED_FUNCTION(CalcSnapGrid) (TransInfo * t, float *UNUSED(vec))
{
snapGridAction(t, t->tsnap.snapPoint, BIG_GEARS);
}
@@ -830,9 +830,9 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
if (max_dist != FLT_MAX) {
copy_v3_v3(loc, p);
/* XXX, is there a correct normal in this case ???, for now just z up */
- no[0]= 0.0;
- no[1]= 0.0;
- no[2]= 1.0;
+ no[0] = 0.0;
+ no[1] = 0.0;
+ no[2] = 1.0;
found = 1;
}
@@ -861,12 +861,12 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
t->tsnap.status &= ~POINT_INIT;
}
}
- else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type==OB_MESH) {
+ else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type == OB_MESH) {
/* same as above but for UV's */
- Image *ima= ED_space_image(t->sa->spacedata.first);
+ Image *ima = ED_space_image(t->sa->spacedata.first);
float aspx, aspy, co[2];
- UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co+1);
+ UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co + 1);
if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
@@ -888,8 +888,8 @@ static void TargetSnapCenter(TransInfo *t)
/* Only need to calculate once */
if ((t->tsnap.status & TARGET_INIT) == 0) {
copy_v3_v3(t->tsnap.snapTarget, t->center);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
}
@@ -905,7 +905,7 @@ static void TargetSnapActive(TransInfo *t)
TransData *active_td = NULL;
int i;
- for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
+ for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
if (td->flag & TD_ACTIVE) {
active_td = td;
break;
@@ -915,8 +915,8 @@ static void TargetSnapActive(TransInfo *t)
if (active_td) {
copy_v3_v3(t->tsnap.snapTarget, active_td->center);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
}
@@ -942,14 +942,14 @@ static void TargetSnapMedian(TransInfo *t)
t->tsnap.snapTarget[1] = 0;
t->tsnap.snapTarget[2] = 0;
- for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
+ for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
add_v3_v3(t->tsnap.snapTarget, td->center);
}
mul_v3_fl(t->tsnap.snapTarget, 1.0 / i);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
}
@@ -966,7 +966,7 @@ static void TargetSnapClosest(TransInfo *t)
/* Object mode */
if (t->flag & T_OBJECT) {
int i;
- for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
+ for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
struct BoundBox *bb = BKE_object_boundbox_get(td->ob);
/* use boundbox if possible */
@@ -1008,14 +1008,14 @@ static void TargetSnapClosest(TransInfo *t)
}
else {
int i;
- for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
+ for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
float loc[3];
float dist;
copy_v3_v3(loc, td->center);
- if (t->flag & (T_EDIT|T_POSE)) {
- Object *ob= t->obedit?t->obedit:t->poseobj;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, loc);
}
@@ -1230,10 +1230,10 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm
if (arm->edbo) {
EditBone *eBone;
- for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
+ for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
if (eBone->layer & arm->layer) {
/* skip hidden or moving (selected) bones */
- if ((eBone->flag & (BONE_HIDDEN_A|BONE_ROOTSEL|BONE_TIPSEL))==0) {
+ if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
switch (snap_mode) {
case SCE_SNAP_MODE_VERTEX:
retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
@@ -1251,10 +1251,10 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm
bPoseChannel *pchan;
Bone *bone;
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- bone= pchan->bone;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bone = pchan->bone;
/* skip hidden bones */
- if (bone && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) {
+ if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
float *head_vec = pchan->pose_head;
float *tail_vec = pchan->pose_tail;
@@ -1313,22 +1313,22 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
switch (snap_mode) {
case SCE_SNAP_MODE_FACE:
{
-#ifdef USE_BVH_FACE_SNAP // Added for durian
+#ifdef USE_BVH_FACE_SNAP // Added for durian
BVHTreeRayHit hit;
BVHTreeFromMesh treeData;
/* local scale in normal direction */
float local_scale = len_v3(ray_normal_local);
- treeData.em_evil= em;
+ treeData.em_evil = em;
bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6);
hit.index = -1;
hit.dist = *r_depth * (*r_depth == FLT_MAX ? 1.0f : local_scale);
if (treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) {
- if (hit.dist/local_scale <= *r_depth) {
- *r_depth= hit.dist/local_scale;
+ if (hit.dist / local_scale <= *r_depth) {
+ *r_depth = hit.dist / local_scale;
copy_v3_v3(r_loc, hit.co);
copy_v3_v3(r_no, hit.no);
@@ -1356,7 +1356,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
EDBM_index_arrays_init(em, 0, 0, 1);
}
- for ( i = 0; i < totface; i++) {
+ for (i = 0; i < totface; i++) {
BMFace *efa = NULL;
MFace *f = faces + i;
@@ -1384,7 +1384,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
BMLoop *l;
l = BM_iter_new(&iter, em->bm, BM_LOOPS_OF_FACE, efa);
- for ( ; l; l=BM_iter_step(&iter)) {
+ for (; l; l = BM_iter_step(&iter)) {
if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) {
test = 0;
break;
@@ -1430,7 +1430,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
EDBM_index_arrays_init(em, 1, 0, 0);
}
- for ( i = 0; i < totvert; i++) {
+ for (i = 0; i < totvert; i++) {
BMVert *eve = NULL;
MVert *v = verts + i;
@@ -1481,7 +1481,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
EDBM_index_arrays_init(em, 0, 1, 0);
}
- for ( i = 0; i < totedge; i++) {
+ for (i = 0; i < totedge; i++) {
BMEdge *eed = NULL;
MEdge *e = edges + i;
@@ -1502,8 +1502,8 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
eed = EDBM_edge_at_index(em, index);
if (eed && (BM_elem_flag_test(eed, BM_ELEM_HIDDEN) ||
- BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
- BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))
+ BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))
{
test = 0;
}
@@ -1531,7 +1531,7 @@ static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, flo
const float ray_start[3], const float ray_normal[3], const float mval[2],
float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
{
- ToolSettings *ts= scene->toolsettings;
+ ToolSettings *ts = scene->toolsettings;
int retval = 0;
if (ob->type == OB_MESH) {
@@ -1580,18 +1580,18 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, c
*
* To solve that problem, we do it first as an exception.
* */
- base= BASACT;
+ base = BASACT;
if (base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT) {
Object *ob = base->object;
retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth);
}
- for ( base = FIRSTBASE; base != NULL; base = base->next ) {
- if ( (BASE_VISIBLE(v3d, base)) &&
- (base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 &&
+ for (base = FIRSTBASE; base != NULL; base = base->next) {
+ if ((BASE_VISIBLE(v3d, base)) &&
+ (base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
- ( (mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) ||
- (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) )
+ ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) ||
+ (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)))
{
Object *ob = base->object;
@@ -1719,7 +1719,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4],
MFace *faces = dm->getTessFaceArray(dm);
int i;
- for ( i = 0; i < totface; i++) {
+ for (i = 0; i < totface; i++) {
MFace *f = faces + i;
float lambda;
int result;
@@ -1837,7 +1837,7 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L
if (ob->type == OB_MESH) {
int val = 0;
- if (ob != obedit && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT))) {
+ if (ob != obedit && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) || ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT))) {
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
val = peelDerivedMesh(ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
@@ -1918,7 +1918,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea
if (max_index > 2) {
printf("applyGrid: invalid index %d, clamping\n", max_index);
- max_index= 2;
+ max_index = 2;
}
// Early bailing out if no need to snap
@@ -1926,11 +1926,11 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea
return;
/* evil hack - snapping needs to be adapted for image aspect ratio */
- if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
- ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp+1);
+ if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
+ ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp + 1);
}
- for (i=0; i<=max_index; i++) {
- val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +0.5f);
+ for (i = 0; i <= max_index; i++) {
+ val[i] = fac[action] * asp[i] * (float)floor(val[i] / (fac[action] * asp[i]) + 0.5f);
}
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 4c0e96426e7..87ff36ebf27 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -706,7 +706,7 @@ static void p_face_restore_uvs(PFace *f)
/* Construction (use only during construction, relies on u.key being set */
-static PVert *p_vert_add(PHandle *handle, PHashKey key, float *co, PEdge *e)
+static PVert *p_vert_add(PHandle *handle, PHashKey key, const float co[3], PEdge *e)
{
PVert *v = (PVert *)BLI_memarena_alloc(handle->arena, sizeof *v);
copy_v3_v3(v->co, co);
@@ -719,7 +719,7 @@ static PVert *p_vert_add(PHandle *handle, PHashKey key, float *co, PEdge *e)
return v;
}
-static PVert *p_vert_lookup(PHandle *handle, PHashKey key, float *co, PEdge *e)
+static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PEdge *e)
{
PVert *v = (PVert *)phash_lookup(handle->hash_verts, key);
@@ -3596,7 +3596,7 @@ typedef struct SmoothNode {
int axis, ntri;
} SmoothNode;
-static void p_barycentric_2d(const float v1[2], const float v2[2], const float v3[2], float p[2], float b[2])
+static void p_barycentric_2d(const float v1[2], const float v2[2], const float v3[2], const float p[2], float b[3])
{
float a[2], c[2], h[2], div;
@@ -3624,7 +3624,7 @@ static void p_barycentric_2d(const float v1[2], const float v2[2], const float v
}
}
-static PBool p_triangle_inside(SmoothTriangle *t, float *co)
+static PBool p_triangle_inside(SmoothTriangle *t, float co[2])
{
float b[3];
@@ -3706,7 +3706,7 @@ static void p_node_delete(SmoothNode *node)
MEM_freeN(node->tri);
}
-static PBool p_node_intersect(SmoothNode *node, float *co)
+static PBool p_node_intersect(SmoothNode *node, float co[2])
{
int i;
@@ -3726,7 +3726,7 @@ static PBool p_node_intersect(SmoothNode *node, float *co)
}
-/* smooothing */
+/* smoothing */
static int p_compare_float(const void *a, const void *b)
{
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 89976699114..438cfd6b741 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -112,6 +112,9 @@ void GPU_paint_set_mipmap(int mipmap);
void GPU_set_anisotropic(float value);
float GPU_get_anisotropic(void);
+/* enable gpu mipmapping */
+void GPU_set_gpu_mipmapping(int gpu_mipmap);
+
/* Image updates and free
* - these deal with images bound as opengl textures */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 3e53f2f3836..a1bd8dcb3a3 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -234,11 +234,23 @@ static struct GPUTextureState {
int alphablend;
float anisotropic;
+ int gpu_mipmap;
MTFace *lasttface;
-} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.f, NULL};
+} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.f, 0, NULL};
/* Mipmap settings */
+void GPU_set_gpu_mipmapping(int gpu_mipmap){
+ int old_value = GTS.gpu_mipmap;
+
+ /* only actually enable if it's supported */
+ GTS.gpu_mipmap = gpu_mipmap && GLEW_EXT_framebuffer_object;
+
+ if(old_value != GTS.gpu_mipmap) {
+ GPU_free_images();
+ }
+}
+
void GPU_set_mipmap(int mipmap)
{
if (GTS.domipmap != (mipmap != 0)) {
@@ -632,10 +644,19 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
}
else {
- if (use_high_bit_depth)
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect);
- else
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ if(GTS.gpu_mipmap) {
+ if (use_high_bit_depth)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+ else
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+
+ glGenerateMipmapEXT(GL_TEXTURE_2D);
+ } else {
+ if (use_high_bit_depth)
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect);
+ else
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 279fd5d59be..1b68c520336 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -538,12 +538,16 @@ void IMB_rect_from_float(ImBuf *ibuf)
imb_addrectImBuf(ibuf);
/* determine profiles */
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
profile_from = IB_PROFILE_LINEAR_RGB;
- else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE))
+ }
+ else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) {
profile_from = IB_PROFILE_SRGB;
- else
+ }
+ else {
+ profile_from = IB_PROFILE_SRGB; /* should never happen */
BLI_assert(0);
+ }
/* do conversion */
IMB_buffer_byte_from_float((uchar *)ibuf->rect, ibuf->rect_float,
@@ -571,12 +575,16 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
imb_addrectImBuf(ibuf);
/* determine profiles */
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
profile_from = IB_PROFILE_LINEAR_RGB;
- else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE))
+ }
+ else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) {
profile_from = IB_PROFILE_SRGB;
- else
+ }
+ else {
+ profile_from = IB_PROFILE_SRGB; /* should never happen */
BLI_assert(0);
+ }
/* do conversion */
rect_float = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 7d1d5906dd8..a5826634724 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -43,6 +43,7 @@
static char JP2_HEAD[] = {0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A};
/* We only need this because of how the presets are set */
+/* this typedef is copied from 'openjpeg-1.5.0/applications/codec/image_to_j2k.c' */
typedef struct img_folder {
/** The directory path of the folder containing input images*/
char *imgdirpath;
@@ -92,27 +93,35 @@ static void info_callback(const char *msg, void *client_data)
fprintf(stdout, "[INFO] %s", msg);
}
+# define PIXEL_LOOPER_BEGIN(_rect) \
+ for (y = h - 1; y != (unsigned int)(-1); y--) { \
+ for (i = y * w, i_next = (y + 1) * w; \
+ i < i_next; \
+ i++, _rect += 4) \
+ { \
+# define PIXEL_LOOPER_END \
+ } \
+ } (void)0 \
struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
{
struct ImBuf *ibuf = NULL;
int use_float = FALSE; /* for precision higher then 8 use float */
+ int use_alpha = FALSE;
long signed_offsets[4] = {0, 0, 0, 0};
int float_divs[4] = {1, 1, 1, 1};
- int index;
-
- int w, h, planes;
+ unsigned int i, i_next, w, h, planes;
+ unsigned int y;
+ int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */
opj_dparameters_t parameters; /* decompression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *image = NULL;
-
- int i;
-
+
opj_dinfo_t *dinfo = NULL; /* handle to a decompressor */
opj_cio_t *cio = NULL;
@@ -169,9 +178,11 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
case 1: /* Greyscale */
case 3: /* Color */
planes = 24;
+ use_alpha = FALSE;
break;
default: /* 2 or 4 - Greyscale or Color + alpha */
planes = 32; /* greyscale + alpha */
+ use_alpha = TRUE;
break;
}
@@ -206,64 +217,102 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
float *rect_float = ibuf->rect_float;
if (image->numcomps < 3) {
+ r = image->comps[0].data;
+ a = (use_alpha) ? image->comps[1].data : NULL;
+
/* greyscale 12bits+ */
- for (i = 0; i < w * h; i++, rect_float += 4) {
- index = w * h - ((i) / (w) + 1) * w + (i) % (w);
-
- rect_float[0] = rect_float[1] = rect_float[2] = (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
-
- if (image->numcomps == 2)
- rect_float[3] = (image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
- else
+ if (use_alpha) {
+ a = image->comps[1].data;
+ PIXEL_LOOPER_BEGIN(rect_float) {
+ rect_float[0] = rect_float[1] = rect_float[2] = (float)(r[i] + signed_offsets[0]) / float_divs[0];
+ rect_float[3] = (a[i] + signed_offsets[1]) / float_divs[1];
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float) {
+ rect_float[0] = rect_float[1] = rect_float[2] = (float)(r[i] + signed_offsets[0]) / float_divs[0];
rect_float[3] = 1.0f;
+ }
+ PIXEL_LOOPER_END;
}
}
else {
+ r = image->comps[0].data;
+ g = image->comps[1].data;
+ b = image->comps[2].data;
+
/* rgb or rgba 12bits+ */
- for (i = 0; i < w * h; i++, rect_float += 4) {
- index = w * h - ((i) / (w) + 1) * w + (i) % (w);
-
- rect_float[0] = (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
- rect_float[1] = (float)(image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
- rect_float[2] = (float)(image->comps[2].data[index] + signed_offsets[2]) / float_divs[2];
-
- if (image->numcomps >= 4)
- rect_float[3] = (float)(image->comps[3].data[index] + signed_offsets[3]) / float_divs[3];
- else
+ if (use_alpha) {
+ a = image->comps[3].data;
+ PIXEL_LOOPER_BEGIN(rect_float) {
+ rect_float[0] = (float)(r[i] + signed_offsets[0]) / float_divs[0];
+ rect_float[1] = (float)(g[i] + signed_offsets[1]) / float_divs[1];
+ rect_float[2] = (float)(b[i] + signed_offsets[2]) / float_divs[2];
+ rect_float[3] = (float)(a[i] + signed_offsets[3]) / float_divs[3];
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float) {
+ rect_float[0] = (float)(r[i] + signed_offsets[0]) / float_divs[0];
+ rect_float[1] = (float)(g[i] + signed_offsets[1]) / float_divs[1];
+ rect_float[2] = (float)(b[i] + signed_offsets[2]) / float_divs[2];
rect_float[3] = 1.0f;
+ }
+ PIXEL_LOOPER_END;
}
}
}
else {
- unsigned char *rect = (unsigned char *)ibuf->rect;
+ unsigned char *rect_uchar = (unsigned char *)ibuf->rect;
if (image->numcomps < 3) {
+ r = image->comps[0].data;
+ a = (use_alpha) ? image->comps[1].data : NULL;
+
/* greyscale */
- for (i = 0; i < w * h; i++, rect += 4) {
- index = w * h - ((i) / (w) + 1) * w + (i) % (w);
-
- rect[0] = rect[1] = rect[2] = (image->comps[0].data[index] + signed_offsets[0]);
-
- if (image->numcomps == 2)
- rect[3] = image->comps[1].data[index] + signed_offsets[1];
- else
- rect[3] = 255;
+ if (use_alpha) {
+ a = image->comps[3].data;
+ PIXEL_LOOPER_BEGIN(rect_uchar) {
+ rect_uchar[0] = rect_uchar[1] = rect_uchar[2] = (r[i] + signed_offsets[0]);
+ rect_uchar[3] = a[i] + signed_offsets[1];
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_uchar) {
+ rect_uchar[0] = rect_uchar[1] = rect_uchar[2] = (r[i] + signed_offsets[0]);
+ rect_uchar[3] = 255;
+ }
+ PIXEL_LOOPER_END;
}
}
else {
+ r = image->comps[0].data;
+ g = image->comps[1].data;
+ b = image->comps[2].data;
+
/* 8bit rgb or rgba */
- for (i = 0; i < w * h; i++, rect += 4) {
- int index = w * h - ((i) / (w) + 1) * w + (i) % (w);
-
- rect[0] = image->comps[0].data[index] + signed_offsets[0];
- rect[1] = image->comps[1].data[index] + signed_offsets[1];
- rect[2] = image->comps[2].data[index] + signed_offsets[2];
-
- if (image->numcomps >= 4)
- rect[3] = image->comps[3].data[index] + signed_offsets[3];
- else
- rect[3] = 255;
+ if (use_alpha) {
+ a = image->comps[3].data;
+ PIXEL_LOOPER_BEGIN(rect_uchar) {
+ rect_uchar[0] = r[i] + signed_offsets[0];
+ rect_uchar[1] = g[i] + signed_offsets[1];
+ rect_uchar[2] = b[i] + signed_offsets[2];
+ rect_uchar[3] = a[i] + signed_offsets[3];
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_uchar) {
+ rect_uchar[0] = r[i] + signed_offsets[0];
+ rect_uchar[1] = g[i] + signed_offsets[1];
+ rect_uchar[2] = b[i] + signed_offsets[2];
+ rect_uchar[3] = 255;
+ }
+ PIXEL_LOOPER_END;
}
}
}
@@ -286,13 +335,38 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
/* prec can be 8, 12, 16 */
+/* use inline because the float passed can be a function call that would end up being called many times */
+#if 0
#define UPSAMPLE_8_TO_12(_val) ((_val << 4) | (_val & ((1 << 4) - 1)))
#define UPSAMPLE_8_TO_16(_val) ((_val << 8) + _val)
#define DOWNSAMPLE_FLOAT_TO_8BIT(_val) (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : (int)(255.0f * (_val)))
#define DOWNSAMPLE_FLOAT_TO_12BIT(_val) (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : (int)(4095.0f * (_val)))
#define DOWNSAMPLE_FLOAT_TO_16BIT(_val) (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val)))
+#else
+
+BLI_INLINE int UPSAMPLE_8_TO_12(const unsigned char _val)
+{
+ return (_val << 4) | (_val & ((1 << 4) - 1));
+}
+BLI_INLINE int UPSAMPLE_8_TO_16(const unsigned char _val)
+{
+ return (_val << 8) + _val;
+}
+BLI_INLINE int DOWNSAMPLE_FLOAT_TO_8BIT(const float _val)
+{
+ return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : (int)(255.0f * (_val)));
+}
+BLI_INLINE int DOWNSAMPLE_FLOAT_TO_12BIT(const float _val)
+{
+ return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : (int)(4095.0f * (_val)));
+}
+BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT(const float _val)
+{
+ return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val)));
+}
+#endif
/*
* 2048x1080 (2K) at 24 fps or 48 fps, or 4096x2160 (4K) at 24 fps; 3x12 bits per pixel, XYZ color space
@@ -457,15 +531,15 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
{
- unsigned char *rect;
+ unsigned char *rect_uchar;
float *rect_float;
- int subsampling_dx = parameters->subsampling_dx;
- int subsampling_dy = parameters->subsampling_dy;
+ unsigned int subsampling_dx = parameters->subsampling_dx;
+ unsigned int subsampling_dy = parameters->subsampling_dy;
-
- int i, numcomps, w, h, prec;
- int x, y, y_row;
+ unsigned int i, i_next, numcomps, w, h, prec;
+ unsigned int y;
+ int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */
OPJ_COLOR_SPACE color_space;
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
opj_image_t *image = NULL;
@@ -515,7 +589,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
/* initialize image components */
- memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
+ memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t));
for (i = 0; i < numcomps; i++) {
cmptparm[i].prec = prec;
cmptparm[i].bpp = prec;
@@ -535,78 +609,157 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
/* set image offset and reference grid */
image->x0 = parameters->image_offset_x0;
image->y0 = parameters->image_offset_y0;
- image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1;
- image->y1 = parameters->image_offset_y0 + (h - 1) * subsampling_dy + 1;
-
+ image->x1 = image->x0 + (w - 1) * subsampling_dx + 1 + image->x0;
+ image->y1 = image->y0 + (h - 1) * subsampling_dy + 1 + image->y0;
+
/* set image data */
- rect = (unsigned char *) ibuf->rect;
+ rect_uchar = (unsigned char *) ibuf->rect;
rect_float = ibuf->rect_float;
- if (rect_float && rect && prec == 8) {
+ /* set the destination channels */
+ r = image->comps[0].data;
+ g = image->comps[1].data;
+ b = image->comps[2].data;
+ a = (numcomps == 4) ? image->comps[3].data : NULL;
+
+ if (rect_float && rect_uchar && prec == 8) {
/* No need to use the floating point buffer, just write the 8 bits from the char buffer */
rect_float = NULL;
}
-
if (rect_float) {
- float rgb[3];
-
switch (prec) {
case 8: /* Convert blenders float color channels to 8, 12 or 16bit ints */
- for (y = h - 1; y >= 0; y--) {
- y_row = y * w;
- for (x = 0; x < w; x++, rect_float += 4) {
- i = y_row + x;
-
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
- linearrgb_to_srgb_v3_v3(rgb, rect_float);
- else
- copy_v3_v3(rgb, rect_float);
-
- image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[0]);
- image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[1]);
- image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[2]);
- if (numcomps > 3)
- image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
+ if (numcomps == 4) {
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2]));
+ a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]);
+ g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]);
+ b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]);
+ a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ }
+ else {
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2]));
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]);
+ g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]);
+ b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]);
+ }
+ PIXEL_LOOPER_END;
}
}
break;
case 12:
- for (y = h - 1; y >= 0; y--) {
- y_row = y * w;
- for (x = 0; x < w; x++, rect_float += 4) {
- i = y_row + x;
-
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
- linearrgb_to_srgb_v3_v3(rgb, rect_float);
- else
- copy_v3_v3(rgb, rect_float);
-
- image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[0]);
- image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[1]);
- image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[2]);
- if (numcomps > 3)
- image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
+ if (numcomps == 4) {
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2]));
+ a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]);
+ g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]);
+ b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]);
+ a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ }
+ else {
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2]));
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]);
+ g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]);
+ b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]);
+ }
+ PIXEL_LOOPER_END;
}
}
break;
+
case 16:
- for (y = h - 1; y >= 0; y--) {
- y_row = y * w;
- for (x = 0; x < w; x++, rect_float += 4) {
- i = y_row + x;
-
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
- linearrgb_to_srgb_v3_v3(rgb, rect_float);
- else
- copy_v3_v3(rgb, rect_float);
-
- image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[0]);
- image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[1]);
- image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[2]);
- if (numcomps > 3)
- image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
+ if (numcomps == 4) {
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2]));
+ a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]);
+ g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]);
+ b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]);
+ a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ }
+ else {
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2]));
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]);
+ g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]);
+ b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]);
+ }
+ PIXEL_LOOPER_END;
}
}
break;
@@ -616,46 +769,68 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
/* just use rect*/
switch (prec) {
case 8:
- for (y = h - 1; y >= 0; y--) {
- y_row = y * w;
- for (x = 0; x < w; x++, rect += 4) {
- i = y_row + x;
-
- image->comps[0].data[i] = rect[0];
- image->comps[1].data[i] = rect[1];
- image->comps[2].data[i] = rect[2];
- if (numcomps > 3)
- image->comps[3].data[i] = rect[3];
+ if (numcomps == 4) {
+ PIXEL_LOOPER_BEGIN(rect_uchar)
+ {
+ r[i] = rect_uchar[0];
+ g[i] = rect_uchar[1];
+ b[i] = rect_uchar[2];
+ a[i] = rect_uchar[3];
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_uchar)
+ {
+ r[i] = rect_uchar[0];
+ g[i] = rect_uchar[1];
+ b[i] = rect_uchar[2];
}
+ PIXEL_LOOPER_END;
}
break;
case 12: /* Up Sampling, a bit pointless but best write the bit depth requested */
- for (y = h - 1; y >= 0; y--) {
- y_row = y * w;
- for (x = 0; x < w; x++, rect += 4) {
- i = y_row + x;
-
- image->comps[0].data[i] = UPSAMPLE_8_TO_12(rect[0]);
- image->comps[1].data[i] = UPSAMPLE_8_TO_12(rect[1]);
- image->comps[2].data[i] = UPSAMPLE_8_TO_12(rect[2]);
- if (numcomps > 3)
- image->comps[3].data[i] = UPSAMPLE_8_TO_12(rect[3]);
+ if (numcomps == 4) {
+ PIXEL_LOOPER_BEGIN(rect_uchar)
+ {
+ r[i] = UPSAMPLE_8_TO_12(rect_uchar[0]);
+ g[i] = UPSAMPLE_8_TO_12(rect_uchar[1]);
+ b[i] = UPSAMPLE_8_TO_12(rect_uchar[2]);
+ a[i] = UPSAMPLE_8_TO_12(rect_uchar[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_uchar)
+ {
+ r[i] = UPSAMPLE_8_TO_12(rect_uchar[0]);
+ g[i] = UPSAMPLE_8_TO_12(rect_uchar[1]);
+ b[i] = UPSAMPLE_8_TO_12(rect_uchar[2]);
}
+ PIXEL_LOOPER_END;
}
break;
+
case 16:
- for (y = h - 1; y >= 0; y--) {
- y_row = y * w;
- for (x = 0; x < w; x++, rect += 4) {
- i = y_row + x;
-
- image->comps[0].data[i] = UPSAMPLE_8_TO_16(rect[0]);
- image->comps[1].data[i] = UPSAMPLE_8_TO_16(rect[1]);
- image->comps[2].data[i] = UPSAMPLE_8_TO_16(rect[2]);
- if (numcomps > 3)
- image->comps[3].data[i] = UPSAMPLE_8_TO_16(rect[3]);
+ if (numcomps == 4) {
+ PIXEL_LOOPER_BEGIN(rect_uchar)
+ {
+ r[i] = UPSAMPLE_8_TO_16(rect_uchar[0]);
+ g[i] = UPSAMPLE_8_TO_16(rect_uchar[1]);
+ b[i] = UPSAMPLE_8_TO_16(rect_uchar[2]);
+ a[i] = UPSAMPLE_8_TO_16(rect_uchar[3]);
+ }
+ PIXEL_LOOPER_END;
+ }
+ else {
+ PIXEL_LOOPER_BEGIN(rect_uchar)
+ {
+ r[i] = UPSAMPLE_8_TO_16(rect_uchar[0]);
+ g[i] = UPSAMPLE_8_TO_16(rect_uchar[1]);
+ b[i] = UPSAMPLE_8_TO_16(rect_uchar[2]);
}
+ PIXEL_LOOPER_END;
}
break;
}
@@ -720,7 +895,7 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags)
opj_cinfo_t *cinfo = opj_create_compress(CODEC_JP2);
/* catch events using our callbacks and give a local context */
- opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
+ opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
/* setup the encoder parameters using the current image and using user parameters */
opj_setup_encoder(cinfo, &parameters, image);
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index baea18d4898..18957cb8260 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -64,7 +64,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
#include <iostream>
-#if defined (_WIN32) && !defined(FREE_WINDOWS)
+#if defined(_WIN32) && !defined(FREE_WINDOWS)
#include <half.h>
#include <IlmImf/ImfVersion.h>
#include <IlmImf/ImfArray.h>
@@ -95,19 +95,21 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
using namespace Imf;
using namespace Imath;
-class Mem_IStream: public Imf::IStream
+class Mem_IStream : public Imf::IStream
{
public:
-
- Mem_IStream (unsigned char *exrbuf, size_t exrsize):
- IStream("dummy"), _exrpos (0), _exrsize(exrsize) { _exrbuf = exrbuf; }
-
- virtual bool read (char c[], int n);
- virtual Int64 tellg ();
- virtual void seekg (Int64 pos);
- virtual void clear ();
+
+ Mem_IStream (unsigned char *exrbuf, size_t exrsize) :
+ IStream("dummy"), _exrpos(0), _exrsize(exrsize) {
+ _exrbuf = exrbuf;
+ }
+
+ virtual bool read(char c[], int n);
+ virtual Int64 tellg();
+ virtual void seekg(Int64 pos);
+ virtual void clear();
//virtual ~Mem_IStream() {}; // unused
-
+
private:
Int64 _exrpos;
@@ -115,7 +117,7 @@ private:
unsigned char *_exrbuf;
};
-bool Mem_IStream::read (char c[], int n)
+bool Mem_IStream::read(char c[], int n)
{
if (n + _exrpos <= _exrsize) {
memcpy(c, (void *)(&_exrbuf[_exrpos]), n);
@@ -126,22 +128,21 @@ bool Mem_IStream::read (char c[], int n)
return false;
}
-Int64 Mem_IStream::tellg ()
+Int64 Mem_IStream::tellg()
{
return _exrpos;
}
-void Mem_IStream::seekg (Int64 pos)
+void Mem_IStream::seekg(Int64 pos)
{
_exrpos = pos;
}
-void Mem_IStream::clear ()
-{
+void Mem_IStream::clear()
+{
}
-struct _RGBAZ
-{
+struct _RGBAZ {
half r;
half g;
half b;
@@ -153,10 +154,10 @@ typedef struct _RGBAZ RGBAZ;
extern "C"
{
-
+
int imb_is_a_openexr(unsigned char *mem)
{
- return Imf::isImfMagic ((const char *)mem);
+ return Imf::isImfMagic((const char *)mem);
}
static void openexr_header_compression(Header *header, int compression)
@@ -179,69 +180,70 @@ static void openexr_header_compression(Header *header, int compression)
break;
default:
header->compression() = ZIP_COMPRESSION;
- break;
+ break;
}
}
static void openexr_header_metadata(Header *header, struct ImBuf *ibuf)
{
- ImMetaData* info;
+ ImMetaData *info;
- for (info= ibuf->metadata; info; info= info->next)
+ for (info = ibuf->metadata; info; info = info->next)
header->insert(info->key, StringAttribute(info->value));
}
static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags)
{
- int channels = ibuf->channels;
- int width = ibuf->x;
- int height = ibuf->y;
- int write_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; // summarize
-
+ const int channels = ibuf->channels;
+ const int is_alpha = (channels >= 4) && (ibuf->planes == 32);
+ const int is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
+ const int width = ibuf->x;
+ const int height = ibuf->y;
+
try
{
- Header header (width, height);
-
+ Header header(width, height);
+
openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS);
openexr_header_metadata(&header, ibuf);
-
- header.channels().insert ("R", Channel (HALF));
- header.channels().insert ("G", Channel (HALF));
- header.channels().insert ("B", Channel (HALF));
- if (ibuf->planes==32 && channels >= 4)
- header.channels().insert ("A", Channel (HALF));
- if (write_zbuf) // z we do as float always
- header.channels().insert ("Z", Channel (Imf::FLOAT));
-
- FrameBuffer frameBuffer;
- OutputFile *file = new OutputFile(name, header);
-
+
+ header.channels().insert("R", Channel(HALF));
+ header.channels().insert("G", Channel(HALF));
+ header.channels().insert("B", Channel(HALF));
+ if (is_alpha)
+ header.channels().insert("A", Channel(HALF));
+ if (is_zbuf) // z we do as float always
+ header.channels().insert("Z", Channel(Imf::FLOAT));
+
+ FrameBuffer frameBuffer;
+ OutputFile *file = new OutputFile(name, header);
+
/* we store first everything in half array */
RGBAZ *pixels = new RGBAZ[height * width];
RGBAZ *to = pixels;
- int xstride= sizeof (RGBAZ);
- int ystride= xstride*width;
+ int xstride = sizeof(RGBAZ);
+ int ystride = xstride * width;
/* indicate used buffers */
- frameBuffer.insert ("R", Slice (HALF, (char *) &pixels[0].r, xstride, ystride));
- frameBuffer.insert ("G", Slice (HALF, (char *) &pixels[0].g, xstride, ystride));
- frameBuffer.insert ("B", Slice (HALF, (char *) &pixels[0].b, xstride, ystride));
- if (ibuf->planes==32 && channels >= 4)
- frameBuffer.insert ("A", Slice (HALF, (char *) &pixels[0].a, xstride, ystride));
- if (write_zbuf)
- frameBuffer.insert ("Z", Slice (Imf::FLOAT, (char *)(ibuf->zbuf_float + (height-1)*width),
- sizeof(float), sizeof(float) * -width));
+ frameBuffer.insert("R", Slice(HALF, (char *) &pixels[0].r, xstride, ystride));
+ frameBuffer.insert("G", Slice(HALF, (char *) &pixels[0].g, xstride, ystride));
+ frameBuffer.insert("B", Slice(HALF, (char *) &pixels[0].b, xstride, ystride));
+ if (is_alpha)
+ frameBuffer.insert("A", Slice(HALF, (char *) &pixels[0].a, xstride, ystride));
+ if (is_zbuf)
+ frameBuffer.insert("Z", Slice(Imf::FLOAT, (char *)(ibuf->zbuf_float + (height - 1) * width),
+ sizeof(float), sizeof(float) * -width));
if (ibuf->rect_float) {
float *from;
- for (int i = ibuf->y-1; i >= 0; i--) {
- from= ibuf->rect_float + channels*i*width;
+ for (int i = ibuf->y - 1; i >= 0; i--) {
+ from = ibuf->rect_float + channels * i * width;
for (int j = ibuf->x; j > 0; j--) {
to->r = from[0];
to->g = from[1];
to->b = from[2];
- to->a = (channels >= 4)? from[3]: 1.0f;
+ to->a = (channels >= 4) ? from[3] : 1.0f;
to++; from += 4;
}
}
@@ -250,105 +252,106 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags
unsigned char *from;
if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- for (int i = ibuf->y-1; i >= 0; i--) {
- from= (unsigned char *)ibuf->rect + channels*i*width;
+ for (int i = ibuf->y - 1; i >= 0; i--) {
+ from = (unsigned char *)ibuf->rect + channels * i * width;
for (int j = ibuf->x; j > 0; j--) {
- to->r = (float)(from[0])/255.0;
- to->g = (float)(from[1])/255.0;
- to->b = (float)(from[2])/255.0;
- to->a = (float)(channels >= 4) ? from[3]/255.0 : 1.0f;
+ to->r = (float)(from[0]) / 255.0;
+ to->g = (float)(from[1]) / 255.0;
+ to->b = (float)(from[2]) / 255.0;
+ to->a = (float)(channels >= 4) ? from[3] / 255.0 : 1.0f;
to++; from += 4;
}
}
}
else {
- for (int i = ibuf->y-1; i >= 0; i--) {
- from= (unsigned char *)ibuf->rect + channels*i*width;
+ for (int i = ibuf->y - 1; i >= 0; i--) {
+ from = (unsigned char *)ibuf->rect + channels * i * width;
for (int j = ibuf->x; j > 0; j--) {
to->r = srgb_to_linearrgb((float)from[0] / 255.0);
to->g = srgb_to_linearrgb((float)from[1] / 255.0);
to->b = srgb_to_linearrgb((float)from[2] / 255.0);
- to->a = channels >= 4 ? (float)from[3]/255.0 : 1.0f;
+ to->a = channels >= 4 ? (float)from[3] / 255.0 : 1.0f;
to++; from += 4;
}
}
}
}
-
+
// printf("OpenEXR-save: Writing OpenEXR file of height %d.\n", height);
-
- file->setFrameBuffer (frameBuffer);
- file->writePixels (height);
+
+ file->setFrameBuffer(frameBuffer);
+ file->writePixels(height);
delete file;
- delete [] pixels;
+ delete[] pixels;
}
catch (const std::exception &exc)
{
printf("OpenEXR-save: ERROR: %s\n", exc.what());
if (ibuf) IMB_freeImBuf(ibuf);
-
+
return (0);
}
-
+
return (1);
}
static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flags)
{
- int channels = ibuf->channels;
- int width = ibuf->x;
- int height = ibuf->y;
- int write_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; // summarize
+ const int channels = ibuf->channels;
+ const int is_alpha = (channels >= 4) && (ibuf->planes == 32);
+ const int is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
+ const int width = ibuf->x;
+ const int height = ibuf->y;
try
{
- Header header (width, height);
-
+ Header header(width, height);
+
openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS);
openexr_header_metadata(&header, ibuf);
-
- header.channels().insert ("R", Channel (Imf::FLOAT));
- header.channels().insert ("G", Channel (Imf::FLOAT));
- header.channels().insert ("B", Channel (Imf::FLOAT));
- if (ibuf->planes==32 && channels >= 4)
- header.channels().insert ("A", Channel (Imf::FLOAT));
- if (write_zbuf)
- header.channels().insert ("Z", Channel (Imf::FLOAT));
-
- FrameBuffer frameBuffer;
- OutputFile *file = new OutputFile(name, header);
+
+ header.channels().insert("R", Channel(Imf::FLOAT));
+ header.channels().insert("G", Channel(Imf::FLOAT));
+ header.channels().insert("B", Channel(Imf::FLOAT));
+ if (is_alpha)
+ header.channels().insert("A", Channel(Imf::FLOAT));
+ if (is_zbuf)
+ header.channels().insert("Z", Channel(Imf::FLOAT));
+
+ FrameBuffer frameBuffer;
+ OutputFile *file = new OutputFile(name, header);
int xstride = sizeof(float) * channels;
- int ystride = - xstride*width;
+ int ystride = -xstride * width;
float *rect[4] = {NULL, NULL, NULL, NULL};
/* last scanline, stride negative */
- rect[0]= ibuf->rect_float + channels*(height-1)*width;
- rect[1]= rect[0]+1;
- rect[2]= rect[0]+2;
- rect[3]= (channels >= 4)? rect[0]+3:rect[0]; /* red as alpha, is this needed since alpha isn't written? */
-
- frameBuffer.insert ("R", Slice (Imf::FLOAT, (char *)rect[0], xstride, ystride));
- frameBuffer.insert ("G", Slice (Imf::FLOAT, (char *)rect[1], xstride, ystride));
- frameBuffer.insert ("B", Slice (Imf::FLOAT, (char *)rect[2], xstride, ystride));
- if (ibuf->planes==32 && channels >= 4)
- frameBuffer.insert ("A", Slice (Imf::FLOAT, (char *)rect[3], xstride, ystride));
- if (write_zbuf)
- frameBuffer.insert ("Z", Slice (Imf::FLOAT, (char *) (ibuf->zbuf_float + (height-1)*width),
- sizeof(float), sizeof(float) * -width));
- file->setFrameBuffer (frameBuffer);
- file->writePixels (height);
+ rect[0] = ibuf->rect_float + channels * (height - 1) * width;
+ rect[1] = rect[0] + 1;
+ rect[2] = rect[0] + 2;
+ rect[3] = (channels >= 4) ? rect[0] + 3 : rect[0]; /* red as alpha, is this needed since alpha isn't written? */
+
+ frameBuffer.insert("R", Slice(Imf::FLOAT, (char *)rect[0], xstride, ystride));
+ frameBuffer.insert("G", Slice(Imf::FLOAT, (char *)rect[1], xstride, ystride));
+ frameBuffer.insert("B", Slice(Imf::FLOAT, (char *)rect[2], xstride, ystride));
+ if (is_alpha)
+ frameBuffer.insert("A", Slice(Imf::FLOAT, (char *)rect[3], xstride, ystride));
+ if (is_zbuf)
+ frameBuffer.insert("Z", Slice(Imf::FLOAT, (char *) (ibuf->zbuf_float + (height - 1) * width),
+ sizeof(float), sizeof(float) * -width));
+ file->setFrameBuffer(frameBuffer);
+ file->writePixels(height);
delete file;
}
catch (const std::exception &exc)
{
printf("OpenEXR-save: ERROR: %s\n", exc.what());
if (ibuf) IMB_freeImBuf(ibuf);
-
+
return (0);
}
-
+
return (1);
// printf("OpenEXR-save: Done.\n");
}
@@ -359,15 +362,15 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
if (flags & IB_mem) {
printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
imb_addencodedbufferImBuf(ibuf);
- ibuf->encodedsize = 0;
+ ibuf->encodedsize = 0;
return(0);
- }
-
- if (ibuf->ftype & OPENEXR_HALF)
+ }
+
+ if (ibuf->ftype & OPENEXR_HALF)
return imb_save_openexr_half(ibuf, name, flags);
else {
/* when no float rect, we save as half (16 bits is sufficient) */
- if (ibuf->rect_float==NULL)
+ if (ibuf->rect_float == NULL)
return imb_save_openexr_half(ibuf, name, flags);
else
return imb_save_openexr_float(ibuf, name, flags);
@@ -383,30 +386,30 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
* - separated with a dot: the Layer name (like "Lamp1" or "Walls" or "Characters")
*/
-static ListBase exrhandles= {NULL, NULL};
+static ListBase exrhandles = {NULL, NULL};
typedef struct ExrHandle {
struct ExrHandle *next, *prev;
-
+
InputFile *ifile;
TiledOutputFile *tofile;
OutputFile *ofile;
int tilex, tiley;
int width, height;
int mipmap;
-
- ListBase channels; /* flattened out, ExrChannel */
- ListBase layers; /* hierarchical, pointing in end to ExrChannel */
+
+ ListBase channels; /* flattened out, ExrChannel */
+ ListBase layers; /* hierarchical, pointing in end to ExrChannel */
} ExrHandle;
/* flattened out channel */
typedef struct ExrChannel {
struct ExrChannel *next, *prev;
-
- char name[EXR_TOT_MAXNAME+1]; /* full name of layer+pass */
- int xstride, ystride; /* step to next pixel, to next scanline */
- float *rect; /* first pointer to write in */
- char chan_id; /* quick lookup of channel char */
+
+ char name[EXR_TOT_MAXNAME + 1]; /* full name of layer+pass */
+ int xstride, ystride; /* step to next pixel, to next scanline */
+ float *rect; /* first pointer to write in */
+ char chan_id; /* quick lookup of channel char */
} ExrChannel;
@@ -422,7 +425,7 @@ typedef struct ExrPass {
typedef struct ExrLayer {
struct ExrLayer *next, *prev;
- char name[EXR_LAY_MAXNAME+1];
+ char name[EXR_LAY_MAXNAME + 1];
ListBase passes;
} ExrLayer;
@@ -430,7 +433,7 @@ typedef struct ExrLayer {
void *IMB_exr_get_handle(void)
{
- ExrHandle *data= (ExrHandle *)MEM_callocN(sizeof(ExrHandle), "exr handle");
+ ExrHandle *data = (ExrHandle *)MEM_callocN(sizeof(ExrHandle), "exr handle");
BLI_addtail(&exrhandles, data);
return data;
}
@@ -439,25 +442,26 @@ void *IMB_exr_get_handle(void)
/* xstride, ystride and rect can be done in set_channel too, for tile writing */
void IMB_exr_add_channel(void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect)
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
ExrChannel *echan;
-
- echan= (ExrChannel *)MEM_callocN(sizeof(ExrChannel), "exr tile channel");
-
+
+ echan = (ExrChannel *)MEM_callocN(sizeof(ExrChannel), "exr tile channel");
+
if (layname) {
- char lay[EXR_LAY_MAXNAME+1], pass[EXR_PASS_MAXNAME+1];
+ char lay[EXR_LAY_MAXNAME + 1], pass[EXR_PASS_MAXNAME + 1];
BLI_strncpy(lay, layname, EXR_LAY_MAXNAME);
BLI_strncpy(pass, passname, EXR_PASS_MAXNAME);
- sprintf(echan->name, "%s.%s", lay, pass);
+ BLI_snprintf(echan->name, sizeof(echan->name), "%s.%s", lay, pass);
}
- else
- BLI_strncpy(echan->name, passname, EXR_TOT_MAXNAME-1);
-
- echan->xstride= xstride;
- echan->ystride= ystride;
- echan->rect= rect;
-
+ else {
+ BLI_strncpy(echan->name, passname, EXR_TOT_MAXNAME - 1);
+ }
+
+ echan->xstride = xstride;
+ echan->ystride = ystride;
+ echan->rect = rect;
+
// printf("added channel %s\n", echan->name);
BLI_addtail(&data->channels, echan);
}
@@ -465,21 +469,21 @@ void IMB_exr_add_channel(void *handle, const char *layname, const char *passname
/* only used for writing temp. render results (not image files) */
int IMB_exr_begin_write(void *handle, const char *filename, int width, int height, int compress)
{
- ExrHandle *data= (ExrHandle *)handle;
- Header header (width, height);
+ ExrHandle *data = (ExrHandle *)handle;
+ Header header(width, height);
ExrChannel *echan;
-
- data->width= width;
- data->height= height;
-
- for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next)
- header.channels().insert (echan->name, Channel (Imf::FLOAT));
-
+
+ data->width = width;
+ data->height = height;
+
+ for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next)
+ header.channels().insert(echan->name, Channel(Imf::FLOAT));
+
openexr_header_compression(&header, compress);
// openexr_header_metadata(&header, ibuf); // no imbuf. cant write
/* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */
-
- header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.55.1 and newer"));
+
+ header.insert("BlenderMultiChannel", StringAttribute("Blender V2.55.1 and newer"));
/* avoid crash/abort when we don't have permission to write here */
try {
@@ -495,45 +499,45 @@ int IMB_exr_begin_write(void *handle, const char *filename, int width, int heigh
void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley)
{
- ExrHandle *data= (ExrHandle *)handle;
- Header header (width, height);
+ ExrHandle *data = (ExrHandle *)handle;
+ Header header(width, height);
ExrChannel *echan;
-
- data->tilex= tilex;
- data->tiley= tiley;
- data->width= width;
- data->height= height;
- data->mipmap= mipmap;
-
- for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next)
- header.channels().insert (echan->name, Channel (Imf::FLOAT));
-
- header.setTileDescription (TileDescription (tilex, tiley, (mipmap)? MIPMAP_LEVELS: ONE_LEVEL));
+
+ data->tilex = tilex;
+ data->tiley = tiley;
+ data->width = width;
+ data->height = height;
+ data->mipmap = mipmap;
+
+ for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next)
+ header.channels().insert(echan->name, Channel(Imf::FLOAT));
+
+ header.setTileDescription(TileDescription(tilex, tiley, (mipmap) ? MIPMAP_LEVELS : ONE_LEVEL));
header.lineOrder() = RANDOM_Y;
header.compression() = RLE_COMPRESSION;
-
- header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43"));
-
+
+ header.insert("BlenderMultiChannel", StringAttribute("Blender V2.43"));
+
data->tofile = new TiledOutputFile(filename, header);
}
/* read from file */
int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *height)
{
- ExrHandle *data= (ExrHandle *)handle;
-
- if (BLI_exists(filename) && BLI_file_size(filename)>32) { /* 32 is arbitrary, but zero length files crashes exr */
+ ExrHandle *data = (ExrHandle *)handle;
+
+ if (BLI_exists(filename) && BLI_file_size(filename) > 32) { /* 32 is arbitrary, but zero length files crashes exr */
data->ifile = new InputFile(filename);
if (data->ifile) {
Box2i dw = data->ifile->header().dataWindow();
- data->width= *width = dw.max.x - dw.min.x + 1;
- data->height= *height = dw.max.y - dw.min.y + 1;
-
+ data->width = *width = dw.max.x - dw.min.x + 1;
+ data->height = *height = dw.max.y - dw.min.y + 1;
+
const ChannelList &channels = data->ifile->header().channels();
-
+
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
IMB_exr_add_channel(data, NULL, i.name(), 0, 0, NULL);
-
+
return 1;
}
}
@@ -543,26 +547,26 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
/* still clumsy name handling, layers/channels can be ordered as list in list later */
void IMB_exr_set_channel(void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect)
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
ExrChannel *echan;
char name[EXR_TOT_MAXNAME + 1];
-
+
if (layname) {
- char lay[EXR_LAY_MAXNAME+1], pass[EXR_PASS_MAXNAME+1];
+ char lay[EXR_LAY_MAXNAME + 1], pass[EXR_PASS_MAXNAME + 1];
BLI_strncpy(lay, layname, EXR_LAY_MAXNAME);
BLI_strncpy(pass, passname, EXR_PASS_MAXNAME);
-
- sprintf(name, "%s.%s", lay, pass);
+
+ BLI_snprintf(name, sizeof(name), "%s.%s", lay, pass);
}
else
- BLI_strncpy(name, passname, EXR_TOT_MAXNAME-1);
+ BLI_strncpy(name, passname, EXR_TOT_MAXNAME - 1);
- echan= (ExrChannel *)BLI_findstring(&data->channels, name, offsetof(ExrChannel, name));
+ echan = (ExrChannel *)BLI_findstring(&data->channels, name, offsetof(ExrChannel, name));
if (echan) {
- echan->xstride= xstride;
- echan->ystride= ystride;
- echan->rect= rect;
+ echan->xstride = xstride;
+ echan->ystride = ystride;
+ echan->rect = rect;
}
else
printf("IMB_exrtile_set_channel error %s\n", name);
@@ -570,28 +574,28 @@ void IMB_exr_set_channel(void *handle, const char *layname, const char *passname
void IMB_exrtile_clear_channels(void *handle)
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
BLI_freelistN(&data->channels);
}
void IMB_exrtile_write_channels(void *handle, int partx, int party, int level)
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
FrameBuffer frameBuffer;
ExrChannel *echan;
-
- for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) {
- float *rect= echan->rect - echan->xstride*partx - echan->ystride*party;
- frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)rect,
- echan->xstride*sizeof(float), echan->ystride*sizeof(float)));
+ for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
+ float *rect = echan->rect - echan->xstride * partx - echan->ystride * party;
+
+ frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)rect,
+ echan->xstride * sizeof(float), echan->ystride * sizeof(float)));
}
-
- data->tofile->setFrameBuffer (frameBuffer);
+
+ data->tofile->setFrameBuffer(frameBuffer);
try {
// printf("write tile %d %d\n", partx/data->tilex, party/data->tiley);
- data->tofile->writeTile (partx/data->tilex, party/data->tiley, level);
+ data->tofile->writeTile(partx / data->tilex, party / data->tiley, level);
}
catch (const std::exception &exc) {
std::cerr << "OpenEXR-writeTile: ERROR: " << exc.what() << std::endl;
@@ -600,22 +604,22 @@ void IMB_exrtile_write_channels(void *handle, int partx, int party, int level)
void IMB_exr_write_channels(void *handle)
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
FrameBuffer frameBuffer;
ExrChannel *echan;
-
+
if (data->channels.first) {
- for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) {
+ for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
/* last scanline, stride negative */
- float *rect = echan->rect + echan->xstride*(data->height-1)*data->width;
-
- frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)rect,
- echan->xstride*sizeof(float), -echan->ystride*sizeof(float)));
+ float *rect = echan->rect + echan->xstride * (data->height - 1) * data->width;
+
+ frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)rect,
+ echan->xstride * sizeof(float), -echan->ystride * sizeof(float)));
}
-
- data->ofile->setFrameBuffer (frameBuffer);
+
+ data->ofile->setFrameBuffer(frameBuffer);
try {
- data->ofile->writePixels (data->height);
+ data->ofile->writePixels(data->height);
}
catch (const std::exception &exc) {
std::cerr << "OpenEXR-writePixels: ERROR: " << exc.what() << std::endl;
@@ -628,58 +632,58 @@ void IMB_exr_write_channels(void *handle)
void IMB_exr_read_channels(void *handle)
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
FrameBuffer frameBuffer;
ExrChannel *echan;
-
+
/* check if exr was saved with previous versions of blender which flipped images */
const StringAttribute *ta = data->ifile->header().findTypedAttribute <StringAttribute> ("BlenderMultiChannel");
- short flip = (ta && strncmp(ta->value().c_str(), "Blender V2.43", 13)==0); /* 'previous multilayer attribute, flipped */
-
- for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) {
-
+ short flip = (ta && strncmp(ta->value().c_str(), "Blender V2.43", 13) == 0); /* 'previous multilayer attribute, flipped */
+
+ for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
+
if (echan->rect) {
if (flip)
- frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)echan->rect,
- echan->xstride*sizeof(float), echan->ystride*sizeof(float)));
+ frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)echan->rect,
+ echan->xstride * sizeof(float), echan->ystride * sizeof(float)));
else
- frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)(echan->rect + echan->xstride*(data->height-1)*data->width),
- echan->xstride*sizeof(float), -echan->ystride*sizeof(float)));
+ frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)(echan->rect + echan->xstride * (data->height - 1) * data->width),
+ echan->xstride * sizeof(float), -echan->ystride * sizeof(float)));
}
- else
+ else
printf("warning, channel with no rect set %s\n", echan->name);
}
-
- data->ifile->setFrameBuffer (frameBuffer);
+
+ data->ifile->setFrameBuffer(frameBuffer);
try {
- data->ifile->readPixels (0, data->height-1);
+ data->ifile->readPixels(0, data->height - 1);
}
catch (const std::exception &exc) {
std::cerr << "OpenEXR-readPixels: ERROR: " << exc.what() << std::endl;
}
}
-void IMB_exr_multilayer_convert(void *handle, void *base,
- void * (*addlayer)(void *base, char *str),
- void (*addpass)(void *base, void *lay, char *str,
- float *rect, int totchan, char *chan_id))
+void IMB_exr_multilayer_convert(void *handle, void *base,
+ void * (*addlayer)(void *base, char *str),
+ void (*addpass)(void *base, void *lay, char *str,
+ float *rect, int totchan, char *chan_id))
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
ExrLayer *lay;
ExrPass *pass;
- if (data->layers.first==NULL) {
+ if (data->layers.first == NULL) {
printf("cannot convert multilayer, no layers in handle\n");
return;
}
- for (lay= (ExrLayer *)data->layers.first; lay; lay= lay->next) {
- void *laybase= addlayer(base, lay->name);
+ for (lay = (ExrLayer *)data->layers.first; lay; lay = lay->next) {
+ void *laybase = addlayer(base, lay->name);
if (laybase) {
- for (pass= (ExrPass *)lay->passes.first; pass; pass= pass->next) {
+ for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next) {
addpass(base, laybase, pass->name, pass->rect, pass->totchan, pass->chan_id);
- pass->rect= NULL;
+ pass->rect = NULL;
}
}
}
@@ -688,31 +692,31 @@ void IMB_exr_multilayer_convert(void *handle, void *base,
void IMB_exr_close(void *handle)
{
- ExrHandle *data= (ExrHandle *)handle;
+ ExrHandle *data = (ExrHandle *)handle;
ExrLayer *lay;
ExrPass *pass;
-
+
if (data->ifile)
delete data->ifile;
else if (data->ofile)
delete data->ofile;
else if (data->tofile)
delete data->tofile;
-
- data->ifile= NULL;
- data->ofile= NULL;
- data->tofile= NULL;
-
+
+ data->ifile = NULL;
+ data->ofile = NULL;
+ data->tofile = NULL;
+
BLI_freelistN(&data->channels);
-
- for (lay= (ExrLayer *)data->layers.first; lay; lay= lay->next) {
- for (pass= (ExrPass *)lay->passes.first; pass; pass= pass->next)
+
+ for (lay = (ExrLayer *)data->layers.first; lay; lay = lay->next) {
+ for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next)
if (pass->rect)
MEM_freeN(pass->rect);
BLI_freelistN(&lay->passes);
}
BLI_freelistN(&data->layers);
-
+
BLI_remlink(&exrhandles, data);
MEM_freeN(data);
}
@@ -722,12 +726,12 @@ void IMB_exr_close(void *handle)
/* get a substring from the end of the name, separated by '.' */
static int imb_exr_split_token(const char *str, const char *end, const char **token)
{
- int maxlen = end-str;
+ int maxlen = end - str;
int len = 0;
- while (len < maxlen && *(end-len-1) != '.')
+ while (len < maxlen && *(end - len - 1) != '.')
++len;
-
- *token = end-len;
+
+ *token = end - len;
return len;
}
@@ -738,7 +742,7 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa
const char *token;
char tokenbuf[EXR_TOT_MAXNAME];
int len;
-
+
/* last token is single character channel identifier */
len = imb_exr_split_token(name, end, &token);
if (len == 0) {
@@ -751,32 +755,32 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa
return 0;
}
echan->chan_id = token[0];
- end -= len + 1; /* +1 to skip '.' separator */
-
+ end -= len + 1; /* +1 to skip '.' separator */
+
/* second token is pass name */
len = imb_exr_split_token(name, end, &token);
if (len == 0) {
printf("multilayer read: bad channel name: %s\n", name);
return 0;
}
- BLI_strncpy(passname, token, len+1);
- end -= len + 1; /* +1 to skip '.' separator */
-
+ BLI_strncpy(passname, token, len + 1);
+ end -= len + 1; /* +1 to skip '.' separator */
+
/* all preceding tokens combined as layer name */
if (end > name)
- BLI_strncpy(layname, name, (int)(end-name)+1);
+ BLI_strncpy(layname, name, (int)(end - name) + 1);
else
layname[0] = '\0';
-
+
return 1;
}
static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname)
{
- ExrLayer *lay= (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name));
+ ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name));
- if (lay==NULL) {
- lay= (ExrLayer *)MEM_callocN(sizeof(ExrLayer), "exr layer");
+ if (lay == NULL) {
+ lay = (ExrLayer *)MEM_callocN(sizeof(ExrLayer), "exr layer");
BLI_addtail(lb, lay);
BLI_strncpy(lay->name, layname, EXR_LAY_MAXNAME);
}
@@ -786,19 +790,19 @@ static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname)
static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname)
{
- ExrPass *pass= (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name));
-
- if (pass==NULL) {
- pass= (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass");
+ ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name));
- if (strcmp(passname, "Combined")==0)
+ if (pass == NULL) {
+ pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass");
+
+ if (strcmp(passname, "Combined") == 0)
BLI_addhead(lb, pass);
else
BLI_addtail(lb, pass);
}
BLI_strncpy(pass->name, passname, EXR_LAY_MAXNAME);
-
+
return pass;
}
@@ -808,29 +812,29 @@ static ExrHandle *imb_exr_begin_read_mem(InputFile *file, int width, int height)
ExrLayer *lay;
ExrPass *pass;
ExrChannel *echan;
- ExrHandle *data= (ExrHandle *)IMB_exr_get_handle();
+ ExrHandle *data = (ExrHandle *)IMB_exr_get_handle();
int a;
char layname[EXR_TOT_MAXNAME], passname[EXR_TOT_MAXNAME];
-
- data->ifile= file;
- data->width= width;
- data->height= height;
-
+
+ data->ifile = file;
+ data->width = width;
+ data->height = height;
+
const ChannelList &channels = data->ifile->header().channels();
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
IMB_exr_add_channel(data, NULL, i.name(), 0, 0, NULL);
-
+
/* now try to sort out how to assign memory to the channels */
/* first build hierarchical layer list */
- for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) {
- if ( imb_exr_split_channel_name(echan, layname, passname) ) {
- ExrLayer *lay= imb_exr_get_layer(&data->layers, layname);
- ExrPass *pass= imb_exr_get_pass(&lay->passes, passname);
-
- pass->chan[pass->totchan]= echan;
+ for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
+ if (imb_exr_split_channel_name(echan, layname, passname) ) {
+ ExrLayer *lay = imb_exr_get_layer(&data->layers, layname);
+ ExrPass *pass = imb_exr_get_pass(&lay->passes, passname);
+
+ pass->chan[pass->totchan] = echan;
pass->totchan++;
- if (pass->totchan>=EXR_PASS_MAXCHAN)
+ if (pass->totchan >= EXR_PASS_MAXCHAN)
break;
}
}
@@ -839,65 +843,65 @@ static ExrHandle *imb_exr_begin_read_mem(InputFile *file, int width, int height)
IMB_exr_close(data);
return NULL;
}
-
+
/* with some heuristics, try to merge the channels in buffers */
- for (lay= (ExrLayer *)data->layers.first; lay; lay= lay->next) {
- for (pass= (ExrPass *)lay->passes.first; pass; pass= pass->next) {
+ for (lay = (ExrLayer *)data->layers.first; lay; lay = lay->next) {
+ for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next) {
if (pass->totchan) {
- pass->rect= (float *)MEM_mapallocN(width*height*pass->totchan*sizeof(float), "pass rect");
- if (pass->totchan==1) {
- echan= pass->chan[0];
- echan->rect= pass->rect;
- echan->xstride= 1;
- echan->ystride= width;
- pass->chan_id[0]= echan->chan_id;
+ pass->rect = (float *)MEM_mapallocN(width * height * pass->totchan * sizeof(float), "pass rect");
+ if (pass->totchan == 1) {
+ echan = pass->chan[0];
+ echan->rect = pass->rect;
+ echan->xstride = 1;
+ echan->ystride = width;
+ pass->chan_id[0] = echan->chan_id;
}
else {
char lookup[256];
-
+
memset(lookup, 0, sizeof(lookup));
-
+
/* we can have RGB(A), XYZ(W), UVA */
- if (pass->totchan==3 || pass->totchan==4) {
- if (pass->chan[0]->chan_id=='B' || pass->chan[1]->chan_id=='B' || pass->chan[2]->chan_id=='B') {
- lookup[(unsigned int)'R']= 0;
- lookup[(unsigned int)'G']= 1;
- lookup[(unsigned int)'B']= 2;
- lookup[(unsigned int)'A']= 3;
+ if (pass->totchan == 3 || pass->totchan == 4) {
+ if (pass->chan[0]->chan_id == 'B' || pass->chan[1]->chan_id == 'B' || pass->chan[2]->chan_id == 'B') {
+ lookup[(unsigned int)'R'] = 0;
+ lookup[(unsigned int)'G'] = 1;
+ lookup[(unsigned int)'B'] = 2;
+ lookup[(unsigned int)'A'] = 3;
}
- else if (pass->chan[0]->chan_id=='Y' || pass->chan[1]->chan_id=='Y' || pass->chan[2]->chan_id=='Y') {
- lookup[(unsigned int)'X']= 0;
- lookup[(unsigned int)'Y']= 1;
- lookup[(unsigned int)'Z']= 2;
- lookup[(unsigned int)'W']= 3;
+ else if (pass->chan[0]->chan_id == 'Y' || pass->chan[1]->chan_id == 'Y' || pass->chan[2]->chan_id == 'Y') {
+ lookup[(unsigned int)'X'] = 0;
+ lookup[(unsigned int)'Y'] = 1;
+ lookup[(unsigned int)'Z'] = 2;
+ lookup[(unsigned int)'W'] = 3;
}
else {
- lookup[(unsigned int)'U']= 0;
- lookup[(unsigned int)'V']= 1;
- lookup[(unsigned int)'A']= 2;
+ lookup[(unsigned int)'U'] = 0;
+ lookup[(unsigned int)'V'] = 1;
+ lookup[(unsigned int)'A'] = 2;
}
- for (a=0; a<pass->totchan; a++) {
- echan= pass->chan[a];
- echan->rect= pass->rect + lookup[(unsigned int)echan->chan_id];
- echan->xstride= pass->totchan;
- echan->ystride= width*pass->totchan;
- pass->chan_id[ (unsigned int)lookup[(unsigned int)echan->chan_id] ]= echan->chan_id;
+ for (a = 0; a < pass->totchan; a++) {
+ echan = pass->chan[a];
+ echan->rect = pass->rect + lookup[(unsigned int)echan->chan_id];
+ echan->xstride = pass->totchan;
+ echan->ystride = width * pass->totchan;
+ pass->chan_id[(unsigned int)lookup[(unsigned int)echan->chan_id]] = echan->chan_id;
}
}
else { /* unknown */
- for (a=0; a<pass->totchan; a++) {
- echan= pass->chan[a];
- echan->rect= pass->rect + a;
- echan->xstride= pass->totchan;
- echan->ystride= width*pass->totchan;
- pass->chan_id[a]= echan->chan_id;
+ for (a = 0; a < pass->totchan; a++) {
+ echan = pass->chan[a];
+ echan->rect = pass->rect + a;
+ echan->xstride = pass->totchan;
+ echan->ystride = width * pass->totchan;
+ pass->chan_id[a] = echan->chan_id;
}
}
}
}
}
}
-
+
return data;
}
@@ -916,7 +920,7 @@ typedef struct RGBA {
static void exr_print_filecontents(InputFile *file)
{
const ChannelList &channels = file->header().channels();
-
+
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i) {
const Channel &channel = i.channel();
printf("OpenEXR-load: Found channel %s of type %d\n", i.name(), channel.type);
@@ -927,13 +931,13 @@ static void exr_print_filecontents(InputFile *file)
static const char *exr_rgba_channelname(InputFile *file, const char *chan)
{
const ChannelList &channels = file->header().channels();
-
+
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i) {
/* const Channel &channel = i.channel(); */ /* Not used yet */
- const char *str= i.name();
- int len= strlen(str);
+ const char *str = i.name();
+ int len = strlen(str);
if (len) {
- if (BLI_strcasecmp(chan, str+len-1)==0) {
+ if (BLI_strcasecmp(chan, str + len - 1) == 0) {
return str;
}
}
@@ -941,23 +945,26 @@ static const char *exr_rgba_channelname(InputFile *file, const char *chan)
return chan;
}
-
-
static int exr_has_zbuffer(InputFile *file)
{
return !(file->header().channels().findChannel("Z") == NULL);
}
+static int exr_has_alpha(InputFile *file)
+{
+ return !(file->header().channels().findChannel("A") == NULL);
+}
+
static int exr_is_multilayer(InputFile *file)
{
- const StringAttribute *comments= file->header().findTypedAttribute<StringAttribute>("BlenderMultiChannel");
+ const StringAttribute *comments = file->header().findTypedAttribute<StringAttribute>("BlenderMultiChannel");
const ChannelList &channels = file->header().channels();
std::set <std::string> layerNames;
channels.layers(layerNames);
- if (comments || layerNames.size()>1)
- return 1;
+ if (comments || layerNames.size() > 1)
+ return 1;
return 0;
}
@@ -966,82 +973,84 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags)
{
struct ImBuf *ibuf = NULL;
InputFile *file = NULL;
-
+
if (imb_is_a_openexr(mem) == 0) return(NULL);
-
+
try
{
- Mem_IStream *membuf = new Mem_IStream(mem, size);
+ Mem_IStream *membuf = new Mem_IStream(mem, size);
int is_multi;
file = new InputFile(*membuf);
-
+
Box2i dw = file->header().dataWindow();
- int width = dw.max.x - dw.min.x + 1;
- int height = dw.max.y - dw.min.y + 1;
-
- //printf("OpenEXR-load: image data window %d %d %d %d\n",
+ const int width = dw.max.x - dw.min.x + 1;
+ const int height = dw.max.y - dw.min.y + 1;
+
+ //printf("OpenEXR-load: image data window %d %d %d %d\n",
// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
if (0) // debug
exr_print_filecontents(file);
-
- is_multi= exr_is_multilayer(file);
-
+
+ is_multi = exr_is_multilayer(file);
+
/* do not make an ibuf when */
if (is_multi && !(flags & IB_test) && !(flags & IB_multilayer)) {
printf("Error: can't process EXR multilayer file\n");
}
else {
-
- ibuf = IMB_allocImBuf(width, height, 32, 0);
+ const int is_alpha = exr_has_alpha(file);
+
+ ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0);
ibuf->ftype = OPENEXR;
/* openEXR is linear as per EXR spec */
ibuf->profile = IB_PROFILE_LINEAR_RGB;
-
+
if (!(flags & IB_test)) {
if (is_multi) { /* only enters with IB_multilayer flag set */
/* constructs channels for reading, allocates memory in channels */
- ExrHandle *handle= imb_exr_begin_read_mem(file, width, height);
+ ExrHandle *handle = imb_exr_begin_read_mem(file, width, height);
if (handle) {
IMB_exr_read_channels(handle);
- ibuf->userdata= handle; /* potential danger, the caller has to check for this! */
+ ibuf->userdata = handle; /* potential danger, the caller has to check for this! */
}
}
else {
FrameBuffer frameBuffer;
float *first;
int xstride = sizeof(float) * 4;
- int ystride = - xstride*width;
-
+ int ystride = -xstride * width;
+
imb_addrectfloatImBuf(ibuf);
-
+
/* inverse correct first pixel for datawindow coordinates (- dw.min.y because of y flip) */
- first= ibuf->rect_float - 4*(dw.min.x - dw.min.y*width);
+ first = ibuf->rect_float - 4 * (dw.min.x - dw.min.y * width);
/* but, since we read y-flipped (negative y stride) we move to last scanline */
- first+= 4*(height-1)*width;
-
- frameBuffer.insert ( exr_rgba_channelname(file, "R"),
- Slice (Imf::FLOAT, (char *) first, xstride, ystride));
- frameBuffer.insert ( exr_rgba_channelname(file, "G"),
- Slice (Imf::FLOAT, (char *) (first+1), xstride, ystride));
- frameBuffer.insert ( exr_rgba_channelname(file, "B"),
- Slice (Imf::FLOAT, (char *) (first+2), xstride, ystride));
-
- frameBuffer.insert ( exr_rgba_channelname(file, "A"),
- Slice (Imf::FLOAT, (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */
+ first += 4 * (height - 1) * width;
+
+ frameBuffer.insert(exr_rgba_channelname(file, "R"),
+ Slice(Imf::FLOAT, (char *) first, xstride, ystride));
+ frameBuffer.insert(exr_rgba_channelname(file, "G"),
+ Slice(Imf::FLOAT, (char *) (first + 1), xstride, ystride));
+ frameBuffer.insert(exr_rgba_channelname(file, "B"),
+ Slice(Imf::FLOAT, (char *) (first + 2), xstride, ystride));
+
+ /* 1.0 is fill value, this still neesd to be assigned even when (is_alpha == 0) */
+ frameBuffer.insert(exr_rgba_channelname(file, "A"),
+ Slice(Imf::FLOAT, (char *) (first + 3), xstride, ystride, 1, 1, 1.0f));
if (exr_has_zbuffer(file)) {
float *firstz;
-
+
addzbuffloatImBuf(ibuf);
- firstz= ibuf->zbuf_float - (dw.min.x - dw.min.y*width);
- firstz+= (height-1)*width;
- frameBuffer.insert("Z", Slice (Imf::FLOAT, (char *)firstz, sizeof(float), -width * sizeof(float)));
+ firstz = ibuf->zbuf_float - (dw.min.x - dw.min.y * width);
+ firstz += (height - 1) * width;
+ frameBuffer.insert("Z", Slice(Imf::FLOAT, (char *)firstz, sizeof(float), -width * sizeof(float)));
}
-
- file->setFrameBuffer (frameBuffer);
- file->readPixels (dw.min.y, dw.max.y);
+
+ file->setFrameBuffer(frameBuffer);
+ file->readPixels(dw.min.y, dw.max.y);
// XXX, ImBuf has no nice way to deal with this.
// ideally IM_rect would be used when the caller wants a rect BUT
@@ -1052,7 +1061,7 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags)
//
// if (flag & IM_rect)
// IMB_rect_from_float(ibuf);
-
+
/* file is no longer needed */
delete file;
}
@@ -1065,10 +1074,10 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags)
std::cerr << exc.what() << std::endl;
if (ibuf) IMB_freeImBuf(ibuf);
delete file;
-
+
return (0);
}
-
+
}
void imb_initopenexr(void)
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 46a0f21fde0..fb6ae8e3833 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -139,8 +139,8 @@ typedef struct Library {
} Library;
enum eIconSizes {
- ICON_SIZE_ICON,
- ICON_SIZE_PREVIEW
+ ICON_SIZE_ICON = 0,
+ ICON_SIZE_PREVIEW = 1
};
#define NUM_ICON_SIZES (ICON_SIZE_PREVIEW + 1)
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 651b69f6aca..a3918c3ca26 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -373,7 +373,7 @@ typedef enum ePose_Flags {
/* bPose->iksolver and bPose->ikparam->iksolver */
typedef enum ePose_IKSolverType {
IKSOLVER_LEGACY = 0,
- IKSOLVER_ITASC
+ IKSOLVER_ITASC = 1
} ePose_IKSolverType;
/* header for all bPose->ikparam structures */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index fd4b86a4155..55fb3322806 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -72,15 +72,15 @@ typedef struct FModifier {
*/
typedef enum eFModifier_Types {
FMODIFIER_TYPE_NULL = 0,
- FMODIFIER_TYPE_GENERATOR,
- FMODIFIER_TYPE_FN_GENERATOR,
- FMODIFIER_TYPE_ENVELOPE,
- FMODIFIER_TYPE_CYCLES,
- FMODIFIER_TYPE_NOISE,
- FMODIFIER_TYPE_FILTER, /* unimplemented - for applying: fft, high/low pass filters, etc. */
- FMODIFIER_TYPE_PYTHON,
- FMODIFIER_TYPE_LIMITS,
- FMODIFIER_TYPE_STEPPED,
+ FMODIFIER_TYPE_GENERATOR = 1,
+ FMODIFIER_TYPE_FN_GENERATOR = 2,
+ FMODIFIER_TYPE_ENVELOPE = 3,
+ FMODIFIER_TYPE_CYCLES = 4,
+ FMODIFIER_TYPE_NOISE = 5,
+ FMODIFIER_TYPE_FILTER = 6, /* unimplemented - for applying: fft, high/low pass filters, etc. */
+ FMODIFIER_TYPE_PYTHON = 7,
+ FMODIFIER_TYPE_LIMITS = 8,
+ FMODIFIER_TYPE_STEPPED = 9,
/* NOTE: all new modifiers must be added above this line */
FMODIFIER_NUM_TYPES
@@ -120,7 +120,7 @@ typedef struct FMod_Generator {
/* generator modes */
typedef enum eFMod_Generator_Modes {
FCM_GENERATOR_POLYNOMIAL = 0,
- FCM_GENERATOR_POLYNOMIAL_FACTORISED
+ FCM_GENERATOR_POLYNOMIAL_FACTORISED = 1
} eFMod_Generator_Modes;
@@ -156,11 +156,11 @@ typedef struct FMod_FunctionGenerator {
/* 'function' generator types */
typedef enum eFMod_Generator_Functions {
FCM_GENERATOR_FN_SIN = 0,
- FCM_GENERATOR_FN_COS,
- FCM_GENERATOR_FN_TAN,
- FCM_GENERATOR_FN_SQRT,
- FCM_GENERATOR_FN_LN,
- FCM_GENERATOR_FN_SINC
+ FCM_GENERATOR_FN_COS = 1,
+ FCM_GENERATOR_FN_TAN = 2,
+ FCM_GENERATOR_FN_SQRT = 3,
+ FCM_GENERATOR_FN_LN = 4,
+ FCM_GENERATOR_FN_SINC = 5
} eFMod_Generator_Functions;
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 7faeccd2a32..cc08d0e92bd 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -135,16 +135,16 @@ typedef enum eArmature_Flag {
/* armature->drawtype */
typedef enum eArmature_Drawtype {
ARM_OCTA = 0,
- ARM_LINE,
- ARM_B_BONE,
- ARM_ENVELOPE,
- ARM_WIRE
+ ARM_LINE = 1,
+ ARM_B_BONE = 2,
+ ARM_ENVELOPE = 3,
+ ARM_WIRE = 4
} eArmature_Drawtype;
/* armature->gevertdeformer */
typedef enum eArmature_VertDeformer {
- ARM_VDEF_BLENDER,
- ARM_VDEF_BGE_CPU
+ ARM_VDEF_BLENDER = 0,
+ ARM_VDEF_BGE_CPU = 1
} eArmature_VertDeformer;
/* armature->deformflag */
@@ -170,8 +170,8 @@ typedef enum eArmature_PathFlag {
// XXX depreceated... old animation system (armature only viz)
typedef enum eArmature_GhostType {
ARM_GHOST_CUR = 0,
- ARM_GHOST_RANGE,
- ARM_GHOST_KEYS
+ ARM_GHOST_RANGE = 1,
+ ARM_GHOST_KEYS = 2
} eArmature_GhostType;
/* bone->flag */
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index 698667ff33c..ce5fc4b0c3c 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -36,18 +36,18 @@
typedef enum BoidRuleType {
eBoidRuleType_None = 0,
- eBoidRuleType_Goal, /* go to goal assigned object or loudest assigned signal source */
- eBoidRuleType_Avoid, /* get away from assigned object or loudest assigned signal source */
- eBoidRuleType_AvoidCollision, /* manoeuver to avoid collisions with other boids and deflector object in near future */
- eBoidRuleType_Separate, /* keep from going through other boids */
- eBoidRuleType_Flock, /* move to center of neighbors and match their velocity */
- eBoidRuleType_FollowLeader, /* follow a boid or assigned object */
- eBoidRuleType_AverageSpeed, /* maintain speed, flight level or wander*/
- eBoidRuleType_Fight, /* go to closest enemy and attack when in range */
- //eBoidRuleType_Protect, /* go to enemy closest to target and attack when in range */
- //eBoidRuleType_Hide, /* find a deflector move to it's other side from closest enemy */
- //eBoidRuleType_FollowPath, /* move along a assigned curve or closest curve in a group */
- //eBoidRuleType_FollowWall, /* move next to a deflector object's in direction of it's tangent */
+ eBoidRuleType_Goal = 1, /* go to goal assigned object or loudest assigned signal source */
+ eBoidRuleType_Avoid = 2, /* get away from assigned object or loudest assigned signal source */
+ eBoidRuleType_AvoidCollision = 3, /* manoeuver to avoid collisions with other boids and deflector object in near future */
+ eBoidRuleType_Separate = 4, /* keep from going through other boids */
+ eBoidRuleType_Flock = 5, /* move to center of neighbors and match their velocity */
+ eBoidRuleType_FollowLeader = 6, /* follow a boid or assigned object */
+ eBoidRuleType_AverageSpeed = 7, /* maintain speed, flight level or wander*/
+ eBoidRuleType_Fight = 8, /* go to closest enemy and attack when in range */
+ //eBoidRuleType_Protect = 9, /* go to enemy closest to target and attack when in range */
+ //eBoidRuleType_Hide = 10, /* find a deflector move to it's other side from closest enemy */
+ //eBoidRuleType_FollowPath = 11, /* move along a assigned curve or closest curve in a group */
+ //eBoidRuleType_FollowWall = 12, /* move next to a deflector object's in direction of it's tangent */
NUM_BOID_RULE_TYPES
} BoidRuleType;
@@ -98,10 +98,10 @@ typedef struct BoidRuleFight {
typedef enum BoidMode {
eBoidMode_InAir = 0,
- eBoidMode_OnLand,
- eBoidMode_Climbing,
- eBoidMode_Falling,
- eBoidMode_Liftoff,
+ eBoidMode_OnLand = 1,
+ eBoidMode_Climbing = 2,
+ eBoidMode_Falling = 3,
+ eBoidMode_Liftoff = 4,
NUM_BOID_MODES
} BoidMode;
@@ -114,20 +114,20 @@ typedef struct BoidData {
// planned for near future
//typedef enum BoidConditionMode {
// eBoidConditionType_Then = 0,
-// eBoidConditionType_And,
-// eBoidConditionType_Or,
+// eBoidConditionType_And = 1,
+// eBoidConditionType_Or = 2,
// NUM_BOID_CONDITION_MODES
//} BoidConditionMode;
//typedef enum BoidConditionType {
// eBoidConditionType_None = 0,
-// eBoidConditionType_Signal,
-// eBoidConditionType_NoSignal,
-// eBoidConditionType_HealthBelow,
-// eBoidConditionType_HealthAbove,
-// eBoidConditionType_See,
-// eBoidConditionType_NotSee,
-// eBoidConditionType_StateTime,
-// eBoidConditionType_Touching,
+// eBoidConditionType_Signal = 1,
+// eBoidConditionType_NoSignal = 2,
+// eBoidConditionType_HealthBelow = 3,
+// eBoidConditionType_HealthAbove = 4,
+// eBoidConditionType_See = 5,
+// eBoidConditionType_NotSee = 6,
+// eBoidConditionType_StateTime = 7,
+// eBoidConditionType_Touching = 8,
// NUM_BOID_CONDITION_TYPES
//} BoidConditionType;
//typedef struct BoidCondition {
@@ -142,8 +142,8 @@ typedef struct BoidData {
typedef enum BoidRulesetType {
eBoidRulesetType_Fuzzy = 0,
- eBoidRulesetType_Random,
- eBoidRulesetType_Average,
+ eBoidRulesetType_Random = 1,
+ eBoidRulesetType_Average = 2,
NUM_BOID_RULESET_TYPES
} BoidRulesetType;
#define BOIDSTATE_CURRENT 1
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 0cef9aa03b7..cc26ee479d7 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -174,26 +174,26 @@ typedef enum BrushSculptTool {
/* direction that the brush displaces along */
enum {
- SCULPT_DISP_DIR_AREA,
- SCULPT_DISP_DIR_VIEW,
- SCULPT_DISP_DIR_X,
- SCULPT_DISP_DIR_Y,
- SCULPT_DISP_DIR_Z
+ SCULPT_DISP_DIR_AREA = 0,
+ SCULPT_DISP_DIR_VIEW = 1,
+ SCULPT_DISP_DIR_X = 2,
+ SCULPT_DISP_DIR_Y = 3,
+ SCULPT_DISP_DIR_Z = 4
};
enum {
- PAINT_BLEND_MIX,
- PAINT_BLEND_ADD,
- PAINT_BLEND_SUB,
- PAINT_BLEND_MUL,
- PAINT_BLEND_BLUR,
- PAINT_BLEND_LIGHTEN,
- PAINT_BLEND_DARKEN
+ PAINT_BLEND_MIX = 0,
+ PAINT_BLEND_ADD = 1,
+ PAINT_BLEND_SUB = 2,
+ PAINT_BLEND_MUL = 3,
+ PAINT_BLEND_BLUR = 4,
+ PAINT_BLEND_LIGHTEN = 5,
+ PAINT_BLEND_DARKEN = 6
};
typedef enum {
- BRUSH_MASK_DRAW,
- BRUSH_MASK_SMOOTH
+ BRUSH_MASK_DRAW = 0,
+ BRUSH_MASK_SMOOTH = 1
} BrushMaskTool;
#define MAX_BRUSH_PIXEL_RADIUS 200
diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h
index 99e2a123fe7..1f8fdd20dda 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -86,13 +86,13 @@ typedef struct CurveMapping {
/* cumapping->preset */
typedef enum CurveMappingPreset {
- CURVE_PRESET_LINE,
- CURVE_PRESET_SHARP,
- CURVE_PRESET_SMOOTH,
- CURVE_PRESET_MAX,
- CURVE_PRESET_MID9,
- CURVE_PRESET_ROUND,
- CURVE_PRESET_ROOT,
+ CURVE_PRESET_LINE = 0,
+ CURVE_PRESET_SHARP = 1,
+ CURVE_PRESET_SMOOTH = 2,
+ CURVE_PRESET_MAX = 3,
+ CURVE_PRESET_MID9 = 4,
+ CURVE_PRESET_ROUND = 5,
+ CURVE_PRESET_ROOT = 6,
} CurveMappingPreset;
/* histogram->mode */
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 59d8e81de39..40362424532 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -104,9 +104,9 @@ typedef enum B_CONSTRAINT_TARGET_FLAG {
/* bConstraintTarget/bConstraintOb -> type */
typedef enum B_CONSTRAINT_OB_TYPE {
CONSTRAINT_OBTYPE_OBJECT = 1, /* string is "" */
- CONSTRAINT_OBTYPE_BONE, /* string is bone-name */
- CONSTRAINT_OBTYPE_VERT, /* string is vertex-group name */
- CONSTRAINT_OBTYPE_CV /* string is vertex-group name - is not available until curves get vgroups */
+ CONSTRAINT_OBTYPE_BONE = 2, /* string is bone-name */
+ CONSTRAINT_OBTYPE_VERT = 3, /* string is vertex-group name */
+ CONSTRAINT_OBTYPE_CV = 4 /* string is vertex-group name - is not available until curves get vgroups */
} B_CONSTRAINT_OB_TYPE;
@@ -152,7 +152,7 @@ typedef struct bKinematicConstraint {
typedef enum B_CONSTRAINT_IK_TYPE {
CONSTRAINT_IK_COPYPOSE = 0, /* 'standard' IK constraint: match position and/or orientation of target */
- CONSTRAINT_IK_DISTANCE /* maintain distance with target */
+ CONSTRAINT_IK_DISTANCE = 1 /* maintain distance with target */
} B_CONSTRAINT_IK_TYPE;
@@ -247,7 +247,7 @@ typedef struct bActionConstraint {
int end;
float min;
float max;
- int pad;
+ int flag;
struct bAction *act;
char subtarget[64]; /* MAX_ID_NAME-2 */
} bActionConstraint;
@@ -444,34 +444,34 @@ typedef struct bObjectSolverConstraint {
*/
typedef enum eBConstraint_Types {
CONSTRAINT_TYPE_NULL = 0, /* Invalid/legacy constraint */
- CONSTRAINT_TYPE_CHILDOF, /* Unimplemented non longer :) - during constraints recode, Aligorith */
- CONSTRAINT_TYPE_TRACKTO,
- CONSTRAINT_TYPE_KINEMATIC,
- CONSTRAINT_TYPE_FOLLOWPATH,
- CONSTRAINT_TYPE_ROTLIMIT, /* Unimplemented no longer :) - Aligorith */
- CONSTRAINT_TYPE_LOCLIMIT, /* Unimplemented no longer :) - Aligorith */
- CONSTRAINT_TYPE_SIZELIMIT, /* Unimplemented no longer :) - Aligorith */
- CONSTRAINT_TYPE_ROTLIKE,
- CONSTRAINT_TYPE_LOCLIKE,
- CONSTRAINT_TYPE_SIZELIKE,
- CONSTRAINT_TYPE_PYTHON, /* Unimplemented no longer :) - Aligorith. Scripts */
- CONSTRAINT_TYPE_ACTION,
- CONSTRAINT_TYPE_LOCKTRACK, /* New Tracking constraint that locks an axis in place - theeth */
- CONSTRAINT_TYPE_DISTLIMIT, /* limit distance */
- CONSTRAINT_TYPE_STRETCHTO, /* claiming this to be mine :) is in tuhopuu bjornmose */
- CONSTRAINT_TYPE_MINMAX, /* floor constraint */
- CONSTRAINT_TYPE_RIGIDBODYJOINT, /* rigidbody constraint */
- CONSTRAINT_TYPE_CLAMPTO, /* clampto constraint */
- CONSTRAINT_TYPE_TRANSFORM, /* transformation (loc/rot/size -> loc/rot/size) constraint */
- CONSTRAINT_TYPE_SHRINKWRAP, /* shrinkwrap (loc/rot) constraint */
- CONSTRAINT_TYPE_DAMPTRACK, /* New Tracking constraint that minimises twisting */
- CONSTRAINT_TYPE_SPLINEIK, /* Spline-IK - Align 'n' bones to a curve */
- CONSTRAINT_TYPE_TRANSLIKE, /* Copy transform matrix */
- CONSTRAINT_TYPE_SAMEVOL, /* Maintain volume during scaling */
- CONSTRAINT_TYPE_PIVOT, /* Pivot Constraint */
- CONSTRAINT_TYPE_FOLLOWTRACK, /* Follow Track Constraint */
- CONSTRAINT_TYPE_CAMERASOLVER, /* Camera Solver Constraint */
- CONSTRAINT_TYPE_OBJECTSOLVER, /* Object Solver Constraint */
+ CONSTRAINT_TYPE_CHILDOF = 1, /* Unimplemented non longer :) - during constraints recode, Aligorith */
+ CONSTRAINT_TYPE_TRACKTO = 2,
+ CONSTRAINT_TYPE_KINEMATIC = 3,
+ CONSTRAINT_TYPE_FOLLOWPATH = 4,
+ CONSTRAINT_TYPE_ROTLIMIT = 5, /* Unimplemented no longer :) - Aligorith */
+ CONSTRAINT_TYPE_LOCLIMIT = 6, /* Unimplemented no longer :) - Aligorith */
+ CONSTRAINT_TYPE_SIZELIMIT = 7, /* Unimplemented no longer :) - Aligorith */
+ CONSTRAINT_TYPE_ROTLIKE = 8,
+ CONSTRAINT_TYPE_LOCLIKE = 9,
+ CONSTRAINT_TYPE_SIZELIKE = 10,
+ CONSTRAINT_TYPE_PYTHON = 11, /* Unimplemented no longer :) - Aligorith. Scripts */
+ CONSTRAINT_TYPE_ACTION = 12,
+ CONSTRAINT_TYPE_LOCKTRACK = 13, /* New Tracking constraint that locks an axis in place - theeth */
+ CONSTRAINT_TYPE_DISTLIMIT = 14, /* limit distance */
+ CONSTRAINT_TYPE_STRETCHTO = 15, /* claiming this to be mine :) is in tuhopuu bjornmose */
+ CONSTRAINT_TYPE_MINMAX = 16, /* floor constraint */
+ CONSTRAINT_TYPE_RIGIDBODYJOINT = 17, /* rigidbody constraint */
+ CONSTRAINT_TYPE_CLAMPTO = 18, /* clampto constraint */
+ CONSTRAINT_TYPE_TRANSFORM = 19, /* transformation (loc/rot/size -> loc/rot/size) constraint */
+ CONSTRAINT_TYPE_SHRINKWRAP = 20, /* shrinkwrap (loc/rot) constraint */
+ CONSTRAINT_TYPE_DAMPTRACK = 21, /* New Tracking constraint that minimises twisting */
+ CONSTRAINT_TYPE_SPLINEIK = 22, /* Spline-IK - Align 'n' bones to a curve */
+ CONSTRAINT_TYPE_TRANSLIKE = 23, /* Copy transform matrix */
+ CONSTRAINT_TYPE_SAMEVOL = 24, /* Maintain volume during scaling */
+ CONSTRAINT_TYPE_PIVOT = 25, /* Pivot Constraint */
+ CONSTRAINT_TYPE_FOLLOWTRACK = 26, /* Follow Track Constraint */
+ CONSTRAINT_TYPE_CAMERASOLVER = 27, /* Camera Solver Constraint */
+ CONSTRAINT_TYPE_OBJECTSOLVER = 28, /* Object Solver Constraint */
/* NOTE: no constraints are allowed to be added after this */
NUM_CONSTRAINT_TYPES
@@ -504,13 +504,13 @@ typedef enum eBConstraint_SpaceTypes {
/* for objects (relative to parent/without parent influence),
* for bones (along normals of bone, without parent/restpositions)
*/
- CONSTRAINT_SPACE_LOCAL, /* = 1 */
+ CONSTRAINT_SPACE_LOCAL = 1,
/* for posechannels - pose space */
- CONSTRAINT_SPACE_POSE, /* = 2 */
+ CONSTRAINT_SPACE_POSE = 2,
/* for posechannels - local with parent */
- CONSTRAINT_SPACE_PARLOCAL, /* = 3 */
+ CONSTRAINT_SPACE_PARLOCAL = 3,
/* for files from between 2.43-2.46 (should have been parlocal) */
- CONSTRAINT_SPACE_INVALID /* = 4. do not exchange for anything! */
+ CONSTRAINT_SPACE_INVALID = 4 /* do not exchange for anything! */
} eBConstraint_SpaceTypes;
/* bConstraintChannel.flag */
@@ -557,32 +557,38 @@ typedef enum eCopyScale_Flags {
/* bSameVolumeConstraint.flag */
typedef enum eSameVolume_Modes {
SAMEVOL_X = 0,
- SAMEVOL_Y,
- SAMEVOL_Z
+ SAMEVOL_Y = 1,
+ SAMEVOL_Z = 2
} eSameVolume_Modes;
+/* bActionConstraint.flag */
+typedef enum eActionConstraint_Flags {
+ /* Bones use "object" part of target action, instead of "same bone name" part */
+ ACTCON_BONE_USE_OBJECT_ACTION = (1 << 0),
+} eActionConstraint_Flags;
+
/* Locked-Axis Values (Locked Track) */
typedef enum eLockAxis_Modes {
- LOCK_X = 0,
- LOCK_Y,
- LOCK_Z
+ LOCK_X = 0,
+ LOCK_Y = 1,
+ LOCK_Z = 2
} eLockAxis_Modes;
/* Up-Axis Values (TrackTo and Locked Track) */
typedef enum eUpAxis_Modes {
- UP_X = 0,
- UP_Y,
- UP_Z
+ UP_X = 0,
+ UP_Y = 1,
+ UP_Z = 2
} eUpAxis_Modes;
/* Tracking axis (TrackTo, Locked Track, Damped Track) and minmax (floor) constraint */
typedef enum eTrackToAxis_Modes {
TRACK_X = 0,
- TRACK_Y,
- TRACK_Z,
- TRACK_nX,
- TRACK_nY,
- TRACK_nZ
+ TRACK_Y = 1,
+ TRACK_Z = 2,
+ TRACK_nX = 3,
+ TRACK_nY = 4,
+ TRACK_nZ = 5
} eTrackToAxis_Modes;
/* FollowPath flags */
@@ -600,24 +606,24 @@ typedef enum eTrackTo_Flags {
/* Strech To Constraint -> volmode */
typedef enum eStretchTo_VolMode {
VOLUME_XZ = 0,
- VOLUME_X,
- VOLUME_Z,
- NO_VOLUME
+ VOLUME_X = 1,
+ VOLUME_Z = 2,
+ NO_VOLUME = 3
} eStretchTo_VolMode;
/* Stretch To Constraint -> plane mode */
typedef enum eStretchTo_PlaneMode {
PLANE_X = 0,
- PLANE_Y,
- PLANE_Z
+ PLANE_Y = 1,
+ PLANE_Z = 2
} eStretchTo_PlaneMode;
/* Clamp-To Constraint ->flag */
typedef enum eClampTo_Modes {
CLAMPTO_AUTO = 0,
- CLAMPTO_X,
- CLAMPTO_Y,
- CLAMPTO_Z
+ CLAMPTO_X = 1,
+ CLAMPTO_Y = 2,
+ CLAMPTO_Z = 3
} eClampTo_Modes;
/* ClampTo Constraint ->flag2 */
@@ -667,9 +673,9 @@ typedef enum eSplineIK_XZScaleModes {
/* no x/z scaling */
CONSTRAINT_SPLINEIK_XZS_NONE = 0,
/* bones in the chain should take their x/z scales from the original scaling */
- CONSTRAINT_SPLINEIK_XZS_ORIGINAL,
+ CONSTRAINT_SPLINEIK_XZS_ORIGINAL = 1,
/* x/z scales are the inverse of the y-scale */
- CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC
+ CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC = 2
} eSplineIK_XZScaleModes;
/* MinMax (floor) flags */
@@ -715,9 +721,9 @@ typedef enum eDistLimit_Flag {
/* bDistLimitConstraint->mode */
typedef enum eDistLimit_Modes {
- LIMITDIST_INSIDE = 0,
- LIMITDIST_OUTSIDE,
- LIMITDIST_ONSURFACE
+ LIMITDIST_INSIDE = 0,
+ LIMITDIST_OUTSIDE = 1,
+ LIMITDIST_ONSURFACE = 2
} eDistLimit_Modes;
/* python constraint -> flag */
@@ -747,18 +753,18 @@ typedef enum ePivotConstraint_Axis {
PIVOTCON_AXIS_NONE = -1,
/* consider -ve x-axis rotations */
- PIVOTCON_AXIS_X_NEG,
+ PIVOTCON_AXIS_X_NEG = 0,
/* consider -ve y-axis rotations */
- PIVOTCON_AXIS_Y_NEG,
+ PIVOTCON_AXIS_Y_NEG = 1,
/* consider -ve z-axis rotations */
- PIVOTCON_AXIS_Z_NEG,
+ PIVOTCON_AXIS_Z_NEG = 2,
/* consider +ve x-axis rotations */
- PIVOTCON_AXIS_X,
+ PIVOTCON_AXIS_X = 3,
/* consider +ve y-axis rotations */
- PIVOTCON_AXIS_Y,
+ PIVOTCON_AXIS_Y = 4,
/* consider +ve z-axis rotations */
- PIVOTCON_AXIS_Z
+ PIVOTCON_AXIS_Z = 5
} ePivotConstraint_Axis;
/* settings for Pivot Constraint in general */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index da8458d587e..f5c0148d9d0 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -315,26 +315,26 @@ typedef struct Curve {
/* h1 h2 (beztriple) */
typedef enum eBezTriple_Handle {
- HD_FREE = 0,
- HD_AUTO,
- HD_VECT,
- HD_ALIGN,
- HD_AUTO_ANIM /* auto-clamped handles for animation */
+ HD_FREE = 0,
+ HD_AUTO = 1,
+ HD_VECT = 2,
+ HD_ALIGN = 3,
+ HD_AUTO_ANIM = 4 /* auto-clamped handles for animation */
} eBezTriple_Handle;
/* interpolation modes (used only for BezTriple->ipo) */
typedef enum eBezTriple_Interpolation {
BEZT_IPO_CONST = 0, /* constant interpolation */
- BEZT_IPO_LIN, /* linear interpolation */
- BEZT_IPO_BEZ /* bezier interpolation */
+ BEZT_IPO_LIN = 1, /* linear interpolation */
+ BEZT_IPO_BEZ = 2 /* bezier interpolation */
} eBezTriple_Interpolation;
/* types of keyframe (used only for BezTriple->hide when BezTriple is used in F-Curves) */
typedef enum eBezTriple_KeyframeType {
BEZT_KEYTYPE_KEYFRAME = 0, /* default - 'proper' Keyframe */
- BEZT_KEYTYPE_EXTREME, /* 'extreme' keyframe */
- BEZT_KEYTYPE_BREAKDOWN, /* 'breakdown' keyframe */
- BEZT_KEYTYPE_JITTER, /* 'jitter' keyframe (for adding 'filler' secondary motion) */
+ BEZT_KEYTYPE_EXTREME = 1, /* 'extreme' keyframe */
+ BEZT_KEYTYPE_BREAKDOWN = 2, /* 'breakdown' keyframe */
+ BEZT_KEYTYPE_JITTER = 3, /* 'jitter' keyframe (for adding 'filler' secondary motion) */
} eBezTriple_KeyframeType;
/* checks if the given BezTriple is selected */
diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h
index 20701f9adc0..52fedd72e86 100644
--- a/source/blender/makesdna/DNA_mask_types.h
+++ b/source/blender/makesdna/DNA_mask_types.h
@@ -155,9 +155,9 @@ typedef struct MaskLayer {
/* SpaceClip->mask_draw_type */
enum {
MASK_DT_OUTLINE = 0,
- MASK_DT_DASH,
- MASK_DT_BLACK,
- MASK_DT_WHITE
+ MASK_DT_DASH = 1,
+ MASK_DT_BLACK = 2,
+ MASK_DT_WHITE = 3
};
/* masklay->blend */
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index cf8b08549f6..4172db90c05 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -35,49 +35,49 @@
* (ONLY ADD NEW ITEMS AT THE END) */
typedef enum ModifierType {
- eModifierType_None = 0,
- eModifierType_Subsurf,
- eModifierType_Lattice,
- eModifierType_Curve,
- eModifierType_Build,
- eModifierType_Mirror,
- eModifierType_Decimate,
- eModifierType_Wave,
- eModifierType_Armature,
- eModifierType_Hook,
- eModifierType_Softbody,
- eModifierType_Boolean,
- eModifierType_Array,
- eModifierType_EdgeSplit,
- eModifierType_Displace,
- eModifierType_UVProject,
- eModifierType_Smooth,
- eModifierType_Cast,
- eModifierType_MeshDeform,
- eModifierType_ParticleSystem,
- eModifierType_ParticleInstance,
- eModifierType_Explode,
- eModifierType_Cloth,
- eModifierType_Collision,
- eModifierType_Bevel,
- eModifierType_Shrinkwrap,
- eModifierType_Fluidsim,
- eModifierType_Mask,
- eModifierType_SimpleDeform,
- eModifierType_Multires,
- eModifierType_Surface,
- eModifierType_Smoke,
- eModifierType_ShapeKey,
- eModifierType_Solidify,
- eModifierType_Screw,
- eModifierType_Warp,
- eModifierType_WeightVGEdit,
- eModifierType_WeightVGMix,
- eModifierType_WeightVGProximity,
- eModifierType_Ocean,
- eModifierType_DynamicPaint,
- eModifierType_Remesh,
- eModifierType_Skin,
+ eModifierType_None = 0,
+ eModifierType_Subsurf = 1,
+ eModifierType_Lattice = 2,
+ eModifierType_Curve = 3,
+ eModifierType_Build = 4,
+ eModifierType_Mirror = 5,
+ eModifierType_Decimate = 6,
+ eModifierType_Wave = 7,
+ eModifierType_Armature = 8,
+ eModifierType_Hook = 9,
+ eModifierType_Softbody = 10,
+ eModifierType_Boolean = 11,
+ eModifierType_Array = 12,
+ eModifierType_EdgeSplit = 13,
+ eModifierType_Displace = 14,
+ eModifierType_UVProject = 15,
+ eModifierType_Smooth = 16,
+ eModifierType_Cast = 17,
+ eModifierType_MeshDeform = 18,
+ eModifierType_ParticleSystem = 19,
+ eModifierType_ParticleInstance = 20,
+ eModifierType_Explode = 21,
+ eModifierType_Cloth = 22,
+ eModifierType_Collision = 23,
+ eModifierType_Bevel = 24,
+ eModifierType_Shrinkwrap = 25,
+ eModifierType_Fluidsim = 26,
+ eModifierType_Mask = 27,
+ eModifierType_SimpleDeform = 28,
+ eModifierType_Multires = 29,
+ eModifierType_Surface = 30,
+ eModifierType_Smoke = 31,
+ eModifierType_ShapeKey = 32,
+ eModifierType_Solidify = 33,
+ eModifierType_Screw = 34,
+ eModifierType_Warp = 35,
+ eModifierType_WeightVGEdit = 36,
+ eModifierType_WeightVGMix = 37,
+ eModifierType_WeightVGProximity = 38,
+ eModifierType_Ocean = 39,
+ eModifierType_DynamicPaint = 40,
+ eModifierType_Remesh = 41,
+ eModifierType_Skin = 42,
NUM_MODIFIER_TYPES
} ModifierType;
@@ -327,19 +327,19 @@ typedef struct DisplaceModifierData {
/* DisplaceModifierData->direction */
enum {
- MOD_DISP_DIR_X,
- MOD_DISP_DIR_Y,
- MOD_DISP_DIR_Z,
- MOD_DISP_DIR_NOR,
- MOD_DISP_DIR_RGB_XYZ,
+ MOD_DISP_DIR_X = 0,
+ MOD_DISP_DIR_Y = 1,
+ MOD_DISP_DIR_Z = 2,
+ MOD_DISP_DIR_NOR = 3,
+ MOD_DISP_DIR_RGB_XYZ = 4,
};
/* DisplaceModifierData->texmapping */
enum {
- MOD_DISP_MAP_LOCAL,
- MOD_DISP_MAP_GLOBAL,
- MOD_DISP_MAP_OBJECT,
- MOD_DISP_MAP_UV
+ MOD_DISP_MAP_LOCAL = 0,
+ MOD_DISP_MAP_GLOBAL = 1,
+ MOD_DISP_MAP_OBJECT = 2,
+ MOD_DISP_MAP_UV = 3
};
typedef struct UVProjectModifierData {
@@ -509,9 +509,9 @@ typedef struct SurfaceModifierData {
} SurfaceModifierData;
typedef enum {
- eBooleanModifierOp_Intersect,
- eBooleanModifierOp_Union,
- eBooleanModifierOp_Difference,
+ eBooleanModifierOp_Intersect = 0,
+ eBooleanModifierOp_Union = 1,
+ eBooleanModifierOp_Difference = 2,
} BooleanModifierOp;
typedef struct BooleanModifierData {
ModifierData modifier;
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index b9d63167700..d8bba4a3bf5 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -47,97 +47,105 @@ struct MovieTrackingTrack;
struct MovieTrackingMarker;
typedef struct MovieClipUser {
- int framenr; /* current frame number */
- short render_size, render_flag; /* proxy render size */
+ int framenr; /* current frame number */
+ short render_size, render_flag; /* proxy render size */
} MovieClipUser;
typedef struct MovieClipProxy {
- char dir[768]; /* 768=FILE_MAXDIR custom directory for index and proxy files (defaults to BL_proxy) */
+ char dir[768]; /* 768=FILE_MAXDIR custom directory for index and proxy files (defaults to BL_proxy) */
- short tc; /* time code in use */
- short quality; /* proxy build quality */
- short build_size_flag; /* size flags (see below) of all proxies to build */
- short build_tc_flag; /* time code flags (see below) of all tc indices to build */
+ short tc; /* time code in use */
+ short quality; /* proxy build quality */
+ short build_size_flag; /* size flags (see below) of all proxies to build */
+ short build_tc_flag; /* time code flags (see below) of all tc indices to build */
} MovieClipProxy;
typedef struct MovieClip {
ID id;
- struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
+ struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
- char name[1024]; /* file path, 1024 = FILE_MAX */
+ char name[1024]; /* file path, 1024 = FILE_MAX */
- int source; /* sequence or movie */
- int lastframe; /* last accessed frame number */
- int lastsize[2]; /* size of last accessed frame */
+ int source; /* sequence or movie */
+ int lastframe; /* last accessed frame number */
+ int lastsize[2]; /* size of last accessed frame */
- float aspx, aspy; /* display aspect */
+ float aspx, aspy; /* display aspect */
- struct anim *anim; /* movie source data */
- struct MovieClipCache *cache; /* cache for different stuff, not in file */
- struct bGPdata *gpd; /* grease pencil data */
+ struct anim *anim; /* movie source data */
+ struct MovieClipCache *cache; /* cache for different stuff, not in file */
+ struct bGPdata *gpd; /* grease pencil data */
- struct MovieTracking tracking; /* data for SfM tracking */
- void *tracking_context; /* context of tracking job
- * used to synchronize data like framenumber
- * in SpaceClip clip user */
+ struct MovieTracking tracking; /* data for SfM tracking */
+ void *tracking_context; /* context of tracking job
+ * used to synchronize data like framenumber
+ * in SpaceClip clip user */
- struct MovieClipProxy proxy; /* proxy to clip data */
+ struct MovieClipProxy proxy; /* proxy to clip data */
int flag;
- int len; /* length of movie */
+ int len; /* length of movie */
- int start_frame, pad;
+ int start_frame; /* scene frame number footage starts playing at */
+ /* affects all data which is associated with a clip */
+ /* such as motion tracking, camera reconstruciton and so */
+
+ int frame_offset; /* offset which is adding to a file number when reading frame */
+ /* from a file. affects only a way how scene frame is mapping */
+ /* to a file name and not touches other data associated with */
+ /* a clip */
} MovieClip;
typedef struct MovieClipScopes {
- int ok; /* 1 means scopes are ok and recalculation is unneeded */
- int track_preview_height; /* height of track preview widget */
- int frame_width, frame_height; /* width and height of frame for which scopes are calculated */
- struct MovieTrackingMarker undist_marker; /* undistorted position of marker used for pattern sampling */
- struct ImBuf *track_search; /* search area of a track */
- struct ImBuf *track_preview; /* ImBuf displayed in track preview */
- float track_pos[2]; /* sub-pizel position of marker in track ImBuf */
- short track_disabled; /* active track is disabled, special notifier should be drawn */
- char pad[2];
- int framenr; /* frame number scopes are created for */
- struct MovieTrackingTrack *track; /* track scopes are created for */
- struct MovieTrackingMarker *marker; /* marker scopes are created for */
- float slide_scale[2]; /* scale used for sliding from previewe area */
+ short ok; /* 1 means scopes are ok and recalculation is unneeded */
+ short use_track_mask; /* whether track's mask should be applied on preview */
+ int track_preview_height; /* height of track preview widget */
+ int frame_width, frame_height; /* width and height of frame for which scopes are calculated */
+ struct MovieTrackingMarker undist_marker; /* undistorted position of marker used for pattern sampling */
+ struct ImBuf *track_search; /* search area of a track */
+ struct ImBuf *track_preview; /* ImBuf displayed in track preview */
+ float track_pos[2]; /* sub-pizel position of marker in track ImBuf */
+ short track_disabled; /* active track is disabled, special notifier should be drawn */
+ short track_locked; /* active track is locked, no transformation should be allowed */
+ int framenr; /* frame number scopes are created for */
+ struct MovieTrackingTrack *track; /* track scopes are created for */
+ struct MovieTrackingMarker *marker; /* marker scopes are created for */
+ float slide_scale[2]; /* scale used for sliding from previewe area */
} MovieClipScopes;
/* MovieClipProxy->build_size_flag */
-#define MCLIP_PROXY_SIZE_25 (1<<0)
-#define MCLIP_PROXY_SIZE_50 (1<<1)
-#define MCLIP_PROXY_SIZE_75 (1<<2)
-#define MCLIP_PROXY_SIZE_100 (1<<3)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_25 (1<<4)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_50 (1<<5)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_75 (1<<6)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_100 (1<<7)
+#define MCLIP_PROXY_SIZE_25 (1 << 0)
+#define MCLIP_PROXY_SIZE_50 (1 << 1)
+#define MCLIP_PROXY_SIZE_75 (1 << 2)
+#define MCLIP_PROXY_SIZE_100 (1 << 3)
+#define MCLIP_PROXY_UNDISTORTED_SIZE_25 (1 << 4)
+#define MCLIP_PROXY_UNDISTORTED_SIZE_50 (1 << 5)
+#define MCLIP_PROXY_UNDISTORTED_SIZE_75 (1 << 6)
+#define MCLIP_PROXY_UNDISTORTED_SIZE_100 (1 << 7)
/* MovieClip->source */
-#define MCLIP_SRC_SEQUENCE 1
-#define MCLIP_SRC_MOVIE 2
+#define MCLIP_SRC_SEQUENCE 1
+#define MCLIP_SRC_MOVIE 2
/* MovieClip->selection types */
-#define MCLIP_SEL_NONE 0
-#define MCLIP_SEL_TRACK 1
+#define MCLIP_SEL_NONE 0
+#define MCLIP_SEL_TRACK 1
/* MovieClip->flag */
-#define MCLIP_USE_PROXY (1<<0)
-#define MCLIP_USE_PROXY_CUSTOM_DIR (1<<1)
+#define MCLIP_USE_PROXY (1 << 0)
+#define MCLIP_USE_PROXY_CUSTOM_DIR (1 << 1)
/*#define MCLIP_CUSTOM_START_FRAME (1<<2)*/ /* UNUSED */
-#define MCLIP_TIMECODE_FLAGS (MCLIP_USE_PROXY|MCLIP_USE_PROXY_CUSTOM_DIR)
+#define MCLIP_TIMECODE_FLAGS (MCLIP_USE_PROXY | MCLIP_USE_PROXY_CUSTOM_DIR)
/* MovieClip->render_size */
-#define MCLIP_PROXY_RENDER_SIZE_FULL 0
-#define MCLIP_PROXY_RENDER_SIZE_25 1
-#define MCLIP_PROXY_RENDER_SIZE_50 2
-#define MCLIP_PROXY_RENDER_SIZE_75 3
-#define MCLIP_PROXY_RENDER_SIZE_100 4
+#define MCLIP_PROXY_RENDER_SIZE_FULL 0
+#define MCLIP_PROXY_RENDER_SIZE_25 1
+#define MCLIP_PROXY_RENDER_SIZE_50 2
+#define MCLIP_PROXY_RENDER_SIZE_75 3
+#define MCLIP_PROXY_RENDER_SIZE_100 4
/* MovieClip->render_flag */
-#define MCLIP_PROXY_RENDER_UNDISTORT 1
+#define MCLIP_PROXY_RENDER_UNDISTORT 1
#endif
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 5be7688d714..a10d610c6d4 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -628,6 +628,20 @@ typedef struct TexNodeOutput {
char name[64];
} TexNodeOutput;
+typedef struct NodeKeyingScreenData {
+ char tracking_object[64];
+} NodeKeyingScreenData;
+
+typedef struct NodeKeyingData {
+ float screen_balance;
+ float despill_factor;
+ int edge_kernel_radius;
+ float edge_kernel_tolerance;
+ float clip_black, clip_white;
+ int dilate_distance;
+ int blur_pre, blur_post;
+} NodeKeyingData;
+
/* frame node flags */
#define NODE_FRAME_SHRINK 1 /* keep the bounding box minimal */
#define NODE_FRAME_RESIZEABLE 2 /* test flag, if frame can be resized by user */
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index cc212dd6d06..854087b3b5b 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -40,20 +40,20 @@ extern "C" {
/* pd->forcefield: Effector Fields types */
typedef enum PFieldType {
- PFIELD_NULL = 0, /* (this is used for general effector weight) */
- PFIELD_FORCE, /* Force away/towards a point depending on force strength */
- PFIELD_VORTEX, /* Force around the effector normal */
- PFIELD_MAGNET, /* Force from the cross product of effector normal and point velocity */
- PFIELD_WIND, /* Force away and towards a point depending which side of the effector */
- /* normal the point is */
- PFIELD_GUIDE, /* Force along curve for dynamics, a shaping curve for hair paths */
- PFIELD_TEXTURE, /* Force based on texture values calculated at point coordinates */
- PFIELD_HARMONIC, /* Force of a harmonic (damped) oscillator */
- PFIELD_CHARGE, /* Force away/towards a point depending on point charge */
- PFIELD_LENNARDJ, /* Force due to a Lennard-Jones potential */
- PFIELD_BOID, /* Defines predator / goal for boids */
- PFIELD_TURBULENCE, /* Force defined by BLI_gTurbulence */
- PFIELD_DRAG, /* Linear & quadratic drag */
+ PFIELD_NULL = 0, /* (this is used for general effector weight) */
+ PFIELD_FORCE = 1, /* Force away/towards a point depending on force strength */
+ PFIELD_VORTEX = 2, /* Force around the effector normal */
+ PFIELD_MAGNET = 3, /* Force from the cross product of effector normal and point velocity */
+ PFIELD_WIND = 4, /* Force away and towards a point depending which side of the effector */
+ /* normal the point is */
+ PFIELD_GUIDE = 5, /* Force along curve for dynamics, a shaping curve for hair paths */
+ PFIELD_TEXTURE = 6, /* Force based on texture values calculated at point coordinates */
+ PFIELD_HARMONIC = 7, /* Force of a harmonic (damped) oscillator */
+ PFIELD_CHARGE = 8, /* Force away/towards a point depending on point charge */
+ PFIELD_LENNARDJ = 9, /* Force due to a Lennard-Jones potential */
+ PFIELD_BOID = 10, /* Defines predator / goal for boids */
+ PFIELD_TURBULENCE = 11, /* Force defined by BLI_gTurbulence */
+ PFIELD_DRAG = 12, /* Linear & quadratic drag */
NUM_PFIELD_TYPES
} PFieldType;
diff --git a/source/blender/makesdna/DNA_packedFile_types.h b/source/blender/makesdna/DNA_packedFile_types.h
index 339ac0f8c0d..f01e89d18c9 100644
--- a/source/blender/makesdna/DNA_packedFile_types.h
+++ b/source/blender/makesdna/DNA_packedFile_types.h
@@ -43,18 +43,18 @@ typedef struct PackedFile {
enum PF_FileStatus
{
PF_EQUAL = 0,
- PF_DIFFERS,
- PF_NOFILE,
+ PF_DIFFERS = 1,
+ PF_NOFILE = 2,
- PF_WRITE_ORIGINAL,
- PF_WRITE_LOCAL,
- PF_USE_LOCAL,
- PF_USE_ORIGINAL,
- PF_KEEP,
- PF_REMOVE,
- PF_NOOP,
+ PF_WRITE_ORIGINAL = 3,
+ PF_WRITE_LOCAL = 4,
+ PF_USE_LOCAL = 5,
+ PF_USE_ORIGINAL = 6,
+ PF_KEEP = 7,
+ PF_REMOVE = 8,
+ PF_NOOP = 9,
- PF_ASK
+ PF_ASK = 10
};
#endif /* PACKEDFILE_TYPES_H */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index eb6742aa9f9..59f91869780 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -34,7 +34,7 @@
#include "DNA_defs.h"
-// XXX, temp feature - campbell
+/* XXX, temp feature - campbell */
#define DURIAN_CAMERA_SWITCH
#ifdef __cplusplus
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 75d9b91e9c8..34fb7ce60be 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -225,13 +225,13 @@ typedef struct ARegion {
/* Do NOT change order, append on end. Types are hardcoded needed */
enum {
RGN_TYPE_WINDOW = 0,
- RGN_TYPE_HEADER,
- RGN_TYPE_CHANNELS,
- RGN_TYPE_TEMPORARY,
- RGN_TYPE_UI,
- RGN_TYPE_TOOLS,
- RGN_TYPE_TOOL_PROPS,
- RGN_TYPE_PREVIEW
+ RGN_TYPE_HEADER = 1,
+ RGN_TYPE_CHANNELS = 2,
+ RGN_TYPE_TEMPORARY = 3,
+ RGN_TYPE_UI = 4,
+ RGN_TYPE_TOOLS = 5,
+ RGN_TYPE_TOOL_PROPS = 6,
+ RGN_TYPE_PREVIEW = 7
};
/* region alignment */
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index 6f67f1fd3c9..6dc45e4a6de 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -104,8 +104,8 @@ typedef struct bSound {
typedef enum eSound_Type {
SOUND_TYPE_INVALID = -1,
SOUND_TYPE_FILE = 0,
- SOUND_TYPE_BUFFER,
- SOUND_TYPE_LIMITER
+ SOUND_TYPE_BUFFER = 1,
+ SOUND_TYPE_LIMITER = 2
} eSound_Type;
#endif
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index a315feed6c5..2f6ea861cba 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -35,11 +35,11 @@
#include "DNA_defs.h"
#include "DNA_listBase.h"
-#include "DNA_color_types.h" /* for Histogram */
+#include "DNA_color_types.h" /* for Histogram */
#include "DNA_vec_types.h"
-#include "DNA_outliner_types.h" /* for TreeStoreElem */
-#include "DNA_image_types.h" /* ImageUser */
-#include "DNA_movieclip_types.h" /* MovieClipUser */
+#include "DNA_outliner_types.h" /* for TreeStoreElem */
+#include "DNA_image_types.h" /* ImageUser */
+#include "DNA_movieclip_types.h" /* MovieClipUser */
/* Hum ... Not really nice... but needed for spacebuts. */
#include "DNA_view2d_types.h"
@@ -79,9 +79,9 @@ struct Mask;
*/
typedef struct SpaceLink {
struct SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED; /* XXX make deprecated */
+ float blockscale DNA_DEPRECATED; /* XXX make deprecated */
short blockhandler[8] DNA_DEPRECATED; /* XXX make deprecated */
} SpaceLink;
@@ -91,10 +91,10 @@ typedef struct SpaceLink {
/* Info Header */
typedef struct SpaceInfo {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
- short blockhandler[8] DNA_DEPRECATED; /* XXX make deprecated */
+ float blockscale DNA_DEPRECATED;
+ short blockhandler[8] DNA_DEPRECATED; /* XXX make deprecated */
char rpt_mask;
char pad[7];
@@ -102,11 +102,11 @@ typedef struct SpaceInfo {
/* SpaceInfo.rpt_mask */
typedef enum eSpaceInfo_RptMask {
- INFO_RPT_DEBUG = (1 << 0),
- INFO_RPT_INFO = (1 << 1),
- INFO_RPT_OP = (1 << 2),
- INFO_RPT_WARN = (1 << 3),
- INFO_RPT_ERR = (1 << 4),
+ INFO_RPT_DEBUG = (1 << 0),
+ INFO_RPT_INFO = (1 << 1),
+ INFO_RPT_OP = (1 << 2),
+ INFO_RPT_WARN = (1 << 3),
+ INFO_RPT_ERR = (1 << 4),
} eSpaceInfo_RptMask;
@@ -115,22 +115,22 @@ typedef enum eSpaceInfo_RptMask {
/* Properties Editor */
typedef struct SpaceButs {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
+ View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
- short mainb, mainbo, mainbuser; /* context tabs */
- short re_align, align; /* align for panels */
- short preview; /* preview is signal to refresh */
- short texture_context; /* texture context selector (material, world, brush)*/
+ short mainb, mainbo, mainbuser; /* context tabs */
+ short re_align, align; /* align for panels */
+ short preview; /* preview is signal to refresh */
+ short texture_context; /* texture context selector (material, world, brush)*/
char flag, pad;
- void *path; /* runtime */
- int pathflag, dataicon; /* runtime */
+ void *path; /* runtime */
+ int pathflag, dataicon; /* runtime */
ID *pinid;
void *texuser;
@@ -139,87 +139,87 @@ typedef struct SpaceButs {
/* button defines (deprecated) */
/* warning: the values of these defines are used in sbuts->tabs[8] */
/* sbuts->mainb new */
-#define CONTEXT_SCENE 0
-#define CONTEXT_OBJECT 1
-#define CONTEXT_TYPES 2
-#define CONTEXT_SHADING 3
-#define CONTEXT_EDITING 4
-#define CONTEXT_SCRIPT 5
-#define CONTEXT_LOGIC 6
+#define CONTEXT_SCENE 0
+#define CONTEXT_OBJECT 1
+#define CONTEXT_TYPES 2
+#define CONTEXT_SHADING 3
+#define CONTEXT_EDITING 4
+#define CONTEXT_SCRIPT 5
+#define CONTEXT_LOGIC 6
/* sbuts->mainb old (deprecated) */
-#define BUTS_VIEW 0
-#define BUTS_LAMP 1
-#define BUTS_MAT 2
-#define BUTS_TEX 3
-#define BUTS_ANIM 4
-#define BUTS_WORLD 5
-#define BUTS_RENDER 6
-#define BUTS_EDIT 7
-#define BUTS_GAME 8
-#define BUTS_FPAINT 9
-#define BUTS_RADIO 10
-#define BUTS_SCRIPT 11
-#define BUTS_SOUND 12
-#define BUTS_CONSTRAINT 13
-#define BUTS_EFFECTS 14
+#define BUTS_VIEW 0
+#define BUTS_LAMP 1
+#define BUTS_MAT 2
+#define BUTS_TEX 3
+#define BUTS_ANIM 4
+#define BUTS_WORLD 5
+#define BUTS_RENDER 6
+#define BUTS_EDIT 7
+#define BUTS_GAME 8
+#define BUTS_FPAINT 9
+#define BUTS_RADIO 10
+#define BUTS_SCRIPT 11
+#define BUTS_SOUND 12
+#define BUTS_CONSTRAINT 13
+#define BUTS_EFFECTS 14
/* buts->mainb new */
typedef enum eSpaceButtons_Context {
BCONTEXT_RENDER = 0,
- BCONTEXT_SCENE,
- BCONTEXT_WORLD,
- BCONTEXT_OBJECT,
- BCONTEXT_DATA,
- BCONTEXT_MATERIAL,
- BCONTEXT_TEXTURE,
- BCONTEXT_PARTICLE,
- BCONTEXT_PHYSICS,
- BCONTEXT_BONE,
- BCONTEXT_MODIFIER,
- BCONTEXT_CONSTRAINT,
- BCONTEXT_BONE_CONSTRAINT,
+ BCONTEXT_SCENE = 1,
+ BCONTEXT_WORLD = 2,
+ BCONTEXT_OBJECT = 3,
+ BCONTEXT_DATA = 4,
+ BCONTEXT_MATERIAL = 5,
+ BCONTEXT_TEXTURE = 6,
+ BCONTEXT_PARTICLE = 7,
+ BCONTEXT_PHYSICS = 8,
+ BCONTEXT_BONE = 9,
+ BCONTEXT_MODIFIER = 10,
+ BCONTEXT_CONSTRAINT = 11,
+ BCONTEXT_BONE_CONSTRAINT = 12,
/* always as last... */
BCONTEXT_TOT
} eSpaceButtons_Context;
/* sbuts->flag */
-#define SB_PRV_OSA 1
-#define SB_PIN_CONTEXT 2
+#define SB_PRV_OSA 1
+#define SB_PIN_CONTEXT 2
//#define SB_WORLD_TEX 4 //not used anymore
//#define SB_BRUSH_TEX 8 //not used anymore
-#define SB_SHADING_CONTEXT 16
+#define SB_SHADING_CONTEXT 16
/* sbuts->texture_context */
typedef enum eSpaceButtons_Texture_Context {
SB_TEXC_MAT_OR_LAMP = 0,
- SB_TEXC_WORLD,
- SB_TEXC_BRUSH,
- SB_TEXC_PARTICLES,
+ SB_TEXC_WORLD = 1,
+ SB_TEXC_BRUSH = 2,
+ SB_TEXC_PARTICLES = 3,
} eSpaceButtons_Texture_Context;
/* sbuts->align */
typedef enum eSpaceButtons_Align {
BUT_FREE = 0,
- BUT_HORIZONTAL,
- BUT_VERTICAL,
- BUT_AUTO,
+ BUT_HORIZONTAL = 1,
+ BUT_VERTICAL = 2,
+ BUT_AUTO = 3,
} eSpaceButtons_Align;
/* sbuts->scaflag */
-#define BUTS_SENS_SEL 1
-#define BUTS_SENS_ACT 2
-#define BUTS_SENS_LINK 4
-#define BUTS_CONT_SEL 8
-#define BUTS_CONT_ACT 16
-#define BUTS_CONT_LINK 32
-#define BUTS_ACT_SEL 64
-#define BUTS_ACT_ACT 128
-#define BUTS_ACT_LINK 256
-#define BUTS_SENS_STATE 512
-#define BUTS_ACT_STATE 1024
-#define BUTS_CONT_INIT_STATE 2048
+#define BUTS_SENS_SEL 1
+#define BUTS_SENS_ACT 2
+#define BUTS_SENS_LINK 4
+#define BUTS_CONT_SEL 8
+#define BUTS_CONT_ACT 16
+#define BUTS_CONT_LINK 32
+#define BUTS_ACT_SEL 64
+#define BUTS_ACT_ACT 128
+#define BUTS_ACT_LINK 256
+#define BUTS_SENS_STATE 512
+#define BUTS_ACT_STATE 1024
+#define BUTS_CONT_INIT_STATE 2048
/* Outliner =============================================== */
@@ -227,12 +227,12 @@ typedef enum eSpaceButtons_Align {
/* Outliner */
typedef struct SpaceOops {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
+ View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
ListBase tree;
struct TreeStore *treestore;
@@ -256,26 +256,26 @@ typedef enum eSpaceOutliner_Flag {
/* SpaceOops->outlinevis */
typedef enum eSpaceOutliner_Mode {
SO_ALL_SCENES = 0,
- SO_CUR_SCENE,
- SO_VISIBLE,
- SO_SELECTED,
- SO_ACTIVE,
- SO_SAME_TYPE,
- SO_GROUPS,
- SO_LIBRARIES,
- SO_VERSE_SESSION,
- SO_VERSE_MS,
- SO_SEQUENCE,
- SO_DATABLOCKS,
- SO_USERDEF,
- SO_KEYMAP,
+ SO_CUR_SCENE = 1,
+ SO_VISIBLE = 2,
+ SO_SELECTED = 3,
+ SO_ACTIVE = 4,
+ SO_SAME_TYPE = 5,
+ SO_GROUPS = 6,
+ SO_LIBRARIES = 7,
+ SO_VERSE_SESSION = 8,
+ SO_VERSE_MS = 9,
+ SO_SEQUENCE = 10,
+ SO_DATABLOCKS = 11,
+ SO_USERDEF = 12,
+ SO_KEYMAP = 13,
} eSpaceOutliner_Mode;
/* SpaceOops->storeflag */
typedef enum eSpaceOutliner_StoreFlag {
- /* rebuild tree */
+ /* rebuild tree */
SO_TREESTORE_CLEANUP = (1 << 0),
- /* if set, it allows redraws. gets set for some allqueue events */
+ /* if set, it allows redraws. gets set for some allqueue events */
SO_TREESTORE_REDRAW = (1 << 1),
} eSpaceOutliner_StoreFlag;
@@ -292,23 +292,23 @@ typedef enum eSpaceOutliner_Search_Flags {
/* 'Graph' Editor (formerly known as the IPO Editor) */
typedef struct SpaceIpo {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
+ View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
- struct bDopeSheet *ads; /* settings for filtering animation data (NOTE: we use a pointer due to code-linking issues) */
+ struct bDopeSheet *ads; /* settings for filtering animation data (NOTE: we use a pointer due to code-linking issues) */
- ListBase ghostCurves; /* sampled snapshots of F-Curves used as in-session guides */
+ ListBase ghostCurves; /* sampled snapshots of F-Curves used as in-session guides */
- short mode; /* mode for the Graph editor (eGraphEdit_Mode) */
- short autosnap; /* time-transform autosnapping settings for Graph editor (eAnimEdit_AutoSnap in DNA_action_types.h) */
- int flag; /* settings for Graph editor (eGraphEdit_Flag) */
+ short mode; /* mode for the Graph editor (eGraphEdit_Mode) */
+ short autosnap; /* time-transform autosnapping settings for Graph editor (eAnimEdit_AutoSnap in DNA_action_types.h) */
+ int flag; /* settings for Graph editor (eGraphEdit_Flag) */
- float cursorVal; /* cursor value (y-value, x-value is current frame) */
- int around; /* pivot point for transforms */
+ float cursorVal; /* cursor value (y-value, x-value is current frame) */
+ int around; /* pivot point for transforms */
} SpaceIpo;
@@ -348,10 +348,10 @@ typedef enum eGraphEdit_Flag {
/* SpaceIpo->mode (Graph Editor Mode) */
typedef enum eGraphEdit_Mode {
- /* all animation curves (from all over Blender) */
- SIPO_MODE_ANIMATION = 0,
- /* drivers only */
- SIPO_MODE_DRIVERS,
+ /* all animation curves (from all over Blender) */
+ SIPO_MODE_ANIMATION = 0,
+ /* drivers only */
+ SIPO_MODE_DRIVERS = 1,
} eGraphEdit_Mode;
@@ -360,17 +360,17 @@ typedef enum eGraphEdit_Mode {
/* NLA Editor */
typedef struct SpaceNla {
struct SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
- short autosnap; /* this uses the same settings as autosnap for Action Editor */
+ short autosnap; /* this uses the same settings as autosnap for Action Editor */
short flag;
int pad;
struct bDopeSheet *ads;
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
+ View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
} SpaceNla;
/* nla->flag */
@@ -401,11 +401,11 @@ typedef struct SpaceTimeCache {
/* Timeline View */
typedef struct SpaceTime {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
+ View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
ListBase caches;
@@ -454,35 +454,35 @@ typedef enum eTimeline_Cache_Flag {
/* Sequencer */
typedef struct SpaceSeq {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
+ View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
- float xof DNA_DEPRECATED, yof DNA_DEPRECATED; /* deprecated: offset for drawing the image preview */
- short mainb; /* weird name for the sequencer subtype (seq, image, luma... etc) */
+ float xof DNA_DEPRECATED, yof DNA_DEPRECATED; /* deprecated: offset for drawing the image preview */
+ short mainb; /* weird name for the sequencer subtype (seq, image, luma... etc) */
short render_size;
short chanshown;
short zebra;
int flag;
- float zoom DNA_DEPRECATED; /* deprecated, handled by View2D now */
+ float zoom DNA_DEPRECATED; /* deprecated, handled by View2D now */
int view; /* see SEQ_VIEW_* below */
int pad;
- struct bGPdata *gpd; /* grease-pencil data */
+ struct bGPdata *gpd; /* grease-pencil data */
} SpaceSeq;
/* sseq->mainb */
typedef enum eSpaceSeq_RegionType {
SEQ_DRAW_SEQUENCE = 0,
- SEQ_DRAW_IMG_IMBUF,
- SEQ_DRAW_IMG_WAVEFORM,
- SEQ_DRAW_IMG_VECTORSCOPE,
- SEQ_DRAW_IMG_HISTOGRAM,
+ SEQ_DRAW_IMG_IMBUF = 1,
+ SEQ_DRAW_IMG_WAVEFORM = 2,
+ SEQ_DRAW_IMG_VECTORSCOPE = 3,
+ SEQ_DRAW_IMG_HISTOGRAM = 4,
} eSpaceSeq_RegionType;
/* sseq->flag */
@@ -491,15 +491,15 @@ typedef enum eSpaceSeq_Flag {
SEQ_MARKER_TRANS = (1 << 1),
SEQ_DRAW_COLOR_SEPARATED = (1 << 2),
SEQ_DRAW_SAFE_MARGINS = (1 << 3),
- SEQ_DRAW_GPENCIL = (1 << 4), /* DEPRECATED */
+/* SEQ_DRAW_GPENCIL = (1 << 4), */ /* DEPRECATED */
SEQ_NO_DRAW_CFRANUM = (1 << 5),
} eSpaceSeq_Flag;
/* sseq->view */
typedef enum eSpaceSeq_Displays {
SEQ_VIEW_SEQUENCE = 1,
- SEQ_VIEW_PREVIEW,
- SEQ_VIEW_SEQUENCE_PREVIEW,
+ SEQ_VIEW_PREVIEW = 2,
+ SEQ_VIEW_SEQUENCE_PREVIEW = 3,
} eSpaceSeq_Dispays;
/* sseq->render_size */
@@ -527,7 +527,7 @@ typedef struct FileSelectParams {
char filter_glob[64]; /* list of filetypes to filter */
- int active_file;
+ int active_file;
int sel_first;
int sel_last;
@@ -548,7 +548,7 @@ typedef struct FileSelectParams {
/* File Browser */
typedef struct SpaceFile {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
int scroll_offset;
@@ -579,41 +579,41 @@ typedef struct SpaceFile {
/* FileSelectParams.display */
enum FileDisplayTypeE {
FILE_DEFAULTDISPLAY = 0,
- FILE_SHORTDISPLAY,
- FILE_LONGDISPLAY,
- FILE_IMGDISPLAY
+ FILE_SHORTDISPLAY = 1,
+ FILE_LONGDISPLAY = 2,
+ FILE_IMGDISPLAY = 3
};
/* FileSelectParams.sort */
enum FileSortTypeE {
FILE_SORT_NONE = 0,
FILE_SORT_ALPHA = 1,
- FILE_SORT_EXTENSION,
- FILE_SORT_TIME,
- FILE_SORT_SIZE
+ FILE_SORT_EXTENSION = 2,
+ FILE_SORT_TIME = 3,
+ FILE_SORT_SIZE = 4
};
/* these values need to be hardcoded in structs, dna does not recognize defines */
/* also defined in BKE */
-#define FILE_MAXDIR 768
-#define FILE_MAXFILE 256
-#define FILE_MAX 1024
+#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
-#define FILE_BLENDER 8 /* don't display relative paths */
-#define FILE_SPECIAL 9
+#define FILE_UNIX 8
+#define FILE_BLENDER 8 /* don't display relative paths */
+#define FILE_SPECIAL 9
-#define FILE_LOADLIB 1
-#define FILE_MAIN 2
-#define FILE_LOADFONT 3
+#define FILE_LOADLIB 1
+#define FILE_MAIN 2
+#define FILE_LOADFONT 3
/* filesel op property -> action */
typedef enum eFileSel_Action {
FILE_OPENFILE = 0,
- FILE_SAVE,
+ FILE_SAVE = 1,
} eFileSel_Action;
/* sfile->params->flag and simasel->flag */
@@ -624,7 +624,7 @@ typedef enum eFileSel_Params_Flag {
FILE_HIDE_DOT = (1 << 3),
FILE_AUTOSELECT = (1 << 4),
FILE_ACTIVELAY = (1 << 5),
-/* FILE_ATCURSOR = (1 << 6), */ /* deprecated */
+/* FILE_ATCURSOR = (1 << 6), */ /* deprecated */
FILE_DIRSEL_ONLY = (1 << 7),
FILE_FILTER = (1 << 8),
FILE_BOOKMARKS = (1 << 9),
@@ -651,7 +651,7 @@ typedef enum eFileSel_File_Types {
/* Selection Flags in filesel: struct direntry, unsigned char selflag */
typedef enum eDirEntry_SelectFlag {
-/* ACTIVE_FILE = (1 << 1), */ /* UNUSED */
+/* ACTIVE_FILE = (1 << 1), */ /* UNUSED */
HILITED_FILE = (1 << 2),
SELECTED_FILE = (1 << 3),
EDITING_FILE = (1 << 4),
@@ -662,7 +662,7 @@ typedef enum eDirEntry_SelectFlag {
/* Image/UV Editor */
typedef struct SpaceImage {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
int flag;
@@ -671,15 +671,15 @@ typedef struct SpaceImage {
struct ImageUser iuser;
struct CurveMapping *cumap;
- struct Scopes scopes; /* histogram waveform and vectorscope */
- struct Histogram sample_line_hist; /* sample line histogram */
+ struct Scopes scopes; /* histogram waveform and vectorscope */
+ struct Histogram sample_line_hist; /* sample line histogram */
- struct bGPdata *gpd; /* grease pencil data */
+ struct bGPdata *gpd; /* grease pencil data */
- float cursor[2]; /* UV editor 2d cursor */
- float xof, yof; /* user defined offset, image is centered */
- float zoom; /* user defined zoom level */
- float centx, centy; /* storage for offset while render drawing */
+ float cursor[2]; /* UV editor 2d cursor */
+ float xof, yof; /* user defined offset, image is centered */
+ float zoom; /* user defined zoom level */
+ float centx, centy; /* storage for offset while render drawing */
short curtile; /* the currently active tile of the image when tile is enabled, is kept in sync with the active faces tile */
short pad;
@@ -695,15 +695,15 @@ typedef struct SpaceImage {
/* SpaceImage->dt_uv */
typedef enum eSpaceImage_UVDT {
SI_UVDT_OUTLINE = 0,
- SI_UVDT_DASH,
- SI_UVDT_BLACK,
- SI_UVDT_WHITE,
+ SI_UVDT_DASH = 1,
+ SI_UVDT_BLACK = 2,
+ SI_UVDT_WHITE = 3,
} eSpaceImage_UVDT;
/* SpaceImage->dt_uvstretch */
typedef enum eSpaceImage_UVDT_Stretch {
SI_UVDT_STRETCH_ANGLE = 0,
- SI_UVDT_STRETCH_AREA,
+ SI_UVDT_STRETCH_AREA = 1,
} eSpaceImage_UVDT_Stretch;
/* SpaceImage->sticky
@@ -717,15 +717,15 @@ typedef enum eSpaceImage_Sticky {
/* SpaceImage->flag */
typedef enum eSpaceImage_Flag {
- SI_BE_SQUARE = (1 << 0),
- SI_EDITTILE = (1 << 1),
- SI_CLIP_UV = (1 << 2),
- SI_DRAWTOOL = (1 << 3),
- SI_NO_DRAWFACES = (1 << 4),
+ SI_BE_SQUARE = (1 << 0),
+ SI_EDITTILE = (1 << 1),
+ SI_CLIP_UV = (1 << 2),
+ SI_DRAWTOOL = (1 << 3),
+ SI_NO_DRAWFACES = (1 << 4),
SI_DRAWSHADOW = (1 << 5),
-/* SI_SELACTFACE = (1 << 6), */ /* deprecated */
+/* SI_SELACTFACE = (1 << 6), */ /* deprecated */
SI_DEPRECATED2 = (1 << 7),
- SI_DEPRECATED3 = (1 << 8), /* stick UV selection to mesh vertex (UVs wont always be touching) */
+ SI_DEPRECATED3 = (1 << 8), /* stick UV selection to mesh vertex (UVs wont always be touching) */
SI_COORDFLOATS = (1 << 9),
SI_PIXELSNAP = (1 << 10),
SI_LIVE_UNWRAP = (1 << 11),
@@ -733,20 +733,20 @@ typedef enum eSpaceImage_Flag {
SI_SHOW_ALPHA = (1 << 13),
SI_SHOW_ZBUF = (1 << 14),
- /* next two for render window display */
+ /* next two for render window display */
SI_PREVSPACE = (1 << 15),
SI_FULLWINDOW = (1 << 16),
SI_DEPRECATED4 = (1 << 17),
SI_DEPRECATED5 = (1 << 18),
- /* this means that the image is drawn until it reaches the view edge,
- * in the image view, its unrelated to the 'tile' mode for texface
- */
+ /* this means that the image is drawn until it reaches the view edge,
+ * in the image view, its unrelated to the 'tile' mode for texface
+ */
SI_DRAW_TILE = (1 << 19),
SI_SMOOTH_UV = (1 << 20),
SI_DRAW_STRETCH = (1 << 21),
- SI_DISPGP = (1 << 22), /* DEPRECATED */
+/* SI_DISPGP = (1 << 22), */ /* DEPRECATED */
SI_DRAW_OTHER = (1 << 23),
SI_COLOR_CORRECTION = (1 << 24),
@@ -757,9 +757,9 @@ typedef enum eSpaceImage_Flag {
/* Text Editor */
typedef struct SpaceText {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
struct Text *text;
@@ -767,8 +767,8 @@ typedef struct SpaceText {
int top, viewlines;
short flags, menunr;
- short lheight; /* user preference */
- char cwidth, linenrs_tot; /* runtime computed, character width and the number of chars to use when showing line numbers */
+ short lheight; /* user preference */
+ char cwidth, linenrs_tot; /* runtime computed, character width and the number of chars to use when showing line numbers */
int left;
int showlinenrs;
int tabnumber;
@@ -783,8 +783,8 @@ typedef struct SpaceText {
int wordwrap, doplugins;
- char findstr[256]; /* ST_MAX_FIND_STR */
- char replacestr[256]; /* ST_MAX_FIND_STR */
+ char findstr[256]; /* ST_MAX_FIND_STR */
+ char replacestr[256]; /* ST_MAX_FIND_STR */
short margin_column; /* column number to show right margin at */
char pad[6];
@@ -807,7 +807,7 @@ typedef enum eSpaceText_Flags {
} eSpaceText_Flags;
/* stext->findstr/replacestr */
-#define ST_MAX_FIND_STR 256
+#define ST_MAX_FIND_STR 256
/* Script View (Obsolete) ================================== */
@@ -831,9 +831,9 @@ typedef struct Script {
/* Script View - Obsolete (pre 2.5) */
typedef struct SpaceScript {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
struct Script *script;
short flags, menunr;
@@ -847,36 +847,36 @@ typedef struct SpaceScript {
/* Node Editor */
typedef struct SpaceNode {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
+ View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
- struct ID *id, *from; /* context, no need to save in file? well... pinning... */
- short flag, pad1; /* menunr: browse id block in header */
+ struct ID *id, *from; /* context, no need to save in file? well... pinning... */
+ short flag, pad1; /* menunr: browse id block in header */
float aspect;
- float xof, yof; /* offset for drawing the backdrop */
- float zoom, padf; /* zoom for backdrop */
- float mx, my; /* mousepos for drawing socketless link */
+ float xof, yof; /* offset for drawing the backdrop */
+ float zoom, padf; /* zoom for backdrop */
+ float mx, my; /* mousepos for drawing socketless link */
struct bNodeTree *nodetree, *edittree;
- int treetype; /* treetype: as same nodetree->type */
- short texfrom; /* texfrom object, world or brush */
- short shaderfrom; /* shader from object or world */
- short recalc; /* currently on 0/1, for auto compo */
+ int treetype; /* treetype: as same nodetree->type */
+ short texfrom; /* texfrom object, world or brush */
+ short shaderfrom; /* shader from object or world */
+ short recalc; /* currently on 0/1, for auto compo */
short pad[3];
- ListBase linkdrag; /* temporary data for modal linking operator */
+ ListBase linkdrag; /* temporary data for modal linking operator */
- struct bGPdata *gpd; /* grease-pencil data */
+ struct bGPdata *gpd; /* grease-pencil data */
} SpaceNode;
/* snode->flag */
typedef enum eSpaceNode_Flag {
SNODE_BACKDRAW = (1 << 1),
- SNODE_DISPGP = (1 << 2), /* XXX: Grease Pencil - deprecated? */
+/* SNODE_DISPGP = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */
SNODE_USE_ALPHA = (1 << 3),
SNODE_SHOW_ALPHA = (1 << 4),
SNODE_AUTO_RENDER = (1 << 5),
@@ -885,14 +885,14 @@ typedef enum eSpaceNode_Flag {
/* snode->texfrom */
typedef enum eSpaceNode_TexFrom {
SNODE_TEX_OBJECT = 0,
- SNODE_TEX_WORLD,
- SNODE_TEX_BRUSH,
+ SNODE_TEX_WORLD = 1,
+ SNODE_TEX_BRUSH = 2,
} eSpaceNode_TexFrom;
/* snode->shaderfrom */
typedef enum eSpaceNode_ShaderFrom {
- SNODE_SHADER_OBJECT = 0,
- SNODE_SHADER_WORLD,
+ SNODE_SHADER_OBJECT = 0,
+ SNODE_SHADER_WORLD = 1,
} eSpaceNode_ShaderFrom;
/* Game Logic Editor ===================================== */
@@ -900,16 +900,16 @@ typedef enum eSpaceNode_ShaderFrom {
/* Logic Editor */
typedef struct SpaceLogic {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED;
+ float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
short flag, scaflag;
int pad;
- struct bGPdata *gpd; /* grease-pencil data */
+ struct bGPdata *gpd; /* grease-pencil data */
} SpaceLogic;
/* Console ================================================ */
@@ -919,8 +919,8 @@ typedef struct ConsoleLine {
struct ConsoleLine *next, *prev;
/* keep these 3 vars so as to share free, realloc funcs */
- int len_alloc; /* allocated length */
- int len; /* real len - strlen() */
+ int len_alloc; /* allocated length */
+ int len; /* real len - strlen() */
char *line;
int cursor;
@@ -930,19 +930,19 @@ typedef struct ConsoleLine {
/* ConsoleLine.type */
typedef enum eConsoleLine_Type {
CONSOLE_LINE_OUTPUT = 0,
- CONSOLE_LINE_INPUT,
- CONSOLE_LINE_INFO, /* autocomp feedback */
- CONSOLE_LINE_ERROR
+ CONSOLE_LINE_INPUT = 1,
+ CONSOLE_LINE_INFO = 2, /* autocomp feedback */
+ CONSOLE_LINE_ERROR = 3
} eConsoleLine_Type;
/* Console View */
typedef struct SpaceConsole {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float blockscale DNA_DEPRECATED; // XXX are these needed?
- short blockhandler[8] DNA_DEPRECATED; // XXX are these needed?
+ float blockscale DNA_DEPRECATED; // XXX are these needed?
+ short blockhandler[8] DNA_DEPRECATED; // XXX are these needed?
/* space vars */
int lheight, pad;
@@ -962,12 +962,12 @@ typedef struct SpaceConsole {
/* User Preferences View */
typedef struct SpaceUserPref {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
int pad;
- char filter[64]; /* search term for filtering in the UI */
+ char filter[64]; /* search term for filtering in the UI */
} SpaceUserPref;
/* Motion Tracking ======================================== */
@@ -975,25 +975,25 @@ typedef struct SpaceUserPref {
/* Clip Editor */
typedef struct SpaceClip {
SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
+ ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
- float xof, yof; /* user defined offset, image is centered */
- float xlockof, ylockof; /* user defined offset from locked position */
- float zoom; /* user defined zoom level */
+ float xof, yof; /* user defined offset, image is centered */
+ float xlockof, ylockof; /* user defined offset from locked position */
+ float zoom; /* user defined zoom level */
- struct MovieClipUser user; /* user of clip */
- struct MovieClip *clip; /* clip data */
- struct MovieClipScopes scopes; /* different scoped displayed in space panels */
+ struct MovieClipUser user; /* user of clip */
+ struct MovieClip *clip; /* clip data */
+ struct MovieClipScopes scopes; /* different scoped displayed in space panels */
- int flag; /* flags */
- short mode; /* editor mode (editing context being displayed) */
- short view; /* type of the clip editor view */
+ int flag; /* flags */
+ short mode; /* editor mode (editing context being displayed) */
+ short view; /* type of the clip editor view */
- int path_length; /* length of displaying path, in frames */
+ int path_length; /* length of displaying path, in frames */
/* current stabilization data */
- float loc[2], scale, angle; /* pre-composed stabilization data */
+ float loc[2], scale, angle; /* pre-composed stabilization data */
int pad;
float stabmat[4][4], unistabmat[4][4]; /* current stabilization matrix and the same matrix in unified space,
* defined when drawing and used for mouse position calculation */
@@ -1006,11 +1006,7 @@ typedef struct SpaceClip {
void *draw_context;
- /* dopesheet */
- short dope_sort; /* sort order in dopesheet view */
- short dope_flag; /* dopsheet view flags */
-
- int around; /* pivot point for transforms */
+ int around, pad4; /* pivot point for transforms */
/* **** mask editing **** */
struct Mask *mask;
@@ -1041,36 +1037,25 @@ typedef enum eSpaceClip_Flag {
/* SC_SHOW_PYRAMID_LEVELS = (1 << 16), */ /* UNUSED */
SC_LOCK_TIMECURSOR = (1 << 17),
SC_SHOW_SECONDS = (1 << 18),
+ SC_SHOW_GRAPH_SEL_ONLY = (1 << 19),
+ SC_SHOW_GRAPH_HIDDEN = (1 << 20),
} eSpaceClip_Flag;
/* SpaceClip->mode */
typedef enum eSpaceClip_Mode {
SC_MODE_TRACKING = 0,
- SC_MODE_RECONSTRUCTION,
- SC_MODE_DISTORTION,
- SC_MODE_MASKEDIT,
+ SC_MODE_RECONSTRUCTION = 1,
+ SC_MODE_DISTORTION = 2,
+ SC_MODE_MASKEDIT = 3,
} eSpaceClip_Mode;
/* SpaceClip->view */
typedef enum eSpaceClip_View {
SC_VIEW_CLIP = 0,
- SC_VIEW_GRAPH,
- SC_VIEW_DOPESHEET,
+ SC_VIEW_GRAPH = 1,
+ SC_VIEW_DOPESHEET = 2,
} eSpaceClip_View;
-/* SpaceClip->dope_sort */
-typedef enum eSpaceClip_Dopesheet_Sort {
- SC_DOPE_SORT_NAME = 0,
- SC_DOPE_SORT_LONGEST,
- SC_DOPE_SORT_TOTAL,
- SC_DOPE_SORT_AVERAGE_ERROR,
-} eSpaceClip_Dopesheet_Sort;
-
-/* SpaceClip->dope_flag */
-typedef enum eSpaceClip_Dopesheet_Flag {
- SC_DOPE_SORT_INVERSE = (1 << 0),
-} eSpaceClip_Dopesheet_Flag;
-
/* SpaceClip->gpencil_src */
typedef enum eSpaceClip_GPencil_Source {
SC_GPENCIL_SRC_CLIP = 0,
@@ -1080,34 +1065,34 @@ typedef enum eSpaceClip_GPencil_Source {
/* **************** SPACE DEFINES ********************* */
/* headerbuttons: 450-499 */
-#define B_IMASELHOME 451
-#define B_IMASELREMOVEBIP 452
+#define B_IMASELHOME 451
+#define B_IMASELREMOVEBIP 452
/* space types, moved from DNA_screen_types.h */
/* Do NOT change order, append on end. types are hardcoded needed */
typedef enum eSpace_Type {
- SPACE_EMPTY,
- SPACE_VIEW3D,
- SPACE_IPO,
- SPACE_OUTLINER,
- SPACE_BUTS,
- SPACE_FILE,
- SPACE_IMAGE,
- SPACE_INFO,
- SPACE_SEQ,
- SPACE_TEXT,
- SPACE_IMASEL, /* deprecated */
- SPACE_SOUND, /* Deprecated */
- SPACE_ACTION,
- SPACE_NLA,
- SPACE_SCRIPT, /* Deprecated */
- SPACE_TIME,
- SPACE_NODE,
- SPACE_LOGIC,
- SPACE_CONSOLE,
- SPACE_USERPREF,
- SPACE_CLIP,
+ SPACE_EMPTY = 0,
+ SPACE_VIEW3D = 1,
+ SPACE_IPO = 2,
+ SPACE_OUTLINER = 3,
+ SPACE_BUTS = 4,
+ SPACE_FILE = 5,
+ SPACE_IMAGE = 6,
+ SPACE_INFO = 7,
+ SPACE_SEQ = 8,
+ SPACE_TEXT = 9,
+ SPACE_IMASEL = 10, /* deprecated */
+ SPACE_SOUND = 11, /* Deprecated */
+ SPACE_ACTION = 12,
+ SPACE_NLA = 13,
+ SPACE_SCRIPT = 14, /* Deprecated */
+ SPACE_TIME = 15,
+ SPACE_NODE = 16,
+ SPACE_LOGIC = 17,
+ SPACE_CONSOLE = 18,
+ SPACE_USERPREF = 19,
+ SPACE_CLIP = 20,
SPACEICONMAX = SPACE_CLIP
} eSpace_Type;
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index c5b0174a3c9..1ab64ed1cc1 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -56,20 +56,20 @@ typedef struct MovieReconstructedCamera {
} MovieReconstructedCamera;
typedef struct MovieTrackingCamera {
- void *intrinsics; /* intrinsics handle */
+ void *intrinsics; /* intrinsics handle */
- float sensor_width; /* width of CCD sensor */
- float pixel_aspect; /* pixel aspect ratio */
+ float sensor_width; /* width of CCD sensor */
+ float pixel_aspect; /* pixel aspect ratio */
float pad;
- float focal; /* focal length */
- short units; /* units of focal length user is working with */
+ float focal; /* focal length */
+ short units; /* units of focal length user is working with */
short pad1;
- float principal[2]; /* principal point */
- float k1, k2, k3; /* radial distortion */
+ float principal[2]; /* principal point */
+ float k1, k2, k3; /* radial distortion */
} MovieTrackingCamera;
typedef struct MovieTrackingMarker {
- float pos[2]; /* 2d position of marker on frame (in unified 0..1 space) */
+ float pos[2]; /* 2d position of marker on frame (in unified 0..1 space) */
/* corners of pattern in the following order:
*
@@ -91,14 +91,14 @@ typedef struct MovieTrackingMarker {
*/
float search_min[2], search_max[2];
- int framenr; /* number of frame marker is associated with */
- int flag; /* Marker's flag (alive, ...) */
+ int framenr; /* number of frame marker is associated with */
+ int flag; /* Marker's flag (alive, ...) */
} MovieTrackingMarker;
typedef struct MovieTrackingTrack {
struct MovieTrackingTrack *next, *prev;
- char name[64]; /* MAX_NAME */
+ char name[64]; /* MAX_NAME */
/* ** setings ** */
@@ -114,32 +114,32 @@ typedef struct MovieTrackingTrack {
*/
float search_min[2] DNA_DEPRECATED, search_max[2] DNA_DEPRECATED;
- float offset[2]; /* offset to "parenting" point */
+ float offset[2]; /* offset to "parenting" point */
/* ** track ** */
- int markersnr; /* count of markers in track */
- int last_marker; /* most recently used marker */
- MovieTrackingMarker *markers; /* markers in track */
+ int markersnr; /* count of markers in track */
+ int last_marker; /* most recently used marker */
+ MovieTrackingMarker *markers; /* markers in track */
/* ** reconstruction data ** */
- float bundle_pos[3]; /* reconstructed position */
- float error; /* average track reprojection error */
+ float bundle_pos[3]; /* reconstructed position */
+ float error; /* average track reprojection error */
/* ** UI editing ** */
- int flag, pat_flag, search_flag; /* flags (selection, ...) */
- float color[3]; /* custom color for track */
+ int flag, pat_flag, search_flag; /* flags (selection, ...) */
+ float color[3]; /* custom color for track */
/* ** control how tracking happens */
- short frames_limit; /* number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set) */
- short margin; /* margin from frame boundaries */
- short pattern_match; /* re-adjust every N frames */
+ short frames_limit; /* number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set) */
+ short margin; /* margin from frame boundaries */
+ short pattern_match; /* re-adjust every N frames */
/* tracking parameters */
short motion_model; /* model of the motion for this track */
int algorithm_flag; /* flags for the tracking algorithm (use brute, use esm, use pyramid, etc */
- float minimum_correlation; /* minimal correlation which is still treated as successful tracking */
+ float minimum_correlation; /* minimal correlation which is still treated as successful tracking */
- struct bGPdata *gpd; /* grease-pencil data */
+ struct bGPdata *gpd; /* grease-pencil data */
} MovieTrackingTrack;
typedef struct MovieTrackingSettings {
@@ -156,13 +156,13 @@ typedef struct MovieTrackingSettings {
short default_pattern_match; /* re-adjust every N frames */
short default_flag; /* default flags like color channels used by default */
- short motion_flag; /* flags describes motion type */
+ short motion_flag; /* flags describes motion type */
/* ** common tracker settings ** */
- short speed; /* speed of tracking */
+ short speed; /* speed of tracking */
/* ** reconstruction settings ** */
- int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */
+ int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */
/* which camera intrinsics to refine. uses on the REFINE_* flags */
short refine_camera_intrinsics, pad2;
@@ -170,56 +170,56 @@ typedef struct MovieTrackingSettings {
/* ** tool settings ** */
/* set scale */
- float dist; /* distance between two bundles used for scene scaling */
+ float dist; /* distance between two bundles used for scene scaling */
/* cleanup */
int clean_frames, clean_action;
float clean_error;
/* set object scale */
- float object_distance; /* distance between two bundles used for object scaling */
+ float object_distance; /* distance between two bundles used for object scaling */
int pad3;
} MovieTrackingSettings;
typedef struct MovieTrackingStabilization {
int flag;
- int tot_track, act_track; /* total number and index of active track in list */
+ int tot_track, act_track; /* total number and index of active track in list */
/* 2d stabilization */
- float maxscale; /* max auto-scale factor */
- MovieTrackingTrack *rot_track; /* track used to stabilize rotation */
+ float maxscale; /* max auto-scale factor */
+ MovieTrackingTrack *rot_track; /* track used to stabilize rotation */
- float locinf, scaleinf, rotinf; /* influence on location, scale and rotation */
+ float locinf, scaleinf, rotinf; /* influence on location, scale and rotation */
- int filter; /* filter used for pixel interpolation */
+ int filter; /* filter used for pixel interpolation */
/* some pre-computing run-time variables */
- int ok; /* are precomputed values and scaled buf relevant? */
- float scale; /* autoscale factor */
+ int ok; /* are precomputed values and scaled buf relevant? */
+ float scale; /* autoscale factor */
- struct ImBuf *scaleibuf; /* currently scaled ibuf */
+ struct ImBuf *scaleibuf; /* currently scaled ibuf */
} MovieTrackingStabilization;
typedef struct MovieTrackingReconstruction {
int flag;
- float error; /* average error of reconstruction */
+ float error; /* average error of reconstruction */
- int last_camera; /* most recently used camera */
- int camnr; /* number of reconstructed cameras */
- struct MovieReconstructedCamera *cameras; /* reconstructed cameras */
+ int last_camera; /* most recently used camera */
+ int camnr; /* number of reconstructed cameras */
+ struct MovieReconstructedCamera *cameras; /* reconstructed cameras */
} MovieTrackingReconstruction;
typedef struct MovieTrackingObject {
struct MovieTrackingObject *next, *prev;
- char name[64]; /* Name of tracking object, MAX_NAME */
+ char name[64]; /* Name of tracking object, MAX_NAME */
int flag;
- float scale; /* scale of object solution in amera space */
+ float scale; /* scale of object solution in amera space */
- ListBase tracks; /* list of tracks use to tracking this object */
- MovieTrackingReconstruction reconstruction; /* reconstruction data for this object */
+ ListBase tracks; /* list of tracks use to tracking this object */
+ MovieTrackingReconstruction reconstruction; /* reconstruction data for this object */
} MovieTrackingObject;
typedef struct MovieTrackingStats {
@@ -229,64 +229,70 @@ typedef struct MovieTrackingStats {
typedef struct MovieTrackingDopesheetChannel {
struct MovieTrackingDopesheetChannel *next, *prev;
- MovieTrackingTrack *track; /* motion track for which channel is created */
+ MovieTrackingTrack *track; /* motion track for which channel is created */
int pad;
- int tot_segment; /* total number of segments */
- int *segments; /* tracked segments */
- int max_segment, total_frames; /* longest segment length and total number of tracked frames */
+ char name[64]; /* name of channel */
+
+ int tot_segment; /* total number of segments */
+ int *segments; /* tracked segments */
+ int max_segment, total_frames; /* longest segment length and total number of tracked frames */
} MovieTrackingDopesheetChannel;
typedef struct MovieTrackingDopesheet {
- int ok, pad; /* flag if dopesheet information is still relevant */
+ int ok; /* flag if dopesheet information is still relevant */
+
+ short sort_method; /* method to be used to sort tracks */
+ short flag; /* dopesheet building flag such as inverted order of sort */
+ /* runtime stuff */
ListBase channels;
int tot_channel;
- short sort_method; /* method to be used to sort tracks */
- short sort_inverse; /* order of tracks is inverted */
+ int pad;
} MovieTrackingDopesheet;
typedef struct MovieTracking {
- MovieTrackingSettings settings; /* different tracking-related settings */
- MovieTrackingCamera camera; /* camera intrinsics */
- ListBase tracks; /* list of tracks used for camera object */
- MovieTrackingReconstruction reconstruction; /* reconstruction data for camera object */
- MovieTrackingStabilization stabilization; /* stabilization data */
- MovieTrackingTrack *act_track; /* active track */
+ MovieTrackingSettings settings; /* different tracking-related settings */
+ MovieTrackingCamera camera; /* camera intrinsics */
+ ListBase tracks; /* list of tracks used for camera object */
+ MovieTrackingReconstruction reconstruction; /* reconstruction data for camera object */
+ MovieTrackingStabilization stabilization; /* stabilization data */
+ MovieTrackingTrack *act_track; /* active track */
ListBase objects;
- int objectnr, tot_object; /* index of active object and total number of objects */
+ int objectnr, tot_object; /* index of active object and total number of objects */
- MovieTrackingStats *stats; /* statistics displaying in clip editor */
+ MovieTrackingStats *stats; /* statistics displaying in clip editor */
- MovieTrackingDopesheet dopesheet; /* dopesheet data */
+ MovieTrackingDopesheet dopesheet; /* dopesheet data */
} MovieTracking;
/* MovieTrackingCamera->units */
enum {
CAMERA_UNITS_PX = 0,
- CAMERA_UNITS_MM
+ CAMERA_UNITS_MM = 1
};
/* MovieTrackingMarker->flag */
-#define MARKER_DISABLED (1<<0)
-#define MARKER_TRACKED (1<<1)
-#define MARKER_GRAPH_SEL_X (1<<2)
-#define MARKER_GRAPH_SEL_Y (1<<3)
-#define MARKER_GRAPH_SEL (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y)
+#define MARKER_DISABLED (1 << 0)
+#define MARKER_TRACKED (1 << 1)
+#define MARKER_GRAPH_SEL_X (1 << 2)
+#define MARKER_GRAPH_SEL_Y (1 << 3)
+#define MARKER_GRAPH_SEL (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)
/* MovieTrackingTrack->flag */
-#define TRACK_HAS_BUNDLE (1<<1)
-#define TRACK_DISABLE_RED (1<<2)
-#define TRACK_DISABLE_GREEN (1<<3)
-#define TRACK_DISABLE_BLUE (1<<4)
-#define TRACK_HIDDEN (1<<5)
-#define TRACK_LOCKED (1<<6)
-#define TRACK_CUSTOMCOLOR (1<<7)
-#define TRACK_USE_2D_STAB (1<<8)
-#define TRACK_PREVIEW_GRAYSCALE (1<<9)
-#define TRACK_DOPE_SEL (1<<10)
+#define TRACK_HAS_BUNDLE (1 << 1)
+#define TRACK_DISABLE_RED (1 << 2)
+#define TRACK_DISABLE_GREEN (1 << 3)
+#define TRACK_DISABLE_BLUE (1 << 4)
+#define TRACK_HIDDEN (1 << 5)
+#define TRACK_LOCKED (1 << 6)
+#define TRACK_CUSTOMCOLOR (1 << 7)
+#define TRACK_USE_2D_STAB (1 << 8)
+#define TRACK_PREVIEW_GRAYSCALE (1 << 9)
+#define TRACK_DOPE_SEL (1 << 10)
+#define TRACK_PREVIEW_ALPHA (1 << 11)
/* MovieTrackingTrack->motion_model */
#define TRACK_MOTION_MODEL_TRANSLATION 0
@@ -297,52 +303,64 @@ enum {
#define TRACK_MOTION_MODEL_HOMOGRAPHY 5
/* MovieTrackingTrack->algorithm_flag */
-#define TRACK_ALGORITHM_FLAG_USE_BRUTE 1
-#define TRACK_ALGORITHM_FLAG_USE_NORMALIZATION 2
+#define TRACK_ALGORITHM_FLAG_USE_BRUTE (1 << 0)
+#define TRACK_ALGORITHM_FLAG_USE_NORMALIZATION (1 << 2)
+#define TRACK_ALGORITHM_FLAG_USE_MASK (1 << 3)
/* MovieTrackingTrack->adjframes */
-#define TRACK_MATCH_KEYFRAME 0
-#define TRACK_MATCH_PREVFRAME 1
+#define TRACK_MATCH_KEYFRAME 0
+#define TRACK_MATCH_PREVFRAME 1
/* MovieTrackingSettings->flag */
-#define TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED (1<<0)
+#define TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED (1 << 0)
/* MovieTrackingSettings->motion_flag */
-#define TRACKING_MOTION_TRIPOD (1<<0)
+#define TRACKING_MOTION_TRIPOD (1 << 0)
-#define TRACKING_MOTION_MODAL (TRACKING_MOTION_TRIPOD)
+#define TRACKING_MOTION_MODAL (TRACKING_MOTION_TRIPOD)
/* MovieTrackingSettings->speed */
-#define TRACKING_SPEED_FASTEST 0
-#define TRACKING_SPEED_REALTIME 1
-#define TRACKING_SPEED_HALF 2
-#define TRACKING_SPEED_QUARTER 4
-#define TRACKING_SPEED_DOUBLE 5
+#define TRACKING_SPEED_FASTEST 0
+#define TRACKING_SPEED_REALTIME 1
+#define TRACKING_SPEED_HALF 2
+#define TRACKING_SPEED_QUARTER 4
+#define TRACKING_SPEED_DOUBLE 5
/* MovieTrackingSettings->refine_camera_intrinsics */
-#define REFINE_FOCAL_LENGTH (1<<0)
-#define REFINE_PRINCIPAL_POINT (1<<1)
-#define REFINE_RADIAL_DISTORTION_K1 (1<<2)
-#define REFINE_RADIAL_DISTORTION_K2 (1<<4)
+#define REFINE_FOCAL_LENGTH (1 << 0)
+#define REFINE_PRINCIPAL_POINT (1 << 1)
+#define REFINE_RADIAL_DISTORTION_K1 (1 << 2)
+#define REFINE_RADIAL_DISTORTION_K2 (1 << 4)
/* MovieTrackingStrabilization->flag */
-#define TRACKING_2D_STABILIZATION (1<<0)
-#define TRACKING_AUTOSCALE (1<<1)
-#define TRACKING_STABILIZE_ROTATION (1<<2)
+#define TRACKING_2D_STABILIZATION (1 << 0)
+#define TRACKING_AUTOSCALE (1 << 1)
+#define TRACKING_STABILIZE_ROTATION (1 << 2)
/* MovieTrackingStrabilization->filter */
-#define TRACKING_FILTER_NEAREAST 0
-#define TRACKING_FILTER_BILINEAR 1
-#define TRACKING_FILTER_BICUBIC 2
+#define TRACKING_FILTER_NEAREAST 0
+#define TRACKING_FILTER_BILINEAR 1
+#define TRACKING_FILTER_BICUBIC 2
/* MovieTrackingReconstruction->flag */
-#define TRACKING_RECONSTRUCTED (1<<0)
+#define TRACKING_RECONSTRUCTED (1 << 0)
/* MovieTrackingObject->flag */
-#define TRACKING_OBJECT_CAMERA (1<<0)
-
-#define TRACKING_CLEAN_SELECT 0
-#define TRACKING_CLEAN_DELETE_TRACK 1
-#define TRACKING_CLEAN_DELETE_SEGMENT 2
+#define TRACKING_OBJECT_CAMERA (1 << 0)
+
+#define TRACKING_CLEAN_SELECT 0
+#define TRACKING_CLEAN_DELETE_TRACK 1
+#define TRACKING_CLEAN_DELETE_SEGMENT 2
+
+/* MovieTrackingDopesheet->sort_method */
+#define TRACKING_DOPE_SORT_NAME 0
+#define TRACKING_DOPE_SORT_LONGEST 1
+#define TRACKING_DOPE_SORT_TOTAL 2
+#define TRACKING_DOPE_SORT_AVERAGE_ERROR 3
+
+/* MovieTrackingDopesheet->flag */
+#define TRACKING_DOPE_SORT_INVERSE (1 << 0)
+#define TRACKING_DOPE_SELECTED_ONLY (1 << 1)
+#define TRACKING_DOPE_SHOW_HIDDEN (1 << 2)
#endif
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 6160af6eaf9..8690d0a26e4 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -413,7 +413,7 @@ typedef struct UserDef {
short widget_unit; /* defaults to 20 for 72 DPI setting */
short anisotropic_filter;
- short use_16bit_textures, pad8;
+ short use_16bit_textures, use_gpu_mipmap;
float ndof_sensitivity; /* overall sensitivity of 3D mouse */
int ndof_flag; /* flags for 3D mouse */
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index e89cc751a69..487c0d97e5e 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -311,11 +311,19 @@ typedef struct View3D {
/* #define V3D_CALC_MANIPULATOR 4 */ /*UNUSED*/
/* BGPic->flag */
-/* may want to use 1 for select ?*/
-#define V3D_BGPIC_EXPANDED 2
-#define V3D_BGPIC_CAMERACLIP 4
-#define V3D_BGPIC_DISABLED 8
-#define V3D_BGPIC_FOREGROUND 16
+/* may want to use 1 for select ? */
+enum {
+ V3D_BGPIC_EXPANDED = (1 << 1),
+ V3D_BGPIC_CAMERACLIP = (1 << 2),
+ V3D_BGPIC_DISABLED = (1 << 3),
+ V3D_BGPIC_FOREGROUND = (1 << 4),
+
+ /* Camera framing options */
+ V3D_BGPIC_CAMERA_ASPECT = (1 << 5), /* don't stretch to fit the camera view */
+ V3D_BGPIC_CAMERA_CROP = (1 << 6) /* crop out the image */
+};
+
+#define V3D_BGPIC_EXPANDED (V3D_BGPIC_EXPANDED | V3D_BGPIC_CAMERACLIP)
/* BGPic->source */
/* may want to use 1 for select ?*/
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index c15bf04796c..d237fb5abd1 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -878,14 +878,14 @@ int RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index);
* UI code or Actions, though efficiency is a concern. */
char *RNA_path_append(const char *path, PointerRNA *ptr, PropertyRNA *prop,
- int intkey, const char *strkey);
+ int intkey, const char *strkey);
char *RNA_path_back(const char *path);
int RNA_path_resolve(PointerRNA *ptr, const char *path,
- PointerRNA *r_ptr, PropertyRNA **r_prop);
+ PointerRNA *r_ptr, PropertyRNA **r_prop);
int RNA_path_resolve_full(PointerRNA *ptr, const char *path,
- PointerRNA *r_ptr, PropertyRNA **r_prop, int *index);
+ PointerRNA *r_ptr, PropertyRNA **r_prop, int *index);
char *RNA_path_from_ID_to_struct(PointerRNA *ptr);
char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop);
@@ -1002,7 +1002,7 @@ char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr, Poi
char *RNA_pointer_as_string_keywords(struct bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
const short skip_optional_value, const short all_args);
char *RNA_function_as_string_keywords(struct bContext *C, FunctionRNA *func, PointerRNA *ptr_default,
- const short as_function, const short all_args);
+ const short as_function, const short all_args);
/* Function */
@@ -1041,12 +1041,12 @@ int RNA_function_call_lookup(struct bContext *C, struct ReportList *reports, Poi
int RNA_function_call_direct(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...)
#ifdef __GNUC__
-__attribute__ ((format (printf, 5, 6)))
+__attribute__ ((format(printf, 5, 6)))
#endif
;
int RNA_function_call_direct_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...)
#ifdef __GNUC__
-__attribute__ ((format (printf, 5, 6)))
+__attribute__ ((format(printf, 5, 6)))
#endif
;
int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args);
@@ -1060,14 +1060,14 @@ StructRNA *ID_code_to_RNA_type(short idcode);
/* macro which inserts the function name */
#if defined __GNUC__ || defined __sun
-# define RNA_warning(format, args...) _RNA_warning("%s: " format "\n", __func__, ##args)
+# define RNA_warning(format, args ...) _RNA_warning("%s: " format "\n", __func__, ##args)
#else
# define RNA_warning(format, ...) _RNA_warning("%s: " format "\n", __FUNCTION__, __VA_ARGS__)
#endif
void _RNA_warning(const char *format, ...)
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
+__attribute__ ((format(printf, 1, 2)))
#endif
;
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index a851911f49e..1596e4573ab 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -619,7 +619,7 @@ static void rna_def_histogram(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_line", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", HISTO_FLAG_LINE);
- RNA_def_property_ui_text(prop, "Show Line", "Displays lines rather then filled shapes");
+ RNA_def_property_ui_text(prop, "Show Line", "Display lines rather then filled shapes");
RNA_def_property_ui_icon(prop, ICON_IPO, 0);
}
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 8e29e5c2e79..ae8b0c51544 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -1111,6 +1111,13 @@ static void rna_def_constraint_action(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+ prop = RNA_def_property(srna, "use_bone_object_action", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", ACTCON_BONE_USE_OBJECT_ACTION);
+ RNA_def_property_ui_text(prop, "Object Action",
+ "Bones only: apply the object's transformation channels of the action "
+ "to the constrained bone, instead of bone's channels");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "start");
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index fdad91165c4..9d63e0e687d 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -180,7 +180,7 @@ static void rna_Lamp_use_nodes_update(Main *blain, Scene *scene, PointerRNA *ptr
}
#else
-
+/* Don't define icons here, so they don't show up in the Lamp UI (properties Editor) - DingTo */
EnumPropertyItem lamp_type_items[] = {
{LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"},
{LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"},
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 64f1663a524..dfcbbe0653b 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -665,6 +665,7 @@ static void rna_def_mask(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_funcs(prop, "rna_Mask_layer_active_index_get", "rna_Mask_layer_active_index_set", "rna_Mask_layer_active_index_range");
RNA_def_property_ui_text(prop, "Active Shape Index", "Index of active layer in list of all mask's layers");
+ RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL);
/* frame range */
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index eb31d83fce8..e9b3faa2c86 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2450,12 +2450,12 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna)
prop = RNA_def_property(srna, "lock_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_X);
- RNA_def_property_ui_text(prop, "Lock X Axis", "Do not allow tapering along the X axis");
+ RNA_def_property_ui_text(prop, "Lock X Axis", "Do not allow deformation along the X axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "lock_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_Y);
- RNA_def_property_ui_text(prop, "Lock Y Axis", "Do not allow tapering along the Y axis");
+ RNA_def_property_ui_text(prop, "Lock Y Axis", "Do not allow deformation along the Y axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
@@ -2651,7 +2651,7 @@ static void rna_def_modifier_screw(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
#if 0
- prop= RNA_def_property(srna, "use_angle_object", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_angle_object", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_OBJECT_ANGLE);
RNA_def_property_ui_text(prop, "Object Angle", "Use the angle between the objects rather than the fixed angle");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
@@ -3219,7 +3219,7 @@ static void rna_def_modifier_skin(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- srna= RNA_def_struct(brna, "SkinModifier", "Modifier");
+ srna = RNA_def_struct(brna, "SkinModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Skin Modifier", "Generate Skin");
RNA_def_struct_sdna(srna, "SkinModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN);
diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c
index a4b7516a930..2a12fa8b116 100644
--- a/source/blender/makesrna/intern/rna_movieclip.c
+++ b/source/blender/makesrna/intern/rna_movieclip.c
@@ -286,10 +286,16 @@ static void rna_def_movieclip(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this movie clip");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
- /* frame offset */
+ /* start_frame */
prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "start_frame");
- RNA_def_property_ui_text(prop, "Start Frame", "Global scene frame number at which this movie starts playing");
+ RNA_def_property_ui_text(prop, "Start Frame", "Global scene frame number at which this movie starts playing. Affects all data associated with a clip");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
+
+ /* frame_offset */
+ prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "frame_offset");
+ RNA_def_property_ui_text(prop, "Frame Offset", "Offset of footage first frame relative to it's file name. Affects only how footage is loaing, not changes data associated with a clip");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 65d572c6c11..683a49a7690 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -634,6 +634,23 @@ static EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), PointerRNA
return item;
}
+static PointerRNA rna_NodeTree_active_node_get(PointerRNA *ptr)
+{
+ bNodeTree *ntree = (bNodeTree *)ptr->data;
+ bNode *node = nodeGetActive(ntree);
+ return rna_pointer_inherit_refine(ptr, &RNA_Node, node);
+}
+
+static void rna_NodeTree_active_node_set(PointerRNA *ptr, PointerRNA value)
+{
+ bNodeTree *ntree = (bNodeTree *)ptr->data;
+ bNode *node = (bNode *)value.data;
+ if (node && BLI_findindex(&ntree->nodes, node) != -1)
+ nodeSetActive(ntree, node);
+ else
+ nodeClearActive(ntree);
+}
+
static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *reports,
int type, bNodeTree *group)
{
@@ -1041,6 +1058,7 @@ static void init(void)
reg_node(NODE_FORLOOP, Category_LoopNode, "FORLOOP", "NodeForLoop", "Node", "ForLoop", "");
reg_node(NODE_WHILELOOP, Category_LoopNode, "WHILELOOP", "NodeWhileLoop", "Node", "WhileLoop", "");
reg_node(NODE_FRAME, Category_LayoutNode, "FRAME", "NodeFrame", "Node", "Frame", "");
+ reg_node(NODE_REROUTE, Category_LayoutNode, "REROUTE", "NodeReroute", "Node", "Reroute", "");
}
static StructRNA *def_node(BlenderRNA *brna, int node_id)
@@ -1058,7 +1076,7 @@ static StructRNA *def_node(BlenderRNA *brna, int node_id)
static void alloc_node_type_items(EnumPropertyItem *items, int category)
{
int i;
- int count = 3;
+ int count = 4;
EnumPropertyItem *item = items;
for (i = 0; i < MaxNodes; i++)
@@ -1088,6 +1106,14 @@ static void alloc_node_type_items(EnumPropertyItem *items, int category)
item++;
+ item->value = NODE_REROUTE;
+ item->identifier = "REROUTE";
+ item->icon = 0;
+ item->name = "Reroute";
+ item->description = "";
+
+ item++;
+
/* NOTE!, increase 'count' when adding items here */
memset(item, 0, sizeof(EnumPropertyItem));
@@ -2051,20 +2077,45 @@ static void def_cmp_dilate_erode(StructRNA *srna)
static void def_cmp_scale(StructRNA *srna)
{
PropertyRNA *prop;
-
+
static EnumPropertyItem space_items[] = {
- {0, "RELATIVE", 0, "Relative", ""},
- {1, "ABSOLUTE", 0, "Absolute", ""},
- {2, "SCENE_SIZE", 0, "Scene Size", ""},
- {3, "RENDER_SIZE", 0, "Render Size", ""},
+ {CMP_SCALE_RELATIVE, "RELATIVE", 0, "Relative", ""},
+ {CMP_SCALE_ABSOLUTE, "ABSOLUTE", 0, "Absolute", ""},
+ {CMP_SCALE_SCENEPERCENT, "SCENE_SIZE", 0, "Scene Size", ""},
+ {CMP_SCALE_RENDERPERCENT, "RENDER_SIZE", 0, "Render Size", ""},
{0, NULL, 0, NULL, NULL}
};
+ /* matching bgpic_camera_frame_items[] */
+ static const EnumPropertyItem space_frame_items[] = {
+ {0, "STRETCH", 0, "Stretch", ""},
+ {CMP_SCALE_RENDERSIZE_FRAME_ASPECT, "FIT", 0, "Fit", ""},
+ {CMP_SCALE_RENDERSIZE_FRAME_ASPECT | CMP_SCALE_RENDERSIZE_FRAME_CROP, "CROP", 0, "Crop", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, space_items);
RNA_def_property_ui_text(prop, "Space", "Coordinate space to scale relative to");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ /* expose 2 flags as a enum of 3 items */
+ prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom2");
+ RNA_def_property_enum_items(prop, space_frame_items);
+ RNA_def_property_ui_text(prop, "Frame Method", "How the image fits in the camera frame");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "custom3");
+ RNA_def_property_ui_text(prop, "X Offset", "Offset image horizontally (factor of image size)");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "custom4");
+ RNA_def_property_ui_text(prop, "Y Offset", "Offset image vertically (factor of image size)");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
static void def_cmp_rotate(StructRNA *srna)
@@ -3063,6 +3114,11 @@ static void def_cmp_mask(StructRNA *srna)
{
PropertyRNA *prop;
+ prop = RNA_def_property(srna, "smooth_mask", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0);
+ RNA_def_property_ui_text(prop, "Anti-Alias", "Apply an anti-aliasing filter to the mask");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Mask");
@@ -3070,7 +3126,6 @@ static void def_cmp_mask(StructRNA *srna)
RNA_def_property_ui_text(prop, "Mask", "");
}
-
static void dev_cmd_transform(StructRNA *srna)
{
PropertyRNA *prop;
@@ -3477,6 +3532,85 @@ static void def_cmp_viewer(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_cmp_keyingscreen(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "id");
+ RNA_def_property_struct_type(prop, "MovieClip");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Movie Clip", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "NodeKeyingScreenData", "storage");
+
+ prop = RNA_def_property(srna, "tracking_object", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "tracking_object");
+ RNA_def_property_ui_text(prop, "Tracking Object", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
+static void def_cmp_keying(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeKeyingData", "storage");
+
+ prop = RNA_def_property(srna, "screen_balance", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "screen_balance");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Screen Balance", "Balance between two non-primary channels primary channel is comparing against");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "despill_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "despill_factor");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Despill", "Factor of despilling screen color from image");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "clip_black", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "clip_black");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Clip Black", "Value of on-scaled matte pixel which considers as fully background pixel");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "clip_white", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "clip_white");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Clip White", "Value of on-scaled matte pixel which considers as fully foreground pixel");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "blur_pre", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "blur_pre");
+ RNA_def_property_range(prop, 0, 2048);
+ RNA_def_property_ui_text(prop, "Pre Blur", "Chroma pre-blur size which applies before running keyer");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "blur_post", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "blur_post");
+ RNA_def_property_range(prop, 0, 2048);
+ RNA_def_property_ui_text(prop, "Post Blur", "Matte blur size which applies after clipping and dilate/eroding");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "dilate_distance", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "dilate_distance");
+ RNA_def_property_range(prop, -100, 100);
+ RNA_def_property_ui_text(prop, "Dilate/Erode", "Matte dilate/erode side");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "edge_kernel_radius", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "edge_kernel_radius");
+ RNA_def_property_range(prop, -100, 100);
+ RNA_def_property_ui_text(prop, "Edge Kernel Radius", "Radius of kernel used to detect whether pixel belongs to edge");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "edge_kernel_tolerance", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "edge_kernel_tolerance");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Edge Kernel Tolerance", "Tolerance to pixels inside kernel which are treating as belonging to the same plane");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
/* -- Texture Nodes --------------------------------------------------------- */
@@ -3632,6 +3766,19 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "remove all node links from the node tree");
}
+/* shared between all note tree types*/
+static void rna_def_nodetree_active_api(StructRNA *srna, PropertyRNA *cprop)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Node");
+ RNA_def_property_pointer_funcs(prop, "rna_NodeTree_active_node_get", "rna_NodeTree_active_node_set", NULL, NULL);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
+ RNA_def_property_ui_text(prop, "Active Node", "Active node in this tree");
+ RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL);
+}
+
static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
@@ -3661,6 +3808,8 @@ static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
+
+ rna_def_nodetree_active_api(srna, cprop);
}
static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
@@ -3692,6 +3841,8 @@ static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
+
+ rna_def_nodetree_active_api(srna, cprop);
}
static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
@@ -3723,6 +3874,8 @@ static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
+
+ rna_def_nodetree_active_api(srna, cprop);
}
static void rna_def_node_socket(BlenderRNA *brna)
@@ -3912,6 +4065,27 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Color", "Custom color of the node body");
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
+ prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_SELECT);
+ RNA_def_property_ui_text(prop, "Select", "");
+
+ prop = RNA_def_property(srna, "show_options", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_OPTIONS);
+ RNA_def_property_ui_text(prop, "Show Options", "");
+
+ prop = RNA_def_property(srna, "show_preview", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_PREVIEW);
+ RNA_def_property_ui_text(prop, "Show Preview", "");
+
+ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_HIDDEN);
+ RNA_def_property_ui_text(prop, "Hide", "");
+
+ prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_MUTED);
+ RNA_def_property_ui_text(prop, "Mute", "");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
+
prop = RNA_def_property(srna, "show_texture", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_ACTIVE_TEXTURE);
RNA_def_property_ui_text(prop, "Show Texture", "Draw node in viewport textured draw mode");
@@ -4151,6 +4325,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
define_specific_node(brna, NODE_FORLOOP, def_forloop);
define_specific_node(brna, NODE_WHILELOOP, def_whileloop);
define_specific_node(brna, NODE_FRAME, def_frame);
+ define_specific_node(brna, NODE_REROUTE, 0);
/* special socket types */
rna_def_cmp_output_file_slot_file(brna);
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index 3981afe5349..62c3051727d 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -168,6 +168,8 @@ DefNode( CompositorNode, CMP_NODE_BOKEHBLUR, def_cmp_bokehblur, "BOKEH
DefNode( CompositorNode, CMP_NODE_SWITCH, def_cmp_switch, "SWITCH" ,Switch, "Switch", "" )
DefNode( CompositorNode, CMP_NODE_COLORCORRECTION,def_cmp_colorcorrection,"COLORCORRECTION",ColorCorrection, "ColorCorrection", "" )
DefNode( CompositorNode, CMP_NODE_MASK, def_cmp_mask, "MASK", Mask, "Mask", "" )
+DefNode( CompositorNode, CMP_NODE_KEYINGSCREEN, def_cmp_keyingscreen, "KEYINGSCREEN", KeyingScreen, "KeyingScreen", "" )
+DefNode( CompositorNode, CMP_NODE_KEYING, def_cmp_keying, "KEYING", Keying, "Keying", "" )
DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 5139e17b06d..eaf1ae09524 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -746,6 +746,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Pose Bone", "Channel defining pose data for a bone in a Pose");
RNA_def_struct_path_func(srna, "rna_PoseBone_path");
RNA_def_struct_idprops_func(srna, "rna_PoseBone_idprops");
+ RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
/* Bone Constraints */
prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index b2ff36285e6..76366efe0d1 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -87,17 +87,18 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name
static void rna_Scene_collada_export(
Scene *scene,
- const char *filepath,
- int selected,
- int apply_modifiers,
- int include_armatures,
- int include_bone_children,
- int use_object_instantiation,
- int second_life)
+ const char *filepath,
+ int selected,
+ int apply_modifiers,
+ int include_armatures,
+ int include_children,
+ int use_object_instantiation,
+ int sort_by_name,
+ int second_life)
{
collada_export(scene, filepath, selected, apply_modifiers,
- include_armatures, include_bone_children,
- use_object_instantiation, second_life);
+ include_armatures, include_children,
+ use_object_instantiation, sort_by_name, second_life);
}
#endif
@@ -128,8 +129,9 @@ void RNA_api_scene(StructRNA *srna)
parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements");
parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)");
parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Include armature(s) used by the exported objects");
- parm = RNA_def_boolean(func, "include_bone_children", 0, "Include Bone Children", "Include all objects attached to bones of selected Armature(s)");
+ parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Include all children even if not selected");
parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instantiation", "Instantiate multiple Objects from same Data");
+ parm = RNA_def_boolean(func, "sort_by_name", 0, "Sort by Object name", "Sort exported data by Object name");
parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life");
RNA_def_function_ui_description(func, "Export to collada file");
#endif
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index cafe8ebefad..30b06017568 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1041,9 +1041,9 @@ static void rna_SpaceClipEditor_clip_set(PointerRNA *ptr, PointerRNA value)
static void rna_SpaceClipEditor_mask_set(PointerRNA *ptr, PointerRNA value)
{
- SpaceClip *sc= (SpaceClip*)(ptr->data);
+ SpaceClip *sc = (SpaceClip *)(ptr->data);
- ED_space_clip_set_mask(NULL, sc, (Mask*)value.data);
+ ED_space_clip_set_mask(NULL, sc, (Mask *)value.data);
}
static void rna_SpaceClipEditor_clip_mode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -1297,6 +1297,19 @@ static void rna_def_background_image(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static const EnumPropertyItem bgpic_camera_frame_items[] = {
+ {0, "STRETCH", 0, "Stretch", ""},
+ {V3D_BGPIC_CAMERA_ASPECT, "FIT", 0, "Fit", ""},
+ {V3D_BGPIC_CAMERA_ASPECT | V3D_BGPIC_CAMERA_CROP, "CROP", 0, "Crop", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static const EnumPropertyItem bgpic_draw_depth_items[] = {
+ {0, "BACK", 0, "Back", ""},
+ {V3D_BGPIC_FOREGROUND, "FRONT", 0, "Front", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "BackgroundImage", NULL);
RNA_def_struct_sdna(srna, "BGpic");
RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3d View background");
@@ -1381,6 +1394,20 @@ static void rna_def_background_image(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_FOREGROUND);
RNA_def_property_ui_text(prop, "Show On Foreground", "Show this image in front of objects in viewport");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ /* expose 1 flag as a enum of 2 items */
+ prop = RNA_def_property(srna, "draw_depth", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, bgpic_draw_depth_items);
+ RNA_def_property_ui_text(prop, "Depth", "Draw under or over everything");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ /* expose 2 flags as a enum of 3 items */
+ prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, bgpic_camera_frame_items);
+ RNA_def_property_ui_text(prop, "Frame Method", "How the image fits in the camera frame");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1969,12 +1996,7 @@ static void rna_def_space_image(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "GreasePencil");
RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
-
- prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DISPGP);
- RNA_def_property_ui_text(prop, "Use Grease Pencil",
- "Display and edit the grease pencil freehand annotations overlay");
-
+
/* update */
prop = RNA_def_property(srna, "use_realtime_update", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "lock", 0);
@@ -2050,7 +2072,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Display Mode", "View mode to use for displaying sequencer output");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
- /* flag's */
+ /* flags */
prop = RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_NO_DRAW_CFRANUM);
RNA_def_property_ui_text(prop, "Show Frame Number Indicator",
@@ -2077,23 +2099,10 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Safe Margin", "Draw title safe margins in preview");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
- prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAW_GPENCIL);
- RNA_def_property_ui_text(prop, "Use Grease Pencil",
- "Display and edit the grease pencil freehand annotations overlay");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
-
prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_DRAWFRAMES);
RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
-
- /* grease pencil */
- prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "gpd");
- RNA_def_property_struct_type(prop, "UnknownType");
- RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
prop = RNA_def_property(srna, "display_channel", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "chanshown");
@@ -2114,6 +2123,14 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Proxy render size",
"Draw preview using full resolution or different proxy resolutions");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
+
+ /* grease pencil */
+ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "gpd");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "GreasePencil");
+ RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
}
static void rna_def_space_text(BlenderRNA *brna)
@@ -2995,14 +3012,6 @@ static void rna_def_space_clip(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static EnumPropertyItem dope_sort_items[] = {
- {SC_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"},
- {SC_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"},
- {SC_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"},
- {SC_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", "Sort channels by average reprojection error of tracks after solve"},
- {0, NULL, 0, NULL, NULL}
- };
-
static EnumPropertyItem gpencil_source_items[] = {
{SC_GPENCIL_SRC_CLIP, "CLIP", 0, "Clip", "Show grease pencil datablock which belongs to movie clip"},
{SC_GPENCIL_SRC_TRACK, "TRACK", 0, "Track", "Show grease pencil datablock which belongs to active track"},
@@ -3040,23 +3049,23 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
/* mask */
- prop= RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Mask", "Mask displayed and edited in this space");
RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceClipEditor_mask_set", NULL, NULL);
- RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
/* mask drawing */
prop = RNA_def_property(srna, "mask_draw_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mask_draw_type");
RNA_def_property_enum_items(prop, dt_uv_items);
RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for mask splines");
- RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
prop = RNA_def_property(srna, "show_mask_smooth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mask_draw_flag", MASK_DRAWFLAG_SMOOTH);
RNA_def_property_ui_text(prop, "Draw Smooth Splines", "");
- RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
/* mode */
@@ -3186,6 +3195,20 @@ static void rna_def_space_clip(BlenderRNA *brna)
"for the selected tracks");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+ /* show_only_selected */
+ prop = RNA_def_property(srna, "show_graph_only_selected", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_SEL_ONLY);
+ RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data");
+ RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+
+ /* show_hidden */
+ prop = RNA_def_property(srna, "show_graph_hidden", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_HIDDEN);
+ RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible");
+ RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+
/* ** channels ** */
/* show_red_channel */
@@ -3231,21 +3254,6 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_enum_items(prop, pivot_items);
RNA_def_property_ui_text(prop, "Pivot Point", "Pivot center for rotation/scaling");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
-
- /* ** dopesheet ** */
-
- /* dopesheet sort */
- prop = RNA_def_property(srna, "dopesheet_sort_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "dope_sort");
- RNA_def_property_enum_items(prop, dope_sort_items);
- RNA_def_property_ui_text(prop, "Dopesheet Sort Field", "Method to be used to sort channels in dopesheet view");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
-
- /* invert_dopesheet_sort */
- prop = RNA_def_property(srna, "invert_dopesheet_sort", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "dope_flag", SC_DOPE_SORT_INVERSE);
- RNA_def_property_ui_text(prop, "Invert Dopesheet Sort", "Invert sort order of dopesheet channels");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
}
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index aaa96fc4d95..85dee2617d8 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -40,7 +40,7 @@
#include "rna_internal.h"
#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
#include "WM_types.h"
@@ -61,21 +61,21 @@ static char *rna_tracking_path(PointerRNA *UNUSED(ptr))
static void rna_tracking_defaultSettings_patternUpdate(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTracking *tracking = &clip->tracking;
MovieTrackingSettings *settings = &tracking->settings;
- if (settings->default_search_size<settings->default_pattern_size)
+ if (settings->default_search_size < settings->default_pattern_size)
settings->default_search_size = settings->default_pattern_size;
}
static void rna_tracking_defaultSettings_searchUpdate(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTracking *tracking = &clip->tracking;
MovieTrackingSettings *settings = &tracking->settings;
- if (settings->default_pattern_size>settings->default_search_size)
+ if (settings->default_pattern_size > settings->default_search_size)
settings->default_pattern_size = settings->default_search_size;
}
@@ -88,54 +88,54 @@ static char *rna_trackingTrack_path(PointerRNA *ptr)
static void rna_trackingTracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
rna_iterator_listbase_begin(iter, &clip->tracking.tracks, NULL);
}
static void rna_trackingObjects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
rna_iterator_listbase_begin(iter, &clip->tracking.objects, NULL);
}
static int rna_tracking_active_object_index_get(PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
return clip->tracking.objectnr;
}
static void rna_tracking_active_object_index_set(PointerRNA *ptr, int value)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
clip->tracking.objectnr = value;
}
static void rna_tracking_active_object_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
*min = 0;
- *max = clip->tracking.tot_object-1;
+ *max = clip->tracking.tot_object - 1;
*max = MAX2(0, *max);
}
static PointerRNA rna_tracking_active_track_get(PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
- MovieTrackingTrack *act_track = BKE_tracking_active_track(&clip->tracking);
+ MovieClip *clip = (MovieClip *)ptr->id.data;
+ MovieTrackingTrack *act_track = BKE_tracking_track_get_active(&clip->tracking);
return rna_pointer_inherit_refine(ptr, &RNA_MovieTrackingTrack, act_track);
}
static void rna_tracking_active_track_set(PointerRNA *ptr, PointerRNA value)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTrackingTrack *track = (MovieTrackingTrack *)value.data;
- ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+ ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
int index = BLI_findindex(tracksbase, track);
if (index >= 0)
@@ -169,7 +169,7 @@ void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value)
}
}
- BKE_track_unique_name(tracksbase, track);
+ BKE_tracking_track_unique_name(tracksbase, track);
}
static int rna_trackingTrack_select_get(PointerRNA *ptr)
@@ -202,23 +202,23 @@ static char *rna_trackingCamera_path(PointerRNA *UNUSED(ptr))
static float rna_trackingCamera_focal_mm_get(PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTrackingCamera *camera = &clip->tracking.camera;
float val = camera->focal;
if (clip->lastsize[0])
- val = val*camera->sensor_width/(float)clip->lastsize[0];
+ val = val * camera->sensor_width / (float)clip->lastsize[0];
return val;
}
static void rna_trackingCamera_focal_mm_set(PointerRNA *ptr, float value)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTrackingCamera *camera = &clip->tracking.camera;
if (clip->lastsize[0])
- value = clip->lastsize[0]*value/camera->sensor_width;
+ value = clip->lastsize[0] * value / camera->sensor_width;
if (value >= 0.0001f)
camera->focal = value;
@@ -231,9 +231,9 @@ static char *rna_trackingStabilization_path(PointerRNA *UNUSED(ptr))
static int rna_track_2d_stabilization(CollectionPropertyIterator *UNUSED(iter), void *data)
{
- MovieTrackingTrack *track = (MovieTrackingTrack*)data;
+ MovieTrackingTrack *track = (MovieTrackingTrack *)data;
- if ((track->flag&TRACK_USE_2D_STAB) == 0)
+ if ((track->flag & TRACK_USE_2D_STAB) == 0)
return 1;
return 0;
@@ -241,50 +241,50 @@ static int rna_track_2d_stabilization(CollectionPropertyIterator *UNUSED(iter),
static void rna_tracking_stabTracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
rna_iterator_listbase_begin(iter, &clip->tracking.tracks, rna_track_2d_stabilization);
}
static int rna_tracking_stabTracks_active_index_get(PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
return clip->tracking.stabilization.act_track;
}
static void rna_tracking_stabTracks_active_index_set(PointerRNA *ptr, int value)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
clip->tracking.stabilization.act_track = value;
}
static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
*min = 0;
- *max = clip->tracking.stabilization.tot_track-1;
+ *max = clip->tracking.stabilization.tot_track - 1;
*max = MAX2(0, *max);
}
static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTrackingStabilization *stab = &clip->tracking.stabilization;
stab->ok = 0;
nodeUpdateID(scene->nodetree, &clip->id);
- WM_main_add_notifier(NC_SCENE|ND_NODES, NULL);
+ WM_main_add_notifier(NC_SCENE | ND_NODES, NULL);
DAG_id_tag_update(&clip->id, 0);
}
static void rna_trackingObject_tracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
- MovieTrackingObject *object = (MovieTrackingObject* )ptr->data;
+ MovieTrackingObject *object = (MovieTrackingObject * )ptr->data;
- if (object->flag&TRACKING_OBJECT_CAMERA) {
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
+ MovieClip *clip = (MovieClip *)ptr->id.data;
rna_iterator_listbase_begin(iter, &clip->tracking.tracks, NULL);
}
@@ -295,10 +295,10 @@ static void rna_trackingObject_tracks_begin(CollectionPropertyIterator *iter, Po
static PointerRNA rna_trackingObject_reconstruction_get(PointerRNA *ptr)
{
- MovieTrackingObject *object = (MovieTrackingObject* )ptr->data;
+ MovieTrackingObject *object = (MovieTrackingObject * )ptr->data;
if (object->flag & TRACKING_OBJECT_CAMERA) {
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_MovieTrackingReconstruction, &clip->tracking.reconstruction);
}
@@ -309,7 +309,7 @@ static PointerRNA rna_trackingObject_reconstruction_get(PointerRNA *ptr)
static PointerRNA rna_tracking_active_object_get(PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTrackingObject *object = BLI_findlink(&clip->tracking.objects, clip->tracking.objectnr);
return rna_pointer_inherit_refine(ptr, &RNA_MovieTrackingObject, object);
@@ -317,7 +317,7 @@ static PointerRNA rna_tracking_active_object_get(PointerRNA *ptr)
static void rna_tracking_active_object_set(PointerRNA *ptr, PointerRNA value)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTrackingObject *object = (MovieTrackingObject *)value.data;
int index = BLI_findindex(&clip->tracking.objects, object);
@@ -337,9 +337,9 @@ void rna_trackingObject_name_set(PointerRNA *ptr, const char *value)
static void rna_trackingObject_flushUpdate(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- MovieClip *clip = (MovieClip*)ptr->id.data;
+ MovieClip *clip = (MovieClip *)ptr->id.data;
- WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, NULL);
DAG_id_tag_update(&clip->id, 0);
}
@@ -352,7 +352,7 @@ static void rna_trackingMarker_frame_set(PointerRNA *ptr, int value)
track = tracking->tracks.first;
while (track) {
- if (marker >= track->markers && marker < track->markers+track->markersnr) {
+ if (marker >= track->markers && marker < track->markers + track->markersnr) {
break;
}
@@ -363,8 +363,8 @@ static void rna_trackingMarker_frame_set(PointerRNA *ptr, int value)
MovieTrackingMarker new_marker = *marker;
new_marker.framenr = value;
- BKE_tracking_delete_marker(track, marker->framenr);
- BKE_tracking_insert_marker(track, &new_marker);
+ BKE_tracking_marker_delete(track, marker->framenr);
+ BKE_tracking_marker_insert(track, &new_marker);
}
}
@@ -372,14 +372,22 @@ static void rna_tracking_markerPattern_update(Main *UNUSED(bmain), Scene *UNUSED
{
MovieTrackingMarker *marker = (MovieTrackingMarker *)ptr->data;
- BKE_tracking_clamp_marker(marker, CLAMP_PAT_DIM);
+ BKE_tracking_marker_clamp(marker, CLAMP_PAT_DIM);
}
static void rna_tracking_markerSearch_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
MovieTrackingMarker *marker = (MovieTrackingMarker *)ptr->data;
- BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_DIM);
+ BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_DIM);
+}
+
+static void rna_trackingDopesheet_tagUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
+{
+ MovieClip *clip = (MovieClip *)ptr->id.data;
+ MovieTrackingDopesheet *dopesheet = &clip->tracking.dopesheet;
+
+ dopesheet->ok = 0;
}
/* API */
@@ -393,8 +401,8 @@ static void add_tracks_to_base(MovieClip *clip, MovieTracking *tracking, ListBas
BKE_movieclip_get_size(clip, &user, &width, &height);
- for (a = 0; a<number; a++)
- BKE_tracking_add_track(tracking, tracksbase, 0, 0, frame, width, height);
+ for (a = 0; a < number; a++)
+ BKE_tracking_track_add(tracking, tracksbase, 0, 0, frame, width, height);
}
static void rna_trackingTracks_add(ID *id, MovieTracking *tracking, int frame, int number)
@@ -403,7 +411,7 @@ static void rna_trackingTracks_add(ID *id, MovieTracking *tracking, int frame, i
add_tracks_to_base(clip, tracking, &tracking->tracks, frame, number);
- WM_main_add_notifier(NC_MOVIECLIP|NA_EDITED, clip);
+ WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, clip);
}
static void rna_trackingObject_tracks_add(ID *id, MovieTrackingObject *object, int frame, int number)
@@ -411,36 +419,36 @@ static void rna_trackingObject_tracks_add(ID *id, MovieTrackingObject *object, i
MovieClip *clip = (MovieClip *) id;
ListBase *tracksbase = &object->tracks;
- if (object->flag&TRACKING_OBJECT_CAMERA)
+ if (object->flag & TRACKING_OBJECT_CAMERA)
tracksbase = &clip->tracking.tracks;
add_tracks_to_base(clip, &clip->tracking, tracksbase, frame, number);
- WM_main_add_notifier(NC_MOVIECLIP|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL);
}
static MovieTrackingObject *rna_trackingObject_new(MovieTracking *tracking, const char *name)
{
- MovieTrackingObject *object = BKE_tracking_new_object(tracking, name);
+ MovieTrackingObject *object = BKE_tracking_object_add(tracking, name);
- WM_main_add_notifier(NC_MOVIECLIP|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL);
return object;
}
void rna_trackingObject_remove(MovieTracking *tracking, MovieTrackingObject *object)
{
- BKE_tracking_remove_object(tracking, object);
+ BKE_tracking_object_delete(tracking, object);
- WM_main_add_notifier(NC_MOVIECLIP|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL);
}
static MovieTrackingMarker *rna_trackingMarkers_find_frame(MovieTrackingTrack *track, int framenr)
{
- return BKE_tracking_exact_marker(track, framenr);
+ return BKE_tracking_marker_get_exact(track, framenr);
}
-static MovieTrackingMarker* rna_trackingMarkers_insert_frame(MovieTrackingTrack *track, int framenr, float *co)
+static MovieTrackingMarker *rna_trackingMarkers_insert_frame(MovieTrackingTrack *track, int framenr, float *co)
{
MovieTrackingMarker marker, *new_marker;
@@ -448,9 +456,9 @@ static MovieTrackingMarker* rna_trackingMarkers_insert_frame(MovieTrackingTrack
marker.framenr = framenr;
copy_v2_v2(marker.pos, co);
- new_marker = BKE_tracking_insert_marker(track, &marker);
+ new_marker = BKE_tracking_marker_insert(track, &marker);
- WM_main_add_notifier(NC_MOVIECLIP|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL);
return new_marker;
}
@@ -460,32 +468,34 @@ void rna_trackingMarkers_delete_frame(MovieTrackingTrack *track, int framenr)
if (track->markersnr == 1)
return;
- BKE_tracking_delete_marker(track, framenr);
+ BKE_tracking_marker_delete(track, framenr);
- WM_main_add_notifier(NC_MOVIECLIP|NA_EDITED, NULL);
+ WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL);
}
#else
static EnumPropertyItem tracker_motion_model[] = {
{TRACK_MOTION_MODEL_HOMOGRAPHY, "Perspective", 0, "Perspective",
- "Search for markers that are perspectively deformed (homography) between frames."},
+ "Search for markers that are perspectively deformed (homography) between frames"},
{TRACK_MOTION_MODEL_AFFINE, "Affine", 0, "Affine",
- "Search for markers that are affine-deformed (t, r, k, and skew) between frames."},
+ "Search for markers that are affine-deformed (t, r, k, and skew) between frames"},
{TRACK_MOTION_MODEL_TRANSLATION_ROTATION_SCALE, "LocRotScale", 0, "LocRotScale",
- "Search for markers that are translated, rotated, and scaled between frames."},
+ "Search for markers that are translated, rotated, and scaled between frames"},
{TRACK_MOTION_MODEL_TRANSLATION_SCALE, "LocScale", 0, "LocScale",
- "Search for markers that are translated and scaled between frames."},
+ "Search for markers that are translated and scaled between frames"},
{TRACK_MOTION_MODEL_TRANSLATION_ROTATION, "LocRot", 0, "LocRot",
- "Search for markers that are translated and rotated between frames."},
+ "Search for markers that are translated and rotated between frames"},
{TRACK_MOTION_MODEL_TRANSLATION, "Loc", 0, "Loc",
- "Search for markers that are translated between frames."},
- {0, NULL, 0, NULL, NULL}};
+ "Search for markers that are translated between frames"},
+ {0, NULL, 0, NULL, NULL}
+};
static EnumPropertyItem pattern_match_items[] = {
{TRACK_MATCH_KEYFRAME, "KEYFRAME", 0, "Keyframe", "Track pattern from keyframe to next frame"},
{TRACK_MATCH_PREVFRAME, "PREV_FRAME", 0, "Previous frame", "Track pattern from current frame to next frame"},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+};
static int rna_matrix_dimsize_4x4[] = {4, 4};
static int rna_matrix_dimsize_4x2[] = {4, 2};
@@ -497,11 +507,12 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
static EnumPropertyItem speed_items[] = {
{0, "FASTEST", 0, "Fastest", "Track as fast as it's possible"},
- {TRACKING_SPEED_DOUBLE, "DOUBLE", 0, "Double", "Track with double speed"},
+ {TRACKING_SPEED_DOUBLE, "DOUBLE", 0, "Double", "Track with double speed"},
{TRACKING_SPEED_REALTIME, "REALTIME", 0, "Realtime", "Track with realtime speed"},
{TRACKING_SPEED_HALF, "HALF", 0, "Half", "Track with half of realtime speed"},
{TRACKING_SPEED_QUARTER, "QUARTER", 0, "Quarter", "Track with quarter of realtime speed"},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
static EnumPropertyItem cleanup_items[] = {
{TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"},
@@ -513,21 +524,21 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
static EnumPropertyItem refine_items[] = {
{0, "NONE", 0, "Nothing", "Do not refine camera intrinsics"},
{REFINE_FOCAL_LENGTH, "FOCAL_LENGTH", 0, "Focal Length", "Refine focal length"},
- {REFINE_FOCAL_LENGTH|REFINE_RADIAL_DISTORTION_K1, "FOCAL_LENGTH_RADIAL_K1", 0, "Focal length, K1",
- "Refine focal length and radial distortion K1"},
- {REFINE_FOCAL_LENGTH|
- REFINE_RADIAL_DISTORTION_K1|
+ {REFINE_FOCAL_LENGTH | REFINE_RADIAL_DISTORTION_K1, "FOCAL_LENGTH_RADIAL_K1", 0, "Focal length, K1",
+ "Refine focal length and radial distortion K1"},
+ {REFINE_FOCAL_LENGTH |
+ REFINE_RADIAL_DISTORTION_K1 |
REFINE_RADIAL_DISTORTION_K2, "FOCAL_LENGTH_RADIAL_K1_K2", 0, "Focal length, K1, K2",
- "Refine focal length and radial distortion K1 and K2"},
- {REFINE_FOCAL_LENGTH|
- REFINE_PRINCIPAL_POINT|
- REFINE_RADIAL_DISTORTION_K1|
+ "Refine focal length and radial distortion K1 and K2"},
+ {REFINE_FOCAL_LENGTH |
+ REFINE_PRINCIPAL_POINT |
+ REFINE_RADIAL_DISTORTION_K1 |
REFINE_RADIAL_DISTORTION_K2, "FOCAL_LENGTH_PRINCIPAL_POINT_RADIAL_K1_K2", 0,
- "Focal Length, Optical Center, K1, K2",
- "Refine focal length, optical center and radial distortion K1 and K2"},
- {REFINE_FOCAL_LENGTH|
+ "Focal Length, Optical Center, K1, K2",
+ "Refine focal length, optical center and radial distortion K1 and K2"},
+ {REFINE_FOCAL_LENGTH |
REFINE_PRINCIPAL_POINT, "FOCAL_LENGTH_PRINCIPAL_POINT", 0, "Focal Length, Optical Center",
- "Refine focal length and optical center"},
+ "Refine focal length and optical center"},
{0, NULL, 0, NULL, NULL}
};
@@ -634,17 +645,23 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, tracker_motion_model);
RNA_def_property_ui_text(prop, "Motion model", "Default motion model to use for tracking");
- /* use_brute */
+ /* default_use_brute */
prop = RNA_def_property(srna, "default_use_brute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "default_algorithm_flag", TRACK_ALGORITHM_FLAG_USE_BRUTE);
RNA_def_property_ui_text(prop, "Prepass", "Use a brute-force translation-only initialization when tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
- /* default use_normalization */
+ /* default_use_brute */
+ prop = RNA_def_property(srna, "default_use_mask", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "default_algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK);
+ RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+
+ /* default_use_normalization */
prop = RNA_def_property(srna, "default_use_normalization", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "default_algorithm_flag", TRACK_ALGORITHM_FLAG_USE_NORMALIZATION);
- RNA_def_property_ui_text(prop, "Normalize", "Normalize light intensities while tracking. Slower");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_ui_text(prop, "Normalize", "Normalize light intensities while tracking (slower)");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* default minmal correlation */
prop = RNA_def_property(srna, "default_correlation_min", PROP_FLOAT, PROP_NONE);
@@ -677,19 +694,19 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_default_red_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "default_flag", TRACK_DISABLE_RED);
RNA_def_property_ui_text(prop, "Use Red Channel", "Use red channel from footage for tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* default_use_green_channel */
prop = RNA_def_property(srna, "use_default_green_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "default_flag", TRACK_DISABLE_GREEN);
RNA_def_property_ui_text(prop, "Use Green Channel", "Use green channel from footage for tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* default_use_blue_channel */
prop = RNA_def_property(srna, "use_default_blue_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "default_flag", TRACK_DISABLE_BLUE);
RNA_def_property_ui_text(prop, "Use Blue Channel", "Use blue channel from footage for tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* ** object tracking ** */
@@ -711,7 +728,8 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
static EnumPropertyItem camera_units_items[] = {
{CAMERA_UNITS_PX, "PIXELS", 0, "px", "Use pixels for units of focal length"},
{CAMERA_UNITS_MM, "MILLIMETERS", 0, "mm", "Use millimeters for units of focal length"},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "MovieTrackingCamera", NULL);
RNA_def_struct_path_func(srna, "rna_trackingCamera_path");
@@ -723,7 +741,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, 500.0f);
RNA_def_property_ui_text(prop, "Sensor", "Width of CCD sensor in millimeters");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
/* Focal Length */
prop = RNA_def_property(srna, "focal_length", PROP_FLOAT, PROP_NONE);
@@ -732,7 +750,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0001f, 5000.0f);
RNA_def_property_float_funcs(prop, "rna_trackingCamera_focal_mm_get", "rna_trackingCamera_focal_mm_set", NULL);
RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
/* Focal Length in pixels */
prop = RNA_def_property(srna, "focal_length_pixels", PROP_FLOAT, PROP_NONE);
@@ -740,7 +758,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, 5000.0f);
RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
/* Units */
prop = RNA_def_property(srna, "units", PROP_ENUM, PROP_NONE);
@@ -756,7 +774,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "principal");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Principal Point", "Optical center of lens");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
/* Radial distortion parameters */
prop = RNA_def_property(srna, "k1", PROP_FLOAT, PROP_NONE);
@@ -764,21 +782,21 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K1", "First coefficient of third order polynomial radial distortion");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate");
prop = RNA_def_property(srna, "k2", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "k2");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K2", "Second coefficient of third order polynomial radial distortion");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate");
prop = RNA_def_property(srna, "k3", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "k3");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K3", "Third coefficient of third order polynomial radial distortion");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate");
/* pixel aspect */
prop = RNA_def_property(srna, "pixel_aspect", PROP_FLOAT, PROP_XYZ);
@@ -788,7 +806,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Pixel Aspect Ratio", "Pixel aspect ratio");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
}
static void rna_def_trackingMarker(BlenderRNA *brna)
@@ -805,20 +823,20 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_float_sdna(prop, NULL, "pos");
RNA_def_property_ui_text(prop, "Position", "Marker position at frame in normalized coordinates");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
/* frame */
prop = RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "framenr");
RNA_def_property_ui_text(prop, "Frame", "Frame number marker is keyframed on");
RNA_def_property_int_funcs(prop, NULL, "rna_trackingMarker_frame_set", NULL);
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, 0);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, 0);
/* enable */
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MARKER_DISABLED);
RNA_def_property_ui_text(prop, "Mode", "Is marker muted for current frame");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
/* pattern */
prop = RNA_def_property(srna, "pattern_corners", PROP_FLOAT, PROP_MATRIX);
@@ -827,9 +845,9 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x2);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(prop, "Pattern Corners",
- "Array of coordinates which represents patter's corners in "
- " normalized coordinates relative to marker position");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_markerPattern_update");
+ "Array of coordinates which represents pattern's corners in "
+ "normalized coordinates relative to marker position");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_markerPattern_update");
/* search */
prop = RNA_def_property(srna, "search_min", PROP_FLOAT, PROP_TRANSLATION);
@@ -838,9 +856,9 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "search_min");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Search Min",
- "Left-bottom corner of search area in normalized coordinates relative "
- "to marker position");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_markerSearch_update");
+ "Left-bottom corner of search area in normalized coordinates relative "
+ "to marker position");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_markerSearch_update");
prop = RNA_def_property(srna, "search_max", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 2);
@@ -848,9 +866,9 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "search_max");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Search Max",
- "Right-bottom corner of search area in normalized coordinates relative "
- "to marker position");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_markerSearch_update");
+ "Right-bottom corner of search area in normalized coordinates relative "
+ "to marker position");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_markerSearch_update");
}
static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop)
@@ -907,8 +925,8 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Unique name of track");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_trackingTrack_name_set");
- RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2);
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
RNA_def_struct_name_property(srna, prop);
/* limit frames */
@@ -958,14 +976,20 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "algorithm_flag", TRACK_ALGORITHM_FLAG_USE_BRUTE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Prepass", "Use a brute-force translation only pre-track before refinement");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* use_brute */
+ prop = RNA_def_property(srna, "use_mask", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK);
+ RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+
+ /* use_normalization */
prop = RNA_def_property(srna, "use_normalization", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "algorithm_flag", TRACK_ALGORITHM_FLAG_USE_NORMALIZATION);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Normalize", "Normalize light intensities while tracking. Slower");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* markers */
prop = RNA_def_property(srna, "markers", PROP_COLLECTION, PROP_NONE);
@@ -981,28 +1005,35 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_RED);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Red Channel", "Use red channel from footage for tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* use_green_channel */
prop = RNA_def_property(srna, "use_green_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_GREEN);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Green Channel", "Use green channel from footage for tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* use_blue_channel */
prop = RNA_def_property(srna, "use_blue_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_BLUE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Blue Channel", "Use blue channel from footage for tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* preview_grayscale */
prop = RNA_def_property(srna, "use_grayscale_preview", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_PREVIEW_GRAYSCALE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Grayscale", "Display what the tracking algorithm sees in the preview");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+
+ /* preview_alpha */
+ prop = RNA_def_property(srna, "use_alpha_preview", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_PREVIEW_ALPHA);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Alpha", "Apply track's mask on displaying preview");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* has bundle */
prop = RNA_def_property(srna, "has_bundle", PROP_BOOLEAN, PROP_NONE);
@@ -1023,45 +1054,45 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_HIDDEN);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Hide", "Track is hidden");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* select */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_trackingTrack_select_get", "rna_trackingTrack_select_set");
RNA_def_property_ui_text(prop, "Select", "Track is selected");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* select_anchor */
prop = RNA_def_property(srna, "select_anchor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_ui_text(prop, "Select Anchor", "Track's anchor point is selected");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* select_pattern */
prop = RNA_def_property(srna, "select_pattern", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "pat_flag", SELECT);
RNA_def_property_ui_text(prop, "Select Pattern", "Track's pattern area is selected");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* select_search */
prop = RNA_def_property(srna, "select_search", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "search_flag", SELECT);
RNA_def_property_ui_text(prop, "Select Search", "Track's search area is selected");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* locked */
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_LOCKED);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Lock", "Track is locked and all changes to it are disabled");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* custom color */
prop = RNA_def_property(srna, "use_custom_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_CUSTOMCOLOR);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Custom Color", "Use custom color instead of theme-defined");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* color */
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
@@ -1069,7 +1100,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Color",
"Color of the track in the Movie Clip Editor and the 3D viewport after a solve");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* average error */
prop = RNA_def_property(srna, "average_error", PROP_FLOAT, PROP_NONE);
@@ -1095,7 +1126,8 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
{TRACKING_FILTER_NEAREAST, "NEAREST", 0, "Nearest", ""},
{TRACKING_FILTER_BILINEAR, "BILINEAR", 0, "Bilinear", ""},
{TRACKING_FILTER_BICUBIC, "BICUBIC", 0, "Bicubic", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "MovieTrackingStabilization", NULL);
RNA_def_struct_path_func(srna, "rna_trackingStabilization_path");
@@ -1106,7 +1138,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_2D_STABILIZATION);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use 2D stabilization", "Use 2D stabilization for footage");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* tracks */
prop = RNA_def_property(srna, "tracks", PROP_COLLECTION, PROP_NONE);
@@ -1115,14 +1147,14 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
NULL, NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "MovieTrackingTrack");
RNA_def_property_ui_text(prop, "Tracks", "Collection of tracks used for stabilization");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* rotation track */
prop = RNA_def_property(srna, "rotation_track", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "rot_track");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Rotation Track", "Track used to compensate rotation");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate");
/* active track index */
prop = RNA_def_property(srna, "active_track_index", PROP_INT, PROP_NONE);
@@ -1139,49 +1171,49 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Autoscale",
"Automatically scale footage to cover unfilled areas when stabilizating");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* max scale */
prop = RNA_def_property(srna, "scale_max", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "maxscale");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Maximal Scale", "Limit the amount of automatic scaling");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* influence_location */
prop = RNA_def_property(srna, "influence_location", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "locinf");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Location Influence", "Influence of stabilization algorithm on footage location");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* influence_scale */
prop = RNA_def_property(srna, "influence_scale", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "scaleinf");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Scale Influence", "Influence of stabilization algorithm on footage scale");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* use_stabilize_rotation */
prop = RNA_def_property(srna, "use_stabilize_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_STABILIZE_ROTATION);
RNA_def_property_ui_text(prop, "Stabilize Rotation", "Stabilize horizon line on the shot");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* influence_rotation */
prop = RNA_def_property(srna, "influence_rotation", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "rotinf");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Rotation Influence", "Influence of stabilization algorithm on footage rotation");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
/* filter */
prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "filter");
RNA_def_property_enum_items(prop, filter_items);
RNA_def_property_ui_text(prop, "Filter", "Method to use to filter stabilization");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");
}
static void rna_def_reconstructedCamera(BlenderRNA *brna)
@@ -1263,7 +1295,7 @@ static void rna_def_trackingTracks(BlenderRNA *brna)
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "MovieTrackingTrack");
RNA_def_property_pointer_funcs(prop, "rna_tracking_active_track_get", "rna_tracking_active_track_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Track", "Active track in this tracking data object");
}
@@ -1287,7 +1319,7 @@ static void rna_def_trackingObjectTracks(BlenderRNA *brna)
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "MovieTrackingTrack");
RNA_def_property_pointer_funcs(prop, "rna_tracking_active_track_get", "rna_tracking_active_track_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Track", "Active track in this tracking data object");
}
@@ -1303,8 +1335,8 @@ static void rna_def_trackingObject(BlenderRNA *brna)
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Unique name of object");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_trackingObject_name_set");
- RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2);
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+ RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
RNA_def_struct_name_property(srna, prop);
/* is_camera */
@@ -1312,7 +1344,7 @@ static void rna_def_trackingObject(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_OBJECT_CAMERA);
RNA_def_property_ui_text(prop, "Camera", "Object is used for camera tracking");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* tracks */
prop = RNA_def_property(srna, "tracks", PROP_COLLECTION, PROP_NONE);
@@ -1336,7 +1368,7 @@ static void rna_def_trackingObject(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0001f, 10000.0, 1, 4);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Scale", "Scale of object solution in camera space");
- RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_trackingObject_flushUpdate");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingObject_flushUpdate");
}
static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1368,10 +1400,54 @@ static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_struct_type(prop, "MovieTrackingObject");
RNA_def_property_pointer_funcs(prop, "rna_tracking_active_object_get",
"rna_tracking_active_object_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Object", "Active object in this tracking data object");
}
+static void rna_def_trackingDopesheet(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static EnumPropertyItem sort_items[] = {
+ {TRACKING_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"},
+ {TRACKING_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"},
+ {TRACKING_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"},
+ {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", "Sort channels by average reprojection error of tracks after solve"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "MovieTrackingDopesheet", NULL);
+ RNA_def_struct_ui_text(srna, "Movie Tracking Dopesheet", "Match-moving dopesheet data");
+
+ /* dopesheet sort */
+ prop = RNA_def_property(srna, "sort_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "sort_method");
+ RNA_def_property_enum_items(prop, sort_items);
+ RNA_def_property_ui_text(prop, "Dopesheet Sort Field", "Method to be used to sort channels in dopesheet view");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate");
+
+ /* invert_dopesheet_sort */
+ prop = RNA_def_property(srna, "use_invert_sort", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_DOPE_SORT_INVERSE);
+ RNA_def_property_ui_text(prop, "Invert Dopesheet Sort", "Invert sort order of dopesheet channels");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate");
+
+ /* show_only_selected */
+ prop = RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_DOPE_SELECTED_ONLY);
+ RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data");
+ RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate");
+
+ /* show_hidden */
+ prop = RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_DOPE_SHOW_HIDDEN);
+ RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible");
+ RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate");
+}
+
static void rna_def_tracking(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1385,6 +1461,7 @@ static void rna_def_tracking(BlenderRNA *brna)
rna_def_trackingStabilization(brna);
rna_def_trackingReconstruction(brna);
rna_def_trackingObject(brna);
+ rna_def_trackingDopesheet(brna);
srna = RNA_def_struct(brna, "MovieTracking", NULL);
RNA_def_struct_path_func(srna, "rna_tracking_path");
@@ -1431,7 +1508,11 @@ static void rna_def_tracking(BlenderRNA *brna)
RNA_def_property_int_funcs(prop, "rna_tracking_active_object_index_get", "rna_tracking_active_object_index_set",
"rna_tracking_active_object_index_range");
RNA_def_property_ui_text(prop, "Active Object Index", "Index of active object");
- RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+
+ /* dopesheet */
+ prop = RNA_def_property(srna, "dopesheet", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "MovieTrackingDopesheet");
}
void RNA_def_tracking(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 792d3b88d73..26e241a0311 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -144,6 +144,11 @@ static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA
rna_userdef_update(bmain, scene, ptr);
}
+static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) {
+ GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
+ rna_userdef_update(bmain, scene, ptr);
+}
+
static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
GPU_free_images();
@@ -3153,6 +3158,11 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "16 Bit Float Textures", "Use 16 bit per component texture for float images");
RNA_def_property_update(prop, 0, "rna_userdef_gl_use_16bit_textures");
+ prop = RNA_def_property(srna, "use_gpu_mipmap", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_gpu_mipmap", 1);
+ RNA_def_property_ui_text(prop, "GPU Mipmap Generation", "Generate Image Mipmaps on the GPU");
+ RNA_def_property_update(prop, 0, "rna_userdef_gl_gpu_mipmaps");
+
prop = RNA_def_property(srna, "use_vertex_buffer_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_VBO);
RNA_def_property_ui_text(prop, "VBOs",
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 39e08c1cb5d..41057234d9b 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -220,9 +220,12 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4],
const char *dupe_slot_name,
BMOperator *weld_op)
{
- BMVert *v, *v2;
+ BMVert *v, *v2, *v3;
BMIter iter;
+ /* Add the DerivedMesh's elements to the BMesh. The pre-existing
+ elements were already tagged, so the new elements can be
+ identified by not having the BM_ELEM_TAG flag set. */
DM_to_bmesh_ex(dm, bm);
if (amd->flags & MOD_ARR_MERGE) {
@@ -252,6 +255,11 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4],
/* add new merge targets to weld operator */
BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) {
v2 = BMO_iter_map_value_p(&oiter);
+ /* check in case the target vertex (v2) is already marked
+ * for merging */
+ while ((v3 = BMO_slot_map_ptr_get(bm, weld_op, "targetmap", v2))) {
+ v2 = v3;
+ }
BMO_slot_map_ptr_insert(bm, weld_op, "targetmap", v, v2);
}
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 36c052440b6..14735810cad 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -51,8 +51,6 @@
#include "MOD_util.h"
-
-
/* Clamps/Limits the given coordinate to: limits[0] <= co[axis] <= limits[1]
* The amount of clamp is saved on dcut */
static void axis_limit(int axis, const float limits[2], float co[3], float dcut[3])
@@ -65,79 +63,79 @@ static void axis_limit(int axis, const float limits[2], float co[3], float dcut[
co[axis] = val;
}
-static void simpleDeform_taper(const float factor, const float dcut[3], float *co)
+static void simpleDeform_taper(const float factor, const float dcut[3], float r_co[3])
{
- float x = co[0], y = co[1], z = co[2];
+ float x = r_co[0], y = r_co[1], z = r_co[2];
float scale = z * factor;
- co[0] = x + x * scale;
- co[1] = y + y * scale;
- co[2] = z;
+ r_co[0] = x + x * scale;
+ r_co[1] = y + y * scale;
+ r_co[2] = z;
if (dcut) {
- co[0] += dcut[0];
- co[1] += dcut[1];
- co[2] += dcut[2];
+ r_co[0] += dcut[0];
+ r_co[1] += dcut[1];
+ r_co[2] += dcut[2];
}
}
-static void simpleDeform_stretch(const float factor, const float dcut[3], float *co)
+static void simpleDeform_stretch(const float factor, const float dcut[3], float r_co[3])
{
- float x = co[0], y = co[1], z = co[2];
+ float x = r_co[0], y = r_co[1], z = r_co[2];
float scale;
scale = (z * z * factor - factor + 1.0f);
- co[0] = x * scale;
- co[1] = y * scale;
- co[2] = z * (1.0f + factor);
+ r_co[0] = x * scale;
+ r_co[1] = y * scale;
+ r_co[2] = z * (1.0f + factor);
if (dcut) {
- co[0] += dcut[0];
- co[1] += dcut[1];
- co[2] += dcut[2];
+ r_co[0] += dcut[0];
+ r_co[1] += dcut[1];
+ r_co[2] += dcut[2];
}
}
-static void simpleDeform_twist(const float factor, const float *dcut, float *co)
+static void simpleDeform_twist(const float factor, const float *dcut, float r_co[3])
{
- float x = co[0], y = co[1], z = co[2];
+ float x = r_co[0], y = r_co[1], z = r_co[2];
float theta, sint, cost;
theta = z * factor;
- sint = sin(theta);
- cost = cos(theta);
+ sint = sinf(theta);
+ cost = cosf(theta);
- co[0] = x * cost - y * sint;
- co[1] = x * sint + y * cost;
- co[2] = z;
+ r_co[0] = x * cost - y * sint;
+ r_co[1] = x * sint + y * cost;
+ r_co[2] = z;
if (dcut) {
- co[0] += dcut[0];
- co[1] += dcut[1];
- co[2] += dcut[2];
+ r_co[0] += dcut[0];
+ r_co[1] += dcut[1];
+ r_co[2] += dcut[2];
}
}
-static void simpleDeform_bend(const float factor, const float dcut[3], float *co)
+static void simpleDeform_bend(const float factor, const float dcut[3], float r_co[3])
{
- float x = co[0], y = co[1], z = co[2];
+ float x = r_co[0], y = r_co[1], z = r_co[2];
float theta, sint, cost;
theta = x * factor;
- sint = sin(theta);
- cost = cos(theta);
+ sint = sinf(theta);
+ cost = cosf(theta);
if (fabsf(factor) > 1e-7f) {
- co[0] = -(y - 1.0f / factor) * sint;
- co[1] = (y - 1.0f / factor) * cost + 1.0f / factor;
- co[2] = z;
+ r_co[0] = -(y - 1.0f / factor) * sint;
+ r_co[1] = (y - 1.0f / factor) * cost + 1.0f / factor;
+ r_co[2] = z;
}
if (dcut) {
- co[0] += cost * dcut[0];
- co[1] += sint * dcut[0];
- co[2] += dcut[2];
+ r_co[0] += cost * dcut[0];
+ r_co[1] += sint * dcut[0];
+ r_co[2] += dcut[2];
}
}
@@ -153,7 +151,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
int limit_axis = 0;
float smd_limit[2], smd_factor;
SpaceTransform *transf = NULL, tmp_transf;
- void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; /* Mode callback */
+ void (*simpleDeform_callback)(const float factor, const float dcut[3], float co[3]) = NULL; /* Mode callback */
int vgroup;
MDeformVert *dvert;
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 8b2a5ebd263..2415c7842a7 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -76,6 +76,8 @@ set(SRC
composite/nodes/node_composite_idMask.c
composite/nodes/node_composite_image.c
composite/nodes/node_composite_invert.c
+ composite/nodes/node_composite_keyingscreen.c
+ composite/nodes/node_composite_keying.c
composite/nodes/node_composite_lensdist.c
composite/nodes/node_composite_levels.c
composite/nodes/node_composite_lummaMatte.c
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index f850ea91f12..33d6327ece1 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -105,6 +105,8 @@ void register_node_type_cmp_channel_matte(struct bNodeTreeType *ttype);
void register_node_type_cmp_color_spill(struct bNodeTreeType *ttype);
void register_node_type_cmp_luma_matte(struct bNodeTreeType *ttype);
void register_node_type_cmp_doubleedgemask(struct bNodeTreeType *ttype);
+void register_node_type_cmp_keyingscreen(struct bNodeTreeType *ttype);
+void register_node_type_cmp_keying(struct bNodeTreeType *ttype);
void register_node_type_cmp_translate(struct bNodeTreeType *ttype);
void register_node_type_cmp_rotate(struct bNodeTreeType *ttype);
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 457322929b0..5813f4d479f 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -222,7 +222,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
copied back to original node */
if (lnode->storage) {
if (lnode->new_node->storage)
- BKE_tracking_distortion_destroy(lnode->new_node->storage);
+ BKE_tracking_distortion_free(lnode->new_node->storage);
lnode->new_node->storage= BKE_tracking_distortion_copy(lnode->storage);
}
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index ff223ac83cf..afd10d96e99 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -1022,7 +1022,7 @@ void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2)
for (y=0; y<in2->y; y++) {
colp = (fRGB*)&in2->rect[y*in2->x*in2->type];
for (x=0; x<in2->x; x++)
- fRGB_add(wt, colp[x]);
+ add_v3_v3(wt, colp[x]);
}
if (wt[0] != 0.f) wt[0] = 1.f/wt[0];
if (wt[1] != 0.f) wt[1] = 1.f/wt[1];
@@ -1030,7 +1030,7 @@ void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2)
for (y=0; y<in2->y; y++) {
colp = (fRGB*)&in2->rect[y*in2->x*in2->type];
for (x=0; x<in2->x; x++)
- fRGB_colormult(colp[x], wt);
+ mul_v3_v3(colp[x], wt);
}
// copy image data, unpacking interleaved RGBA into separate channels
@@ -1279,14 +1279,14 @@ CompBuf* qd_downScaledCopy(CompBuf* src, int scale)
xx = x*scale;
mx = xx + scale;
if (mx > src->x) mx = src->x;
- colsum[0] = colsum[1] = colsum[2] = 0.f;
+ zero_v3(colsum);
for (sy=yy; sy<my; sy++) {
fRGB* scolp = (fRGB*)&src->rect[sy*src->x*src->type];
for (sx=xx; sx<mx; sx++)
- fRGB_add(colsum, scolp[sx]);
+ add_v3_v3(colsum, scolp[sx]);
}
- fRGB_mult(colsum, fscale);
- fRGB_copy(fcolp[x], colsum);
+ mul_v3_fl(colsum, fscale);
+ copy_v3_v3(fcolp[x], colsum);
}
}
}
diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h
index cab60caaae7..8f772b19d5e 100644
--- a/source/blender/nodes/composite/node_composite_util.h
+++ b/source/blender/nodes/composite/node_composite_util.h
@@ -182,30 +182,8 @@ extern void node_ID_title_cb(void *node_v, void *unused_v);
/* utility functions used by glare, tonemap and lens distortion */
/* soms macros for color handling */
typedef float fRGB[4];
-/* clear color */
-#define fRGB_clear(c) { c[0]=c[1]=c[2]=0.f; } (void)0
-/* copy c2 to c1 */
-#define fRGB_copy(c1, c2) { c1[0]=c2[0]; c1[1]=c2[1]; c1[2]=c2[2]; c1[3]=c2[3]; } (void)0
-/* add c2 to c1 */
-#define fRGB_add(c1, c2) { c1[0]+=c2[0]; c1[1]+=c2[1]; c1[2]+=c2[2]; } (void)0
-/* subtract c2 from c1 */
-#define fRGB_sub(c1, c2) { c1[0]-=c2[0]; c1[1]-=c2[1]; c1[2]-=c2[2]; } (void)0
-/* multiply c by float value s */
-#define fRGB_mult(c, s) { c[0]*=s; c[1]*=s; c[2]*=s; } (void)0
-/* multiply c2 by s and add to c1 */
-#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s; c1[1]+=c2[1]*s; c1[2]+=c2[2]*s; } (void)0
-/* multiply c2 by color c1 */
-#define fRGB_colormult(c, cs) { c[0]*=cs[0]; c[1]*=cs[1]; c[2]*=cs[2]; } (void)0
-/* multiply c2 by color c3 and add to c1 */
-#define fRGB_colormadd(c1, c2, c3) { c1[0]+=c2[0]*c3[0]; c1[1]+=c2[1]*c3[1]; c1[2]+=c2[2]*c3[2]; } (void)0
/* multiply c2 by color rgb, rgb as separate arguments */
#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r); c[1]*=(g); c[2]*=(b); } (void)0
-/* swap colors c1 & c2 */
-#define fRGB_swap(c1, c2) { float _t=c1[0]; c1[0]=c2[0]; c2[0]=_t;\
- _t=c1[1]; c1[1]=c2[1]; c2[1]=_t;\
- _t=c1[2]; c1[2]=c2[2]; c2[2]=_t;\
- _t=c1[3]; c1[3]=c2[3]; c3[3]=_t;\
- } (void)0
void qd_getPixel(CompBuf* src, int x, int y, float* col);
void qd_setPixel(CompBuf* src, int x, int y, float* col);
diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
index 196234d658f..62e8138f5e1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
@@ -32,71 +32,71 @@
#include "node_composite_util.h"
/* **************** BILATERALBLUR ******************** */
-static bNodeSocketTemplate cmp_node_bilateralblur_in[]= {
+static bNodeSocketTemplate cmp_node_bilateralblur_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_bilateralblur_out[]= {
+static bNodeSocketTemplate cmp_node_bilateralblur_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
#define INIT_C3 \
- mean0 = 1; \
- mean1[0] = src[0]; \
- mean1[1] = src[1]; \
- mean1[2] = src[2]; \
- mean1[3] = src[3]; \
- (void)0
+ mean0 = 1; \
+ mean1[0] = src[0]; \
+ mean1[1] = src[1]; \
+ mean1[2] = src[2]; \
+ mean1[3] = src[3]; \
+ (void)0
/* finds color distances */
#define COLOR_DISTANCE_C3(c1, c2) \
- ((c1[0] - c2[0])*(c1[0] - c2[0]) + \
- (c1[1] - c2[1])*(c1[1] - c2[1]) + \
- (c1[2] - c2[2])*(c1[2] - c2[2]) + \
- (c1[3] - c2[3])*(c1[3] - c2[3]))
+ ((c1[0] - c2[0]) * (c1[0] - c2[0]) + \
+ (c1[1] - c2[1]) * (c1[1] - c2[1]) + \
+ (c1[2] - c2[2]) * (c1[2] - c2[2]) + \
+ (c1[3] - c2[3]) * (c1[3] - c2[3]))
/* this is the main kernel function for comparing color distances
- and adding them weighted to the final color */
+ and adding them weighted to the final color */
#define KERNEL_ELEMENT_C3(k) \
- temp_color = src + deltas[k]; \
- ref_color = ref + deltas[k]; \
- w = weight_tab[k] + \
- (double)COLOR_DISTANCE_C3(ref, ref_color ) * i2sigma_color; \
- w = 1.0/(w*w + 1); \
- mean0 += w; \
- mean1[0] += (double)temp_color[0] * w; \
- mean1[1] += (double)temp_color[1] * w; \
- mean1[2] += (double)temp_color[2] * w; \
- mean1[3] += (double)temp_color[3] * w; \
- (void)0
+ temp_color = src + deltas[k]; \
+ ref_color = ref + deltas[k]; \
+ w = weight_tab[k] + \
+ (double)COLOR_DISTANCE_C3(ref, ref_color) * i2sigma_color; \
+ w = 1.0 / (w * w + 1); \
+ mean0 += w; \
+ mean1[0] += (double)temp_color[0] * w; \
+ mean1[1] += (double)temp_color[1] * w; \
+ mean1[2] += (double)temp_color[2] * w; \
+ mean1[3] += (double)temp_color[3] * w; \
+ (void)0
/* write blurred values to image */
#define UPDATE_OUTPUT_C3 \
- mean0 = 1.0/mean0; \
- dest[x * pix + 0] = mean1[0] * mean0; \
- dest[x * pix + 1] = mean1[1] * mean0; \
- dest[x * pix + 2] = mean1[2] * mean0; \
- dest[x * pix + 3] = mean1[3] * mean0; \
- (void)0
+ mean0 = 1.0 / mean0; \
+ dest[x * pix + 0] = mean1[0] * mean0; \
+ dest[x * pix + 1] = mean1[1] * mean0; \
+ dest[x * pix + 2] = mean1[2] * mean0; \
+ dest[x * pix + 3] = mean1[3] * mean0; \
+ (void)0
/* initializes deltas for fast access to neighbor pixels */
-#define INIT_3X3_DELTAS( deltas, step, nch ) \
- ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
- (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
- (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
- (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); \
- (void)0
+#define INIT_3X3_DELTAS(deltas, step, nch) \
+ ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
+ (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
+ (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
+ (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); \
+ (void)0
/* code of this node was heavily inspired by the smooth function of opencv library.
* The main change is an optional image input */
static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeBilateralBlurData *nbbd= node->storage;
- CompBuf *new, *source, *img= in[0]->data, *refimg= in[1]->data;
+ NodeBilateralBlurData *nbbd = node->storage;
+ CompBuf *new, *source, *img = in[0]->data, *refimg = in[1]->data;
double mean0, w, i2sigma_color, i2sigma_space;
double mean1[4];
double weight_tab[8];
@@ -104,46 +104,46 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
float sigma_color, sigma_space;
int imgx, imgy, x, y, pix, i, step;
int deltas[8];
- short found_determinator= 0;
+ short found_determinator = 0;
if (img == NULL || out[0]->hasoutput == 0)
return;
if (img->type != CB_RGBA) {
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
}
- imgx= img->x;
- imgy= img->y;
- pix= img->type;
- step= pix * imgx;
+ imgx = img->x;
+ imgy = img->y;
+ pix = img->type;
+ step = pix * imgx;
if (refimg) {
if (refimg->x == imgx && refimg->y == imgy) {
if (ELEM3(refimg->type, CB_VAL, CB_VEC2, CB_VEC3)) {
- refimg= typecheck_compbuf(in[1]->data, CB_RGBA);
- found_determinator= 1;
+ refimg = typecheck_compbuf(in[1]->data, CB_RGBA);
+ found_determinator = 1;
}
}
}
else {
- refimg= img;
+ refimg = img;
}
/* allocs */
- source= dupalloc_compbuf(img);
- new= alloc_compbuf(imgx, imgy, pix, 1);
+ source = dupalloc_compbuf(img);
+ new = alloc_compbuf(imgx, imgy, pix, 1);
/* accept image offsets from other nodes */
- new->xof= img->xof;
- new->yof= img->yof;
+ new->xof = img->xof;
+ new->yof = img->yof;
/* bilateral code properties */
- sigma_color= nbbd->sigma_color;
- sigma_space= nbbd->sigma_space;
+ sigma_color = nbbd->sigma_color;
+ sigma_space = nbbd->sigma_space;
- i2sigma_color= 1.0f / (sigma_color * sigma_color);
- i2sigma_space= 1.0f / (sigma_space * sigma_space);
+ i2sigma_color = 1.0f / (sigma_color * sigma_color);
+ i2sigma_space = 1.0f / (sigma_space * sigma_space);
INIT_3X3_DELTAS(deltas, step, pix);
@@ -151,13 +151,13 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
weight_tab[1] = weight_tab[3] = weight_tab[5] = weight_tab[7] = i2sigma_space * 2;
/* iterations */
- for (i= 0; i < nbbd->iter; i++) {
- src= source->rect;
- ref= refimg->rect;
- dest= new->rect;
+ for (i = 0; i < nbbd->iter; i++) {
+ src = source->rect;
+ ref = refimg->rect;
+ dest = new->rect;
/*goes through image, there are more loops for 1st/last line and all other lines*/
/*kernel element accumulates surrounding colors, which are then written with the update_output function*/
- for (x= 0; x < imgx; x++, src+= pix, ref+= pix) {
+ for (x = 0; x < imgx; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(6);
@@ -175,10 +175,10 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
}
- dest+= step;
+ dest += step;
- for (y= 1; y < imgy - 1; y++, dest+= step, src+= pix, ref+= pix) {
- x= 0;
+ for (y = 1; y < imgy - 1; y++, dest += step, src += pix, ref += pix) {
+ x = 0;
INIT_C3;
@@ -190,10 +190,10 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
- src+= pix;
- ref+= pix;
+ src += pix;
+ ref += pix;
- for (x= 1; x < imgx - 1; x++, src+= pix, ref+= pix) {
+ for (x = 1; x < imgx - 1; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(0);
@@ -219,7 +219,7 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
}
- for (x= 0; x < imgx; x++, src+= pix, ref+= pix) {
+ for (x = 0; x < imgx; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(2);
@@ -249,17 +249,17 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
free_compbuf(refimg);
}
- out[0]->data= source;
+ out[0]->data = source;
free_compbuf(new);
}
-static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeBilateralBlurData *nbbd= MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data");
- node->storage= nbbd;
- nbbd->sigma_color= 0.3;
- nbbd->sigma_space= 5.0;
+ NodeBilateralBlurData *nbbd = MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data");
+ node->storage = nbbd;
+ nbbd->sigma_color = 0.3;
+ nbbd->sigma_space = 5.0;
}
void register_node_type_cmp_bilateralblur(bNodeTreeType *ttype)
diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c
index f10e6bfe939..046623f5b26 100644
--- a/source/blender/nodes/composite/nodes/node_composite_blur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_blur.c
@@ -34,14 +34,14 @@
#include "node_composite_util.h"
/* **************** BLUR ******************** */
-static bNodeSocketTemplate cmp_node_blur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_blur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_blur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_blur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static float *make_gausstab(int filtertype, int rad)
@@ -55,14 +55,14 @@ static float *make_gausstab(int filtertype, int rad)
sum = 0.0f;
for (i = -rad; i <= rad; i++) {
- val= RE_filter_value(filtertype, (float)i/(float)rad);
+ val = RE_filter_value(filtertype, (float)i / (float)rad);
sum += val;
- gausstab[i+rad] = val;
+ gausstab[i + rad] = val;
}
- sum= 1.0f/sum;
- for (i=0; i<n; i++)
- gausstab[i]*= sum;
+ sum = 1.0f / sum;
+ for (i = 0; i < n; i++)
+ gausstab[i] *= sum;
return gausstab;
}
@@ -77,8 +77,8 @@ static float *make_bloomtab(int rad)
bloomtab = (float *) MEM_mallocN(n * sizeof(float), "bloom");
for (i = -rad; i <= rad; i++) {
- val = powf(1.0f - fabsf((float)i)/((float)rad), 4.0f);
- bloomtab[i+rad] = val;
+ val = powf(1.0f - fabsf((float)i) / ((float)rad), 4.0f);
+ bloomtab[i + rad] = val;
}
return bloomtab;
@@ -87,61 +87,61 @@ static float *make_bloomtab(int rad)
/* both input images of same type, either 4 or 1 channel */
static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float scale)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
CompBuf *work;
register float sum, val;
float rval, gval, bval, aval;
float *gausstab, *gausstabcent;
- int rad, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int rad, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, bigstep;
float *src, *dest;
/* helper image */
- work= alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */
+ work = alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */
/* horizontal */
if (nbd->sizex == 0) {
memcpy(work->rect, img->rect, sizeof(float) * img->type * imgx * imgy);
}
else {
- rad = scale*(float)nbd->sizex;
- if (rad>imgx/2)
- rad= imgx/2;
- else if (rad<1)
- rad= 1;
+ rad = scale * (float)nbd->sizex;
+ if (rad > imgx / 2)
+ rad = imgx / 2;
+ else if (rad < 1)
+ rad = 1;
- gausstab= make_gausstab(nbd->filtertype, rad);
- gausstabcent= gausstab+rad;
+ gausstab = make_gausstab(nbd->filtertype, rad);
+ gausstabcent = gausstab + rad;
for (y = 0; y < imgy; y++) {
- float *srcd= img->rect + pix*(y*img->x);
+ float *srcd = img->rect + pix * (y * img->x);
- dest = work->rect + pix*(y * img->x);
+ dest = work->rect + pix * (y * img->x);
- for (x = 0; x < imgx ; x++) {
- int minr= x-rad<0?-x:-rad;
- int maxr= x+rad>imgx?imgx-x:rad;
+ for (x = 0; x < imgx; x++) {
+ int minr = x - rad < 0 ? -x : -rad;
+ int maxr = x + rad > imgx ? imgx - x : rad;
- src= srcd + pix*(x+minr);
+ src = srcd + pix * (x + minr);
- sum= gval = rval= bval= aval= 0.0f;
- for (i= minr; i < maxr; i++) {
- val= gausstabcent[i];
- sum+= val;
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minr; i < maxr; i++) {
+ val = gausstabcent[i];
+ sum += val;
rval += val * (*src++);
- if (pix==4) {
+ if (pix == 4) {
gval += val * (*src++);
bval += val * (*src++);
aval += val * (*src++);
}
}
- sum= 1.0f/sum;
- *dest++ = rval*sum;
- if (pix==4) {
- *dest++ = gval*sum;
- *dest++ = bval*sum;
- *dest++ = aval*sum;
+ sum = 1.0f / sum;
+ *dest++ = rval * sum;
+ if (pix == 4) {
+ *dest++ = gval * sum;
+ *dest++ = bval * sum;
+ *dest++ = aval * sum;
}
}
if (node->exec & NODE_BREAK)
@@ -156,47 +156,47 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca
memcpy(new->rect, work->rect, sizeof(float) * img->type * imgx * imgy);
}
else {
- rad = scale*(float)nbd->sizey;
- if (rad>imgy/2)
- rad= imgy/2;
- else if (rad<1)
- rad= 1;
-
- gausstab= make_gausstab(nbd->filtertype, rad);
- gausstabcent= gausstab+rad;
+ rad = scale * (float)nbd->sizey;
+ if (rad > imgy / 2)
+ rad = imgy / 2;
+ else if (rad < 1)
+ rad = 1;
+
+ gausstab = make_gausstab(nbd->filtertype, rad);
+ gausstabcent = gausstab + rad;
- bigstep = pix*imgx;
+ bigstep = pix * imgx;
for (x = 0; x < imgx; x++) {
- float *srcd= work->rect + pix*x;
+ float *srcd = work->rect + pix * x;
- dest = new->rect + pix*x;
+ dest = new->rect + pix * x;
- for (y = 0; y < imgy ; y++) {
- int minr= y-rad<0?-y:-rad;
- int maxr= y+rad>imgy?imgy-y:rad;
+ for (y = 0; y < imgy; y++) {
+ int minr = y - rad < 0 ? -y : -rad;
+ int maxr = y + rad > imgy ? imgy - y : rad;
- src= srcd + bigstep*(y+minr);
+ src = srcd + bigstep * (y + minr);
- sum= gval = rval= bval= aval= 0.0f;
- for (i= minr; i < maxr; i++) {
- val= gausstabcent[i];
- sum+= val;
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minr; i < maxr; i++) {
+ val = gausstabcent[i];
+ sum += val;
rval += val * src[0];
- if (pix==4) {
+ if (pix == 4) {
gval += val * src[1];
bval += val * src[2];
aval += val * src[3];
}
src += bigstep;
}
- sum= 1.0f/sum;
- dest[0] = rval*sum;
- if (pix==4) {
- dest[1] = gval*sum;
- dest[2] = bval*sum;
- dest[3] = aval*sum;
+ sum = 1.0f / sum;
+ dest[0] = rval * sum;
+ if (pix == 4) {
+ dest[1] = gval * sum;
+ dest[2] = bval * sum;
+ dest[3] = aval * sum;
}
- dest+= bigstep;
+ dest += bigstep;
}
if (node->exec & NODE_BREAK)
break;
@@ -216,83 +216,83 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
float **maintabs;
float *gausstabx, *gausstabcenty;
float *gausstaby, *gausstabcentx;
- int radx, rady, imgx= img->x, imgy= img->y;
+ int radx, rady, imgx = img->x, imgy = img->y;
int x, y;
int i, j;
float *src, *dest, *wb;
- wbuf= alloc_compbuf(imgx, imgy, CB_VAL, 1);
+ wbuf = alloc_compbuf(imgx, imgy, CB_VAL, 1);
/* horizontal */
radx = (float)nbd->sizex;
- if (radx>imgx/2)
- radx= imgx/2;
- else if (radx<1)
- radx= 1;
+ if (radx > imgx / 2)
+ radx = imgx / 2;
+ else if (radx < 1)
+ radx = 1;
/* vertical */
rady = (float)nbd->sizey;
- if (rady>imgy/2)
- rady= imgy/2;
- else if (rady<1)
- rady= 1;
-
- x= MAX2(radx, rady);
- maintabs= MEM_mallocN(x*sizeof(void *), "gauss array");
- for (i= 0; i<x; i++)
- maintabs[i]= make_bloomtab(i+1);
+ if (rady > imgy / 2)
+ rady = imgy / 2;
+ else if (rady < 1)
+ rady = 1;
+
+ x = MAX2(radx, rady);
+ maintabs = MEM_mallocN(x * sizeof(void *), "gauss array");
+ for (i = 0; i < x; i++)
+ maintabs[i] = make_bloomtab(i + 1);
/* vars to store before we go */
// refd= ref->rect;
- src= img->rect;
+ src = img->rect;
- radxf= (float)radx;
- radyf= (float)rady;
+ radxf = (float)radx;
+ radyf = (float)rady;
for (y = 0; y < imgy; y++) {
- for (x = 0; x < imgx ; x++, src+=4) {//, refd++) {
+ for (x = 0; x < imgx; x++, src += 4) { //, refd++) {
// int refradx= (int)(refd[0]*radxf);
// int refrady= (int)(refd[0]*radyf);
- int refradx= (int)(radxf*0.3f*src[3]*(src[0]+src[1]+src[2]));
- int refrady= (int)(radyf*0.3f*src[3]*(src[0]+src[1]+src[2]));
-
- if (refradx>radx) refradx= radx;
- else if (refradx<1) refradx= 1;
- if (refrady>rady) refrady= rady;
- else if (refrady<1) refrady= 1;
+ int refradx = (int)(radxf * 0.3f * src[3] * (src[0] + src[1] + src[2]));
+ int refrady = (int)(radyf * 0.3f * src[3] * (src[0] + src[1] + src[2]));
- if (refradx==1 && refrady==1) {
- wb= wbuf->rect + ( y*imgx + x);
- dest= new->rect + 4*( y*imgx + x);
- wb[0]+= 1.0f;
+ if (refradx > radx) refradx = radx;
+ else if (refradx < 1) refradx = 1;
+ if (refrady > rady) refrady = rady;
+ else if (refrady < 1) refrady = 1;
+
+ if (refradx == 1 && refrady == 1) {
+ wb = wbuf->rect + (y * imgx + x);
+ dest = new->rect + 4 * (y * imgx + x);
+ wb[0] += 1.0f;
dest[0] += src[0];
dest[1] += src[1];
dest[2] += src[2];
dest[3] += src[3];
}
else {
- int minxr= x-refradx<0?-x:-refradx;
- int maxxr= x+refradx>imgx?imgx-x:refradx;
- int minyr= y-refrady<0?-y:-refrady;
- int maxyr= y+refrady>imgy?imgy-y:refrady;
-
- float *destd= new->rect + 4*( (y + minyr)*imgx + x + minxr);
- float *wbufd= wbuf->rect + ( (y + minyr)*imgx + x + minxr);
-
- gausstabx= maintabs[refradx-1];
- gausstabcentx= gausstabx+refradx;
- gausstaby= maintabs[refrady-1];
- gausstabcenty= gausstaby+refrady;
-
- for (i= minyr; i < maxyr; i++, destd+= 4*imgx, wbufd+= imgx) {
- dest= destd;
- wb= wbufd;
- for (j= minxr; j < maxxr; j++, dest+=4, wb++) {
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
+
+ float *destd = new->rect + 4 * ( (y + minyr) * imgx + x + minxr);
+ float *wbufd = wbuf->rect + ( (y + minyr) * imgx + x + minxr);
+
+ gausstabx = maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ for (i = minyr; i < maxyr; i++, destd += 4 * imgx, wbufd += imgx) {
+ dest = destd;
+ wb = wbufd;
+ for (j = minxr; j < maxxr; j++, dest += 4, wb++) {
- val= gausstabcenty[i]*gausstabcentx[j];
- wb[0]+= val;
+ val = gausstabcenty[i] * gausstabcentx[j];
+ wb[0] += val;
dest[0] += val * src[0];
dest[1] += val * src[1];
dest[2] += val * src[2];
@@ -303,23 +303,23 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
}
}
- x= imgx*imgy;
- dest= new->rect;
- wb= wbuf->rect;
+ x = imgx * imgy;
+ dest = new->rect;
+ wb = wbuf->rect;
while (x--) {
- val= 1.0f/wb[0];
- dest[0]*= val;
- dest[1]*= val;
- dest[2]*= val;
- dest[3]*= val;
+ val = 1.0f / wb[0];
+ dest[0] *= val;
+ dest[1] *= val;
+ dest[2] *= val;
+ dest[3] *= val;
wb++;
- dest+= 4;
+ dest += 4;
}
free_compbuf(wbuf);
- x= MAX2(radx, rady);
- for (i= 0; i<x; i++)
+ x = MAX2(radx, rady);
+ for (i = 0; i < x; i++)
MEM_freeN(maintabs[i]);
MEM_freeN(maintabs);
@@ -328,12 +328,12 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
#if 0
static float hexagon_filter(float fi, float fj)
{
- fi= fabs(fi);
- fj= fabs(fj);
+ fi = fabs(fi);
+ fj = fabs(fj);
- if (fj>0.33f) {
- fj= (fj-0.33f)/0.66f;
- if (fi+fj>1.0f)
+ if (fj > 0.33f) {
+ fj = (fj - 0.33f) / 0.66f;
+ if (fi + fj > 1.0f)
return 0.0f;
else
return 1.0f;
@@ -346,85 +346,85 @@ static float hexagon_filter(float fi, float fj)
/* both images same type, either 1 or 4 channels */
static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fac)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
register float val;
float radxf, radyf;
float *gausstab, *dgauss;
- int radx, rady, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int radx, rady, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, j, n;
- float *src= NULL, *dest, *srcd= NULL;
+ float *src = NULL, *dest, *srcd = NULL;
/* horizontal */
- radxf = fac*(float)nbd->sizex;
- if (radxf>imgx/2.0f)
- radxf= imgx/2.0f;
- else if (radxf<1.0f)
- radxf= 1.0f;
+ radxf = fac * (float)nbd->sizex;
+ if (radxf > imgx / 2.0f)
+ radxf = imgx / 2.0f;
+ else if (radxf < 1.0f)
+ radxf = 1.0f;
/* vertical */
- radyf = fac*(float)nbd->sizey;
- if (radyf>imgy/2.0f)
- radyf= imgy/2.0f;
- else if (radyf<1.0f)
- radyf= 1.0f;
+ radyf = fac * (float)nbd->sizey;
+ if (radyf > imgy / 2.0f)
+ radyf = imgy / 2.0f;
+ else if (radyf < 1.0f)
+ radyf = 1.0f;
- radx= ceil(radxf);
- rady= ceil(radyf);
+ radx = ceil(radxf);
+ rady = ceil(radyf);
- n = (2*radx+1)*(2*rady+1);
+ n = (2 * radx + 1) * (2 * rady + 1);
/* create a full filter image */
- gausstab= MEM_mallocN(sizeof(float)*n, "filter tab");
- dgauss= gausstab;
- val= 0.0f;
- for (j=-rady; j<=rady; j++) {
- for (i=-radx; i<=radx; i++, dgauss++) {
- float fj= (float)j/radyf;
- float fi= (float)i/radxf;
- float dist= sqrt(fj*fj + fi*fi);
-
- //*dgauss= hexagon_filter(fi, fj);
- *dgauss= RE_filter_value(nbd->filtertype, dist);
+ gausstab = MEM_mallocN(sizeof(float) * n, "filter tab");
+ dgauss = gausstab;
+ val = 0.0f;
+ for (j = -rady; j <= rady; j++) {
+ for (i = -radx; i <= radx; i++, dgauss++) {
+ float fj = (float)j / radyf;
+ float fi = (float)i / radxf;
+ float dist = sqrt(fj * fj + fi * fi);
- val+= *dgauss;
+ //*dgauss= hexagon_filter(fi, fj);
+ *dgauss = RE_filter_value(nbd->filtertype, dist);
+
+ val += *dgauss;
}
}
- if (val!=0.0f) {
- val= 1.0f/val;
- for (j= n -1; j>=0; j--)
- gausstab[j]*= val;
+ if (val != 0.0f) {
+ val = 1.0f / val;
+ for (j = n - 1; j >= 0; j--)
+ gausstab[j] *= val;
}
- else gausstab[4]= 1.0f;
-
- for (y = -rady+1; y < imgy+rady-1; y++) {
-
- if (y<=0) srcd= img->rect;
- else if (y<imgy) srcd+= pix*imgx;
- else srcd= img->rect + pix*(imgy-1)*imgx;
-
- for (x = -radx+1; x < imgx+radx-1 ; x++) {
- int minxr= x-radx<0?-x:-radx;
- int maxxr= x+radx>=imgx?imgx-x-1:radx;
- int minyr= y-rady<0?-y:-rady;
- int maxyr= y+rady>imgy-1?imgy-y-1:rady;
-
- float *destd= new->rect + pix*( (y + minyr)*imgx + x + minxr);
- float *dgausd= gausstab + (minyr+rady)*(2*radx+1) + minxr+radx;
-
- if (x<=0) src= srcd;
- else if (x<imgx) src+= pix;
- else src= srcd + pix*(imgx-1);
-
- for (i= minyr; i <=maxyr; i++, destd+= pix*imgx, dgausd+= 2*radx + 1) {
- dest= destd;
- dgauss= dgausd;
- for (j= minxr; j <=maxxr; j++, dest+=pix, dgauss++) {
- val= *dgauss;
- if (val!=0.0f) {
+ else gausstab[4] = 1.0f;
+
+ for (y = -rady + 1; y < imgy + rady - 1; y++) {
+
+ if (y <= 0) srcd = img->rect;
+ else if (y < imgy) srcd += pix * imgx;
+ else srcd = img->rect + pix * (imgy - 1) * imgx;
+
+ for (x = -radx + 1; x < imgx + radx - 1; x++) {
+ int minxr = x - radx < 0 ? -x : -radx;
+ int maxxr = x + radx >= imgx ? imgx - x - 1 : radx;
+ int minyr = y - rady < 0 ? -y : -rady;
+ int maxyr = y + rady > imgy - 1 ? imgy - y - 1 : rady;
+
+ float *destd = new->rect + pix * ( (y + minyr) * imgx + x + minxr);
+ float *dgausd = gausstab + (minyr + rady) * (2 * radx + 1) + minxr + radx;
+
+ if (x <= 0) src = srcd;
+ else if (x < imgx) src += pix;
+ else src = srcd + pix * (imgx - 1);
+
+ for (i = minyr; i <= maxyr; i++, destd += pix * imgx, dgausd += 2 * radx + 1) {
+ dest = destd;
+ dgauss = dgausd;
+ for (j = minxr; j <= maxxr; j++, dest += pix, dgauss++) {
+ val = *dgauss;
+ if (val != 0.0f) {
dest[0] += val * src[0];
- if (pix>1) {
+ if (pix > 1) {
dest[1] += val * src[1];
dest[2] += val * src[2];
dest[3] += val * src[3];
@@ -444,116 +444,116 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa
/* reference has to be mapped 0-1, and equal in size */
static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf *ref)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
CompBuf *blurbuf, *ref_use;
register float sum, val;
float rval, gval, bval, aval, radxf, radyf;
float **maintabs;
float *gausstabx, *gausstabcenty;
float *gausstaby, *gausstabcentx;
- int radx, rady, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int radx, rady, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, j;
float *src, *dest, *refd, *blurd;
- float defcol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* default color for compbuf_get_pixel */
- float proccol[4]; /* local color if compbuf is procedural */
+ float defcol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* default color for compbuf_get_pixel */
+ float proccol[4]; /* local color if compbuf is procedural */
int refradx, refrady;
- if (ref->x!=img->x || ref->y!=img->y)
+ if (ref->x != img->x || ref->y != img->y)
return;
- ref_use= typecheck_compbuf(ref, CB_VAL);
+ ref_use = typecheck_compbuf(ref, CB_VAL);
/* trick is; we blur the reference image... but only works with clipped values*/
- blurbuf= alloc_compbuf(imgx, imgy, CB_VAL, 1);
- blurbuf->xof= ref_use->xof;
- blurbuf->yof= ref_use->yof;
- blurd= blurbuf->rect;
- refd= ref_use->rect;
- for (x= imgx*imgy; x>0; x--, refd++, blurd++) {
- if (refd[0]<0.0f) blurd[0]= 0.0f;
- else if (refd[0]>1.0f) blurd[0]= 1.0f;
- else blurd[0]= refd[0];
+ blurbuf = alloc_compbuf(imgx, imgy, CB_VAL, 1);
+ blurbuf->xof = ref_use->xof;
+ blurbuf->yof = ref_use->yof;
+ blurd = blurbuf->rect;
+ refd = ref_use->rect;
+ for (x = imgx * imgy; x > 0; x--, refd++, blurd++) {
+ if (refd[0] < 0.0f) blurd[0] = 0.0f;
+ else if (refd[0] > 1.0f) blurd[0] = 1.0f;
+ else blurd[0] = refd[0];
}
blur_single_image(node, blurbuf, blurbuf, 1.0f);
/* horizontal */
radx = (float)nbd->sizex;
- if (radx>imgx/2)
- radx= imgx/2;
- else if (radx<1)
- radx= 1;
+ if (radx > imgx / 2)
+ radx = imgx / 2;
+ else if (radx < 1)
+ radx = 1;
/* vertical */
rady = (float)nbd->sizey;
- if (rady>imgy/2)
- rady= imgy/2;
- else if (rady<1)
- rady= 1;
-
- x= MAX2(radx, rady);
- maintabs= MEM_mallocN(x*sizeof(void *), "gauss array");
- for (i= 0; i<x; i++)
- maintabs[i]= make_gausstab(nbd->filtertype, i+1);
-
- dest= new->rect;
- radxf= (float)radx;
- radyf= (float)rady;
+ if (rady > imgy / 2)
+ rady = imgy / 2;
+ else if (rady < 1)
+ rady = 1;
+
+ x = MAX2(radx, rady);
+ maintabs = MEM_mallocN(x * sizeof(void *), "gauss array");
+ for (i = 0; i < x; i++)
+ maintabs[i] = make_gausstab(nbd->filtertype, i + 1);
+
+ dest = new->rect;
+ radxf = (float)radx;
+ radyf = (float)rady;
for (y = 0; y < imgy; y++) {
- for (x = 0; x < imgx ; x++, dest+=pix) {
- refd= compbuf_get_pixel(blurbuf, defcol, proccol, x-blurbuf->xrad, y-blurbuf->yrad, blurbuf->xrad, blurbuf->yrad);
- refradx= (int)(refd[0]*radxf);
- refrady= (int)(refd[0]*radyf);
-
- if (refradx>radx) refradx= radx;
- else if (refradx<1) refradx= 1;
- if (refrady>rady) refrady= rady;
- else if (refrady<1) refrady= 1;
-
- if (refradx==1 && refrady==1) {
- src= img->rect + pix*( y*imgx + x);
- if (pix==1)
- dest[0]= src[0];
+ for (x = 0; x < imgx; x++, dest += pix) {
+ refd = compbuf_get_pixel(blurbuf, defcol, proccol, x - blurbuf->xrad, y - blurbuf->yrad, blurbuf->xrad, blurbuf->yrad);
+ refradx = (int)(refd[0] * radxf);
+ refrady = (int)(refd[0] * radyf);
+
+ if (refradx > radx) refradx = radx;
+ else if (refradx < 1) refradx = 1;
+ if (refrady > rady) refrady = rady;
+ else if (refrady < 1) refrady = 1;
+
+ if (refradx == 1 && refrady == 1) {
+ src = img->rect + pix * (y * imgx + x);
+ if (pix == 1)
+ dest[0] = src[0];
else
copy_v4_v4(dest, src);
}
else {
- int minxr= x-refradx<0?-x:-refradx;
- int maxxr= x+refradx>imgx?imgx-x:refradx;
- int minyr= y-refrady<0?-y:-refrady;
- int maxyr= y+refrady>imgy?imgy-y:refrady;
-
- float *srcd= img->rect + pix*( (y + minyr)*imgx + x + minxr);
-
- gausstabx= maintabs[refradx-1];
- gausstabcentx= gausstabx+refradx;
- gausstaby= maintabs[refrady-1];
- gausstabcenty= gausstaby+refrady;
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
- sum= gval = rval= bval= aval= 0.0f;
-
- for (i= minyr; i < maxyr; i++, srcd+= pix*imgx) {
- src= srcd;
- for (j= minxr; j < maxxr; j++, src+=pix) {
+ float *srcd = img->rect + pix * ( (y + minyr) * imgx + x + minxr);
+
+ gausstabx = maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ sum = gval = rval = bval = aval = 0.0f;
+
+ for (i = minyr; i < maxyr; i++, srcd += pix * imgx) {
+ src = srcd;
+ for (j = minxr; j < maxxr; j++, src += pix) {
- val= gausstabcenty[i]*gausstabcentx[j];
- sum+= val;
+ val = gausstabcenty[i] * gausstabcentx[j];
+ sum += val;
rval += val * src[0];
- if (pix>1) {
+ if (pix > 1) {
gval += val * src[1];
bval += val * src[2];
aval += val * src[3];
}
}
}
- sum= 1.0f/sum;
- dest[0] = rval*sum;
- if (pix>1) {
- dest[1] = gval*sum;
- dest[2] = bval*sum;
- dest[3] = aval*sum;
+ sum = 1.0f / sum;
+ dest[0] = rval * sum;
+ if (pix > 1) {
+ dest[1] = gval * sum;
+ dest[2] = bval * sum;
+ dest[3] = aval * sum;
}
}
}
@@ -563,46 +563,46 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf
free_compbuf(blurbuf);
- x= MAX2(radx, rady);
- for (i= 0; i<x; i++)
+ x = MAX2(radx, rady);
+ for (i = 0; i < x; i++)
MEM_freeN(maintabs[i]);
MEM_freeN(maintabs);
- if (ref_use!=ref)
+ if (ref_use != ref)
free_compbuf(ref_use);
}
static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- CompBuf *new, *img= in[0]->data;
- NodeBlurData *nbd= node->storage;
+ CompBuf *new, *img = in[0]->data;
+ NodeBlurData *nbd = node->storage;
- if (img==NULL) return;
+ if (img == NULL) return;
/* store image in size that is needed for absolute/relative conversions on ui level */
- nbd->image_in_width= img->x;
- nbd->image_in_height= img->y;
+ nbd->image_in_width = img->x;
+ nbd->image_in_height = img->y;
- if (out[0]->hasoutput==0) return;
+ if (out[0]->hasoutput == 0) return;
if (nbd->relative) {
- if (nbd->aspect==CMP_NODE_BLUR_ASPECT_NONE) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+ if (nbd->aspect == CMP_NODE_BLUR_ASPECT_NONE) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_width);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_height);
}
- else if (nbd->aspect==CMP_NODE_BLUR_ASPECT_Y) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_width);
+ else if (nbd->aspect == CMP_NODE_BLUR_ASPECT_Y) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_width);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_width);
}
- else if (nbd->aspect==CMP_NODE_BLUR_ASPECT_X) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_height);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+ else if (nbd->aspect == CMP_NODE_BLUR_ASPECT_X) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_height);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_height);
}
}
- if (nbd->sizex==0 && nbd->sizey==0) {
- new= pass_on_compbuf(img);
- out[0]->data= new;
+ if (nbd->sizex == 0 && nbd->sizey == 0) {
+ new = pass_on_compbuf(img);
+ out[0]->data = new;
}
else if (nbd->filtertype == R_FILTER_FAST_GAUSS) {
if (in[1]->vec[0] < 0.001f) { /* time node inputs can be a tiny value */
@@ -610,10 +610,10 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
else {
// TODO: can this be mapped with reference, too?
- const float sx = ((float)nbd->sizex*in[1]->vec[0])/2.0f, sy = ((float)nbd->sizey*in[1]->vec[0])/2.0f;
+ const float sx = ((float)nbd->sizex * in[1]->vec[0]) / 2.0f, sy = ((float)nbd->sizey * in[1]->vec[0]) / 2.0f;
int c;
- if ((img==NULL) || (out[0]->hasoutput==0)) return;
+ if ((img == NULL) || (out[0]->hasoutput == 0)) return;
if (img->type == CB_VEC2)
new = typecheck_compbuf(img, CB_VAL);
@@ -623,16 +623,16 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
new = dupalloc_compbuf(img);
if ((sx == sy) && (sx > 0.f)) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sx, c, 3);
}
else {
if (sx > 0.f) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sx, c, 1);
}
if (sy > 0.f) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sy, c, 2);
}
}
@@ -641,8 +641,8 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
else {
/* All non fast gauss blur methods */
- if (img->type==CB_VEC2 || img->type==CB_VEC3) {
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ if (img->type == CB_VEC2 || img->type == CB_VEC3) {
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
}
/* if fac input, we do it different */
@@ -650,17 +650,17 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
CompBuf *gammabuf;
/* make output size of input image */
- new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
+ new = alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
/* accept image offsets from other nodes */
new->xof = img->xof;
new->yof = img->yof;
if (nbd->gamma) {
- gammabuf= dupalloc_compbuf(img);
+ gammabuf = dupalloc_compbuf(img);
gamma_correct_compbuf(gammabuf, 0);
}
- else gammabuf= img;
+ else gammabuf = img;
blur_with_reference(node, new, gammabuf, in[1]->data);
@@ -670,30 +670,30 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
if (node->exec & NODE_BREAK) {
free_compbuf(new);
- new= NULL;
+ new = NULL;
}
- out[0]->data= new;
+ out[0]->data = new;
}
else {
- if (in[1]->vec[0]<=0.001f) { /* time node inputs can be a tiny value */
- new= pass_on_compbuf(img);
+ if (in[1]->vec[0] <= 0.001f) { /* time node inputs can be a tiny value */
+ new = pass_on_compbuf(img);
}
else {
CompBuf *gammabuf;
/* make output size of input image */
- new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
+ new = alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
/* accept image offsets from other nodes */
new->xof = img->xof;
new->yof = img->yof;
if (nbd->gamma) {
- gammabuf= dupalloc_compbuf(img);
+ gammabuf = dupalloc_compbuf(img);
gamma_correct_compbuf(gammabuf, 0);
}
- else gammabuf= img;
+ else gammabuf = img;
if (nbd->bokeh)
bokeh_single_image(node, new, gammabuf, in[1]->vec[0]);
@@ -708,28 +708,28 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
if (node->exec & NODE_BREAK) {
free_compbuf(new);
- new= NULL;
+ new = NULL;
}
}
- out[0]->data= new;
+ out[0]->data = new;
}
- if (img!=in[0]->data)
+ if (img != in[0]->data)
free_compbuf(img);
}
generate_preview(data, node, out[0]->data);
}
-static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- node->storage= MEM_callocN(sizeof(NodeBlurData), "node blur data");
+ node->storage = MEM_callocN(sizeof(NodeBlurData), "node blur data");
}
void register_node_type_cmp_blur(bNodeTreeType *ttype)
{
static bNodeType ntype;
- node_type_base(ttype, &ntype, CMP_NODE_BLUR, "Blur", NODE_CLASS_OP_FILTER, NODE_PREVIEW|NODE_OPTIONS);
+ node_type_base(ttype, &ntype, CMP_NODE_BLUR, "Blur", NODE_CLASS_OP_FILTER, NODE_PREVIEW | NODE_OPTIONS);
node_type_socket_templates(&ntype, cmp_node_blur_in, cmp_node_blur_out);
node_type_size(&ntype, 120, 80, 200);
node_type_init(&ntype, node_composit_init_blur);
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
index 6b24bdb5c52..222ac7a5cdf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
@@ -36,20 +36,20 @@
#include "../node_composite_util.h"
/* **************** BLUR ******************** */
-static bNodeSocketTemplate cmp_node_bokehblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Bokeh"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
- { SOCK_FLOAT, 1, N_("Bounding box"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_bokehblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 1, N_("Bokeh"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+ { SOCK_FLOAT, 1, N_("Bounding box"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_bokehblur_out[]= {
- { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_bokehblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static void node_composit_init_bokehblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_bokehblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
node->custom3 = 4.0f;
node->custom4 = 16.0f;
diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c
index 8363d5928bf..2f139831cc9 100644
--- a/source/blender/nodes/composite/nodes/node_composite_dilate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c
@@ -35,13 +35,13 @@
/* **************** Dilate/Erode ******************** */
-static bNodeSocketTemplate cmp_node_dilateerode_in[]= {
- { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dilateerode_in[] = {
+ { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_dilateerode_out[]= {
- { SOCK_FLOAT, 0, N_("Mask")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dilateerode_out[] = {
+ { SOCK_FLOAT, 0, N_("Mask")},
+ { -1, 0, "" }
};
static void morpho_dilate(CompBuf *cbuf)
@@ -49,31 +49,31 @@ static void morpho_dilate(CompBuf *cbuf)
int x, y;
float *p, *rectf = cbuf->rect;
- for (y=0; y < cbuf->y; y++) {
- for (x=0; x < cbuf->x-1; x++) {
- p = rectf + cbuf->x*y + x;
- *p = MAX2(*p, *(p + 1));
+ for (y = 0; y < cbuf->y; y++) {
+ for (x = 0; x < cbuf->x - 1; x++) {
+ p = rectf + cbuf->x * y + x;
+ *p = maxf(*p, *(p + 1));
}
}
- for (y=0; y < cbuf->y; y++) {
- for (x=cbuf->x-1; x >= 1; x--) {
- p = rectf + cbuf->x*y + x;
- *p = MAX2(*p, *(p - 1));
+ for (y = 0; y < cbuf->y; y++) {
+ for (x = cbuf->x - 1; x >= 1; x--) {
+ p = rectf + cbuf->x * y + x;
+ *p = maxf(*p, *(p - 1));
}
}
- for (x=0; x < cbuf->x; x++) {
- for (y=0; y < cbuf->y-1; y++) {
- p = rectf + cbuf->x*y + x;
- *p = MAX2(*p, *(p + cbuf->x));
+ for (x = 0; x < cbuf->x; x++) {
+ for (y = 0; y < cbuf->y - 1; y++) {
+ p = rectf + cbuf->x * y + x;
+ *p = maxf(*p, *(p + cbuf->x));
}
}
- for (x=0; x < cbuf->x; x++) {
- for (y=cbuf->y-1; y >= 1; y--) {
- p = rectf + cbuf->x*y + x;
- *p = MAX2(*p, *(p - cbuf->x));
+ for (x = 0; x < cbuf->x; x++) {
+ for (y = cbuf->y - 1; y >= 1; y--) {
+ p = rectf + cbuf->x * y + x;
+ *p = maxf(*p, *(p - cbuf->x));
}
}
}
@@ -83,31 +83,31 @@ static void morpho_erode(CompBuf *cbuf)
int x, y;
float *p, *rectf = cbuf->rect;
- for (y=0; y < cbuf->y; y++) {
- for (x=0; x < cbuf->x-1; x++) {
- p = rectf + cbuf->x*y + x;
- *p = MIN2(*p, *(p + 1));
+ for (y = 0; y < cbuf->y; y++) {
+ for (x = 0; x < cbuf->x - 1; x++) {
+ p = rectf + cbuf->x * y + x;
+ *p = minf(*p, *(p + 1));
}
}
- for (y=0; y < cbuf->y; y++) {
- for (x=cbuf->x-1; x >= 1; x--) {
- p = rectf + cbuf->x*y + x;
- *p = MIN2(*p, *(p - 1));
+ for (y = 0; y < cbuf->y; y++) {
+ for (x = cbuf->x - 1; x >= 1; x--) {
+ p = rectf + cbuf->x * y + x;
+ *p = minf(*p, *(p - 1));
}
}
- for (x=0; x < cbuf->x; x++) {
- for (y=0; y < cbuf->y-1; y++) {
- p = rectf + cbuf->x*y + x;
- *p = MIN2(*p, *(p + cbuf->x));
+ for (x = 0; x < cbuf->x; x++) {
+ for (y = 0; y < cbuf->y - 1; y++) {
+ p = rectf + cbuf->x * y + x;
+ *p = minf(*p, *(p + cbuf->x));
}
}
- for (x=0; x < cbuf->x; x++) {
- for (y=cbuf->y-1; y >= 1; y--) {
- p = rectf + cbuf->x*y + x;
- *p = MIN2(*p, *(p - cbuf->x));
+ for (x = 0; x < cbuf->x; x++) {
+ for (y = cbuf->y - 1; y >= 1; y--) {
+ p = rectf + cbuf->x * y + x;
+ *p = minf(*p, *(p - cbuf->x));
}
}
@@ -117,18 +117,17 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod
{
/* stack order in: mask */
/* stack order out: mask */
- if (out[0]->hasoutput==0)
+ if (out[0]->hasoutput == 0)
return;
/* input no image? then only color operation */
- if (in[0]->data==NULL) {
- out[0]->vec[0] = out[0]->vec[1] = out[0]->vec[2] = 0.0f;
- out[0]->vec[3] = 0.0f;
+ if (in[0]->data == NULL) {
+ zero_v4(out[0]->vec);
}
else {
/* make output size of input image */
- CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_VAL);
- CompBuf *stackbuf= dupalloc_compbuf(cbuf);
+ CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_VAL);
+ CompBuf *stackbuf = dupalloc_compbuf(cbuf);
short i;
if (node->custom2 > 0) { // positive, dilate
@@ -140,10 +139,10 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod
morpho_erode(stackbuf);
}
- if (cbuf!=in[0]->data)
+ if (cbuf != in[0]->data)
free_compbuf(cbuf);
- out[0]->data= stackbuf;
+ out[0]->data = stackbuf;
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
index 395fa154a89..73e28658309 100644
--- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
@@ -32,23 +32,23 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_dblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_dblur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
- float center_x, float center_y, float dist, float angle, float spin, float zoom)
+ float center_x, float center_y, float dist, float angle, float spin, float zoom)
{
if ((dist != 0.f) || (spin != 0.f) || (zoom != 0.f)) {
- void (*getpix)(CompBuf*, float, float, float*) = wrap ? qd_getPixelLerpWrap : qd_getPixelLerp;
- const float a= angle;
- const float itsc= 1.f / powf(2.f, (float)iterations);
+ void (*getpix)(CompBuf *, float, float, float *) = wrap ? qd_getPixelLerpWrap : qd_getPixelLerp;
+ const float a = angle;
+ const float itsc = 1.f / powf(2.f, (float)iterations);
float D;
float center_x_pix, center_y_pix;
float tx, ty;
@@ -56,36 +56,36 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
CompBuf *tmp;
int i, j;
- tmp= dupalloc_compbuf(img);
+ tmp = dupalloc_compbuf(img);
- D= dist * sqrtf(img->x * img->x + img->y * img->y);
- center_x_pix= center_x * img->x;
- center_y_pix= center_y * img->y;
+ D = dist * sqrtf(img->x * img->x + img->y * img->y);
+ center_x_pix = center_x * img->x;
+ center_y_pix = center_y * img->y;
- tx= itsc * D * cosf(a);
- ty= -itsc * D * sinf(a);
- sc= itsc * zoom;
- rot= itsc * spin;
+ tx = itsc * D * cosf(a);
+ ty = -itsc *D *sinf(a);
+ sc = itsc * zoom;
+ rot = itsc * spin;
/* blur the image */
- for (i= 0; i < iterations; ++i) {
- const float cs= cosf(rot), ss= sinf(rot);
- const float isc= 1.f / (1.f + sc);
+ for (i = 0; i < iterations; ++i) {
+ const float cs = cosf(rot), ss = sinf(rot);
+ const float isc = 1.f / (1.f + sc);
unsigned int x, y;
- float col[4]= {0, 0, 0, 0};
+ float col[4] = {0, 0, 0, 0};
- for (y= 0; y < img->y; ++y) {
- const float v= isc * (y - center_y_pix) + ty;
+ for (y = 0; y < img->y; ++y) {
+ const float v = isc * (y - center_y_pix) + ty;
- for (x= 0; x < img->x; ++x) {
- const float u= isc * (x - center_x_pix) + tx;
- unsigned int p= (x + y * img->x) * img->type;
+ for (x = 0; x < img->x; ++x) {
+ const float u = isc * (x - center_x_pix) + tx;
+ unsigned int p = (x + y * img->x) * img->type;
getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col);
/* mix img and transformed tmp */
- for (j= 0; j < 4; ++j) {
- img->rect[p + j]= 0.5f * (img->rect[p + j] + col[j]);
+ for (j = 0; j < 4; ++j) {
+ img->rect[p + j] = 0.5f * (img->rect[p + j] + col[j]);
}
}
}
@@ -109,8 +109,8 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeDBlurData *ndbd= node->storage;
- CompBuf *new, *img= in[0]->data;
+ NodeDBlurData *ndbd = node->storage;
+ CompBuf *new, *img = in[0]->data;
if ((img == NULL) || (out[0]->hasoutput == 0)) return;
@@ -119,15 +119,15 @@ static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack
else
new = dupalloc_compbuf(img);
- out[0]->data= dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom);
+ out[0]->data = dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom);
}
-static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeDBlurData *ndbd= MEM_callocN(sizeof(NodeDBlurData), "node dblur data");
- node->storage= ndbd;
- ndbd->center_x= 0.5;
- ndbd->center_y= 0.5;
+ NodeDBlurData *ndbd = MEM_callocN(sizeof(NodeDBlurData), "node dblur data");
+ node->storage = ndbd;
+ ndbd->center_x = 0.5;
+ ndbd->center_y = 0.5;
}
void register_node_type_cmp_dblur(bNodeTreeType *ttype)
diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c
index 1e32d6f0461..17a23d4295e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_glare.c
+++ b/source/blender/nodes/composite/nodes/node_composite_glare.c
@@ -53,16 +53,16 @@ static void mixImages(CompBuf *dst, CompBuf *src, float mix)
dcolp = (fRGB*)&dst->rect[y*dst->x*dst->type];
scolp = (fRGB*)&src->rect[y*dst->x*dst->type];
for (x=0; x<dst->x; x++) {
- fRGB_copy(c1, dcolp[x]);
- fRGB_copy(c2, scolp[x]);
+ copy_v3_v3(c1, dcolp[x]);
+ copy_v3_v3(c2, scolp[x]);
c1[0] += mix*(c2[0] - c1[0]);
c1[1] += mix*(c2[1] - c1[1]);
c1[2] += mix*(c2[2] - c1[2]);
if (c1[0] < 0.f) c1[0] = 0.f;
if (c1[1] < 0.f) c1[1] = 0.f;
if (c1[2] < 0.f) c1[2] = 0.f;
- fRGB_mult(c1, mf);
- fRGB_copy(dcolp[x], c1);
+ mul_v3_fl(c1, mf);
+ copy_v3_v3(dcolp[x], c1);
}
}
}
@@ -72,7 +72,7 @@ static void mixImages(CompBuf *dst, CompBuf *src, float mix)
for (y=0; y<dst->y; y++) {
dcolp = (fRGB*)&dst->rect[y*dst->x*dst->type];
for (x=0; x<dst->x; x++) {
- fRGB_copy(c1, dcolp[x]);
+ copy_v3_v3(c1, dcolp[x]);
qd_getPixelLerp(src, (x + 0.5f)*xr - 0.5f, (y + 0.5f)*yr - 0.5f, c2);
c1[0] += mix*(c2[0] - c1[0]);
c1[1] += mix*(c2[1] - c1[1]);
@@ -80,8 +80,8 @@ static void mixImages(CompBuf *dst, CompBuf *src, float mix)
if (c1[0] < 0.f) c1[0] = 0.f;
if (c1[1] < 0.f) c1[1] = 0.f;
if (c1[2] < 0.f) c1[2] = 0.f;
- fRGB_mult(c1, mf);
- fRGB_copy(dcolp[x], c1);
+ mul_v3_fl(c1, mf);
+ copy_v3_v3(dcolp[x], c1);
}
}
}
@@ -107,7 +107,7 @@ static CompBuf* BTP(CompBuf* src, float threshold, int scaledown)
float* cr = bsrc->rect;
for (y=0; y<bsrc->y; ++y)
for (x=0; x<bsrc->x; ++x, cr+=4) {
- if ((0.212671f*cr[0] + 0.71516f*cr[1] + 0.072169f*cr[2]) >= threshold) {
+ if (rgb_to_luma_y(cr) >= threshold) {
cr[0] -= threshold, cr[1] -= threshold, cr[2] -= threshold;
cr[0] = MAX2(cr[0], 0.f);
cr[1] = MAX2(cr[1], 0.f);
@@ -146,11 +146,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf1, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf1, (ndg->angle ? xm : x), ym, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf1, (ndg->angle ? xp : x), yp, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf1, x, y, c);
}
}
@@ -162,11 +162,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf1, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf1, (ndg->angle ? xm : x), ym, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf1, (ndg->angle ? xp : x), yp, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf1, x, y, c);
}
}
@@ -179,11 +179,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf2, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf2, xm, (ndg->angle ? yp : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf2, xp, (ndg->angle ? ym : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf2, x, y, c);
}
}
@@ -195,11 +195,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf2, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf2, xm, (ndg->angle ? yp : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf2, xp, (ndg->angle ? ym : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf2, x, y, c);
}
}
@@ -342,11 +342,11 @@ static void ghosts(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
s = (u-0.5f)*sc + 0.5f, t = (v-0.5f)*sc + 0.5f;
qd_getPixelLerp(tbuf1, s*gbuf->x, t*gbuf->y, c);
sm = smoothMask(s, t);
- fRGB_mult(c, sm);
+ mul_v3_fl(c, sm);
s = (u-0.5f)*isc + 0.5f, t = (v-0.5f)*isc + 0.5f;
qd_getPixelLerp(tbuf2, s*gbuf->x - 0.5f, t*gbuf->y - 0.5f, tc);
sm = smoothMask(s, t);
- fRGB_madd(c, tc, sm);
+ madd_v3_v3fl(c, tc, sm);
qd_setPixel(gbuf, x, y, c);
}
}
@@ -363,9 +363,9 @@ static void ghosts(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
s = (u-0.5f)*scalef[np] + 0.5f;
t = (v-0.5f)*scalef[np] + 0.5f;
qd_getPixelLerp(gbuf, s*gbuf->x - 0.5f, t*gbuf->y - 0.5f, c);
- fRGB_colormult(c, cm[np]);
+ mul_v3_v3(c, cm[np]);
sm = smoothMask(s, t)*0.25f;
- fRGB_madd(tc, c, sm);
+ madd_v3_v3fl(tc, c, sm);
}
p = (x + y*tbuf1->x)*tbuf1->type;
tbuf1->rect[p] += tc[0];
@@ -413,7 +413,7 @@ static void fglow(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
//w = (1.f-fabs(u))*(1.f-fabs(v));
// actually, Hanning window is ok, cos^2 for some reason is slower
w = (0.5f + 0.5f*cos((double)u*M_PI))*(0.5f + 0.5f*cos((double)v*M_PI));
- fRGB_mult(fcol, w);
+ mul_v3_fl(fcol, w);
qd_setPixel(ckrn, x, y, fcol);
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.c b/source/blender/nodes/composite/nodes/node_composite_keying.c
new file mode 100644
index 00000000000..f37c3686e2b
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_keying.c
@@ -0,0 +1,96 @@
+/*
+ * ***** 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) 2011 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Blender Foundation,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/composite/nodes/node_composite_keying.c
+ * \ingroup cmpnodes
+ */
+
+#include "BLF_translation.h"
+
+#include "DNA_movieclip_types.h"
+
+#include "BKE_movieclip.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math_base.h"
+#include "BLI_math_color.h"
+#include "BLI_voronoi.h"
+
+#include "node_composite_util.h"
+
+/* **************** Translate ******************** */
+
+static bNodeSocketTemplate cmp_node_keying_in[] = {
+ { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 1, "Key Color", 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Garbage Matte", 0.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Core Matte", 0.0f, 1.0f, 1.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate cmp_node_keying_out[] = {
+ { SOCK_RGBA, 0, "Image"},
+ { SOCK_FLOAT, 0, "Matte"},
+ { SOCK_FLOAT, 0, "Edges"},
+ { -1, 0, "" }
+};
+
+static void exec(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeKeyingData *data;
+
+ data = MEM_callocN(sizeof(NodeKeyingData), "node keying data");
+
+ data->screen_balance = 0.5f;
+ data->despill_factor = 1.0f;
+ data->edge_kernel_radius = 3;
+ data->edge_kernel_tolerance = 0.1f;
+ data->clip_white = 1.0f;
+ data->clip_black = 0.0f;
+ data->clip_white = 1.0f;
+
+ node->storage = data;
+}
+
+void register_node_type_cmp_keying(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_KEYING, "Keying", NODE_CLASS_MATTE, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_keying_in, cmp_node_keying_out);
+ node_type_size(&ntype, 140, 100, 320);
+ node_type_init(&ntype, node_composit_init_keying);
+ node_type_storage(&ntype, "NodeKeyingData", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, exec);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
new file mode 100644
index 00000000000..73423e2bdd3
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
@@ -0,0 +1,202 @@
+/*
+ * ***** 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) 2011 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Blender Foundation,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/composite/nodes/node_composite_keyingscreen.c
+ * \ingroup cmpnodes
+ */
+
+#include "BLF_translation.h"
+
+#include "DNA_movieclip_types.h"
+
+#include "BKE_movieclip.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math_base.h"
+#include "BLI_math_color.h"
+#include "BLI_voronoi.h"
+
+#include "node_composite_util.h"
+
+/* **************** Translate ******************** */
+
+static bNodeSocketTemplate cmp_node_keyingscreen_out[] = {
+ { SOCK_RGBA, 0, "Screen"},
+ { -1, 0, "" }
+};
+
+
+static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keyingscreen_data, MovieClip *clip, CompBuf *screenbuf)
+{
+ MovieClipUser user = {0};
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingTrack *track;
+ VoronoiTriangulationPoint *triangulated_points;
+ VoronoiSite *sites;
+ ImBuf *ibuf;
+ ListBase *tracksbase;
+ ListBase edges = {NULL, NULL};
+ int sites_total, triangulated_points_total, triangles_total;
+ int (*triangles)[3];
+ int i, x, y;
+ float *rect = screenbuf->rect;
+
+ if (keyingscreen_data->tracking_object[0]) {
+ MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, keyingscreen_data->tracking_object);
+
+ if (!object)
+ return;
+
+ tracksbase = BKE_tracking_object_get_tracks(tracking, object);
+ }
+ else
+ tracksbase = BKE_tracking_get_active_tracks(tracking);
+
+ sites_total = BLI_countlist(tracksbase);
+
+ if (!sites_total)
+ return;
+
+ BKE_movieclip_user_set_frame(&user, rd->cfra);
+ ibuf = BKE_movieclip_get_ibuf(clip, &user);
+
+ sites = MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites");
+ track = tracksbase->first;
+ i = 0;
+ while (track) {
+ VoronoiSite *site = &sites[i];
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, rd->cfra);
+ ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
+ int j;
+
+ zero_v3(site->color);
+ for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
+ if (pattern_ibuf->rect_float) {
+ add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
+ }
+ else {
+ unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
+
+ site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
+ site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
+ site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ }
+ }
+
+ mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
+ IMB_freeImBuf(pattern_ibuf);
+
+ site->co[0] = marker->pos[0] * screenbuf->x;
+ site->co[1] = marker->pos[1] * screenbuf->y;
+
+ track = track->next;
+ i++;
+ }
+
+ IMB_freeImBuf(ibuf);
+
+ BLI_voronoi_compute(sites, sites_total, screenbuf->x, screenbuf->y, &edges);
+
+ BLI_voronoi_triangulate(sites, sites_total, &edges, screenbuf->x, screenbuf->y,
+ &triangulated_points, &triangulated_points_total,
+ &triangles, &triangles_total);
+
+ for (y = 0; y < screenbuf->y; y++) {
+ for (x = 0; x < screenbuf->x; x++) {
+ int index = 4 * (y * screenbuf->x + x);
+
+ rect[index + 0] = rect[index + 1] = rect[index + 2] = 0.0f;
+ rect[index + 3] = 1.0f;
+
+ for (i = 0; i < triangles_total; i++) {
+ int *triangle = triangles[i];
+ VoronoiTriangulationPoint *a = &triangulated_points[triangle[0]],
+ *b = &triangulated_points[triangle[1]],
+ *c = &triangulated_points[triangle[2]];
+ float co[2] = {x, y}, w[3];
+
+ if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) {
+ if (barycentric_inside_triangle_v2(w)) {
+ rect[index + 0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2];
+ rect[index + 1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2];
+ rect[index + 2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2];
+ }
+ }
+ }
+ }
+ }
+
+ MEM_freeN(triangulated_points);
+ MEM_freeN(triangles);
+ MEM_freeN(sites);
+ BLI_freelistN(&edges);
+}
+
+static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
+{
+ NodeKeyingScreenData *keyingscreen_data = node->storage;
+ RenderData *rd = data;
+ CompBuf *screenbuf = NULL;
+
+ if (node->id) {
+ MovieClip *clip = (MovieClip *) node->id;
+ MovieClipUser user = {0};
+ int width, height;
+
+ BKE_movieclip_user_set_frame(&user, rd->cfra);
+ BKE_movieclip_get_size(clip, &user, &width, &height);
+
+ screenbuf = alloc_compbuf(width, height, CB_RGBA, TRUE);
+ compute_gradient_screen(rd, keyingscreen_data, clip, screenbuf);
+ }
+
+ out[0]->data = screenbuf;
+}
+
+static void node_composit_init_keyingscreen(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeKeyingScreenData *data;
+
+ data = MEM_callocN(sizeof(NodeKeyingScreenData), "node keyingscreen data");
+
+ node->storage = data;
+}
+
+void register_node_type_cmp_keyingscreen(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_KEYINGSCREEN, "Keying Screen", NODE_CLASS_MATTE, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, NULL, cmp_node_keyingscreen_out);
+ node_type_size(&ntype, 140, 100, 320);
+ node_type_init(&ntype, node_composit_init_keyingscreen);
+ node_type_storage(&ntype, "NodeKeyingScreenData", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, exec);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c
index 01461aec08d..d323839e690 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mask.c
@@ -38,19 +38,16 @@
#include "node_composite_util.h"
-/* **************** Translate ******************** */
+#include "../../../../intern/raskter/raskter.h"
-static bNodeSocketTemplate cmp_node_mask_in[] = {
- { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
-};
+/* **************** Translate ******************** */
static bNodeSocketTemplate cmp_node_mask_out[] = {
- { SOCK_RGBA, 0, "Image"},
+ { SOCK_FLOAT, 0, "Mask"},
{ -1, 0, "" }
};
-static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
{
if (node->id) {
Mask *mask = (Mask *)node->id;
@@ -66,23 +63,18 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
return;
}
- if (in[0]->hasinput && in[0]->data) {
- CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
-
- sx = cbuf->x;
- sy = cbuf->y;
- }
- else {
- sx = (rd->size * rd->xsch) / 100;
- sy = (rd->size * rd->ysch) / 100;
- }
+ sx = (rd->size * rd->xsch) / 100;
+ sy = (rd->size * rd->ysch) / 100;
/* allocate the output buffer */
stackbuf = alloc_compbuf(sx, sy, CB_VAL, TRUE);
res = stackbuf->rect;
- BKE_mask_rasterize(mask, sx, sy, res, TRUE, TRUE);
+ BKE_mask_rasterize(mask, sx, sy, res, TRUE, node->custom1);
+ if(node->custom1){
+ PLX_antialias_buffer(res,sx,sy);
+ }
/* pass on output and free */
out[0]->data = stackbuf;
}
@@ -93,7 +85,7 @@ void register_node_type_cmp_mask(bNodeTreeType *ttype)
static bNodeType ntype;
node_type_base(ttype, &ntype, CMP_NODE_MASK, "Mask", NODE_CLASS_INPUT, NODE_OPTIONS);
- node_type_socket_templates(&ntype, cmp_node_mask_in, cmp_node_mask_out);
+ node_type_socket_templates(&ntype, NULL, cmp_node_mask_out);
node_type_size(&ntype, 140, 100, 320);
node_type_exec(&ntype, exec);
diff --git a/source/blender/nodes/composite/nodes/node_composite_movieclip.c b/source/blender/nodes/composite/nodes/node_composite_movieclip.c
index 9f5a7e67c96..e8f09ae08d7 100644
--- a/source/blender/nodes/composite/nodes/node_composite_movieclip.c
+++ b/source/blender/nodes/composite/nodes/node_composite_movieclip.c
@@ -120,8 +120,9 @@ static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **U
if (stab->flag & TRACKING_2D_STABILIZATION) {
float loc[2], scale, angle;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, rd->cfra);
- BKE_tracking_stabilization_data(&clip->tracking, rd->cfra, stackbuf->x, stackbuf->y,
+ BKE_tracking_stabilization_data_get(&clip->tracking, clip_framenr, stackbuf->x, stackbuf->y,
loc, &scale, &angle);
out[1]->vec[0] = loc[0];
diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
index 5def9c41e19..65fe3b251d0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
+++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
@@ -73,7 +73,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
BKE_movieclip_get_size(clip, &user, &width, &height);
if (!node->storage)
- node->storage = BKE_tracking_distortion_create();
+ node->storage = BKE_tracking_distortion_new();
if (node->custom1 == 0)
obuf = BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 1);
@@ -116,7 +116,7 @@ static const char *label(bNode *node)
static void storage_free(bNode *node)
{
if (node->storage)
- BKE_tracking_distortion_destroy(node->storage);
+ BKE_tracking_distortion_free(node->storage);
node->storage = NULL;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c
index a36919ba553..1df67724762 100644
--- a/source/blender/nodes/composite/nodes/node_composite_scale.c
+++ b/source/blender/nodes/composite/nodes/node_composite_scale.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -34,82 +34,134 @@
/* **************** Scale ******************** */
-static bNodeSocketTemplate cmp_node_scale_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("X"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX, PROP_FACTOR},
- { SOCK_FLOAT, 1, N_("Y"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX, PROP_FACTOR},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_scale_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("X"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX, PROP_FACTOR},
+ { SOCK_FLOAT, 1, N_("Y"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX, PROP_FACTOR},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_scale_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_scale_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
/* only supports RGBA nodes now */
/* node->custom1 stores if input values are absolute or relative scale */
static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- if (out[0]->hasoutput==0)
+ if (out[0]->hasoutput == 0)
return;
-
+
if (in[0]->data) {
- RenderData *rd= data;
- CompBuf *stackbuf, *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
+ RenderData *rd = data;
+ CompBuf *stackbuf, *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
ImBuf *ibuf;
int newx, newy;
-
- if (node->custom1==CMP_SCALE_RELATIVE) {
- newx= MAX2((int)(in[1]->vec[0]*cbuf->x), 1);
- newy= MAX2((int)(in[2]->vec[0]*cbuf->y), 1);
+ float ofsx = 0.0f, ofsy = 0.0f;
+
+ if (node->custom1 == CMP_SCALE_RELATIVE) {
+ newx = MAX2((int)(in[1]->vec[0] * cbuf->x), 1);
+ newy = MAX2((int)(in[2]->vec[0] * cbuf->y), 1);
}
- else if (node->custom1==CMP_SCALE_SCENEPERCENT) {
+ else if (node->custom1 == CMP_SCALE_SCENEPERCENT) {
newx = cbuf->x * (rd->size / 100.0f);
newy = cbuf->y * (rd->size / 100.0f);
}
- else if (node->custom1==CMP_SCALE_RENDERPERCENT) {
- newx= (rd->xsch * rd->size)/100;
- newy= (rd->ysch * rd->size)/100;
+ else if (node->custom1 == CMP_SCALE_RENDERPERCENT) {
+
+ if (node->custom3 != 0.0f || node->custom4 != 0.0f) {
+ const float w_dst = (rd->xsch * rd->size) / 100;
+ const float h_dst = (rd->ysch * rd->size) / 100;
+
+ if (w_dst > h_dst) {
+ ofsx = node->custom3 * w_dst;
+ ofsy = node->custom4 * w_dst;
+ }
+ else {
+ ofsx = node->custom3 * h_dst;
+ ofsy = node->custom4 * h_dst;
+ }
+ }
+
+ /* supports framing options */
+ if (node->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) {
+ /* apply aspect from clip */
+ const float w_src = cbuf->x;
+ const float h_src = cbuf->y;
+
+ /* destination aspect is already applied from the camera frame */
+ const float w_dst = (rd->xsch * rd->size) / 100;
+ const float h_dst = (rd->ysch * rd->size) / 100;
+
+ const float asp_src = w_src / h_src;
+ const float asp_dst = w_dst / h_dst;
+
+ if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
+ if ((asp_src > asp_dst) == ((node->custom2 & CMP_SCALE_RENDERSIZE_FRAME_CROP) != 0)) {
+ /* fit X */
+ const float div = asp_src / asp_dst;
+ newx = w_dst * div;
+ newy = h_dst;
+ }
+ else {
+ /* fit Y */
+ const float div = asp_dst / asp_src;
+ newx = w_dst;
+ newy = h_dst * div;
+ }
+ }
+ else {
+ /* same as below - no aspect correction needed */
+ newx = w_dst;
+ newy = h_dst;
+ }
+ }
+ else {
+ /* stretch */
+ newx = (rd->xsch * rd->size) / 100;
+ newy = (rd->ysch * rd->size) / 100;
+ }
}
- else { /* CMP_SCALE_ABSOLUTE */
- newx= MAX2((int)in[1]->vec[0], 1);
- newy= MAX2((int)in[2]->vec[0], 1);
+ else { /* CMP_SCALE_ABSOLUTE */
+ newx = MAX2((int)in[1]->vec[0], 1);
+ newy = MAX2((int)in[2]->vec[0], 1);
}
- newx= MIN2(newx, CMP_SCALE_MAX);
- newy= MIN2(newy, CMP_SCALE_MAX);
+ newx = MIN2(newx, CMP_SCALE_MAX);
+ newy = MIN2(newy, CMP_SCALE_MAX);
- ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
+ ibuf = IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
if (ibuf) {
- ibuf->rect_float= cbuf->rect;
+ ibuf->rect_float = cbuf->rect;
IMB_scaleImBuf(ibuf, newx, newy);
-
+
if (ibuf->rect_float == cbuf->rect) {
/* no scaling happened. */
- stackbuf= pass_on_compbuf(in[0]->data);
+ stackbuf = pass_on_compbuf(in[0]->data);
}
else {
- stackbuf= alloc_compbuf(newx, newy, CB_RGBA, 0);
- stackbuf->rect= ibuf->rect_float;
- stackbuf->malloc= 1;
+ stackbuf = alloc_compbuf(newx, newy, CB_RGBA, 0);
+ stackbuf->rect = ibuf->rect_float;
+ stackbuf->malloc = 1;
}
- ibuf->rect_float= NULL;
+ ibuf->rect_float = NULL;
ibuf->mall &= ~IB_rectfloat;
IMB_freeImBuf(ibuf);
-
+
/* also do the translation vector */
- stackbuf->xof = (int)(((float)newx/(float)cbuf->x) * (float)cbuf->xof);
- stackbuf->yof = (int)(((float)newy/(float)cbuf->y) * (float)cbuf->yof);
+ stackbuf->xof = (int)(ofsx + (((float)newx / (float)cbuf->x) * (float)cbuf->xof));
+ stackbuf->yof = (int)(ofsy + (((float)newy / (float)cbuf->y) * (float)cbuf->yof));
}
else {
- stackbuf= dupalloc_compbuf(cbuf);
+ stackbuf = dupalloc_compbuf(cbuf);
printf("Scaling to %dx%d failed\n", newx, newy);
}
-
- out[0]->data= stackbuf;
- if (cbuf!=in[0]->data)
+
+ out[0]->data = stackbuf;
+ if (cbuf != in[0]->data)
free_compbuf(cbuf);
}
- else if (node->custom1==CMP_SCALE_ABSOLUTE) {
+ else if (node->custom1 == CMP_SCALE_ABSOLUTE) {
CompBuf *stackbuf;
int a, x, y;
float *fp;
@@ -126,7 +178,7 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b
fp += 4;
}
- out[0]->data= stackbuf;
+ out[0]->data = stackbuf;
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
index 9ed04ab165c..fabdf8c0536 100644
--- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
+++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
@@ -53,8 +53,9 @@ static void node_composit_exec_stabilize2d(void *data, bNode *node, bNodeStack *
CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
CompBuf *stackbuf;
float loc[2], scale, angle;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, rd->cfra);
- BKE_tracking_stabilization_data(&clip->tracking, rd->cfra, cbuf->x, cbuf->y, loc, &scale, &angle);
+ BKE_tracking_stabilization_data_get(&clip->tracking, clip_framenr, cbuf->x, cbuf->y, loc, &scale, &angle);
stackbuf = node_composit_transform(cbuf, loc[0], loc[1], angle, scale, node->custom1);
diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
index a9d071ececc..50006e599e5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c
+++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
@@ -51,16 +51,16 @@ static float avgLogLum(CompBuf *src, float* auto_key, float* Lav, float* Cav)
const float sc = 1.f/(src->x*src->y);
*Lav = 0.f;
while (p--) {
- float L = 0.212671f*bc[0][0] + 0.71516f*bc[0][1] + 0.072169f*bc[0][2];
+ float L = rgb_to_luma_y(bc[0]);
*Lav += L;
- fRGB_add(Cav, bc[0]);
+ add_v3_v3(Cav, bc[0]);
lsum += (float)log((double)MAX2(L, 0.0) + 1e-5);
maxl = (L > maxl) ? L : maxl;
minl = (L < minl) ? L : minl;
bc++;
}
*Lav *= sc;
- fRGB_mult(Cav, sc);
+ mul_v3_fl(Cav, sc);
maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5f); avl = lsum*sc;
*auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f;
return exp((double)avl);
@@ -86,7 +86,7 @@ static void tonemap(NodeTonemap* ntm, CompBuf* dst, CompBuf* src)
fRGB* sp = (fRGB*)&src->rect[y*src->x*src->type];
fRGB* dp = (fRGB*)&dst->rect[y*src->x*src->type];
for (x=0; x<src->x; ++x) {
- const float L = 0.212671f*sp[x][0] + 0.71516f*sp[x][1] + 0.072169f*sp[x][2];
+ const float L = rgb_to_luma_y(sp[x]);
float I_l = sp[x][0] + ic*(L - sp[x][0]);
float I_g = Cav[0] + ic*(Lav - Cav[0]);
float I_a = I_l + ia*(I_g - I_l);
@@ -109,8 +109,8 @@ static void tonemap(NodeTonemap* ntm, CompBuf* dst, CompBuf* src)
fRGB* sp = (fRGB*)&src->rect[y*src->x*src->type];
fRGB* dp = (fRGB*)&dst->rect[y*src->x*src->type];
for (x=0; x<src->x; x++) {
- fRGB_copy(dp[x], sp[x]);
- fRGB_mult(dp[x], al);
+ copy_v4_v4(dp[x], sp[x]);
+ mul_v3_fl(dp[x], al);
dr = dp[x][0] + ntm->offset;
dg = dp[x][1] + ntm->offset;
db = dp[x][2] + ntm->offset;
diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
index fd2cc724b82..e1a20a65227 100644
--- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
@@ -34,63 +34,63 @@
/* **************** VECTOR BLUR ******************** */
-static bNodeSocketTemplate cmp_node_vecblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Z"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Speed"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_vecblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Z"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
+ { SOCK_VECTOR, 1, N_("Speed"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_vecblur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_vecblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeBlurData *nbd= node->storage;
- CompBuf *new, *img= in[0]->data, *vecbuf= in[2]->data, *zbuf= in[1]->data;
+ NodeBlurData *nbd = node->storage;
+ CompBuf *new, *img = in[0]->data, *vecbuf = in[2]->data, *zbuf = in[1]->data;
- if (img==NULL || vecbuf==NULL || zbuf==NULL || out[0]->hasoutput==0)
+ if (img == NULL || vecbuf == NULL || zbuf == NULL || out[0]->hasoutput == 0)
return;
- if (vecbuf->x!=img->x || vecbuf->y!=img->y) {
+ if (vecbuf->x != img->x || vecbuf->y != img->y) {
printf("ERROR: cannot do different sized vecbuf yet\n");
return;
}
- if (vecbuf->type!=CB_VEC4) {
+ if (vecbuf->type != CB_VEC4) {
printf("ERROR: input should be vecbuf\n");
return;
}
- if (zbuf->type!=CB_VAL) {
+ if (zbuf->type != CB_VAL) {
printf("ERROR: input should be zbuf\n");
return;
}
- if (zbuf->x!=img->x || zbuf->y!=img->y) {
+ if (zbuf->x != img->x || zbuf->y != img->y) {
printf("ERROR: cannot do different sized zbuf yet\n");
return;
}
/* allow the input image to be of another type */
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
- new= dupalloc_compbuf(img);
+ new = dupalloc_compbuf(img);
/* call special zbuffer version */
RE_zbuf_accumulate_vecblur(nbd, img->x, img->y, new->rect, img->rect, vecbuf->rect, zbuf->rect);
- out[0]->data= new;
+ out[0]->data = new;
- if (img!=in[0]->data)
+ if (img != in[0]->data)
free_compbuf(img);
}
-static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data");
- node->storage= nbd;
- nbd->samples= 32;
- nbd->fac= 1.0f;
+ NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur data");
+ node->storage = nbd;
+ nbd->samples = 32;
+ nbd->fac = 1.0f;
}
/* custom1: itterations, custom2: maxspeed (0 = nolimit) */
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c
index 1fc9399e876..e97863a9463 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c
@@ -34,11 +34,11 @@
/* **************** VIEWER ******************** */
-static bNodeSocketTemplate cmp_node_viewer_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Z"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_viewer_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
+ { SOCK_FLOAT, 1, N_("Z"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
+ { -1, 0, "" }
};
@@ -47,9 +47,9 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in,
/* image assigned to output */
/* stack order input sockets: col, alpha, z */
- if (node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */
- RenderData *rd= data;
- Image *ima= (Image *)node->id;
+ if (node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */
+ RenderData *rd = data;
+ Image *ima = (Image *)node->id;
ImBuf *ibuf;
CompBuf *cbuf, *tbuf;
int rectx, recty;
@@ -58,8 +58,8 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in,
BKE_image_user_frame_calc(node->storage, rd->cfra, 0);
/* always returns for viewer image, but we check nevertheless */
- ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock);
- if (ibuf==NULL) {
+ ibuf = BKE_image_acquire_ibuf(ima, node->storage, &lock);
+ if (ibuf == NULL) {
printf("node_composit_exec_viewer error\n");
BKE_image_release_ibuf(ima, lock);
return;
@@ -71,28 +71,28 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in,
IMB_freezbuffloatImBuf(ibuf);
/* get size */
- tbuf= in[0]->data?in[0]->data:(in[1]->data?in[1]->data:in[2]->data);
- if (tbuf==NULL) {
- rectx= 320; recty= 256;
+ tbuf = in[0]->data ? in[0]->data : (in[1]->data ? in[1]->data : in[2]->data);
+ if (tbuf == NULL) {
+ rectx = 320; recty = 256;
}
else {
- rectx= tbuf->x;
- recty= tbuf->y;
+ rectx = tbuf->x;
+ recty = tbuf->y;
}
/* make ibuf, and connect to ima */
- ibuf->x= rectx;
- ibuf->y= recty;
+ ibuf->x = rectx;
+ ibuf->y = recty;
imb_addrectfloatImBuf(ibuf);
- ima->ok= IMA_OK_LOADED;
+ ima->ok = IMA_OK_LOADED;
/* now we combine the input with ibuf */
- cbuf= alloc_compbuf(rectx, recty, CB_RGBA, 0); /* no alloc*/
- cbuf->rect= ibuf->rect_float;
+ cbuf = alloc_compbuf(rectx, recty, CB_RGBA, 0); /* no alloc*/
+ cbuf->rect = ibuf->rect_float;
/* when no alpha, we can simply copy */
- if (in[1]->data==NULL) {
+ if (in[1]->data == NULL) {
composit1_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, do_copy_rgba, CB_RGBA);
}
else
@@ -100,14 +100,14 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in,
/* zbuf option */
if (in[2]->data) {
- CompBuf *zbuf= alloc_compbuf(rectx, recty, CB_VAL, 1);
- ibuf->zbuf_float= zbuf->rect;
+ CompBuf *zbuf = alloc_compbuf(rectx, recty, CB_VAL, 1);
+ ibuf->zbuf_float = zbuf->rect;
ibuf->mall |= IB_zbuffloat;
composit1_pixel_processor(node, zbuf, in[2]->data, in[2]->vec, do_copy_value, CB_VAL);
/* free compbuf, but not the rect */
- zbuf->malloc= 0;
+ zbuf->malloc = 0;
free_compbuf(zbuf);
}
@@ -122,13 +122,13 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in,
}
}
-static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user");
- node->storage= iuser;
- iuser->sfra= 1;
- iuser->fie_ima= 2;
- iuser->ok= 1;
+ ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user");
+ node->storage = iuser;
+ iuser->sfra = 1;
+ iuser->fie_ima = 2;
+ iuser->ok = 1;
node->custom3 = 0.5f;
node->custom4 = 0.5f;
}
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 3d1b656fc4e..150bede4b7c 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -32,8 +32,6 @@
#include <string.h>
-#include "DNA_action_types.h"
-#include "DNA_anim_types.h"
#include "DNA_node_types.h"
#include "BLI_listbase.h"
@@ -42,8 +40,6 @@
#include "BLF_translation.h"
-#include "BKE_action.h"
-#include "BKE_animsys.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -112,294 +108,6 @@ bNodeSocket *node_group_add_extern_socket(bNodeTree *UNUSED(ntree), ListBase *lb
return sock;
}
-bNode *node_group_make_from_selected(bNodeTree *ntree)
-{
- bNodeLink *link, *linkn;
- bNode *node, *gnode, *nextn;
- bNodeTree *ngroup;
- bNodeSocket *gsock;
- ListBase anim_basepaths = {NULL, NULL};
- float min[2], max[2];
- int totnode=0;
- bNodeTemplate ntemp;
-
- INIT_MINMAX2(min, max);
-
- /* is there something to group? also do some clearing */
- for (node= ntree->nodes.first; node; node= node->next) {
- if (node->flag & NODE_SELECT) {
- /* no groups in groups */
- if (node->type==NODE_GROUP)
- return NULL;
- DO_MINMAX2((&node->locx), min, max);
- totnode++;
- }
- node->done = FALSE;
- }
- if (totnode==0) return NULL;
-
- /* check if all connections are OK, no unselected node has both
- * inputs and outputs to a selection */
- for (link= ntree->links.first; link; link= link->next) {
- if (link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT)
- link->tonode->done |= 1;
- if (link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT)
- link->fromnode->done |= 2;
- }
-
- for (node= ntree->nodes.first; node; node= node->next) {
- if ((node->flag & NODE_SELECT)==0)
- if (node->done==3)
- break;
- }
- if (node)
- return NULL;
-
- /* OK! new nodetree */
- ngroup= ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP);
-
- /* move nodes over */
- for (node= ntree->nodes.first; node; node= nextn) {
- nextn= node->next;
- if (node->flag & NODE_SELECT) {
- /* keep track of this node's RNA "base" path (the part of the pat identifying the node)
- * if the old nodetree has animation data which potentially covers this node
- */
- if (ntree->adt) {
- PointerRNA ptr;
- char *path;
-
- RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
- path = RNA_path_from_ID_to_struct(&ptr);
-
- if (path)
- BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
- }
-
- /* change node-collection membership */
- BLI_remlink(&ntree->nodes, node);
- BLI_addtail(&ngroup->nodes, node);
-
- node->locx-= 0.5f*(min[0]+max[0]);
- node->locy-= 0.5f*(min[1]+max[1]);
- }
- }
-
- /* move animation data over */
- if (ntree->adt) {
- LinkData *ld, *ldn=NULL;
-
- BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths);
-
- /* paths + their wrappers need to be freed */
- for (ld = anim_basepaths.first; ld; ld = ldn) {
- ldn = ld->next;
-
- MEM_freeN(ld->data);
- BLI_freelinkN(&anim_basepaths, ld);
- }
- }
-
- /* node groups don't use internal cached data */
- ntreeFreeCache(ngroup);
-
- /* make group node */
- ntemp.type = NODE_GROUP;
- ntemp.ngroup = ngroup;
- gnode= nodeAddNode(ntree, &ntemp);
- gnode->locx= 0.5f*(min[0]+max[0]);
- gnode->locy= 0.5f*(min[1]+max[1]);
-
- /* relink external sockets */
- for (link= ntree->links.first; link; link= linkn) {
- linkn= link->next;
-
- if (link->fromnode && link->tonode && (link->fromnode->flag & link->tonode->flag & NODE_SELECT)) {
- BLI_remlink(&ntree->links, link);
- BLI_addtail(&ngroup->links, link);
- }
- else if (link->tonode && (link->tonode->flag & NODE_SELECT)) {
- gsock = node_group_expose_socket(ngroup, link->tosock, SOCK_IN);
- link->tosock->link = nodeAddLink(ngroup, NULL, gsock, link->tonode, link->tosock);
- link->tosock = node_group_add_extern_socket(ntree, &gnode->inputs, SOCK_IN, gsock);
- link->tonode = gnode;
- }
- else if (link->fromnode && (link->fromnode->flag & NODE_SELECT)) {
- /* search for existing group node socket */
- for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next)
- if (gsock->link && gsock->link->fromsock==link->fromsock)
- break;
- if (!gsock) {
- gsock = node_group_expose_socket(ngroup, link->fromsock, SOCK_OUT);
- gsock->link = nodeAddLink(ngroup, link->fromnode, link->fromsock, NULL, gsock);
- link->fromsock = node_group_add_extern_socket(ntree, &gnode->outputs, SOCK_OUT, gsock);
- }
- else
- link->fromsock = node_group_find_output(gnode, gsock);
- link->fromnode = gnode;
- }
- }
-
- /* update of the group tree */
- ngroup->update |= NTREE_UPDATE;
- ntreeUpdateTree(ngroup);
- /* update of the tree containing the group instance node */
- ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
- ntreeUpdateTree(ntree);
-
- return gnode;
-}
-
-/* returns 1 if its OK */
-int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
-{
- bNodeLink *link, *linkn;
- bNode *node, *nextn;
- bNodeTree *ngroup, *wgroup;
- ListBase anim_basepaths = {NULL, NULL};
-
- ngroup= (bNodeTree *)gnode->id;
- if (ngroup==NULL) return 0;
-
- /* clear new pointers, set in copytree */
- for (node= ntree->nodes.first; node; node= node->next)
- node->new_node= NULL;
-
- /* wgroup is a temporary copy of the NodeTree we're merging in
- * - all of wgroup's nodes are transferred across to their new home
- * - ngroup (i.e. the source NodeTree) is left unscathed
- */
- wgroup= ntreeCopyTree(ngroup);
-
- /* add the nodes into the ntree */
- for (node= wgroup->nodes.first; node; node= nextn) {
- nextn= node->next;
-
- /* keep track of this node's RNA "base" path (the part of the pat identifying the node)
- * if the old nodetree has animation data which potentially covers this node
- */
- if (wgroup->adt) {
- PointerRNA ptr;
- char *path;
-
- RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
- path = RNA_path_from_ID_to_struct(&ptr);
-
- if (path)
- BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
- }
-
- /* migrate node */
- BLI_remlink(&wgroup->nodes, node);
- BLI_addtail(&ntree->nodes, node);
-
- node->locx += gnode->locx;
- node->locy += gnode->locy;
-
- node->flag |= NODE_SELECT;
- }
-
- /* restore external links to and from the gnode */
- for (link= ntree->links.first; link; link= link->next) {
- if (link->fromnode==gnode) {
- if (link->fromsock->groupsock) {
- bNodeSocket *gsock= link->fromsock->groupsock;
- if (gsock->link) {
- if (gsock->link->fromnode) {
- /* NB: using the new internal copies here! the groupsock pointer still maps to the old tree */
- link->fromnode = (gsock->link->fromnode ? gsock->link->fromnode->new_node : NULL);
- link->fromsock = gsock->link->fromsock->new_sock;
- }
- else {
- /* group output directly maps to group input */
- bNodeSocket *insock= node_group_find_input(gnode, gsock->link->fromsock);
- if (insock->link) {
- link->fromnode = insock->link->fromnode;
- link->fromsock = insock->link->fromsock;
- }
- }
- }
- else {
- /* copy the default input value from the group socket default to the external socket */
- node_socket_convert_default_value(link->tosock->type, link->tosock->default_value, gsock->type, gsock->default_value);
- }
- }
- }
- }
- /* remove internal output links, these are not used anymore */
- for (link=wgroup->links.first; link; link= linkn) {
- linkn = link->next;
- if (!link->tonode)
- nodeRemLink(wgroup, link);
- }
- /* restore links from internal nodes */
- for (link= wgroup->links.first; link; link= link->next) {
- /* indicates link to group input */
- if (!link->fromnode) {
- /* NB: can't use find_group_node_input here,
- * because gnode sockets still point to the old tree!
- */
- bNodeSocket *insock;
- for (insock= gnode->inputs.first; insock; insock= insock->next)
- if (insock->groupsock->new_sock == link->fromsock)
- break;
- if (insock->link) {
- link->fromnode = insock->link->fromnode;
- link->fromsock = insock->link->fromsock;
- }
- else {
- /* copy the default input value from the group node socket default to the internal socket */
- node_socket_convert_default_value(link->tosock->type, link->tosock->default_value, insock->type, insock->default_value);
- nodeRemLink(wgroup, link);
- }
- }
- }
-
- /* add internal links to the ntree */
- for (link= wgroup->links.first; link; link= linkn) {
- linkn= link->next;
- BLI_remlink(&wgroup->links, link);
- BLI_addtail(&ntree->links, link);
- }
-
- /* and copy across the animation,
- * note that the animation data's action can be NULL here */
- if (wgroup->adt) {
- LinkData *ld, *ldn=NULL;
- bAction *waction;
-
- /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
- waction = wgroup->adt->action = BKE_action_copy(wgroup->adt->action);
-
- /* now perform the moving */
- BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);
-
- /* paths + their wrappers need to be freed */
- for (ld = anim_basepaths.first; ld; ld = ldn) {
- ldn = ld->next;
-
- MEM_freeN(ld->data);
- BLI_freelinkN(&anim_basepaths, ld);
- }
-
- /* free temp action too */
- if (waction) {
- BKE_libblock_free(&G.main->action, waction);
- }
- }
-
- /* delete the group instance. this also removes old input links! */
- nodeFreeNode(ntree, gnode);
-
- /* free the group tree (takes care of user count) */
- BKE_libblock_free(&G.main->nodetree, wgroup);
-
- ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
- ntreeUpdateTree(ntree);
-
- return 1;
-}
-
bNodeSocket *node_group_add_socket(bNodeTree *ngroup, const char *name, int type, int in_out)
{
bNodeSocketType *stype = ntreeGetSocketType(type);
@@ -849,7 +557,7 @@ static bNodeSocketTemplate node_reroute_out[]= {
};
/* simple, only a single input and output here */
-ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node)
+static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node)
{
bNodeLink *link;
ListBase ret;
@@ -872,6 +580,23 @@ ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node)
return ret;
}
+static void node_reroute_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ bNodeSocket *input = node->inputs.first;
+ bNodeSocket *output = node->outputs.first;
+ int type = SOCK_FLOAT;
+
+ /* determine socket type from unambiguous input/output connection if possible */
+ if (input->limit==1 && input->link)
+ type = input->link->fromsock->type;
+ else if (output->limit==1 && output->link)
+ type = output->link->tosock->type;
+
+ /* same type for input/output */
+ nodeSocketSetType(input, type);
+ nodeSocketSetType(output, type);
+}
+
void register_node_type_reroute(bNodeTreeType *ttype)
{
/* frame type is used for all tree types, needs dynamic allocation */
@@ -880,6 +605,7 @@ void register_node_type_reroute(bNodeTreeType *ttype)
node_type_base(ttype, ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0);
node_type_socket_templates(ntype, node_reroute_in, node_reroute_out);
node_type_internal_connect(ntype, node_reroute_internal_connect);
+ node_type_update(ntype, node_reroute_update, NULL);
ntype->needs_free = 1;
nodeRegisterType(ttype, ntype);
diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h
index 616221d6658..f1bb837e483 100644
--- a/source/blender/nodes/intern/node_common.h
+++ b/source/blender/nodes/intern/node_common.h
@@ -37,8 +37,6 @@
struct bNodeTree;
-struct bNodeSocket *node_group_add_extern_socket(struct bNodeTree *ntree, ListBase *lb, int in_out, struct bNodeSocket *gsock);
-
void node_group_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
void node_forloop_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
void node_whileloop_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 07bda4c2b91..54044b62e04 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -2268,6 +2268,11 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
axis_from = 0;
swizzleClosure = GET_INT_FROM_POINTER(closure);
+ /* We must first copy current vec into tvec, else some org values may be lost.
+ * See [#31760].
+ * Assuming self->size can't be higher than MAX_DIMENSIONS! */
+ memcpy(tvec, self->vec, self->size * sizeof(float));
+
while (swizzleClosure & SWIZZLE_VALID_AXIS) {
axis_to = swizzleClosure & SWIZZLE_AXIS;
tvec[axis_to] = vec_assign[axis_from];
@@ -2275,7 +2280,9 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
axis_from++;
}
- memcpy(self->vec, tvec, axis_from * sizeof(float));
+ /* We must copy back the whole tvec into vec, else some changes may be lost (e.g. xz...).
+ * See [#31760]. */
+ memcpy(self->vec, tvec, self->size * sizeof(float));
/* continue with BaseMathObject_WriteCallback at the end */
if (BaseMath_WriteCallback(self) == -1)
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 36eb74b3d30..4ea9333558d 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1730,7 +1730,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
strandbuf->minwidth= ma->strand_min;
if (ma->strand_widthfade == 0.0f)
- strandbuf->widthfade= 0.0f;
+ strandbuf->widthfade= -1.0f;
else if (ma->strand_widthfade >= 1.0f)
strandbuf->widthfade= 2.0f - ma->strand_widthfade;
else
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index 21e4e216063..b3eb8c0fd5c 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -1197,7 +1197,8 @@ static float occ_form_factor(OccFace *face, float *p, float *n)
return contrib;
}
-static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float *pp, float *pn, float *occ, float rad[3], float bentn[3])
+static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude,
+ const float pp[3], const float pn[3], float *occ, float rad[3], float bentn[3])
{
OccNode *node, **stack;
OccFace *face;
@@ -1391,7 +1392,9 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass)
MEM_freeN(occ);
}
-static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, float *co, float *n, int thread, int onlyshadow, float *ao, float *env, float *indirect)
+static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude,
+ const float co[3], const float n[3], int thread, int onlyshadow,
+ float *ao, float *env, float *indirect)
{
float nn[3], bn[3], fac, occ, occlusion, correction, rad[3];
int envcolor;
@@ -1415,9 +1418,9 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f
/* sky shading using bent normal */
if (ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) {
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;
+ 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;
mul_v3_fl(env, occlusion);
}
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index c37d7e0e5d8..a730868dadd 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -45,7 +45,7 @@
#include "MEM_guardedalloc.h"
-#include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */
+#include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */
#include "BKE_camera.h"
#include "BKE_global.h"
#include "BKE_image.h"
@@ -57,7 +57,7 @@
#include "BKE_scene.h"
#include "BKE_sequencer.h"
#include "BKE_utildefines.h"
-#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */
+#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */
#include "BLI_math.h"
#include "BLI_listbase.h"
@@ -130,7 +130,7 @@ Render R;
static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const char *name_override);
-static volatile int g_break= 0;
+static volatile int g_break = 0;
static int thread_break(void *UNUSED(arg))
{
return g_break;
@@ -148,13 +148,13 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
uintptr_t mem_in_use, mmap_in_use, peak_memory;
float megs_used_memory, mmap_used_memory, megs_peak_memory;
- mem_in_use= MEM_get_memory_in_use();
- mmap_in_use= MEM_get_mapped_memory_in_use();
+ mem_in_use = MEM_get_memory_in_use();
+ mmap_in_use = MEM_get_mapped_memory_in_use();
peak_memory = MEM_get_peak_memory();
- megs_used_memory= (mem_in_use-mmap_in_use)/(1024.0*1024.0);
- mmap_used_memory= (mmap_in_use)/(1024.0*1024.0);
- megs_peak_memory = (peak_memory)/(1024.0*1024.0);
+ megs_used_memory = (mem_in_use - mmap_in_use) / (1024.0 * 1024.0);
+ mmap_used_memory = (mmap_in_use) / (1024.0 * 1024.0);
+ megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
fprintf(stdout, "Fra:%d Mem:%.2fM (%.2fM, peak %.2fM) ", rs->cfra,
megs_used_memory, mmap_used_memory, megs_peak_memory);
@@ -189,8 +189,8 @@ float *RE_RenderLayerGetPass(RenderLayer *rl, int passtype)
{
RenderPass *rpass;
- for (rpass=rl->passes.first; rpass; rpass= rpass->next)
- if (rpass->passtype== passtype)
+ for (rpass = rl->passes.first; rpass; rpass = rpass->next)
+ if (rpass->passtype == passtype)
return rpass->rect;
return NULL;
}
@@ -199,10 +199,10 @@ RenderLayer *RE_GetRenderLayer(RenderResult *rr, const char *name)
{
RenderLayer *rl;
- if (rr==NULL) return NULL;
+ if (rr == NULL) return NULL;
- for (rl= rr->layers.first; rl; rl= rl->next)
- if (strncmp(rl->name, name, RE_MAXNAME)==0)
+ for (rl = rr->layers.first; rl; rl = rl->next)
+ if (strncmp(rl->name, name, RE_MAXNAME) == 0)
return rl;
return NULL;
}
@@ -214,7 +214,7 @@ RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty)
RenderLayer *render_get_active_layer(Render *re, RenderResult *rr)
{
- RenderLayer *rl= BLI_findlink(&rr->layers, re->r.actlay);
+ RenderLayer *rl = BLI_findlink(&rr->layers, re->r.actlay);
if (rl)
return rl;
@@ -226,7 +226,7 @@ static int render_scene_needs_vector(Render *re)
{
SceneRenderLayer *srl;
- for (srl= re->scene->r.layers.first; srl; srl= srl->next)
+ for (srl = re->scene->r.layers.first; srl; srl = srl->next)
if (!(srl->layflag & SCE_LAY_DISABLE))
if (srl->passflag & SCE_PASS_VECTOR)
return 1;
@@ -241,8 +241,8 @@ Render *RE_GetRender(const char *name)
Render *re;
/* search for existing renders */
- for (re= RenderGlobal.renderlist.first; re; re= re->next)
- if (strncmp(re->name, name, RE_MAXNAME)==0)
+ for (re = RenderGlobal.renderlist.first; re; re = re->next)
+ if (strncmp(re->name, name, RE_MAXNAME) == 0)
break;
return re;
@@ -273,7 +273,7 @@ void RE_SwapResult(Render *re, RenderResult **rr)
{
/* for keeping render buffers */
if (re) {
- SWAP(RenderResult*, re->result, *rr);
+ SWAP(RenderResult *, re->result, *rr);
}
}
@@ -303,25 +303,25 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr)
if (re->result) {
RenderLayer *rl;
- rr->rectx= re->result->rectx;
- rr->recty= re->result->recty;
+ rr->rectx = re->result->rectx;
+ rr->recty = re->result->recty;
- rr->rectf= re->result->rectf;
- rr->rectz= re->result->rectz;
- rr->rect32= re->result->rect32;
+ rr->rectf = re->result->rectf;
+ rr->rectz = re->result->rectz;
+ rr->rect32 = re->result->rect32;
/* active layer */
- rl= render_get_active_layer(re, re->result);
+ rl = render_get_active_layer(re, re->result);
if (rl) {
- if (rr->rectf==NULL)
- rr->rectf= rl->rectf;
- if (rr->rectz==NULL)
- rr->rectz= RE_RenderLayerGetPass(rl, SCE_PASS_Z);
+ if (rr->rectf == NULL)
+ rr->rectf = rl->rectf;
+ if (rr->rectz == NULL)
+ rr->rectz = RE_RenderLayerGetPass(rl, SCE_PASS_Z);
}
- rr->have_combined= (re->result->rectf != NULL);
- rr->layers= re->result->layers;
+ rr->have_combined = (re->result->rectf != NULL);
+ rr->layers = re->result->layers;
}
}
}
@@ -352,11 +352,11 @@ Render *RE_NewRender(const char *name)
Render *re;
/* only one render per name exists */
- re= RE_GetRender(name);
- if (re==NULL) {
+ re = RE_GetRender(name);
+ if (re == NULL) {
/* new render data struct */
- re= MEM_callocN(sizeof(Render), "new render");
+ re = MEM_callocN(sizeof(Render), "new render");
BLI_addtail(&RenderGlobal.renderlist, re);
BLI_strncpy(re->name, name, RE_MAXNAME);
BLI_rw_mutex_init(&re->resultmutex);
@@ -365,7 +365,7 @@ Render *RE_NewRender(const char *name)
RE_InitRenderCB(re);
/* init some variables */
- re->ycor= 1.0f;
+ re->ycor = 1.0f;
return re;
}
@@ -375,17 +375,17 @@ Render *RE_NewRender(const char *name)
void RE_InitRenderCB(Render *re)
{
/* set default empty callbacks */
- re->display_init= result_nothing;
- re->display_clear= result_nothing;
- re->display_draw= result_rcti_nothing;
- re->progress= float_nothing;
- re->test_break= default_break;
+ re->display_init = result_nothing;
+ re->display_clear = result_nothing;
+ re->display_draw = result_rcti_nothing;
+ re->progress = float_nothing;
+ re->test_break = default_break;
if (G.background)
- re->stats_draw= stats_background;
+ re->stats_draw = stats_background;
else
- re->stats_draw= stats_nothing;
+ re->stats_draw = stats_nothing;
/* clear callback handles */
- re->dih= re->dch= re->ddh= re->sdh= re->prh= re->tbh= NULL;
+ re->dih = re->dch = re->ddh = re->sdh = re->prh = re->tbh = NULL;
}
/* only call this while you know it will remove the link too */
@@ -432,66 +432,66 @@ void RE_FreeAllRenderResults(void)
/* disprect is optional, if NULL it assumes full window render */
void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *srl, int winx, int winy, rcti *disprect)
{
- re->ok= TRUE; /* maybe flag */
+ re->ok = TRUE; /* maybe flag */
- re->i.starttime= PIL_check_seconds_timer();
- re->r= *rd; /* hardcopy */
+ re->i.starttime = PIL_check_seconds_timer();
+ re->r = *rd; /* hardcopy */
- re->winx= winx;
- re->winy= winy;
+ re->winx = winx;
+ re->winy = winy;
if (disprect) {
- re->disprect= *disprect;
- re->rectx= disprect->xmax-disprect->xmin;
- re->recty= disprect->ymax-disprect->ymin;
+ re->disprect = *disprect;
+ re->rectx = disprect->xmax - disprect->xmin;
+ re->recty = disprect->ymax - disprect->ymin;
}
else {
re->disprect.xmin = re->disprect.ymin = 0;
re->disprect.xmax = winx;
re->disprect.ymax = winy;
- re->rectx= winx;
- re->recty= winy;
+ re->rectx = winx;
+ re->recty = winy;
}
if (re->rectx < 2 || re->recty < 2 || (BKE_imtype_is_movie(rd->im_format.imtype) &&
(re->rectx < 16 || re->recty < 16) ))
{
BKE_report(re->reports, RPT_ERROR, "Image too small");
- re->ok= 0;
+ re->ok = 0;
return;
}
- if ((re->r.mode & (R_OSA))==0)
+ if ((re->r.mode & (R_OSA)) == 0)
re->r.scemode &= ~R_FULL_SAMPLE;
#ifdef WITH_OPENEXR
if (re->r.scemode & R_FULL_SAMPLE)
- re->r.scemode |= R_EXR_TILE_FILE; /* enable automatic */
+ re->r.scemode |= R_EXR_TILE_FILE; /* enable automatic */
/* Until use_border is made compatible with save_buffers/full_sample, render without the later instead of not rendering at all.*/
if (re->r.mode & R_BORDER) {
- re->r.scemode &= ~(R_EXR_TILE_FILE|R_FULL_SAMPLE);
+ re->r.scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
}
#else
/* can't do this without openexr support */
- re->r.scemode &= ~(R_EXR_TILE_FILE|R_FULL_SAMPLE);
+ re->r.scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
#endif
/* fullsample wants uniform osa levels */
if (source && (re->r.scemode & R_FULL_SAMPLE)) {
/* but, if source has no full sample we disable it */
- if ((source->r.scemode & R_FULL_SAMPLE)==0)
+ if ((source->r.scemode & R_FULL_SAMPLE) == 0)
re->r.scemode &= ~R_FULL_SAMPLE;
else
- re->r.osa= re->osa= source->osa;
+ re->r.osa = re->osa = source->osa;
}
else {
/* check state variables, osa? */
if (re->r.mode & (R_OSA)) {
- re->osa= re->r.osa;
- if (re->osa>16) re->osa= 16;
+ re->osa = re->r.osa;
+ if (re->osa > 16) re->osa = 16;
}
- else re->osa= 0;
+ else re->osa = 0;
}
if (srl) {
@@ -509,25 +509,25 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
if (re->r.scemode & R_PREVIEWBUTS) {
- if (re->result && re->result->rectx==re->rectx && re->result->recty==re->recty);
+ if (re->result && re->result->rectx == re->rectx && re->result->recty == re->recty) ;
else {
render_result_free(re->result);
- re->result= NULL;
+ re->result = NULL;
}
}
else {
/* make empty render result, so display callbacks can initialize */
render_result_free(re->result);
- re->result= MEM_callocN(sizeof(RenderResult), "new render result");
- re->result->rectx= re->rectx;
- re->result->recty= re->recty;
+ re->result = MEM_callocN(sizeof(RenderResult), "new render result");
+ re->result->rectx = re->rectx;
+ re->result->recty = re->recty;
}
BLI_rw_mutex_unlock(&re->resultmutex);
/* we clip faces with a minimum of 2 pixel boundary outside of image border. see zbuf.c */
- re->clipcrop= 1.0f + 2.0f/(float)(re->winx>re->winy?re->winy:re->winx);
+ re->clipcrop = 1.0f + 2.0f / (float)(re->winx > re->winy ? re->winy : re->winx);
re->mblur_offs = re->field_offs = 0.f;
@@ -538,9 +538,9 @@ void RE_SetWindow(Render *re, rctf *viewplane, float clipsta, float clipend)
{
/* re->ok flag? */
- re->viewplane= *viewplane;
- re->clipsta= clipsta;
- re->clipend= clipend;
+ re->viewplane = *viewplane;
+ re->clipsta = clipsta;
+ re->clipend = clipend;
re->r.mode &= ~R_ORTHO;
perspective_m4(re->winmat,
@@ -553,9 +553,9 @@ void RE_SetOrtho(Render *re, rctf *viewplane, float clipsta, float clipend)
{
/* re->ok flag? */
- re->viewplane= *viewplane;
- re->clipsta= clipsta;
- re->clipend= clipend;
+ re->viewplane = *viewplane;
+ re->clipsta = clipsta;
+ re->clipend = clipend;
re->r.mode |= R_ORTHO;
orthographic_m4(re->winmat,
@@ -573,40 +573,40 @@ void RE_SetView(Render *re, float mat[][4])
/* image and movie output has to move to either imbuf or kernel */
void RE_display_init_cb(Render *re, void *handle, void (*f)(void *handle, RenderResult *rr))
{
- re->display_init= f;
- re->dih= handle;
+ re->display_init = f;
+ re->dih = handle;
}
void RE_display_clear_cb(Render *re, void *handle, void (*f)(void *handle, RenderResult *rr))
{
- re->display_clear= f;
- re->dch= handle;
+ re->display_clear = f;
+ re->dch = handle;
}
void RE_display_draw_cb(Render *re, void *handle, void (*f)(void *handle, RenderResult *rr, volatile rcti *rect))
{
- re->display_draw= f;
- re->ddh= handle;
+ re->display_draw = f;
+ re->ddh = handle;
}
void RE_stats_draw_cb(Render *re, void *handle, void (*f)(void *handle, RenderStats *rs))
{
- re->stats_draw= f;
- re->sdh= handle;
+ re->stats_draw = f;
+ re->sdh = handle;
}
void RE_progress_cb(Render *re, void *handle, void (*f)(void *handle, float))
{
- re->progress= f;
- re->prh= handle;
+ re->progress = f;
+ re->prh = handle;
}
void RE_draw_lock_cb(Render *re, void *handle, void (*f)(void *handle, int i))
{
- re->draw_lock= f;
- re->tbh= handle;
+ re->draw_lock = f;
+ re->tbh = handle;
}
void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle))
{
- re->test_break= f;
- re->tbh= handle;
+ re->test_break = f;
+ re->tbh = handle;
}
@@ -635,15 +635,15 @@ static int render_display_draw_enabled(Render *re)
/* the main thread call, renders an entire part */
static void *do_part_thread(void *pa_v)
{
- RenderPart *pa= pa_v;
+ RenderPart *pa = pa_v;
/* need to return nicely all parts on esc */
- if (R.test_break(R.tbh)==0) {
+ if (R.test_break(R.tbh) == 0) {
if (!R.sss_points && (R.r.scemode & R_FULL_SAMPLE))
- pa->result= render_result_new_full_sample(&R, &pa->fullresult, &pa->disprect, pa->crop, RR_USE_MEM);
+ pa->result = render_result_new_full_sample(&R, &pa->fullresult, &pa->disprect, pa->crop, RR_USE_MEM);
else
- pa->result= render_result_new(&R, &pa->disprect, pa->crop, RR_USE_MEM);
+ pa->result = render_result_new(&R, &pa->disprect, pa->crop, RR_USE_MEM);
if (R.sss_points)
zbufshade_sss_tile(pa);
@@ -658,12 +658,12 @@ static void *do_part_thread(void *pa_v)
}
else if (render_display_draw_enabled(&R)) {
/* on break, don't merge in result for preview renders, looks nicer */
- if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS));
+ if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)) ;
else render_result_merge(R.result, pa->result);
}
}
- pa->ready= 1;
+ pa->ready = 1;
return NULL;
}
@@ -674,21 +674,21 @@ static void *do_part_thread(void *pa_v)
float panorama_pixel_rot(Render *re)
{
float psize, phi, xfac;
- float borderfac= (float)(re->disprect.xmax - re->disprect.xmin) / (float)re->winx;
+ float borderfac = (float)(re->disprect.xmax - re->disprect.xmin) / (float)re->winx;
/* size of 1 pixel mapped to viewplane coords */
- psize= (re->viewplane.xmax-re->viewplane.xmin)/(float)(re->winx);
+ psize = (re->viewplane.xmax - re->viewplane.xmin) / (float)(re->winx);
/* angle of a pixel */
- phi= atan(psize/re->clipsta);
+ phi = atan(psize / re->clipsta);
/* correction factor for viewplane shifting, first calculate how much the viewplane angle is */
- xfac= borderfac*((re->viewplane.xmax-re->viewplane.xmin))/(float)re->xparts;
- xfac= atan(0.5f*xfac/re->clipsta);
+ xfac = borderfac * ((re->viewplane.xmax - re->viewplane.xmin)) / (float)re->xparts;
+ xfac = atan(0.5f * xfac / re->clipsta);
/* and how much the same viewplane angle is wrapped */
- psize= 0.5f*phi*((float)re->partx);
+ psize = 0.5f * phi * ((float)re->partx);
/* the ratio applied to final per-pixel angle */
- phi*= xfac/psize;
+ phi *= xfac / psize;
return phi;
}
@@ -697,25 +697,25 @@ float panorama_pixel_rot(Render *re)
/* if slice found, it rotates the dbase */
static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane)
{
- RenderPart *pa, *best= NULL;
+ RenderPart *pa, *best = NULL;
- *minx= re->winx;
+ *minx = re->winx;
/* most left part of the non-rendering parts */
- for (pa= re->parts.first; pa; pa= pa->next) {
- if (pa->ready==0 && pa->nr==0) {
+ for (pa = re->parts.first; pa; pa = pa->next) {
+ if (pa->ready == 0 && pa->nr == 0) {
if (pa->disprect.xmin < *minx) {
- best= pa;
- *minx= pa->disprect.xmin;
+ best = pa;
+ *minx = pa->disprect.xmin;
}
}
}
if (best) {
- float phi= panorama_pixel_rot(re);
+ float phi = panorama_pixel_rot(re);
- R.panodxp= (re->winx - (best->disprect.xmin + best->disprect.xmax) )/2;
- R.panodxv= ((viewplane->xmax-viewplane->xmin)*R.panodxp)/(float)(re->winx);
+ R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2;
+ R.panodxv = ((viewplane->xmax - viewplane->xmin) * R.panodxp) / (float)(re->winx);
/* shift viewplane */
R.viewplane.xmin = viewplane->xmin + R.panodxv;
@@ -724,48 +724,48 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane)
copy_m4_m4(R.winmat, re->winmat);
/* rotate database according to part coordinates */
- project_renderdata(re, projectverto, 1, -R.panodxp*phi, 1);
- R.panosi= sin(R.panodxp*phi);
- R.panoco= cos(R.panodxp*phi);
+ project_renderdata(re, projectverto, 1, -R.panodxp * phi, 1);
+ R.panosi = sin(R.panodxp * phi);
+ R.panoco = cos(R.panodxp * phi);
}
return best;
}
static RenderPart *find_next_part(Render *re, int minx)
{
- RenderPart *pa, *best= NULL;
+ RenderPart *pa, *best = NULL;
/* long long int's needed because of overflow [#24414] */
- long long int centx=re->winx/2, centy=re->winy/2, tot=1;
- long long int mindist= (long long int)re->winx * (long long int)re->winy;
+ long long int centx = re->winx / 2, centy = re->winy / 2, tot = 1;
+ long long int mindist = (long long int)re->winx * (long long int)re->winy;
/* find center of rendered parts, image center counts for 1 too */
- for (pa= re->parts.first; pa; pa= pa->next) {
+ for (pa = re->parts.first; pa; pa = pa->next) {
if (pa->ready) {
- centx+= (pa->disprect.xmin+pa->disprect.xmax)/2;
- centy+= (pa->disprect.ymin+pa->disprect.ymax)/2;
+ centx += (pa->disprect.xmin + pa->disprect.xmax) / 2;
+ centy += (pa->disprect.ymin + pa->disprect.ymax) / 2;
tot++;
}
}
- centx/=tot;
- centy/=tot;
+ centx /= tot;
+ centy /= tot;
/* closest of the non-rendering parts */
- for (pa= re->parts.first; pa; pa= pa->next) {
- if (pa->ready==0 && pa->nr==0) {
- long long int distx= centx - (pa->disprect.xmin+pa->disprect.xmax)/2;
- long long int disty= centy - (pa->disprect.ymin+pa->disprect.ymax)/2;
- distx= (long long int)sqrt(distx*distx + disty*disty);
- if (distx<mindist) {
+ for (pa = re->parts.first; pa; pa = pa->next) {
+ if (pa->ready == 0 && pa->nr == 0) {
+ long long int distx = centx - (pa->disprect.xmin + pa->disprect.xmax) / 2;
+ long long int disty = centy - (pa->disprect.ymin + pa->disprect.ymax) / 2;
+ distx = (long long int)sqrt(distx * distx + disty * disty);
+ if (distx < mindist) {
if (re->r.mode & R_PANORAMA) {
- if (pa->disprect.xmin==minx) {
- best= pa;
- mindist= distx;
+ if (pa->disprect.xmin == minx) {
+ best = pa;
+ mindist = distx;
}
}
else {
- best= pa;
- mindist= distx;
+ best = pa;
+ mindist = distx;
}
}
}
@@ -777,37 +777,37 @@ static void print_part_stats(Render *re, RenderPart *pa)
{
char str[64];
- BLI_snprintf(str, sizeof(str), "%s, Part %d-%d", re->scene->id.name+2, pa->nr, re->i.totpart);
- re->i.infostr= str;
+ BLI_snprintf(str, sizeof(str), "%s, Part %d-%d", re->scene->id.name + 2, pa->nr, re->i.totpart);
+ re->i.infostr = str;
re->stats_draw(re->sdh, &re->i);
- re->i.infostr= NULL;
+ re->i.infostr = NULL;
}
static void threaded_tile_processor(Render *re)
{
ListBase threads;
RenderPart *pa, *nextpa;
- rctf viewplane= re->viewplane;
- int rendering=1, counter= 1, drawtimer=0, hasdrawn, minx=0;
+ rctf viewplane = re->viewplane;
+ int rendering = 1, counter = 1, drawtimer = 0, hasdrawn, minx = 0;
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
/* first step; free the entire render result, make new, and/or prepare exr buffer saving */
- if (re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) {
+ if (re->result == NULL || !(re->r.scemode & R_PREVIEWBUTS)) {
render_result_free(re->result);
if (re->sss_points && render_display_draw_enabled(re))
- re->result= render_result_new(re, &re->disprect, 0, RR_USE_MEM);
+ re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM);
else if (re->r.scemode & R_FULL_SAMPLE)
- re->result= render_result_new_full_sample(re, &re->fullresult, &re->disprect, 0, RR_USE_EXR);
+ re->result = render_result_new_full_sample(re, &re->fullresult, &re->disprect, 0, RR_USE_EXR);
else
- re->result= render_result_new(re, &re->disprect, 0,
- (re->r.scemode & R_EXR_TILE_FILE)? RR_USE_EXR: RR_USE_MEM);
+ re->result = render_result_new(re, &re->disprect, 0,
+ (re->r.scemode & R_EXR_TILE_FILE) ? RR_USE_EXR : RR_USE_MEM);
}
BLI_rw_mutex_unlock(&re->resultmutex);
- if (re->result==NULL)
+ if (re->result == NULL)
return;
/* warning; no return here without closing exr file */
@@ -820,32 +820,32 @@ static void threaded_tile_processor(Render *re)
BLI_init_threads(&threads, do_part_thread, re->r.threads);
/* assuming no new data gets added to dbase... */
- R= *re;
+ R = *re;
/* set threadsafe break */
- R.test_break= thread_break;
+ R.test_break = thread_break;
/* timer loop demands to sleep when no parts are left, so we enter loop with a part */
if (re->r.mode & R_PANORAMA)
- nextpa= find_next_pano_slice(re, &minx, &viewplane);
+ nextpa = find_next_pano_slice(re, &minx, &viewplane);
else
- nextpa= find_next_part(re, 0);
+ nextpa = find_next_part(re, 0);
while (rendering) {
if (re->test_break(re->tbh))
PIL_sleep_ms(50);
else if (nextpa && BLI_available_threads(&threads)) {
- drawtimer= 0;
- nextpa->nr= counter++; /* for nicest part, and for stats */
- nextpa->thread= BLI_available_thread_index(&threads); /* sample index */
+ drawtimer = 0;
+ nextpa->nr = counter++; /* for nicest part, and for stats */
+ nextpa->thread = BLI_available_thread_index(&threads); /* sample index */
BLI_insert_thread(&threads, nextpa);
- nextpa= find_next_part(re, minx);
+ nextpa = find_next_part(re, minx);
}
else if (re->r.mode & R_PANORAMA) {
- if (nextpa==NULL && BLI_available_threads(&threads)==re->r.threads)
- nextpa= find_next_pano_slice(re, &minx, &viewplane);
+ if (nextpa == NULL && BLI_available_threads(&threads) == re->r.threads)
+ nextpa = find_next_pano_slice(re, &minx, &viewplane);
else {
PIL_sleep_ms(50);
drawtimer++;
@@ -857,9 +857,9 @@ static void threaded_tile_processor(Render *re)
}
/* check for ready ones to display, and if we need to continue */
- rendering= 0;
- hasdrawn= 0;
- for (pa= re->parts.first; pa; pa= pa->next) {
+ rendering = 0;
+ hasdrawn = 0;
+ for (pa = re->parts.first; pa; pa = pa->next) {
if (pa->ready) {
BLI_remove_thread(&threads, pa);
@@ -870,27 +870,27 @@ static void threaded_tile_processor(Render *re)
print_part_stats(re, pa);
render_result_free_list(&pa->fullresult, pa->result);
- pa->result= NULL;
+ pa->result = NULL;
re->i.partsdone++;
re->progress(re->prh, re->i.partsdone / (float)re->i.totpart);
- hasdrawn= 1;
+ hasdrawn = 1;
}
}
else {
- rendering= 1;
- if (pa->nr && pa->result && drawtimer>20) {
+ rendering = 1;
+ if (pa->nr && pa->result && drawtimer > 20) {
if (render_display_draw_enabled(re))
re->display_draw(re->ddh, pa->result, &pa->result->renrect);
- hasdrawn= 1;
+ hasdrawn = 1;
}
}
}
if (hasdrawn)
- drawtimer= 0;
+ drawtimer = 0;
/* on break, wait for all slots to get freed */
- if ( (g_break=re->test_break(re->tbh)) && BLI_available_threads(&threads)==re->r.threads)
- rendering= 0;
+ if ( (g_break = re->test_break(re->tbh)) && BLI_available_threads(&threads) == re->r.threads)
+ rendering = 0;
}
@@ -901,11 +901,11 @@ static void threaded_tile_processor(Render *re)
}
/* unset threadsafety */
- g_break= 0;
+ g_break = 0;
BLI_end_threads(&threads);
freeparts(re);
- re->viewplane= viewplane; /* restore viewplane, modified by pano render */
+ re->viewplane = viewplane; /* restore viewplane, modified by pano render */
}
/* currently only called by preview renders and envmap */
@@ -964,59 +964,59 @@ static void do_render_3d(Render *re)
/* called by blur loop, accumulate RGBA key alpha */
static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, float blurfac)
{
- float mfac= 1.0f - blurfac;
- int a, b, stride= 4*rr->rectx;
- int len= stride*sizeof(float);
+ float mfac = 1.0f - blurfac;
+ int a, b, stride = 4 * rr->rectx;
+ int len = stride * sizeof(float);
- for (a=0; a<rr->recty; a++) {
- if (blurfac==1.0f) {
+ for (a = 0; a < rr->recty; a++) {
+ if (blurfac == 1.0f) {
memcpy(rectf, rectf1, len);
}
else {
- float *rf= rectf, *rf1= rectf1;
+ float *rf = rectf, *rf1 = rectf1;
- for ( b= rr->rectx; b>0; b--, rf+=4, rf1+=4) {
- if (rf1[3]<0.01f)
- rf[3]= mfac*rf[3];
- else if (rf[3]<0.01f) {
- rf[0]= rf1[0];
- rf[1]= rf1[1];
- rf[2]= rf1[2];
- rf[3]= blurfac*rf1[3];
+ for (b = rr->rectx; b > 0; b--, rf += 4, rf1 += 4) {
+ if (rf1[3] < 0.01f)
+ rf[3] = mfac * rf[3];
+ else if (rf[3] < 0.01f) {
+ rf[0] = rf1[0];
+ rf[1] = rf1[1];
+ rf[2] = rf1[2];
+ rf[3] = blurfac * rf1[3];
}
else {
- rf[0]= mfac*rf[0] + blurfac*rf1[0];
- rf[1]= mfac*rf[1] + blurfac*rf1[1];
- rf[2]= mfac*rf[2] + blurfac*rf1[2];
- rf[3]= mfac*rf[3] + blurfac*rf1[3];
+ rf[0] = mfac * rf[0] + blurfac * rf1[0];
+ rf[1] = mfac * rf[1] + blurfac * rf1[1];
+ rf[2] = mfac * rf[2] + blurfac * rf1[2];
+ rf[3] = mfac * rf[3] + blurfac * rf1[3];
}
}
}
- rectf+= stride;
- rectf1+= stride;
+ rectf += stride;
+ rectf1 += stride;
}
}
/* called by blur loop, accumulate renderlayers */
static void addblur_rect(RenderResult *rr, float *rectf, float *rectf1, float blurfac, int channels)
{
- float mfac= 1.0f - blurfac;
- int a, b, stride= channels*rr->rectx;
- int len= stride*sizeof(float);
+ float mfac = 1.0f - blurfac;
+ int a, b, stride = channels * rr->rectx;
+ int len = stride * sizeof(float);
- for (a=0; a<rr->recty; a++) {
- if (blurfac==1.0f) {
+ for (a = 0; a < rr->recty; a++) {
+ if (blurfac == 1.0f) {
memcpy(rectf, rectf1, len);
}
else {
- float *rf= rectf, *rf1= rectf1;
+ float *rf = rectf, *rf1 = rectf1;
- for ( b= rr->rectx*channels; b>0; b--, rf++, rf1++) {
- rf[0]= mfac*rf[0] + blurfac*rf1[0];
+ for (b = rr->rectx * channels; b > 0; b--, rf++, rf1++) {
+ rf[0] = mfac * rf[0] + blurfac * rf1[0];
}
}
- rectf+= stride;
- rectf1+= stride;
+ rectf += stride;
+ rectf1 += stride;
}
}
@@ -1027,8 +1027,8 @@ static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float b
RenderLayer *rl, *rl1;
RenderPass *rpass, *rpass1;
- rl1= brr->layers.first;
- for (rl= rr->layers.first; rl && rl1; rl= rl->next, rl1= rl1->next) {
+ rl1 = brr->layers.first;
+ for (rl = rr->layers.first; rl && rl1; rl = rl->next, rl1 = rl1->next) {
/* combined */
if (rl->rectf && rl1->rectf) {
@@ -1039,8 +1039,8 @@ static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float b
}
/* passes are allocated in sync */
- rpass1= rl1->passes.first;
- for (rpass= rl->passes.first; rpass && rpass1; rpass= rpass->next, rpass1= rpass1->next) {
+ rpass1 = rl1->passes.first;
+ for (rpass = rl->passes.first; rpass && rpass1; rpass = rpass->next, rpass1 = rpass1->next) {
addblur_rect(rr, rpass->rect, rpass1->rect, blurfac, rpass->channels);
}
}
@@ -1051,20 +1051,20 @@ static void do_render_blur_3d(Render *re)
{
RenderResult *rres;
float blurfac;
- int blur= re->r.mblur_samples;
+ int blur = re->r.mblur_samples;
/* create accumulation render result */
- rres= render_result_new(re, &re->disprect, 0, RR_USE_MEM);
+ rres = render_result_new(re, &re->disprect, 0, RR_USE_MEM);
/* do the blur steps */
while (blur--) {
- re->mblur_offs = re->r.blurfac*((float)(re->r.mblur_samples-blur))/(float)re->r.mblur_samples;
+ re->mblur_offs = re->r.blurfac * ((float)(re->r.mblur_samples - blur)) / (float)re->r.mblur_samples;
- re->i.curblur= re->r.mblur_samples-blur; /* stats */
+ re->i.curblur = re->r.mblur_samples - blur; /* stats */
do_render_3d(re);
- blurfac= 1.0f/(float)(re->r.mblur_samples-blur);
+ blurfac = 1.0f / (float)(re->r.mblur_samples - blur);
merge_renderresult_blur(rres, re->result, blurfac, re->r.alphamode & R_ALPHAKEY);
if (re->test_break(re->tbh)) break;
@@ -1073,14 +1073,14 @@ static void do_render_blur_3d(Render *re)
/* swap results */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
render_result_free(re->result);
- re->result= rres;
+ re->result = rres;
BLI_rw_mutex_unlock(&re->resultmutex);
re->mblur_offs = 0.0f;
- re->i.curblur= 0; /* stats */
+ re->i.curblur = 0; /* stats */
/* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay= render_get_active_layer(re, re->result);
+ re->result->renlay = render_get_active_layer(re, re->result);
re->display_draw(re->ddh, re->result, NULL);
}
@@ -1088,16 +1088,16 @@ static void do_render_blur_3d(Render *re)
/* function assumes rectf1 and rectf2 to be half size of rectf */
static void interleave_rect(RenderResult *rr, float *rectf, float *rectf1, float *rectf2, int channels)
{
- int a, stride= channels*rr->rectx;
- int len= stride*sizeof(float);
+ int a, stride = channels * rr->rectx;
+ int len = stride * sizeof(float);
- for (a=0; a<rr->recty; a+=2) {
+ for (a = 0; a < rr->recty; a += 2) {
memcpy(rectf, rectf1, len);
- rectf+= stride;
- rectf1+= stride;
+ rectf += stride;
+ rectf1 += stride;
memcpy(rectf, rectf2, len);
- rectf+= stride;
- rectf2+= stride;
+ rectf += stride;
+ rectf2 += stride;
}
}
@@ -1107,18 +1107,18 @@ static void merge_renderresult_fields(RenderResult *rr, RenderResult *rr1, Rende
RenderLayer *rl, *rl1, *rl2;
RenderPass *rpass, *rpass1, *rpass2;
- rl1= rr1->layers.first;
- rl2= rr2->layers.first;
- for (rl= rr->layers.first; rl && rl1 && rl2; rl= rl->next, rl1= rl1->next, rl2= rl2->next) {
+ rl1 = rr1->layers.first;
+ rl2 = rr2->layers.first;
+ for (rl = rr->layers.first; rl && rl1 && rl2; rl = rl->next, rl1 = rl1->next, rl2 = rl2->next) {
/* combined */
if (rl->rectf && rl1->rectf && rl2->rectf)
interleave_rect(rr, rl->rectf, rl1->rectf, rl2->rectf, 4);
/* passes are allocated in sync */
- rpass1= rl1->passes.first;
- rpass2= rl2->passes.first;
- for (rpass= rl->passes.first; rpass && rpass1 && rpass2; rpass= rpass->next, rpass1= rpass1->next, rpass2= rpass2->next) {
+ rpass1 = rl1->passes.first;
+ rpass2 = rl2->passes.first;
+ for (rpass = rl->passes.first; rpass && rpass1 && rpass2; rpass = rpass->next, rpass1 = rpass1->next, rpass2 = rpass2->next) {
interleave_rect(rr, rpass->rect, rpass1->rect, rpass2->rect, rpass->channels);
}
}
@@ -1128,8 +1128,8 @@ static void merge_renderresult_fields(RenderResult *rr, RenderResult *rr1, Rende
/* interleaves 2 frames */
static void do_render_fields_3d(Render *re)
{
- Object *camera= RE_GetCamera(re);
- RenderResult *rr1, *rr2= NULL;
+ Object *camera = RE_GetCamera(re);
+ RenderResult *rr1, *rr2 = NULL;
/* no render result was created, we can safely halve render y */
re->winy /= 2;
@@ -1137,31 +1137,31 @@ static void do_render_fields_3d(Render *re)
re->disprect.ymin /= 2;
re->disprect.ymax /= 2;
- re->i.curfield= 1; /* stats */
+ re->i.curfield = 1; /* stats */
/* first field, we have to call camera routine for correct aspect and subpixel offset */
RE_SetCamera(re, camera);
- if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0)
+ if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE) == 0)
do_render_blur_3d(re);
else
do_render_3d(re);
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- rr1= re->result;
- re->result= NULL;
+ rr1 = re->result;
+ re->result = NULL;
BLI_rw_mutex_unlock(&re->resultmutex);
/* second field */
if (!re->test_break(re->tbh)) {
- re->i.curfield= 2; /* stats */
+ re->i.curfield = 2; /* stats */
re->flag |= R_SEC_FIELD;
- if ((re->r.mode & R_FIELDSTILL)==0) {
+ if ((re->r.mode & R_FIELDSTILL) == 0) {
re->field_offs = 0.5f;
}
RE_SetCamera(re, camera);
- if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0)
+ if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE) == 0)
do_render_blur_3d(re);
else
do_render_3d(re);
@@ -1169,7 +1169,7 @@ static void do_render_fields_3d(Render *re)
re->field_offs = 0.0f;
- rr2= re->result;
+ rr2 = re->result;
}
/* allocate original height new buffers */
@@ -1179,7 +1179,7 @@ static void do_render_fields_3d(Render *re)
re->disprect.ymax *= 2;
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- re->result= render_result_new(re, &re->disprect, 0, RR_USE_MEM);
+ re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM);
if (rr2) {
if (re->r.mode & R_ODDFIELD)
@@ -1192,10 +1192,10 @@ static void do_render_fields_3d(Render *re)
render_result_free(rr1);
- re->i.curfield= 0; /* stats */
+ re->i.curfield = 0; /* stats */
/* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay= render_get_active_layer(re, re->result);
+ re->result->renlay = render_get_active_layer(re, re->result);
BLI_rw_mutex_unlock(&re->resultmutex);
@@ -1205,11 +1205,11 @@ static void do_render_fields_3d(Render *re)
/* main render routine, no compositing */
static void do_render_fields_blur_3d(Render *re)
{
- Object *camera= RE_GetCamera(re);
+ Object *camera = RE_GetCamera(re);
/* also check for camera here */
if (camera == NULL) {
printf("ERROR: Cannot render, no camera\n");
- G.afbreek= 1;
+ G.afbreek = 1;
return;
}
@@ -1218,7 +1218,7 @@ static void do_render_fields_blur_3d(Render *re)
if (re->r.mode & R_FIELDS)
do_render_fields_3d(re);
- else if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0)
+ else if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE) == 0)
do_render_blur_3d(re);
else
do_render_3d(re);
@@ -1226,30 +1226,30 @@ static void do_render_fields_blur_3d(Render *re)
/* when border render, check if we have to insert it in black */
if (re->result) {
if (re->r.mode & R_BORDER) {
- if ((re->r.mode & R_CROP)==0) {
+ if ((re->r.mode & R_CROP) == 0) {
RenderResult *rres;
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
/* sub-rect for merge call later on */
- re->result->tilerect= re->disprect;
+ re->result->tilerect = re->disprect;
/* this copying sequence could become function? */
/* weak is: it chances disprect from border */
re->disprect.xmin = re->disprect.ymin = 0;
re->disprect.xmax = re->winx;
re->disprect.ymax = re->winy;
- re->rectx= re->winx;
- re->recty= re->winy;
+ re->rectx = re->winx;
+ re->recty = re->winy;
- rres= render_result_new(re, &re->disprect, 0, RR_USE_MEM);
+ rres = render_result_new(re, &re->disprect, 0, RR_USE_MEM);
render_result_merge(rres, re->result);
render_result_free(re->result);
- re->result= rres;
+ re->result = rres;
/* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay= render_get_active_layer(re, re->result);
+ re->result->renlay = render_get_active_layer(re, re->result);
BLI_rw_mutex_unlock(&re->resultmutex);
@@ -1258,8 +1258,8 @@ static void do_render_fields_blur_3d(Render *re)
}
else {
/* set offset (again) for use in compositor, disprect was manipulated. */
- re->result->xof= 0;
- re->result->yof= 0;
+ re->result->xof = 0;
+ re->result->yof = 0;
}
}
}
@@ -1271,37 +1271,37 @@ static void do_render_fields_blur_3d(Render *re)
*/
static void render_scene(Render *re, Scene *sce, int cfra)
{
- Render *resc= RE_NewRender(sce->id.name);
- int winx= re->winx, winy= re->winy;
+ Render *resc = RE_NewRender(sce->id.name);
+ int winx = re->winx, winy = re->winy;
- sce->r.cfra= cfra;
+ sce->r.cfra = cfra;
BKE_scene_camera_switch_update(sce);
/* exception: scene uses own size (unfinished code) */
if (0) {
- winx= (sce->r.size*sce->r.xsch)/100;
- winy= (sce->r.size*sce->r.ysch)/100;
+ winx = (sce->r.size * sce->r.xsch) / 100;
+ winy = (sce->r.size * sce->r.ysch) / 100;
}
/* initial setup */
RE_InitState(resc, re, &sce->r, NULL, winx, winy, &re->disprect);
/* still unsure entity this... */
- resc->main= re->main;
- resc->scene= sce;
- resc->lay= sce->lay;
+ resc->main = re->main;
+ resc->scene = sce;
+ resc->lay = sce->lay;
/* ensure scene has depsgraph, base flags etc OK */
BKE_scene_set_background(re->main, sce);
/* copy callbacks */
- resc->display_draw= re->display_draw;
- resc->ddh= re->ddh;
- resc->test_break= re->test_break;
- resc->tbh= re->tbh;
- resc->stats_draw= re->stats_draw;
- resc->sdh= re->sdh;
+ resc->display_draw = re->display_draw;
+ resc->ddh = re->ddh;
+ resc->test_break = re->test_break;
+ resc->tbh = re->tbh;
+ resc->stats_draw = re->stats_draw;
+ resc->sdh = re->sdh;
do_render_fields_blur_3d(resc);
}
@@ -1309,16 +1309,16 @@ static void render_scene(Render *re, Scene *sce, int cfra)
/* helper call to detect if this scene needs a render, or if there's a any render layer to render */
static int composite_needs_render(Scene *sce, int this_scene)
{
- bNodeTree *ntree= sce->nodetree;
+ bNodeTree *ntree = sce->nodetree;
bNode *node;
- if (ntree==NULL) return 1;
+ if (ntree == NULL) return 1;
if (sce->use_nodes == FALSE) return 1;
- if ((sce->r.scemode & R_DOCOMP)==0) return 1;
+ if ((sce->r.scemode & R_DOCOMP) == 0) return 1;
- for (node= ntree->nodes.first; node; node= node->next) {
- if (node->type==CMP_NODE_R_LAYERS)
- if (this_scene==0 || node->id==NULL || node->id==&sce->id)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_R_LAYERS)
+ if (this_scene == 0 || node->id == NULL || node->id == &sce->id)
return 1;
}
return 0;
@@ -1329,17 +1329,17 @@ static void tag_scenes_for_render(Render *re)
bNode *node;
Scene *sce;
- for (sce= re->main->scene.first; sce; sce= sce->id.next)
+ for (sce = re->main->scene.first; sce; sce = sce->id.next)
sce->id.flag &= ~LIB_DOIT;
if (RE_GetCamera(re) && composite_needs_render(re->scene, 1))
re->scene->id.flag |= LIB_DOIT;
- if (re->scene->nodetree==NULL) return;
+ if (re->scene->nodetree == NULL) return;
/* check for render-layers nodes using other scenes, we tag them LIB_DOIT */
- for (node= re->scene->nodetree->nodes.first; node; node= node->next) {
- if (node->type==CMP_NODE_R_LAYERS) {
+ for (node = re->scene->nodetree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_R_LAYERS) {
if (node->id) {
if (node->id != (ID *)re->scene)
node->id->flag |= LIB_DOIT;
@@ -1352,23 +1352,23 @@ static void tag_scenes_for_render(Render *re)
static void ntree_render_scenes(Render *re)
{
bNode *node;
- int cfra= re->scene->r.cfra;
- int restore_scene= 0;
+ int cfra = re->scene->r.cfra;
+ int restore_scene = 0;
- if (re->scene->nodetree==NULL) return;
+ if (re->scene->nodetree == NULL) return;
tag_scenes_for_render(re);
/* now foreach render-result node tagged we do a full render */
/* results are stored in a way compisitor will find it */
- for (node= re->scene->nodetree->nodes.first; node; node= node->next) {
- if (node->type==CMP_NODE_R_LAYERS) {
+ for (node = re->scene->nodetree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_R_LAYERS) {
if (node->id && node->id != (ID *)re->scene) {
if (node->id->flag & LIB_DOIT) {
- Scene *scene = (Scene*)node->id;
+ Scene *scene = (Scene *)node->id;
render_scene(re, scene, cfra);
- restore_scene= (scene != re->scene);
+ restore_scene = (scene != re->scene);
node->id->flag &= ~LIB_DOIT;
nodeUpdate(re->scene->nodetree, node);
@@ -1385,9 +1385,9 @@ static void ntree_render_scenes(Render *re)
/* bad call... need to think over proper method still */
static void render_composit_stats(void *UNUSED(arg), char *str)
{
- R.i.infostr= str;
+ R.i.infostr = str;
R.stats_draw(R.sdh, &R.i);
- R.i.infostr= NULL;
+ R.i.infostr = NULL;
}
/* invokes Freestyle stroke rendering */
@@ -1466,33 +1466,33 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
/* interaction callbacks */
if (ntree) {
- ntree->stats_draw= render_composit_stats;
- ntree->test_break= re->test_break;
- ntree->progress= re->progress;
- ntree->sdh= re->sdh;
- ntree->tbh= re->tbh;
- ntree->prh= re->prh;
+ ntree->stats_draw = render_composit_stats;
+ ntree->test_break = re->test_break;
+ ntree->progress = re->progress;
+ ntree->sdh = re->sdh;
+ ntree->tbh = re->tbh;
+ ntree->prh = re->prh;
}
/* filtmask needs it */
- R= *re;
+ R = *re;
/* we accumulate in here */
- rectf= MEM_mapallocN(re->rectx*re->recty*sizeof(float)*4, "fullsample rgba");
+ rectf = MEM_mapallocN(re->rectx * re->recty * sizeof(float) * 4, "fullsample rgba");
- for (sample=0; sample<re->r.osa; sample++) {
+ for (sample = 0; sample < re->r.osa; sample++) {
Render *re1;
RenderResult rres;
int x, y, mask;
/* enable full sample print */
- R.i.curfsa= sample+1;
+ R.i.curfsa = sample + 1;
/* set all involved renders on the samplebuffers (first was done by render itself, but needs tagged) */
/* also function below assumes this */
tag_scenes_for_render(re);
- for (re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
+ for (re1 = RenderGlobal.renderlist.first; re1; re1 = re1->next) {
if (re1->scene->id.flag & LIB_DOIT) {
if (re1->r.scemode & R_FULL_SAMPLE) {
if (sample) {
@@ -1512,25 +1512,25 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
ntreeCompositTagRender(re->scene);
ntreeCompositTagAnimated(ntree);
- ntreeCompositExecTree(ntree, &re->r, 1, G.background==0);
+ ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0);
}
/* ensure we get either composited result or the active layer */
RE_AcquireResultImage(re, &rres);
/* accumulate with filter, and clip */
- mask= (1<<sample);
+ mask = (1 << sample);
mask_array(mask, filt);
- for (y=0; y<re->recty; y++) {
- float *rf= rectf + 4*y*re->rectx;
- float *col= rres.rectf + 4*y*re->rectx;
+ for (y = 0; y < re->recty; y++) {
+ float *rf = rectf + 4 * y * re->rectx;
+ float *col = rres.rectf + 4 * y * re->rectx;
- for (x=0; x<re->rectx; x++, rf+=4, col+=4) {
+ for (x = 0; x < re->rectx; x++, rf += 4, col += 4) {
/* clamping to 1.0 is needed for correct AA */
- if (col[0]<0.0f) col[0]=0.0f; else if (col[0] > 1.0f) col[0]= 1.0f;
- if (col[1]<0.0f) col[1]=0.0f; else if (col[1] > 1.0f) col[1]= 1.0f;
- if (col[2]<0.0f) col[2]=0.0f; else if (col[2] > 1.0f) col[2]= 1.0f;
+ if (col[0] < 0.0f) col[0] = 0.0f; else if (col[0] > 1.0f) col[0] = 1.0f;
+ if (col[1] < 0.0f) col[1] = 0.0f; else if (col[1] > 1.0f) col[1] = 1.0f;
+ if (col[2] < 0.0f) col[2] = 0.0f; else if (col[2] > 1.0f) col[2] = 1.0f;
add_filt_fmask_coord(filt, col, rf, re->rectx, re->recty, x, y);
}
@@ -1539,9 +1539,9 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
RE_ReleaseResultImage(re);
/* show stuff */
- if (sample!=re->osa-1) {
+ if (sample != re->osa - 1) {
/* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay= render_get_active_layer(re, re->result);
+ re->result->renlay = render_get_active_layer(re, re->result);
re->display_draw(re->ddh, re->result, NULL);
}
@@ -1551,19 +1551,19 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
/* clear interaction callbacks */
if (ntree) {
- ntree->stats_draw= NULL;
- ntree->test_break= NULL;
- ntree->progress= NULL;
- ntree->tbh= ntree->sdh= ntree->prh= NULL;
+ ntree->stats_draw = NULL;
+ ntree->test_break = NULL;
+ ntree->progress = NULL;
+ ntree->tbh = ntree->sdh = ntree->prh = NULL;
}
/* disable full sample print */
- R.i.curfsa= 0;
+ R.i.curfsa = 0;
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
if (re->result->rectf)
MEM_freeN(re->result->rectf);
- re->result->rectf= rectf;
+ re->result->rectf = rectf;
BLI_rw_mutex_unlock(&re->resultmutex);
}
@@ -1574,24 +1574,24 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree)
bNode *node;
/* default start situation */
- G.afbreek= 0;
+ G.afbreek = 0;
- re->main= bmain;
- re->scene= sce;
+ re->main = bmain;
+ re->scene = sce;
/* first call RE_ReadRenderResult on every renderlayer scene. this creates Render structs */
/* tag scenes unread */
- for (scene= re->main->scene.first; scene; scene= scene->id.next)
+ for (scene = re->main->scene.first; scene; scene = scene->id.next)
scene->id.flag |= LIB_DOIT;
- for (node= ntree->nodes.first; node; node= node->next) {
- if (node->type==CMP_NODE_R_LAYERS) {
- Scene *nodescene= (Scene *)node->id;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_R_LAYERS) {
+ Scene *nodescene = (Scene *)node->id;
- if (nodescene==NULL) nodescene= sce;
+ if (nodescene == NULL) nodescene = sce;
if (nodescene->id.flag & LIB_DOIT) {
- nodescene->r.mode |= R_OSA; /* render struct needs tables */
+ nodescene->r.mode |= R_OSA; /* render struct needs tables */
RE_ReadRenderResult(sce, nodescene);
nodescene->id.flag &= ~LIB_DOIT;
}
@@ -1614,8 +1614,8 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree)
/* returns fully composited render-result on given time step (in RenderData) */
static void do_render_composite_fields_blur_3d(Render *re)
{
- bNodeTree *ntree= re->scene->nodetree;
- int update_newframe=0;
+ bNodeTree *ntree = re->scene->nodetree;
+ int update_newframe = 0;
/* INIT seeding, compositor can use random texture */
BLI_srandom(re->r.cfra);
@@ -1631,7 +1631,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
render_result_free(re->result);
- re->result= render_result_new(re, &re->disprect, 0, RR_USE_MEM);
+ re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM);
BLI_rw_mutex_unlock(&re->resultmutex);
@@ -1655,20 +1655,20 @@ static void do_render_composite_fields_blur_3d(Render *re)
if (ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) {
/* checks if there are render-result nodes that need scene */
- if ((re->r.scemode & R_SINGLE_LAYER)==0)
+ if ((re->r.scemode & R_SINGLE_LAYER) == 0)
ntree_render_scenes(re);
if (!re->test_break(re->tbh)) {
- ntree->stats_draw= render_composit_stats;
- ntree->test_break= re->test_break;
- ntree->progress= re->progress;
- ntree->sdh= re->sdh;
- ntree->tbh= re->tbh;
- ntree->prh= re->prh;
+ ntree->stats_draw = render_composit_stats;
+ ntree->test_break = re->test_break;
+ ntree->progress = re->progress;
+ ntree->sdh = re->sdh;
+ ntree->tbh = re->tbh;
+ ntree->prh = re->prh;
/* in case it was never initialized */
- R.sdh= re->sdh;
- R.stats_draw= re->stats_draw;
+ R.sdh = re->sdh;
+ R.stats_draw = re->stats_draw;
if (update_newframe)
BKE_scene_update_for_newframe(re->main, re->scene, re->lay);
@@ -1676,13 +1676,13 @@ static void do_render_composite_fields_blur_3d(Render *re)
if (re->r.scemode & R_FULL_SAMPLE)
do_merge_fullsample(re, ntree);
else {
- ntreeCompositExecTree(ntree, &re->r, 1, G.background==0);
+ ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0);
}
- ntree->stats_draw= NULL;
- ntree->test_break= NULL;
- ntree->progress= NULL;
- ntree->tbh= ntree->sdh= ntree->prh= NULL;
+ ntree->stats_draw = NULL;
+ ntree->test_break = NULL;
+ ntree->progress = NULL;
+ ntree->tbh = ntree->sdh = ntree->prh = NULL;
}
}
else if (re->r.scemode & R_FULL_SAMPLE)
@@ -1692,7 +1692,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
free_all_freestyle_renders(re->scene);
/* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay= render_get_active_layer(re, re->result);
+ re->result->renlay = render_get_active_layer(re, re->result);
re->display_draw(re->ddh, re->result, NULL);
}
@@ -1716,7 +1716,7 @@ int RE_seq_render_active(Scene *scene, RenderData *rd)
if (!(rd->scemode & R_DOSEQ) || !ed || !ed->seqbase.first)
return 0;
- for (seq= ed->seqbase.first; seq; seq= seq->next) {
+ for (seq = ed->seqbase.first; seq; seq = seq->next) {
if (seq->type != SEQ_TYPE_SOUND_RAM)
return 1;
}
@@ -1724,7 +1724,7 @@ int RE_seq_render_active(Scene *scene, RenderData *rd)
return 0;
}
-static void do_render_seq(Render * re)
+static void do_render_seq(Render *re)
{
static int recurs_depth = 0;
struct ImBuf *ibuf;
@@ -1732,26 +1732,26 @@ static void do_render_seq(Render * re)
int cfra = re->r.cfra;
SeqRenderData context;
- re->i.cfra= cfra;
+ re->i.cfra = cfra;
- if (recurs_depth==0) {
+ if (recurs_depth == 0) {
/* otherwise sequencer animation isn't updated */
BKE_animsys_evaluate_all_animation(re->main, re->scene, (float)cfra); // XXX, was BKE_scene_frame_get(re->scene)
}
recurs_depth++;
- if ((re->r.mode & R_BORDER) && (re->r.mode & R_CROP)==0) {
+ if ((re->r.mode & R_BORDER) && (re->r.mode & R_CROP) == 0) {
/* if border rendering is used and cropping is disabled, final buffer should
* be as large as the whole frame */
context = seq_new_render_data(re->main, re->scene,
- re->winx, re->winy,
- 100);
+ re->winx, re->winy,
+ 100);
}
else {
context = seq_new_render_data(re->main, re->scene,
- re->result->rectx, re->result->recty,
- 100);
+ re->result->rectx, re->result->recty,
+ 100);
}
ibuf = give_ibuf_seq(context, cfra, 0);
@@ -1767,7 +1767,7 @@ static void do_render_seq(Render * re)
render_result_rect_from_ibuf(rr, &re->r, ibuf);
if (recurs_depth == 0) { /* with nested scenes, only free on toplevel... */
- Editing * ed = re->scene->ed;
+ Editing *ed = re->scene->ed;
if (ed)
free_imbuf_seq(re->scene, &ed->seqbase, TRUE, TRUE);
}
@@ -1784,8 +1784,8 @@ static void do_render_seq(Render * re)
re->r.scemode |= R_DOSEQ;
/* set overall progress of sequence rendering */
- if (re->r.efra!=re->r.sfra)
- re->progress(re->prh, (float)(cfra-re->r.sfra) / (re->r.efra-re->r.sfra));
+ if (re->r.efra != re->r.sfra)
+ re->progress(re->prh, (float)(cfra - re->r.sfra) / (re->r.efra - re->r.sfra));
else
re->progress(re->prh, 1.0f);
}
@@ -1797,7 +1797,7 @@ static void do_render_all_options(Render *re)
{
BKE_scene_camera_switch_update(re->scene);
- re->i.starttime= PIL_check_seconds_timer();
+ re->i.starttime = PIL_check_seconds_timer();
/* ensure no images are in memory from previous animated sequences */
BKE_image_all_free_anim_ibufs(re->r.cfra);
@@ -1817,7 +1817,7 @@ static void do_render_all_options(Render *re)
do_render_composite_fields_blur_3d(re);
}
- re->i.lastframetime= PIL_check_seconds_timer()- re->i.starttime;
+ re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
re->stats_draw(re->sdh, &re->i);
@@ -1830,16 +1830,16 @@ static void do_render_all_options(Render *re)
static int check_valid_camera(Scene *scene, Object *camera_override)
{
- int check_comp= 1;
+ int check_comp = 1;
if (camera_override == NULL && scene->camera == NULL)
- scene->camera= BKE_scene_camera_find(scene);
+ scene->camera = BKE_scene_camera_find(scene);
- if (scene->r.scemode&R_DOSEQ) {
+ if (scene->r.scemode & R_DOSEQ) {
if (scene->ed) {
- Sequence *seq= scene->ed->seqbase.first;
+ Sequence *seq = scene->ed->seqbase.first;
- check_comp= 0;
+ check_comp = 0;
while (seq) {
if (seq->type == SEQ_TYPE_SCENE && seq->scene) {
@@ -1847,7 +1847,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override)
if (!seq->scene->camera && !BKE_scene_camera_find(seq->scene)) {
if (seq->scene == scene) {
/* for current scene camera could be unneeded due to compisite nodes */
- check_comp= 1;
+ check_comp = 1;
}
else {
/* for other scenes camera is necessary */
@@ -1857,18 +1857,18 @@ static int check_valid_camera(Scene *scene, Object *camera_override)
}
}
- seq= seq->next;
+ seq = seq->next;
}
}
}
if (check_comp) { /* no sequencer or sequencer depends on compositor */
- if (scene->r.scemode&R_DOCOMP && scene->use_nodes) {
- bNode *node= scene->nodetree->nodes.first;
+ if (scene->r.scemode & R_DOCOMP && scene->use_nodes) {
+ bNode *node = scene->nodetree->nodes.first;
while (node) {
if (node->type == CMP_NODE_R_LAYERS) {
- Scene *sce= node->id ? (Scene*)node->id : scene;
+ Scene *sce = node->id ? (Scene *)node->id : scene;
if (!sce->camera && !BKE_scene_camera_find(sce)) {
/* all render layers nodes need camera */
@@ -1876,7 +1876,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override)
}
}
- node= node->next;
+ node = node->next;
}
}
else {
@@ -1922,12 +1922,12 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
}
}
- if (scene->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE)) {
+ if (scene->r.scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) {
char str[FILE_MAX];
render_result_exr_file_path(scene, 0, str);
- if (BLI_file_is_writable(str)==0) {
+ if (BLI_file_is_writable(str) == 0) {
BKE_report(reports, RPT_ERROR, "Can not save render buffers, check the temp default path");
return 0;
}
@@ -1940,7 +1940,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
}
else
- scene->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */
+ scene->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */
if (scene->r.scemode & R_DOCOMP) {
if (scene->use_nodes) {
@@ -1955,7 +1955,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
}
if (scene->r.scemode & R_FULL_SAMPLE) {
- if (composite_needs_render(scene, 0)==0) {
+ if (composite_needs_render(scene, 0) == 0) {
BKE_report(reports, RPT_ERROR, "Full Sample AA not supported without 3d rendering");
return 0;
}
@@ -1963,7 +1963,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
}
}
- /* check valid camera, without camera render is OK (compo, seq) */
+ /* check valid camera, without camera render is OK (compo, seq) */
if (!check_valid_camera(scene, camera_override)) {
BKE_report(reports, RPT_ERROR, "No camera");
return 0;
@@ -1982,15 +1982,15 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
/* layer flag tests */
if (scene->r.scemode & R_SINGLE_LAYER) {
- srl= BLI_findlink(&scene->r.layers, scene->r.actlay);
+ srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
/* force layer to be enabled */
srl->layflag &= ~SCE_LAY_DISABLE;
}
- for (srl= scene->r.layers.first; srl; srl= srl->next)
+ for (srl = scene->r.layers.first; srl; srl = srl->next)
if (!(srl->layflag & SCE_LAY_DISABLE))
break;
- if (srl==NULL) {
+ if (srl == NULL) {
BKE_report(reports, RPT_ERROR, "All RenderLayers are disabled");
return 0;
}
@@ -2000,17 +2000,17 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
static void validate_render_settings(Render *re)
{
- if (re->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE)) {
+ if (re->r.scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) {
/* no osa + fullsample won't work... */
- if (re->r.osa==0)
+ if (re->r.osa == 0)
re->r.scemode &= ~R_FULL_SAMPLE;
}
- else re->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */
+ else re->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */
if (RE_engine_is_external(re)) {
/* not supported yet */
- re->r.scemode &= ~(R_EXR_TILE_FILE|R_FULL_SAMPLE);
- re->r.mode &= ~(R_FIELDS|R_MBLUR);
+ re->r.scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
+ re->r.mode &= ~(R_FIELDS | R_MBLUR);
}
}
@@ -2041,16 +2041,16 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc
* r.border is the clipping rect */
/* calculate actual render result and display size */
- winx= (scene->r.size*scene->r.xsch)/100;
- winy= (scene->r.size*scene->r.ysch)/100;
+ winx = (scene->r.size * scene->r.xsch) / 100;
+ winy = (scene->r.size * scene->r.ysch) / 100;
/* we always render smaller part, inserting it in larger image is compositor bizz, it uses disprect for it */
if (scene->r.mode & R_BORDER) {
- disprect.xmin = scene->r.border.xmin*winx;
- disprect.xmax = scene->r.border.xmax*winx;
+ disprect.xmin = scene->r.border.xmin * winx;
+ disprect.xmax = scene->r.border.xmax * winx;
- disprect.ymin = scene->r.border.ymin*winy;
- disprect.ymax = scene->r.border.ymax*winy;
+ disprect.ymin = scene->r.border.ymin * winy;
+ disprect.ymax = scene->r.border.ymax * winy;
}
else {
disprect.xmin = disprect.ymin = 0;
@@ -2058,14 +2058,14 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc
disprect.ymax = winy;
}
- re->main= bmain;
- re->scene= scene;
- re->camera_override= camera_override;
- re->lay= lay;
+ re->main = bmain;
+ re->scene = scene;
+ re->camera_override = camera_override;
+ re->lay = lay;
/* not too nice, but it survives anim-border render */
if (anim) {
- re->disprect= disprect;
+ re->disprect = disprect;
return 1;
}
@@ -2105,16 +2105,16 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc
void RE_SetReports(Render *re, ReportList *reports)
{
- re->reports= reports;
+ re->reports = reports;
}
/* general Blender frame render call */
void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, Object *camera_override, unsigned int lay, int frame, const short write_still)
{
/* ugly global still... is to prevent preview events and signal subsurfs etc to make full resol */
- G.rendering= 1;
+ G.rendering = 1;
- scene->r.cfra= frame;
+ scene->r.cfra = frame;
if (render_initialize_from_main(re, bmain, scene, srl, camera_override, lay, 0, 0)) {
MEM_reset_peak_memory();
@@ -2143,7 +2143,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
BLI_callback_exec(re->main, (ID *)scene, G.afbreek ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE);
/* UGLY WARNING */
- G.rendering= 0;
+ G.rendering = 0;
}
void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene)
@@ -2159,8 +2159,8 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
{
char name[FILE_MAX];
RenderResult rres;
- Object *camera= RE_GetCamera(re);
- int ok= 1;
+ Object *camera = RE_GetCamera(re);
+ int ok = 1;
RE_AcquireResultImage(re, &rres);
@@ -2170,13 +2170,13 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
unsigned int *rect32 = (unsigned int *)rres.rect32;
/* note; the way it gets 32 bits rects is weak... */
if (rres.rect32 == NULL) {
- rect32 = MEM_mapallocN(sizeof(int)*rres.rectx*rres.recty, "temp 32 bits rect");
+ rect32 = MEM_mapallocN(sizeof(int) * rres.rectx * rres.recty, "temp 32 bits rect");
RE_ResultGet32(re, rect32);
do_free = TRUE;
}
- ok= mh->append_movie(&re->r, scene->r.sfra, scene->r.cfra, (int *)rect32,
- rres.rectx, rres.recty, re->reports);
+ ok = mh->append_movie(&re->r, scene->r.sfra, scene->r.cfra, (int *)rect32,
+ rres.rectx, rres.recty, re->reports);
if (do_free) {
MEM_freeN(rect32);
}
@@ -2188,36 +2188,36 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
else
BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE);
- if (re->r.im_format.imtype==R_IMF_IMTYPE_MULTILAYER) {
+ if (re->r.im_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
if (re->result) {
RE_WriteRenderResult(re->reports, re->result, name, scene->r.im_format.exr_codec);
printf("Saved: %s", name);
}
}
else {
- ImBuf *ibuf= render_result_rect_to_ibuf(&rres, &scene->r);
+ ImBuf *ibuf = render_result_rect_to_ibuf(&rres, &scene->r);
- ok= BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format);
+ ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format);
- if (ok==0) {
+ if (ok == 0) {
printf("Render error: cannot save %s\n", name);
}
else printf("Saved: %s", name);
/* optional preview images for exr */
- if (ok && scene->r.im_format.imtype==R_IMF_IMTYPE_OPENEXR && (scene->r.im_format.flag & R_IMF_FLAG_PREVIEW_JPG)) {
- ImageFormatData imf= scene->r.im_format;
- imf.imtype= R_IMF_IMTYPE_JPEG90;
+ if (ok && scene->r.im_format.imtype == R_IMF_IMTYPE_OPENEXR && (scene->r.im_format.flag & R_IMF_FLAG_PREVIEW_JPG)) {
+ ImageFormatData imf = scene->r.im_format;
+ imf.imtype = R_IMF_IMTYPE_JPEG90;
if (BLI_testextensie(name, ".exr"))
- name[strlen(name)-4]= 0;
+ name[strlen(name) - 4] = 0;
BKE_add_image_extension(name, R_IMF_IMTYPE_JPEG90);
- ibuf->planes= 24;
+ ibuf->planes = 24;
BKE_imbuf_write_stamp(scene, camera, ibuf, name, &imf);
printf("\nSaved: %s", name);
}
- /* imbuf knows which rects are not part of ibuf */
+ /* imbuf knows which rects are not part of ibuf */
IMB_freeImBuf(ibuf);
}
}
@@ -2238,9 +2238,9 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
/* saves images to disk */
void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra)
{
- bMovieHandle *mh= BKE_movie_handle_get(scene->r.im_format.imtype);
- int cfrao= scene->r.cfra;
- int nfra, totrendered= 0, totskipped= 0;
+ bMovieHandle *mh = BKE_movie_handle_get(scene->r.im_format.imtype);
+ int cfrao = scene->r.cfra;
+ int nfra, totrendered = 0, totskipped = 0;
/* do not fully call for each frame, it initializes & pops output window */
if (!render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 0, 1))
@@ -2248,13 +2248,13 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
/* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */
/* is also set by caller renderwin.c */
- G.rendering= 1;
+ G.rendering = 1;
re->flag |= R_ANIMATION;
if (BKE_imtype_is_movie(scene->r.im_format.imtype))
if (!mh->start_movie(scene, &re->r, re->rectx, re->recty, re->reports))
- G.afbreek= 1;
+ G.afbreek = 1;
if (mh->get_next_frame) {
while (!(G.afbreek == 1)) {
@@ -2269,7 +2269,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
if (re->test_break(re->tbh) == 0) {
if (!do_write_image_or_movie(re, bmain, scene, mh, NULL))
- G.afbreek= 1;
+ G.afbreek = 1;
}
if (G.afbreek == 0) {
@@ -2278,18 +2278,18 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
}
else {
if (re->test_break(re->tbh))
- G.afbreek= 1;
+ G.afbreek = 1;
}
}
}
else {
- for (nfra= sfra, scene->r.cfra= sfra; scene->r.cfra<=efra; scene->r.cfra++) {
+ for (nfra = sfra, scene->r.cfra = sfra; scene->r.cfra <= efra; scene->r.cfra++) {
char name[FILE_MAX];
/* only border now, todo: camera lens. (ton) */
render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 1, 0);
- if (nfra!=scene->r.cfra) {
+ if (nfra != scene->r.cfra) {
/*
* Skip this frame, but update for physics and particles system.
* From convertblender.c:
@@ -2298,15 +2298,15 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
unsigned int updatelay;
if (re->lay & 0xFF000000)
- updatelay= re->lay & 0xFF000000;
+ updatelay = re->lay & 0xFF000000;
else
- updatelay= re->lay;
+ updatelay = re->lay;
BKE_scene_update_for_newframe(bmain, scene, updatelay);
continue;
}
else
- nfra+= tfra;
+ nfra += tfra;
/* Touch/NoOverwrite options are only valid for image's */
if (BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) {
@@ -2324,7 +2324,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
}
}
- re->r.cfra= scene->r.cfra; /* weak.... */
+ re->r.cfra = scene->r.cfra; /* weak.... */
/* run callbacs before rendering, before the scene is updated */
BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE);
@@ -2336,12 +2336,12 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
if (re->test_break(re->tbh) == 0) {
if (!G.afbreek)
if (!do_write_image_or_movie(re, bmain, scene, mh, NULL))
- G.afbreek= 1;
+ G.afbreek = 1;
}
else
- G.afbreek= 1;
+ G.afbreek = 1;
- if (G.afbreek==1) {
+ if (G.afbreek == 1) {
/* remove touched file */
if (BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) {
if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_file_size(name) == 0) {
@@ -2352,7 +2352,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
break;
}
- if (G.afbreek==0) {
+ if (G.afbreek == 0) {
BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */
}
}
@@ -2365,14 +2365,14 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
if (totskipped && totrendered == 0)
BKE_report(re->reports, RPT_INFO, "No frames rendered, skipped to not overwrite");
- scene->r.cfra= cfrao;
+ scene->r.cfra = cfrao;
re->flag &= ~R_ANIMATION;
BLI_callback_exec(re->main, (ID *)scene, G.afbreek ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE);
/* UGLY WARNING */
- G.rendering= 0;
+ G.rendering = 0;
}
void RE_PreviewRender(Render *re, Main *bmain, Scene *sce)
@@ -2380,8 +2380,8 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce)
Object *camera;
int winx, winy;
- winx= (sce->r.size*sce->r.xsch)/100;
- winy= (sce->r.size*sce->r.ysch)/100;
+ winx = (sce->r.size * sce->r.xsch) / 100;
+ winy = (sce->r.size * sce->r.ysch) / 100;
RE_InitState(re, NULL, &sce->r, NULL, winx, winy, NULL);
@@ -2405,16 +2405,16 @@ int RE_ReadRenderResult(Scene *scene, Scene *scenode)
rcti disprect;
/* calculate actual render result and display size */
- winx= (scene->r.size*scene->r.xsch)/100;
- winy= (scene->r.size*scene->r.ysch)/100;
+ winx = (scene->r.size * scene->r.xsch) / 100;
+ winy = (scene->r.size * scene->r.ysch) / 100;
/* only in movie case we render smaller part */
if (scene->r.mode & R_BORDER) {
- disprect.xmin = scene->r.border.xmin*winx;
- disprect.xmax = scene->r.border.xmax*winx;
+ disprect.xmin = scene->r.border.xmin * winx;
+ disprect.xmax = scene->r.border.xmax * winx;
- disprect.ymin = scene->r.border.ymin*winy;
- disprect.ymax = scene->r.border.ymax*winy;
+ disprect.ymin = scene->r.border.ymin * winy;
+ disprect.ymax = scene->r.border.ymax * winy;
}
else {
disprect.xmin = disprect.ymin = 0;
@@ -2423,17 +2423,17 @@ int RE_ReadRenderResult(Scene *scene, Scene *scenode)
}
if (scenode)
- scene= scenode;
+ scene = scenode;
/* get render: it can be called from UI with draw callbacks */
- re= RE_GetRender(scene->id.name);
- if (re==NULL)
- re= RE_NewRender(scene->id.name);
+ re = RE_GetRender(scene->id.name);
+ if (re == NULL)
+ re = RE_NewRender(scene->id.name);
RE_InitState(re, NULL, &scene->r, NULL, winx, winy, &disprect);
- re->scene= scene;
+ re->scene = scene;
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- success= render_result_exr_file_read(re, 0);
+ success = render_result_exr_file_read(re, 0);
BLI_rw_mutex_unlock(&re->resultmutex);
return success;
@@ -2441,11 +2441,11 @@ int RE_ReadRenderResult(Scene *scene, Scene *scenode)
void RE_set_max_threads(int threads)
{
- if (threads==0) {
+ if (threads == 0) {
RenderGlobal.threads = BLI_system_thread_count();
}
- else if (threads>=1 && threads<=BLENDER_MAX_THREADS) {
- RenderGlobal.threads= threads;
+ else if (threads >= 1 && threads <= BLENDER_MAX_THREADS) {
+ RenderGlobal.threads = threads;
}
else {
printf("Error, threads has to be in range 0-%d\n", BLENDER_MAX_THREADS);
@@ -2455,9 +2455,9 @@ void RE_set_max_threads(int threads)
void RE_init_threadcount(Render *re)
{
if (RenderGlobal.threads >= 1) { /* only set as an arg in background mode */
- re->r.threads= MIN2(RenderGlobal.threads, BLENDER_MAX_THREADS);
+ re->r.threads = MIN2(RenderGlobal.threads, BLENDER_MAX_THREADS);
}
- else if ((re->r.mode & R_FIXED_THREADS)==0 || RenderGlobal.threads == 0) { /* Automatic threads */
+ else if ((re->r.mode & R_FIXED_THREADS) == 0 || RenderGlobal.threads == 0) { /* Automatic threads */
re->r.threads = BLI_system_thread_count();
}
}
@@ -2470,23 +2470,23 @@ void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
if (ibuf->x == layer->rectx && ibuf->y == layer->recty) {
- if (ibuf->rect_float==NULL)
+ if (ibuf->rect_float == NULL)
IMB_float_from_rect(ibuf);
- memcpy(layer->rectf, ibuf->rect_float, sizeof(float)*4*layer->rectx*layer->recty);
+ memcpy(layer->rectf, ibuf->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty);
}
else {
if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) {
ImBuf *ibuf_clip;
- if (ibuf->rect_float==NULL)
+ if (ibuf->rect_float == NULL)
IMB_float_from_rect(ibuf);
ibuf_clip = IMB_allocImBuf(layer->rectx, layer->recty, 32, IB_rectfloat);
if (ibuf_clip) {
IMB_rectcpy(ibuf_clip, ibuf, 0, 0, x, y, layer->rectx, layer->recty);
- memcpy(layer->rectf, ibuf_clip->rect_float, sizeof(float)*4*layer->rectx*layer->recty);
+ memcpy(layer->rectf, ibuf_clip->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty);
IMB_freeImBuf(ibuf_clip);
}
else {
@@ -2518,33 +2518,33 @@ const float default_envmap_layout[] = { 0, 0, 1, 0, 2, 0, 0, 1, 1, 1, 2, 1 };
int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, const char *relpath, const char imtype, float layout[12])
{
ImageFormatData imf;
- ImBuf *ibuf=NULL;
+ ImBuf *ibuf = NULL;
int ok;
int dx;
- int maxX=0, maxY=0, i=0;
+ int maxX = 0, maxY = 0, i = 0;
char filepath[FILE_MAX];
- if (env->cube[1]==NULL) {
+ if (env->cube[1] == NULL) {
BKE_report(reports, RPT_ERROR, "There is no generated environment map available to save");
return 0;
}
- imf= scene->r.im_format;
- imf.imtype= imtype;
+ imf = scene->r.im_format;
+ imf.imtype = imtype;
- dx= env->cube[1]->x;
+ dx = env->cube[1]->x;
if (env->type == ENV_CUBE) {
- for (i=0; i < 12; i+=2) {
+ for (i = 0; i < 12; i += 2) {
maxX = MAX2(maxX, layout[i] + 1);
- maxY = MAX2(maxY, layout[i+1] + 1);
+ maxY = MAX2(maxY, layout[i + 1] + 1);
}
- ibuf = IMB_allocImBuf(maxX*dx, maxY*dx, 24, IB_rectfloat);
+ ibuf = IMB_allocImBuf(maxX * dx, maxY * dx, 24, IB_rectfloat);
- for (i=0; i < 12; i+=2)
- if (layout[i] > -1 && layout[i+1] > -1)
- IMB_rectcpy(ibuf, env->cube[i/2], layout[i]*dx, layout[i+1]*dx, 0, 0, dx, dx);
+ for (i = 0; i < 12; i += 2)
+ if (layout[i] > -1 && layout[i + 1] > -1)
+ IMB_rectcpy(ibuf, env->cube[i / 2], layout[i] * dx, layout[i + 1] * dx, 0, 0, dx, dx);
}
else if (env->type == ENV_PLANE) {
ibuf = IMB_allocImBuf(dx, dx, 24, IB_rectfloat);
@@ -2562,7 +2562,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env,
BLI_strncpy(filepath, relpath, sizeof(filepath));
BLI_path_abs(filepath, G.main->name);
- ok= BKE_imbuf_write(ibuf, filepath, &imf);
+ ok = BKE_imbuf_write(ibuf, filepath, &imf);
IMB_freeImBuf(ibuf);
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 968e78899c3..745ce77bdda 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -61,10 +61,10 @@
void render_result_free(RenderResult *res)
{
- if (res==NULL) return;
+ if (res == NULL) return;
while (res->layers.first) {
- RenderLayer *rl= res->layers.first;
+ RenderLayer *rl = res->layers.first;
if (rl->rectf) MEM_freeN(rl->rectf);
/* acolrect and scolrect are optionally allocated in shade_tile, only free here since it can be used for drawing */
@@ -72,7 +72,7 @@ void render_result_free(RenderResult *res)
if (rl->scolrect) MEM_freeN(rl->scolrect);
while (rl->passes.first) {
- RenderPass *rpass= rl->passes.first;
+ RenderPass *rpass = rl->passes.first;
if (rpass->rect) MEM_freeN(rpass->rect);
BLI_remlink(&rl->passes, rpass);
MEM_freeN(rpass);
@@ -98,8 +98,8 @@ void render_result_free_list(ListBase *lb, RenderResult *rr)
{
RenderResult *rrnext;
- for (; rr; rr= rrnext) {
- rrnext= rr->next;
+ for (; rr; rr = rrnext) {
+ rrnext = rr->next;
if (lb && lb->first)
BLI_remlink(lb, rr);
@@ -116,166 +116,166 @@ static const char *get_pass_name(int passtype, int channel)
{
if (passtype == SCE_PASS_COMBINED) {
- if (channel==-1) return "Combined";
- if (channel==0) return "Combined.R";
- if (channel==1) return "Combined.G";
- if (channel==2) return "Combined.B";
+ if (channel == -1) return "Combined";
+ if (channel == 0) return "Combined.R";
+ if (channel == 1) return "Combined.G";
+ if (channel == 2) return "Combined.B";
return "Combined.A";
}
if (passtype == SCE_PASS_Z) {
- if (channel==-1) return "Depth";
+ if (channel == -1) return "Depth";
return "Depth.Z";
}
if (passtype == SCE_PASS_VECTOR) {
- if (channel==-1) return "Vector";
- if (channel==0) return "Vector.X";
- if (channel==1) return "Vector.Y";
- if (channel==2) return "Vector.Z";
+ if (channel == -1) return "Vector";
+ if (channel == 0) return "Vector.X";
+ if (channel == 1) return "Vector.Y";
+ if (channel == 2) return "Vector.Z";
return "Vector.W";
}
if (passtype == SCE_PASS_NORMAL) {
- if (channel==-1) return "Normal";
- if (channel==0) return "Normal.X";
- if (channel==1) return "Normal.Y";
+ if (channel == -1) return "Normal";
+ if (channel == 0) return "Normal.X";
+ if (channel == 1) return "Normal.Y";
return "Normal.Z";
}
if (passtype == SCE_PASS_UV) {
- if (channel==-1) return "UV";
- if (channel==0) return "UV.U";
- if (channel==1) return "UV.V";
+ if (channel == -1) return "UV";
+ if (channel == 0) return "UV.U";
+ if (channel == 1) return "UV.V";
return "UV.A";
}
if (passtype == SCE_PASS_RGBA) {
- if (channel==-1) return "Color";
- if (channel==0) return "Color.R";
- if (channel==1) return "Color.G";
- if (channel==2) return "Color.B";
+ if (channel == -1) return "Color";
+ if (channel == 0) return "Color.R";
+ if (channel == 1) return "Color.G";
+ if (channel == 2) return "Color.B";
return "Color.A";
}
if (passtype == SCE_PASS_EMIT) {
- if (channel==-1) return "Emit";
- if (channel==0) return "Emit.R";
- if (channel==1) return "Emit.G";
+ if (channel == -1) return "Emit";
+ if (channel == 0) return "Emit.R";
+ if (channel == 1) return "Emit.G";
return "Emit.B";
}
if (passtype == SCE_PASS_DIFFUSE) {
- if (channel==-1) return "Diffuse";
- if (channel==0) return "Diffuse.R";
- if (channel==1) return "Diffuse.G";
+ if (channel == -1) return "Diffuse";
+ if (channel == 0) return "Diffuse.R";
+ if (channel == 1) return "Diffuse.G";
return "Diffuse.B";
}
if (passtype == SCE_PASS_SPEC) {
- if (channel==-1) return "Spec";
- if (channel==0) return "Spec.R";
- if (channel==1) return "Spec.G";
+ if (channel == -1) return "Spec";
+ if (channel == 0) return "Spec.R";
+ if (channel == 1) return "Spec.G";
return "Spec.B";
}
if (passtype == SCE_PASS_SHADOW) {
- if (channel==-1) return "Shadow";
- if (channel==0) return "Shadow.R";
- if (channel==1) return "Shadow.G";
+ if (channel == -1) return "Shadow";
+ if (channel == 0) return "Shadow.R";
+ if (channel == 1) return "Shadow.G";
return "Shadow.B";
}
if (passtype == SCE_PASS_AO) {
- if (channel==-1) return "AO";
- if (channel==0) return "AO.R";
- if (channel==1) return "AO.G";
+ if (channel == -1) return "AO";
+ if (channel == 0) return "AO.R";
+ if (channel == 1) return "AO.G";
return "AO.B";
}
if (passtype == SCE_PASS_ENVIRONMENT) {
- if (channel==-1) return "Env";
- if (channel==0) return "Env.R";
- if (channel==1) return "Env.G";
+ if (channel == -1) return "Env";
+ if (channel == 0) return "Env.R";
+ if (channel == 1) return "Env.G";
return "Env.B";
}
if (passtype == SCE_PASS_INDIRECT) {
- if (channel==-1) return "Indirect";
- if (channel==0) return "Indirect.R";
- if (channel==1) return "Indirect.G";
+ if (channel == -1) return "Indirect";
+ if (channel == 0) return "Indirect.R";
+ if (channel == 1) return "Indirect.G";
return "Indirect.B";
}
if (passtype == SCE_PASS_REFLECT) {
- if (channel==-1) return "Reflect";
- if (channel==0) return "Reflect.R";
- if (channel==1) return "Reflect.G";
+ if (channel == -1) return "Reflect";
+ if (channel == 0) return "Reflect.R";
+ if (channel == 1) return "Reflect.G";
return "Reflect.B";
}
if (passtype == SCE_PASS_REFRACT) {
- if (channel==-1) return "Refract";
- if (channel==0) return "Refract.R";
- if (channel==1) return "Refract.G";
+ if (channel == -1) return "Refract";
+ if (channel == 0) return "Refract.R";
+ if (channel == 1) return "Refract.G";
return "Refract.B";
}
if (passtype == SCE_PASS_INDEXOB) {
- if (channel==-1) return "IndexOB";
+ if (channel == -1) return "IndexOB";
return "IndexOB.X";
}
if (passtype == SCE_PASS_INDEXMA) {
- if (channel==-1) return "IndexMA";
+ if (channel == -1) return "IndexMA";
return "IndexMA.X";
}
if (passtype == SCE_PASS_MIST) {
- if (channel==-1) return "Mist";
+ if (channel == -1) return "Mist";
return "Mist.Z";
}
if (passtype == SCE_PASS_RAYHITS) {
- if (channel==-1) return "Rayhits";
- if (channel==0) return "Rayhits.R";
- if (channel==1) return "Rayhits.G";
+ if (channel == -1) return "Rayhits";
+ if (channel == 0) return "Rayhits.R";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ if (channel == -1) return "TransCol";
+ if (channel == 0) return "TransCol.R";
+ if (channel == 1) return "TransCol.G";
return "TransCol.B";
}
return "Unknown";
@@ -284,88 +284,88 @@ static const char *get_pass_name(int passtype, int channel)
static int passtype_from_name(const char *str)
{
- if (strcmp(str, "Combined")==0)
+ if (strcmp(str, "Combined") == 0)
return SCE_PASS_COMBINED;
- if (strcmp(str, "Depth")==0)
+ if (strcmp(str, "Depth") == 0)
return SCE_PASS_Z;
- if (strcmp(str, "Vector")==0)
+ if (strcmp(str, "Vector") == 0)
return SCE_PASS_VECTOR;
- if (strcmp(str, "Normal")==0)
+ if (strcmp(str, "Normal") == 0)
return SCE_PASS_NORMAL;
- if (strcmp(str, "UV")==0)
+ if (strcmp(str, "UV") == 0)
return SCE_PASS_UV;
- if (strcmp(str, "Color")==0)
+ if (strcmp(str, "Color") == 0)
return SCE_PASS_RGBA;
- if (strcmp(str, "Emit")==0)
+ if (strcmp(str, "Emit") == 0)
return SCE_PASS_EMIT;
- if (strcmp(str, "Diffuse")==0)
+ if (strcmp(str, "Diffuse") == 0)
return SCE_PASS_DIFFUSE;
- if (strcmp(str, "Spec")==0)
+ if (strcmp(str, "Spec") == 0)
return SCE_PASS_SPEC;
- if (strcmp(str, "Shadow")==0)
+ if (strcmp(str, "Shadow") == 0)
return SCE_PASS_SHADOW;
- if (strcmp(str, "AO")==0)
+ if (strcmp(str, "AO") == 0)
return SCE_PASS_AO;
- if (strcmp(str, "Env")==0)
+ if (strcmp(str, "Env") == 0)
return SCE_PASS_ENVIRONMENT;
- if (strcmp(str, "Indirect")==0)
+ if (strcmp(str, "Indirect") == 0)
return SCE_PASS_INDIRECT;
- if (strcmp(str, "Reflect")==0)
+ if (strcmp(str, "Reflect") == 0)
return SCE_PASS_REFLECT;
- if (strcmp(str, "Refract")==0)
+ if (strcmp(str, "Refract") == 0)
return SCE_PASS_REFRACT;
- if (strcmp(str, "IndexOB")==0)
+ if (strcmp(str, "IndexOB") == 0)
return SCE_PASS_INDEXOB;
- if (strcmp(str, "IndexMA")==0)
+ if (strcmp(str, "IndexMA") == 0)
return SCE_PASS_INDEXMA;
- if (strcmp(str, "Mist")==0)
+ if (strcmp(str, "Mist") == 0)
return SCE_PASS_MIST;
- if (strcmp(str, "RayHits")==0)
+ if (strcmp(str, "RayHits") == 0)
return SCE_PASS_RAYHITS;
- if (strcmp(str, "DiffDir")==0)
+ if (strcmp(str, "DiffDir") == 0)
return SCE_PASS_DIFFUSE_DIRECT;
- if (strcmp(str, "DiffInd")==0)
+ if (strcmp(str, "DiffInd") == 0)
return SCE_PASS_DIFFUSE_INDIRECT;
- if (strcmp(str, "DiffCol")==0)
+ if (strcmp(str, "DiffCol") == 0)
return SCE_PASS_DIFFUSE_COLOR;
- if (strcmp(str, "GlossDir")==0)
+ if (strcmp(str, "GlossDir") == 0)
return SCE_PASS_GLOSSY_DIRECT;
- if (strcmp(str, "GlossInd")==0)
+ if (strcmp(str, "GlossInd") == 0)
return SCE_PASS_GLOSSY_INDIRECT;
- if (strcmp(str, "GlossCol")==0)
+ if (strcmp(str, "GlossCol") == 0)
return SCE_PASS_GLOSSY_COLOR;
- if (strcmp(str, "TransDir")==0)
+ if (strcmp(str, "TransDir") == 0)
return SCE_PASS_TRANSM_DIRECT;
- if (strcmp(str, "TransInd")==0)
+ if (strcmp(str, "TransInd") == 0)
return SCE_PASS_TRANSM_INDIRECT;
- if (strcmp(str, "TransCol")==0)
+ if (strcmp(str, "TransCol") == 0)
return SCE_PASS_TRANSM_COLOR;
return 0;
@@ -375,38 +375,38 @@ static int passtype_from_name(const char *str)
static void render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int channels, int passtype)
{
- const char *typestr= get_pass_name(passtype, 0);
- RenderPass *rpass= MEM_callocN(sizeof(RenderPass), typestr);
- int rectsize= rr->rectx*rr->recty*channels;
+ const char *typestr = get_pass_name(passtype, 0);
+ RenderPass *rpass = MEM_callocN(sizeof(RenderPass), typestr);
+ int rectsize = rr->rectx * rr->recty * channels;
BLI_addtail(&rl->passes, rpass);
- rpass->passtype= passtype;
- rpass->channels= channels;
- rpass->rectx= rl->rectx;
- rpass->recty= rl->recty;
+ rpass->passtype = passtype;
+ rpass->channels = channels;
+ rpass->rectx = rl->rectx;
+ rpass->recty = rl->recty;
BLI_strncpy(rpass->name, get_pass_name(rpass->passtype, -1), sizeof(rpass->name));
if (rr->exrhandle) {
int a;
- for (a=0; a<channels; a++)
+ for (a = 0; a < channels; a++)
IMB_exr_add_channel(rr->exrhandle, rl->name, get_pass_name(passtype, a), 0, 0, NULL);
}
else {
float *rect;
int x;
- rpass->rect= MEM_mapallocN(sizeof(float)*rectsize, typestr);
+ rpass->rect = MEM_mapallocN(sizeof(float) * rectsize, typestr);
- if (passtype==SCE_PASS_VECTOR) {
+ if (passtype == SCE_PASS_VECTOR) {
/* initialize to max speed */
- rect= rpass->rect;
- for (x= rectsize-1; x>=0; x--)
- rect[x]= PASS_VECTOR_MAX;
+ rect = rpass->rect;
+ for (x = rectsize - 1; x >= 0; x--)
+ rect[x] = PASS_VECTOR_MAX;
}
- else if (passtype==SCE_PASS_Z) {
- rect= rpass->rect;
- for (x= rectsize-1; x>=0; x--)
- rect[x]= 10e10;
+ else if (passtype == SCE_PASS_Z) {
+ rect = rpass->rect;
+ for (x = rectsize - 1; x >= 0; x--)
+ rect[x] = 10e10;
}
}
}
@@ -422,18 +422,18 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
SceneRenderLayer *srl;
int rectx, recty, nr;
- rectx= partrct->xmax - partrct->xmin;
- recty= partrct->ymax - partrct->ymin;
+ rectx = partrct->xmax - partrct->xmin;
+ recty = partrct->ymax - partrct->ymin;
- if (rectx<=0 || recty<=0)
+ if (rectx <= 0 || recty <= 0)
return NULL;
- rr= MEM_callocN(sizeof(RenderResult), "new render result");
- rr->rectx= rectx;
- rr->recty= recty;
- rr->renrect.xmin = 0; rr->renrect.xmax = rectx-2*crop;
+ rr = MEM_callocN(sizeof(RenderResult), "new render result");
+ rr->rectx = rectx;
+ rr->recty = recty;
+ rr->renrect.xmin = 0; rr->renrect.xmax = rectx - 2 * crop;
/* crop is one or two extra pixels rendered for filtering, is used for merging and display too */
- rr->crop= crop;
+ rr->crop = crop;
/* tilerect is relative coordinates within render disprect. do not subtract crop yet */
rr->tilerect.xmin = partrct->xmin - re->disprect.xmin;
@@ -442,31 +442,31 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
rr->tilerect.ymax = partrct->ymax - re->disprect.ymax;
if (savebuffers) {
- rr->exrhandle= IMB_exr_get_handle();
+ rr->exrhandle = IMB_exr_get_handle();
}
/* check renderdata for amount of layers */
- for (nr=0, srl= re->r.layers.first; srl; srl= srl->next, nr++) {
+ for (nr = 0, srl = re->r.layers.first; srl; srl = srl->next, nr++) {
- if ((re->r.scemode & R_SINGLE_LAYER) && nr!=re->r.actlay)
+ if ((re->r.scemode & R_SINGLE_LAYER) && nr != re->r.actlay)
continue;
if (srl->layflag & SCE_LAY_DISABLE)
continue;
- rl= MEM_callocN(sizeof(RenderLayer), "new render layer");
+ rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
BLI_strncpy(rl->name, srl->name, sizeof(rl->name));
- rl->lay= srl->lay;
- rl->lay_zmask= srl->lay_zmask;
- rl->lay_exclude= srl->lay_exclude;
- rl->layflag= srl->layflag;
- rl->passflag= srl->passflag; // for debugging: srl->passflag|SCE_PASS_RAYHITS;
- rl->pass_xor= srl->pass_xor;
- rl->light_override= srl->light_override;
- rl->mat_override= srl->mat_override;
- rl->rectx= rectx;
- rl->recty= recty;
+ rl->lay = srl->lay;
+ rl->lay_zmask = srl->lay_zmask;
+ rl->lay_exclude = srl->lay_exclude;
+ rl->layflag = srl->layflag;
+ rl->passflag = srl->passflag; // for debugging: srl->passflag|SCE_PASS_RAYHITS;
+ rl->pass_xor = srl->pass_xor;
+ rl->light_override = srl->light_override;
+ rl->mat_override = srl->mat_override;
+ rl->rectx = rectx;
+ rl->recty = recty;
if (rr->exrhandle) {
IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.R", 0, 0, NULL);
@@ -475,7 +475,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.A", 0, 0, NULL);
}
else
- rl->rectf= MEM_mapallocN(rectx*recty*sizeof(float)*4, "Combined rgba");
+ rl->rectf = MEM_mapallocN(rectx * recty * sizeof(float) * 4, "Combined rgba");
if (srl->passflag & SCE_PASS_Z)
render_layer_add_pass(rr, rl, 1, SCE_PASS_Z);
@@ -534,12 +534,12 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
}
/* sss, previewrender and envmap don't do layers, so we make a default one */
- if (rr->layers.first==NULL) {
- rl= MEM_callocN(sizeof(RenderLayer), "new render layer");
+ if (rr->layers.first == NULL) {
+ rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
- rl->rectx= rectx;
- rl->recty= recty;
+ rl->rectx = rectx;
+ rl->recty = recty;
/* duplicate code... */
if (rr->exrhandle) {
@@ -549,20 +549,20 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.A", 0, 0, NULL);
}
else
- rl->rectf= MEM_mapallocN(rectx*recty*sizeof(float)*4, "Combined rgba");
+ rl->rectf = MEM_mapallocN(rectx * recty * sizeof(float) * 4, "Combined rgba");
/* note, this has to be in sync with scene.c */
- rl->lay= (1<<20) -1;
- rl->layflag= 0x7FFF; /* solid ztra halo strand */
- rl->passflag= SCE_PASS_COMBINED;
+ rl->lay = (1 << 20) - 1;
+ rl->layflag = 0x7FFF; /* solid ztra halo strand */
+ rl->passflag = SCE_PASS_COMBINED;
FRS_add_freestyle_config( srl );
- re->r.actlay= 0;
+ re->r.actlay = 0;
}
/* border render; calculate offset for use in compositor. compo is centralized coords */
- rr->xof= re->disprect.xmin + (re->disprect.xmax - re->disprect.xmin)/2 - re->winx/2;
- rr->yof= re->disprect.ymin + (re->disprect.ymax - re->disprect.ymin)/2 - re->winy/2;
+ rr->xof = re->disprect.xmin + (re->disprect.xmax - re->disprect.xmin) / 2 - re->winx / 2;
+ rr->yof = re->disprect.ymin + (re->disprect.ymax - re->disprect.ymin) / 2 - re->winy / 2;
return rr;
}
@@ -572,13 +572,13 @@ RenderResult *render_result_new_full_sample(Render *re, ListBase *lb, rcti *part
{
int a;
- if (re->osa==0)
+ if (re->osa == 0)
return render_result_new(re, partrct, crop, savebuffers);
- for (a=0; a<re->osa; a++) {
- RenderResult *rr= render_result_new(re, partrct, crop, savebuffers);
+ for (a = 0; a < re->osa; a++) {
+ RenderResult *rr = render_result_new(re, partrct, crop, savebuffers);
BLI_addtail(lb, rr);
- rr->sample_nr= a;
+ rr->sample_nr = a;
}
return lb->first;
@@ -587,10 +587,10 @@ RenderResult *render_result_new_full_sample(Render *re, ListBase *lb, rcti *part
/* callbacks for render_result_new_from_exr */
static void *ml_addlayer_cb(void *base, char *str)
{
- RenderResult *rr= base;
+ RenderResult *rr = base;
RenderLayer *rl;
- rl= MEM_callocN(sizeof(RenderLayer), "new render layer");
+ rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
BLI_strncpy(rl->name, str, EXR_LAY_MAXNAME);
@@ -599,44 +599,44 @@ static void *ml_addlayer_cb(void *base, char *str)
static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect, int totchan, char *chan_id)
{
- RenderLayer *rl= lay;
- RenderPass *rpass= MEM_callocN(sizeof(RenderPass), "loaded pass");
+ RenderLayer *rl = lay;
+ RenderPass *rpass = MEM_callocN(sizeof(RenderPass), "loaded pass");
int a;
BLI_addtail(&rl->passes, rpass);
- rpass->channels= totchan;
+ rpass->channels = totchan;
- rpass->passtype= passtype_from_name(str);
- if (rpass->passtype==0) printf("unknown pass %s\n", str);
+ rpass->passtype = passtype_from_name(str);
+ if (rpass->passtype == 0) printf("unknown pass %s\n", str);
rl->passflag |= rpass->passtype;
BLI_strncpy(rpass->name, str, EXR_PASS_MAXNAME);
/* channel id chars */
- for (a=0; a<totchan; a++)
- rpass->chan_id[a]= chan_id[a];
+ for (a = 0; a < totchan; a++)
+ rpass->chan_id[a] = chan_id[a];
- rpass->rect= rect;
+ rpass->rect = rect;
}
/* from imbuf, if a handle was returned we convert this to render result */
RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty)
{
- RenderResult *rr= MEM_callocN(sizeof(RenderResult), "loaded render result");
+ RenderResult *rr = MEM_callocN(sizeof(RenderResult), "loaded render result");
RenderLayer *rl;
RenderPass *rpass;
- rr->rectx= rectx;
- rr->recty= recty;
+ rr->rectx = rectx;
+ rr->recty = recty;
IMB_exr_multilayer_convert(exrhandle, rr, ml_addlayer_cb, ml_addpass_cb);
- for (rl=rr->layers.first; rl; rl=rl->next) {
- rl->rectx= rectx;
- rl->recty= recty;
+ for (rl = rr->layers.first; rl; rl = rl->next) {
+ rl->rectx = rectx;
+ rl->recty = recty;
- for (rpass=rl->passes.first; rpass; rpass=rpass->next) {
- rpass->rectx= rectx;
- rpass->recty= recty;
+ for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
+ rpass->rectx = rectx;
+ rpass->recty = recty;
}
}
@@ -649,31 +649,31 @@ static void do_merge_tile(RenderResult *rr, RenderResult *rrpart, float *target,
{
int y, ofs, copylen, tilex, tiley;
- copylen= tilex= rrpart->rectx;
- tiley= rrpart->recty;
+ copylen = tilex = rrpart->rectx;
+ tiley = rrpart->recty;
- if (rrpart->crop) { /* filters add pixel extra */
- tile+= pixsize*(rrpart->crop + rrpart->crop*tilex);
+ if (rrpart->crop) { /* filters add pixel extra */
+ tile += pixsize * (rrpart->crop + rrpart->crop * tilex);
- copylen= tilex - 2*rrpart->crop;
- tiley -= 2*rrpart->crop;
+ copylen = tilex - 2 * rrpart->crop;
+ tiley -= 2 * rrpart->crop;
- ofs= (rrpart->tilerect.ymin + rrpart->crop)*rr->rectx + (rrpart->tilerect.xmin+rrpart->crop);
- target+= pixsize*ofs;
+ ofs = (rrpart->tilerect.ymin + rrpart->crop) * rr->rectx + (rrpart->tilerect.xmin + rrpart->crop);
+ target += pixsize * ofs;
}
else {
- ofs= (rrpart->tilerect.ymin*rr->rectx + rrpart->tilerect.xmin);
- target+= pixsize*ofs;
+ ofs = (rrpart->tilerect.ymin * rr->rectx + rrpart->tilerect.xmin);
+ target += pixsize * ofs;
}
- copylen *= sizeof(float)*pixsize;
+ copylen *= sizeof(float) * pixsize;
tilex *= pixsize;
- ofs= pixsize*rr->rectx;
+ ofs = pixsize * rr->rectx;
- for (y=0; y<tiley; y++) {
+ for (y = 0; y < tiley; y++) {
memcpy(target, tile, copylen);
- target+= ofs;
- tile+= tilex;
+ target += ofs;
+ tile += tilex;
}
}
@@ -685,14 +685,14 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart)
RenderLayer *rl, *rlp;
RenderPass *rpass, *rpassp;
- for (rl= rr->layers.first, rlp= rrpart->layers.first; rl && rlp; rl= rl->next, rlp= rlp->next) {
+ for (rl = rr->layers.first, rlp = rrpart->layers.first; rl && rlp; rl = rl->next, rlp = rlp->next) {
/* combined */
if (rl->rectf && rlp->rectf)
do_merge_tile(rr, rrpart, rl->rectf, rlp->rectf, 4);
/* passes are allocated in sync */
- for (rpass= rl->passes.first, rpassp= rlp->passes.first; rpass && rpassp; rpass= rpass->next, rpassp= rpassp->next) {
+ for (rpass = rl->passes.first, rpassp = rlp->passes.first; rpass && rpassp; rpass = rpass->next, rpassp = rpassp->next) {
do_merge_tile(rr, rrpart, rpass->rect, rpassp->rect, rpass->channels);
}
}
@@ -705,10 +705,10 @@ static char *make_pass_name(RenderPass *rpass, int chan)
int len;
BLI_strncpy(name, rpass->name, EXR_PASS_MAXNAME);
- len= strlen(name);
- name[len]= '.';
- name[len+1]= rpass->chan_id[chan];
- name[len+2]= 0;
+ len = strlen(name);
+ name[len] = '.';
+ name[len + 1] = rpass->chan_id[chan];
+ name[len + 2] = 0;
return name;
}
@@ -719,40 +719,40 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file
{
RenderLayer *rl;
RenderPass *rpass;
- void *exrhandle= IMB_exr_get_handle();
+ void *exrhandle = IMB_exr_get_handle();
int success;
BLI_make_existing_file(filename);
/* composite result */
if (rr->rectf) {
- IMB_exr_add_channel(exrhandle, "Composite", "Combined.R", 4, 4*rr->rectx, rr->rectf);
- IMB_exr_add_channel(exrhandle, "Composite", "Combined.G", 4, 4*rr->rectx, rr->rectf+1);
- IMB_exr_add_channel(exrhandle, "Composite", "Combined.B", 4, 4*rr->rectx, rr->rectf+2);
- IMB_exr_add_channel(exrhandle, "Composite", "Combined.A", 4, 4*rr->rectx, rr->rectf+3);
+ IMB_exr_add_channel(exrhandle, "Composite", "Combined.R", 4, 4 * rr->rectx, rr->rectf);
+ IMB_exr_add_channel(exrhandle, "Composite", "Combined.G", 4, 4 * rr->rectx, rr->rectf + 1);
+ IMB_exr_add_channel(exrhandle, "Composite", "Combined.B", 4, 4 * rr->rectx, rr->rectf + 2);
+ IMB_exr_add_channel(exrhandle, "Composite", "Combined.A", 4, 4 * rr->rectx, rr->rectf + 3);
}
/* add layers/passes and assign channels */
- for (rl= rr->layers.first; rl; rl= rl->next) {
+ for (rl = rr->layers.first; rl; rl = rl->next) {
/* combined */
if (rl->rectf) {
- int a, xstride= 4;
- for (a=0; a<xstride; a++)
+ int a, xstride = 4;
+ for (a = 0; a < xstride; a++)
IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(SCE_PASS_COMBINED, a),
- xstride, xstride*rr->rectx, rl->rectf+a);
+ xstride, xstride * rr->rectx, rl->rectf + a);
}
/* passes are allocated in sync */
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- int a, xstride= rpass->channels;
- for (a=0; a<xstride; a++) {
+ for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
+ int a, xstride = rpass->channels;
+ for (a = 0; a < xstride; a++) {
if (rpass->passtype)
IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(rpass->passtype, a),
- xstride, xstride*rr->rectx, rpass->rect+a);
+ xstride, xstride * rr->rectx, rpass->rect + a);
else
IMB_exr_add_channel(exrhandle, rl->name, make_pass_name(rpass, a),
- xstride, xstride*rr->rectx, rpass->rect+a);
+ xstride, xstride * rr->rectx, rpass->rect + a);
}
}
}
@@ -760,12 +760,12 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file
/* when the filename has no permissions, this can fail */
if (IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress)) {
IMB_exr_write_channels(exrhandle);
- success= TRUE;
+ success = TRUE;
}
else {
/* TODO, get the error from openexr's exception */
BKE_report(reports, RPT_ERROR, "Error Writing Render Result, see console");
- success= FALSE;
+ success = FALSE;
}
IMB_exr_close(exrhandle);
@@ -781,8 +781,8 @@ void render_result_single_layer_begin(Render *re)
/* officially pushed result should be NULL... error can happen with do_seq */
RE_FreeRenderResult(re->pushedresult);
- re->pushedresult= re->result;
- re->result= NULL;
+ re->pushedresult = re->result;
+ re->result = NULL;
}
/* if scemode is R_SINGLE_LAYER, at end of rendering, merge the both render results */
@@ -793,7 +793,7 @@ void render_result_single_layer_end(Render *re)
RenderLayer *rl;
int nr;
- if (re->result==NULL) {
+ if (re->result == NULL) {
printf("pop render result error; no current result!\n");
return;
}
@@ -801,19 +801,19 @@ void render_result_single_layer_end(Render *re)
if (!re->pushedresult)
return;
- if (re->pushedresult->rectx==re->result->rectx && re->pushedresult->recty==re->result->recty) {
+ if (re->pushedresult->rectx == re->result->rectx && re->pushedresult->recty == re->result->recty) {
/* find which layer in re->pushedresult should be replaced */
- rl= re->result->layers.first;
+ rl = re->result->layers.first;
/* render result should be empty after this */
BLI_remlink(&re->result->layers, rl);
/* reconstruct render result layers */
- for (nr=0, srl= re->scene->r.layers.first; srl; srl= srl->next, nr++) {
- if (nr==re->r.actlay)
+ for (nr = 0, srl = re->scene->r.layers.first; srl; srl = srl->next, nr++) {
+ if (nr == re->r.actlay)
BLI_addtail(&re->result->layers, rl);
else {
- rlpush= RE_GetRenderLayer(re->pushedresult, srl->name);
+ rlpush = RE_GetRenderLayer(re->pushedresult, srl->name);
if (rlpush) {
BLI_remlink(&re->pushedresult->layers, rlpush);
BLI_addtail(&re->result->layers, rlpush);
@@ -823,7 +823,7 @@ void render_result_single_layer_end(Render *re)
}
RE_FreeRenderResult(re->pushedresult);
- re->pushedresult= NULL;
+ re->pushedresult = NULL;
}
/************************* EXR Tile File Rendering ***************************/
@@ -836,35 +836,35 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart)
BLI_lock_thread(LOCK_IMAGE);
- for (rlp= rrpart->layers.first; rlp; rlp= rlp->next) {
+ for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) {
- if (rrpart->crop) { /* filters add pixel extra */
- offs= (rrpart->crop + rrpart->crop*rrpart->rectx);
+ if (rrpart->crop) { /* filters add pixel extra */
+ offs = (rrpart->crop + rrpart->crop * rrpart->rectx);
}
else {
- offs= 0;
+ offs = 0;
}
/* combined */
if (rlp->rectf) {
- int a, xstride= 4;
- for (a=0; a<xstride; a++)
+ int a, xstride = 4;
+ for (a = 0; a < xstride; a++)
IMB_exr_set_channel(rr->exrhandle, rlp->name, get_pass_name(SCE_PASS_COMBINED, a),
- xstride, xstride*rrpart->rectx, rlp->rectf+a + xstride*offs);
+ xstride, xstride * rrpart->rectx, rlp->rectf + a + xstride * offs);
}
/* passes are allocated in sync */
- for (rpassp= rlp->passes.first; rpassp; rpassp= rpassp->next) {
- int a, xstride= rpassp->channels;
- for (a=0; a<xstride; a++)
+ for (rpassp = rlp->passes.first; rpassp; rpassp = rpassp->next) {
+ int a, xstride = rpassp->channels;
+ for (a = 0; a < xstride; a++)
IMB_exr_set_channel(rr->exrhandle, rlp->name, get_pass_name(rpassp->passtype, a),
- xstride, xstride*rrpart->rectx, rpassp->rect+a + xstride*offs);
+ xstride, xstride * rrpart->rectx, rpassp->rect + a + xstride * offs);
}
}
- party= rrpart->tilerect.ymin + rrpart->crop;
- partx= rrpart->tilerect.xmin + rrpart->crop;
+ party = rrpart->tilerect.ymin + rrpart->crop;
+ partx = rrpart->tilerect.xmin + rrpart->crop;
IMB_exrtile_write_channels(rr->exrhandle, partx, party, 0);
BLI_unlock_thread(LOCK_IMAGE);
@@ -875,13 +875,13 @@ static void save_empty_result_tiles(Render *re)
RenderPart *pa;
RenderResult *rr;
- for (rr= re->result; rr; rr= rr->next) {
+ for (rr = re->result; rr; rr = rr->next) {
IMB_exrtile_clear_channels(rr->exrhandle);
- for (pa= re->parts.first; pa; pa= pa->next) {
- if (pa->ready==0) {
- int party= pa->disprect.ymin - re->disprect.ymin + pa->crop;
- int partx= pa->disprect.xmin - re->disprect.xmin + pa->crop;
+ for (pa = re->parts.first; pa; pa = pa->next) {
+ if (pa->ready == 0) {
+ int party = pa->disprect.ymin - re->disprect.ymin + pa->crop;
+ int partx = pa->disprect.xmin - re->disprect.xmin + pa->crop;
IMB_exrtile_write_channels(rr->exrhandle, partx, party, 0);
}
}
@@ -894,7 +894,7 @@ void render_result_exr_file_begin(Render *re)
RenderResult *rr;
char str[FILE_MAX];
- for (rr= re->result; rr; rr= rr->next) {
+ for (rr = re->result; rr; rr = rr->next) {
render_result_exr_file_path(re->scene, rr->sample_nr, str);
printf("write exr tmp file, %dx%d, %s\n", rr->rectx, rr->recty, str);
@@ -909,13 +909,13 @@ void render_result_exr_file_end(Render *re)
save_empty_result_tiles(re);
- for (rr= re->result; rr; rr= rr->next) {
+ for (rr = re->result; rr; rr = rr->next) {
IMB_exr_close(rr->exrhandle);
- rr->exrhandle= NULL;
+ rr->exrhandle = NULL;
}
render_result_free_list(&re->fullresult, re->result);
- re->result= NULL;
+ re->result = NULL;
render_result_exr_file_read(re, 0);
}
@@ -923,22 +923,22 @@ void render_result_exr_file_end(Render *re)
/* save part into exr file */
void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart)
{
- for (; rr && rrpart; rr= rr->next, rrpart= rrpart->next)
+ for (; rr && rrpart; rr = rr->next, rrpart = rrpart->next)
save_render_result_tile(rr, rrpart);
}
/* path to temporary exr file */
void render_result_exr_file_path(Scene *scene, int sample, char *filepath)
{
- char di[FILE_MAX], name[FILE_MAXFILE+MAX_ID_NAME+100], fi[FILE_MAXFILE];
+ char di[FILE_MAX], name[FILE_MAXFILE + MAX_ID_NAME + 100], fi[FILE_MAXFILE];
BLI_strncpy(di, G.main->name, FILE_MAX);
BLI_splitdirstring(di, fi);
- if (sample==0)
- BLI_snprintf(name, sizeof(name), "%s_%s.exr", fi, scene->id.name+2);
+ if (sample == 0)
+ BLI_snprintf(name, sizeof(name), "%s_%s.exr", fi, scene->id.name + 2);
else
- BLI_snprintf(name, sizeof(name), "%s_%s%d.exr", fi, scene->id.name+2, sample);
+ BLI_snprintf(name, sizeof(name), "%s_%s%d.exr", fi, scene->id.name + 2, sample);
BLI_make_file_string("/", filepath, BLI_temporary_dir(), name);
}
@@ -950,17 +950,17 @@ int render_result_exr_file_read(Render *re, int sample)
int success;
RE_FreeRenderResult(re->result);
- re->result= render_result_new(re, &re->disprect, 0, RR_USE_MEM);
+ re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM);
render_result_exr_file_path(re->scene, sample, str);
printf("read exr tmp file: %s\n", str);
if (render_result_exr_file_read_path(re->result, str)) {
- success= TRUE;
+ success = TRUE;
}
else {
printf("cannot read: %s\n", str);
- success= FALSE;
+ success = FALSE;
}
@@ -972,16 +972,16 @@ int render_result_exr_file_read_path(RenderResult *rr, const char *filepath)
{
RenderLayer *rl;
RenderPass *rpass;
- void *exrhandle= IMB_exr_get_handle();
+ void *exrhandle = IMB_exr_get_handle();
int rectx, recty;
- if (IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty)==0) {
+ if (IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty) == 0) {
printf("failed being read %s\n", filepath);
IMB_exr_close(exrhandle);
return 0;
}
- if (rr == NULL || rectx!=rr->rectx || recty!=rr->recty) {
+ if (rr == NULL || rectx != rr->rectx || recty != rr->recty) {
if (rr)
printf("error in reading render result: dimensions don't match\n");
else
@@ -990,21 +990,21 @@ int render_result_exr_file_read_path(RenderResult *rr, const char *filepath)
return 0;
}
- for (rl= rr->layers.first; rl; rl= rl->next) {
+ for (rl = rr->layers.first; rl; rl = rl->next) {
/* combined */
if (rl->rectf) {
- int a, xstride= 4;
- for (a=0; a<xstride; a++)
+ int a, xstride = 4;
+ for (a = 0; a < xstride; a++)
IMB_exr_set_channel(exrhandle, rl->name, get_pass_name(SCE_PASS_COMBINED, a),
- xstride, xstride*rectx, rl->rectf+a);
+ xstride, xstride * rectx, rl->rectf + a);
}
/* passes are allocated in sync */
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- int a, xstride= rpass->channels;
- for (a=0; a<xstride; a++)
+ for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
+ int a, xstride = rpass->channels;
+ for (a = 0; a < xstride; a++)
IMB_exr_set_channel(exrhandle, rl->name, get_pass_name(rpass->passtype, a),
- xstride, xstride*rectx, rpass->rect+a);
+ xstride, xstride * rectx, rpass->rect + a);
BLI_strncpy(rpass->name, get_pass_name(rpass->passtype, -1), sizeof(rpass->name));
}
@@ -1020,23 +1020,23 @@ int render_result_exr_file_read_path(RenderResult *rr, const char *filepath)
ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd)
{
- int flags = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE)? IB_cm_predivide: 0;
- ImBuf *ibuf= IMB_allocImBuf(rr->rectx, rr->recty, rd->im_format.planes, flags);
+ int flags = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) ? IB_cm_predivide : 0;
+ ImBuf *ibuf = IMB_allocImBuf(rr->rectx, rr->recty, rd->im_format.planes, flags);
/* if not exists, BKE_imbuf_write makes one */
- ibuf->rect= (unsigned int *)rr->rect32;
- ibuf->rect_float= rr->rectf;
- ibuf->zbuf_float= rr->rectz;
+ ibuf->rect = (unsigned int *)rr->rect32;
+ ibuf->rect_float = rr->rectf;
+ ibuf->zbuf_float = rr->rectz;
/* float factor for random dither, imbuf takes care of it */
- ibuf->dither= rd->dither_intensity;
+ ibuf->dither = rd->dither_intensity;
/* prepare to gamma correct to sRGB color space */
if (rd->color_mgt_flag & R_COLOR_MANAGEMENT) {
/* sequence editor can generate 8bpc render buffers */
if (ibuf->rect) {
ibuf->profile = IB_PROFILE_SRGB;
- if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12|R_IMF_CHAN_DEPTH_16|R_IMF_CHAN_DEPTH_24|R_IMF_CHAN_DEPTH_32))
+ if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32))
IMB_float_from_rect(ibuf);
}
else {
@@ -1047,10 +1047,10 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd)
/* color -> greyscale */
/* editing directly would alter the render view */
if (rd->im_format.planes == R_IMF_PLANES_BW) {
- ImBuf *ibuf_bw= IMB_dupImBuf(ibuf);
+ ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
IMB_color_to_bw(ibuf_bw);
IMB_freeImBuf(ibuf);
- ibuf= ibuf_bw;
+ ibuf = ibuf_bw;
}
return ibuf;
@@ -1061,34 +1061,34 @@ void render_result_rect_from_ibuf(RenderResult *rr, RenderData *rd, ImBuf *ibuf)
if (ibuf->rect_float) {
/* color management: when off ensure rectf is non-lin, since thats what the internal
* render engine delivers */
- int profile_to= (rd->color_mgt_flag & R_COLOR_MANAGEMENT)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB;
- int profile_from= (ibuf->profile == IB_PROFILE_LINEAR_RGB)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB;
- int predivide= (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
+ int profile_to = (rd->color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
+ int profile_from = (ibuf->profile == IB_PROFILE_LINEAR_RGB) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
+ int predivide = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
if (!rr->rectf)
- rr->rectf= MEM_mallocN(4*sizeof(float)*rr->rectx*rr->recty, "render_seq rectf");
+ rr->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf");
IMB_buffer_float_from_float(rr->rectf, ibuf->rect_float,
- 4, profile_to, profile_from, predivide,
- rr->rectx, rr->recty, rr->rectx, rr->rectx);
+ 4, profile_to, profile_from, predivide,
+ rr->rectx, rr->recty, rr->rectx, rr->rectx);
/* TSK! Since sequence render doesn't free the *rr render result, the old rect32
* can hang around when sequence render has rendered a 32 bits one before */
if (rr->rect32) {
MEM_freeN(rr->rect32);
- rr->rect32= NULL;
+ rr->rect32 = NULL;
}
}
else if (ibuf->rect) {
if (!rr->rect32)
- rr->rect32= MEM_mallocN(sizeof(int)*rr->rectx*rr->recty, "render_seq rect");
+ rr->rect32 = MEM_mallocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
- memcpy(rr->rect32, ibuf->rect, 4*rr->rectx*rr->recty);
+ memcpy(rr->rect32, ibuf->rect, 4 * rr->rectx * rr->recty);
/* Same things as above, old rectf can hang around from previous render. */
if (rr->rectf) {
MEM_freeN(rr->rectf);
- rr->rectf= NULL;
+ rr->rectf = NULL;
}
}
}
@@ -1096,29 +1096,29 @@ void render_result_rect_from_ibuf(RenderResult *rr, RenderData *rd, ImBuf *ibuf)
void render_result_rect_fill_zero(RenderResult *rr)
{
if (rr->rectf)
- memset(rr->rectf, 0, 4*sizeof(float)*rr->rectx*rr->recty);
+ memset(rr->rectf, 0, 4 * sizeof(float) * rr->rectx * rr->recty);
else if (rr->rect32)
- memset(rr->rect32, 0, 4*rr->rectx*rr->recty);
+ memset(rr->rect32, 0, 4 * rr->rectx * rr->recty);
else
- rr->rect32= MEM_callocN(sizeof(int)*rr->rectx*rr->recty, "render_seq rect");
+ rr->rect32 = MEM_callocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
}
void render_result_rect_get_pixels(RenderResult *rr, RenderData *rd, unsigned int *rect, int rectx, int recty)
{
if (rr->rect32) {
- memcpy(rect, rr->rect32, sizeof(int)*rr->rectx*rr->recty);
+ memcpy(rect, rr->rect32, sizeof(int) * rr->rectx * rr->recty);
}
else if (rr->rectf) {
- int profile_from= (rd->color_mgt_flag & R_COLOR_MANAGEMENT)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB;
- int predivide= (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
- int dither= 0;
+ int profile_from = (rd->color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
+ int predivide = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
+ int dither = 0;
- IMB_buffer_byte_from_float((unsigned char*)rect, rr->rectf,
- 4, dither, IB_PROFILE_SRGB, profile_from, predivide,
- rr->rectx, rr->recty, rr->rectx, rr->rectx);
+ IMB_buffer_byte_from_float((unsigned char *)rect, rr->rectf,
+ 4, dither, IB_PROFILE_SRGB, profile_from, predivide,
+ rr->rectx, rr->recty, rr->rectx, rr->rectx);
}
else
/* else fill with black */
- memset(rect, 0, sizeof(int)*rectx*recty);
+ memset(rect, 0, sizeof(int) * rectx * recty);
}
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index 7e0744096b3..0e7c8a13043 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -400,7 +400,7 @@ void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *ss
interpolate_shade_result(&shr1, &shr2, t, ssamp->shr, addpassflag);
/* apply alpha along width */
- if (sseg->buffer->widthfade != 0.0f) {
+ if (sseg->buffer->widthfade != -1.0f) {
s = 1.0f - powf(fabsf(s), sseg->buffer->widthfade);
strand_apply_shaderesult_alpha(ssamp->shr, s);
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 75748696a72..e4c4e905aa6 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -68,12 +68,6 @@
extern struct Render R;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* luminance rec. 709 */
-BLI_INLINE float luminance(const float col[3])
-{
- return (0.212671f * col[0] + 0.71516f * col[1] + 0.072169f * col[2]);
-}
-
/* tracing */
static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3])
{
@@ -502,7 +496,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const
if (shi->mat->vol.shadeflag & MA_VOL_RECV_EXT_SHADOW) {
mul_v3_fl(lacol, vol_get_shadow(shi, lar, co));
- if (luminance(lacol) < 0.001f) return;
+ if (rgb_to_luma_y(lacol) < 0.001f) return;
}
/* find minimum of volume bounds, or lamp coord */
@@ -536,7 +530,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const
}
}
- if (luminance(lacol) < 0.001f) return;
+ if (rgb_to_luma_y(lacol) < 0.001f) return;
normalize_v3(lv);
p = vol_get_phasefunc(shi, shi->mat->vol.asymmetry, view, lv);
@@ -618,7 +612,7 @@ static void volumeintegrate(struct ShadeInput *shi, float col[4], const float co
if (t0 > t1 * 0.25f) {
/* only use depth cutoff after we've traced a little way into the volume */
- if (luminance(tr) < shi->mat->vol.depth_cutoff) break;
+ if (rgb_to_luma_y(tr) < shi->mat->vol.depth_cutoff) break;
}
vol_get_emission(shi, emit_col, p);
@@ -647,7 +641,7 @@ static void volumeintegrate(struct ShadeInput *shi, float col[4], const float co
add_v3_v3(col, radiance);
/* alpha <-- transmission luminance */
- col[3] = 1.0f - luminance(tr);
+ col[3] = 1.0f - rgb_to_luma_y(tr);
}
/* the main entry point for volume shading */
@@ -787,7 +781,7 @@ void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct
copy_v3_v3(shr->combined, tr);
- shr->combined[3] = 1.0f - luminance(tr);
+ shr->combined[3] = 1.0f - rgb_to_luma_y(tr);
shr->alpha = shr->combined[3];
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 5f2d9c6fb54..c46c382c37f 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2716,7 +2716,6 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
case GHOST_kEventButtonUp: {
GHOST_TEventButtonData *bd = customdata;
- /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */
event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE;
if (bd->button == GHOST_kButtonMaskLeft)
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index ab377d53ec7..431094c9ec4 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -178,7 +178,8 @@ void WM_init(bContext *C, int argc, const char **argv)
GPU_extensions_init();
GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
GPU_set_anisotropic(U.anisotropic_filter);
-
+ GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
+
UI_init();
}
@@ -372,7 +373,7 @@ void WM_exit_ext(bContext *C, const short do_python)
wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */
seq_free_clipboard(); /* sequencer.c */
- BKE_tracking_free_clipboard();
+ BKE_tracking_clipboard_free();
free_blender(); /* blender.c, does entire library and spacetypes */
// free_matcopybuf();
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 425baac25fd..f39b8f267a5 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -591,7 +591,7 @@ void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, con
void WM_operator_properties_sanitize(PointerRNA *ptr, const short no_context)
{
- RNA_STRUCT_BEGIN (ptr, prop)
+ RNA_STRUCT_BEGIN(ptr, prop)
{
switch (RNA_property_type(prop)) {
case PROP_ENUM:
@@ -625,7 +625,7 @@ void WM_operator_properties_reset(wmOperator *op)
PropertyRNA *iterprop;
iterprop = RNA_struct_iterator_property(op->type->srna);
- RNA_PROP_BEGIN (op->ptr, itemptr, iterprop)
+ RNA_PROP_BEGIN(op->ptr, itemptr, iterprop)
{
PropertyRNA *prop = itemptr.data;
@@ -1809,7 +1809,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
}
else {
- RNA_BEGIN (op->ptr, itemptr, "files")
+ RNA_BEGIN(op->ptr, itemptr, "files")
{
RNA_string_get(&itemptr, "name", name);
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
@@ -2161,40 +2161,44 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED
/* function used for WM_OT_save_mainfile too */
static int wm_collada_export_exec(bContext *C, wmOperator *op)
{
- char filename[FILE_MAX];
- int selected, second_life,
- include_armatures,
- apply_modifiers,
- include_bone_children,
- use_object_instantiation;
+ char filepath[FILE_MAX];
+ int selected, second_life;
+ int include_armatures;
+ int apply_modifiers;
+ int include_children;
+ int use_object_instantiation;
+ int sort_by_name;
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
- RNA_string_get(op->ptr, "filepath", filename);
+ RNA_string_get(op->ptr, "filepath", filepath);
+ BLI_ensure_extension(filepath, sizeof(filepath), ".dae");
/* Options panel */
selected = RNA_boolean_get(op->ptr, "selected");
apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
include_armatures = RNA_boolean_get(op->ptr, "include_armatures");
- include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children");
+ include_children = RNA_boolean_get(op->ptr, "include_children");
use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation");
+ sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name");
second_life = RNA_boolean_get(op->ptr, "second_life");
/* get editmode results */
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
if (collada_export(
- CTX_data_scene(C),
- filename,
- selected,
- apply_modifiers,
- include_armatures,
- include_bone_children,
- use_object_instantiation,
- second_life)) {
+ CTX_data_scene(C),
+ filepath,
+ selected,
+ apply_modifiers,
+ include_armatures,
+ include_children,
+ use_object_instantiation,
+ sort_by_name,
+ second_life)) {
return OPERATOR_FINISHED;
}
else {
@@ -2202,6 +2206,55 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
}
}
+
+void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
+{
+ ID *id = imfptr->id.data;
+
+ uiLayout *box, *row;
+
+ // Export Options:
+ box = uiLayoutBox(layout);
+ row = uiLayoutRow(box, 0);
+ uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA);
+
+ row = uiLayoutRow(box, 0);
+ uiItemR(row, imfptr, "apply_modifiers", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(box, 0);
+ uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(box, 0);
+ uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE);
+ uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
+
+ row = uiLayoutRow(box, 0);
+ uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE);
+ uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
+
+
+ // Collada options:
+ box = uiLayoutBox(layout);
+ row = uiLayoutRow(box, 0);
+ uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER);
+
+ row = uiLayoutRow(box, 0);
+ uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(box, 0);
+ uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(box, 0);
+ uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE);
+
+}
+
+static void wm_collada_export_draw(bContext *C, wmOperator *op)
+{
+ PointerRNA ptr;
+
+ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+ uiCollada_exportSettings(op->layout, &ptr);
+}
+
static void WM_OT_collada_export(wmOperatorType *ot)
{
ot->name = "Export COLLADA";
@@ -2213,28 +2266,35 @@ static void WM_OT_collada_export(wmOperatorType *ot)
ot->poll = WM_operator_winactive;
ot->flag |= OPTYPE_PRESET;
+
+ ot->ui = wm_collada_export_draw;
WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
+
RNA_def_boolean(ot->srna, "selected", 0, "Selection Only",
"Export only selected elements");
+ RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures",
+ "Include armature(s) even if not selected");
+
+ RNA_def_boolean(ot->srna, "include_children", 0, "Include Children",
+ "Include all children even if not selected");
+
RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers",
"Apply modifiers (Preview Resolution)");
- RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures",
- "Include armature(s) used by the exported objects");
-
- RNA_def_boolean(ot->srna, "include_bone_children", 0, "Include Bone Children",
- "Include all objects attached to bones of selected Armature(s)");
+ RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instances",
+ "Instantiate multiple Objects from same Data");
- RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instantiation",
- "Instantiate multiple Objects from same Data");
+ RNA_def_boolean(ot->srna, "sort_by_name", 0, "Sort by Object name",
+ "Sort exported data by Object name");
RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life",
"Compatibility mode for Second Life");
}
+
/* function used for WM_OT_save_mainfile too */
static int wm_collada_import_exec(bContext *C, wmOperator *op)
{
@@ -2315,7 +2375,7 @@ static void WM_OT_console_toggle(wmOperatorType *ot)
{
/* XXX Have to mark these for xgettext, as under linux they do not exists...
* And even worth, have to give the context as text, as xgettext doesn't expand macros. :( */
- ot->name = CTX_N_("Operator"/* BLF_I18NCONTEXT_OPERATOR_DEFAULT */, "Toggle System Console");
+ ot->name = CTX_N_("Operator" /* BLF_I18NCONTEXT_OPERATOR_DEFAULT */, "Toggle System Console");
ot->idname = "WM_OT_console_toggle";
ot->description = N_("Toggle System Console");
@@ -2869,7 +2929,7 @@ int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, int *m
static int gesture_lasso_exec(bContext *C, wmOperator *op)
{
- RNA_BEGIN (op->ptr, itemptr, "path")
+ RNA_BEGIN(op->ptr, itemptr, "path")
{
float loc[2];
@@ -3825,7 +3885,8 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""},
{GESTURE_MODAL_NOP, "NOP", 0, "No Operation", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Gesture Circle");
@@ -3873,7 +3934,8 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Straight Line");
@@ -3902,7 +3964,8 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
{GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Border");
@@ -3962,7 +4025,8 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_IN, "IN", 0, "In", ""},
{GESTURE_MODAL_OUT, "OUT", 0, "Out", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Zoom Border");