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:
authorSergej Reich <sergej.reich@googlemail.com>2013-11-23 20:17:12 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-11-23 20:17:12 +0400
commit39dc956f593b3406bf1d81fb83c557b7b51f5327 (patch)
tree50b59815aad48902a6563aefc8b944daf34c401e
parent5d5176095e82b34499e15d74f1fb76d56f4d9508 (diff)
parentd846c9a3b75c3d6f20bc7ab7d2da6cdd18bbbef2 (diff)
Merge branch 'master' into soc-2013-rigid_body_simsoc-2013-rigid_body_sim
Conflicts: intern/rigidbody/CMakeLists.txt release/datafiles/splash.png source/blender/editors/space_view3d/drawobject.c source/blender/makesdna/DNA_view3d_types.h
-rw-r--r--.arcconfig6
-rw-r--r--.gitignore25
-rw-r--r--.gitmodules16
-rw-r--r--CMakeLists.txt117
-rw-r--r--GNUmakefile84
-rw-r--r--SConstruct198
-rwxr-xr-xbuild_files/build_environment/install_deps.sh15
-rw-r--r--build_files/buildbot/config/user-config-mac-i386.py422
-rw-r--r--build_files/buildbot/config/user-config-mac-x86_64.py425
-rw-r--r--build_files/buildbot/master.cfg33
-rw-r--r--build_files/buildbot/slave_compile.py2
-rw-r--r--build_files/buildbot/slave_pack.py2
-rw-r--r--build_files/buildbot/slave_test.py2
-rw-r--r--build_files/cmake/buildinfo.cmake59
-rw-r--r--build_files/cmake/macros.cmake51
-rw-r--r--build_files/scons/config/darwin-config.py226
-rw-r--r--build_files/scons/config/freebsd8-config.py5
-rw-r--r--build_files/scons/config/linux-config.py4
-rw-r--r--build_files/scons/config/linuxcross-config.py4
-rw-r--r--build_files/scons/config/win32-mingw-config.py4
-rw-r--r--build_files/scons/config/win32-vc-config.py6
-rw-r--r--build_files/scons/config/win64-mingw-config.py2
-rw-r--r--build_files/scons/tools/Blender.py54
-rw-r--r--build_files/scons/tools/btools.py22
-rw-r--r--doc/license/GPL3-license.txt674
-rw-r--r--doc/python_api/examples/bpy.types.WindowManager.popup_menu.py2
-rw-r--r--doc/python_api/sphinx_doc_gen.py17
-rw-r--r--extern/bullet2/CMakeLists.txt32
-rw-r--r--extern/bullet2/patches/ghost_character.patch28
-rw-r--r--extern/bullet2/patches/ghost_softbody.patch42
-rw-r--r--extern/bullet2/readme.txt6
-rw-r--r--extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h5
-rw-r--r--extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h11
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h37
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp73
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h20
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp9
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h13
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp421
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h90
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp1
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp18
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp1
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp32
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h14
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp278
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h174
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h53
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp8
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h2
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h4
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h5
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h2
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp29
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h2
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp3
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h2
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h2
-rw-r--r--extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h3
-rw-r--r--extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp167
-rw-r--r--extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h6
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h64
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h16
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp129
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h49
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h98
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h44
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h33
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h37
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h22
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp296
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h31
-rwxr-xr-xextern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h46
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h13
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h1
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp10
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h64
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp39
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h15
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h3
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h4
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp4
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp1009
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h466
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp527
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h166
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp795
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h85
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp578
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h56
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp133
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h44
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp89
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.h47
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLink.h110
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h92
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp143
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h60
-rw-r--r--extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h82
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp2079
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.h77
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h112
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp626
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h81
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h33
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h151
-rw-r--r--extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h80
-rw-r--r--extern/bullet2/src/BulletSoftBody/btSoftBody.cpp18
-rw-r--r--extern/bullet2/src/BulletSoftBody/btSoftBody.h2
-rw-r--r--extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp6
-rw-r--r--extern/bullet2/src/BulletSoftBody/btSparseSDF.h17
-rw-r--r--extern/bullet2/src/LinearMath/btIDebugDraw.h138
-rw-r--r--extern/bullet2/src/LinearMath/btMatrix3x3.h31
-rw-r--r--extern/bullet2/src/LinearMath/btMatrixX.h504
-rw-r--r--extern/bullet2/src/LinearMath/btQuaternion.h42
-rw-r--r--extern/bullet2/src/LinearMath/btScalar.h78
-rw-r--r--extern/bullet2/src/LinearMath/btSerializer.cpp1583
-rw-r--r--extern/bullet2/src/LinearMath/btSerializer.h3
-rw-r--r--extern/bullet2/src/LinearMath/btVector3.cpp49
-rw-r--r--extern/bullet2/src/LinearMath/btVector3.h32
-rw-r--r--extern/bullet2/src/SConscript2
-rw-r--r--extern/bullet2/src/btBulletDynamicsCommon.h2
-rw-r--r--extern/libmv/libmv-capi.cc22
-rw-r--r--extern/libmv/libmv-capi.h5
-rw-r--r--extern/libmv/libmv-capi_stub.cc2
-rw-r--r--extern/libmv/libmv/multiview/euclidean_resection.cc28
-rw-r--r--extern/libmv/libmv/multiview/euclidean_resection.h26
-rw-r--r--extern/libmv/libmv/multiview/fundamental.cc75
-rw-r--r--extern/libmv/libmv/multiview/fundamental.h25
-rw-r--r--extern/libmv/libmv/multiview/homography.cc109
-rw-r--r--extern/libmv/libmv/multiview/homography.h50
-rw-r--r--extern/libmv/libmv/simple_pipeline/bundle.cc56
-rw-r--r--extern/libmv/libmv/simple_pipeline/keyframe_selection.cc16
-rw-r--r--extern/libmv/libmv/simple_pipeline/modal_solver.cc27
-rw-r--r--extern/libmv/libmv/simple_pipeline/pipeline.cc26
-rw-r--r--extern/libmv/libmv/simple_pipeline/pipeline.h10
-rw-r--r--extern/libmv/libmv/simple_pipeline/reconstruction.h11
-rw-r--r--extern/libmv/libmv/simple_pipeline/resect.cc17
-rw-r--r--extern/libmv/libmv/simple_pipeline/resect.h6
-rw-r--r--extern/libmv/libmv/simple_pipeline/tracks.cc6
-rw-r--r--extern/libmv/libmv/simple_pipeline/tracks.h13
-rw-r--r--extern/libmv/libmv/tracking/track_region.cc67
-rw-r--r--extern/libmv/libmv/tracking/track_region.h12
-rw-r--r--extern/libmv/third_party/ceres/SConscript2
-rwxr-xr-xextern/libmv/third_party/ceres/bundle.sh2
-rw-r--r--extern/rangetree/range_tree.hh5
-rw-r--r--intern/CMakeLists.txt2
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp24
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.cpp88
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.h14
-rw-r--r--intern/bsp/intern/BOP_CarveInterface.cpp63
-rw-r--r--intern/cycles/CMakeLists.txt4
-rw-r--r--intern/cycles/SConscript10
-rw-r--r--intern/cycles/app/cycles_standalone.cpp2
-rw-r--r--intern/cycles/blender/addon/properties.py8
-rw-r--r--intern/cycles/blender/addon/ui.py4
-rw-r--r--intern/cycles/blender/blender_curves.cpp69
-rw-r--r--intern/cycles/blender/blender_mesh.cpp12
-rw-r--r--intern/cycles/blender/blender_object.cpp6
-rw-r--r--intern/cycles/blender/blender_shader.cpp86
-rw-r--r--intern/cycles/blender/blender_sync.h3
-rw-r--r--intern/cycles/bvh/bvh_build.cpp2
-rw-r--r--intern/cycles/device/CMakeLists.txt4
-rw-r--r--intern/cycles/device/device.cpp7
-rw-r--r--intern/cycles/device/device_cpu.cpp66
-rw-r--r--intern/cycles/kernel/CMakeLists.txt9
-rw-r--r--intern/cycles/kernel/closure/bsdf.h6
-rw-r--r--intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_diffuse.h22
-rw-r--r--intern/cycles/kernel/closure/bsdf_diffuse_ramp.h12
-rw-r--r--intern/cycles/kernel/closure/bsdf_hair.h20
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet.h24
-rw-r--r--intern/cycles/kernel/closure/bsdf_oren_nayar.h12
-rw-r--r--intern/cycles/kernel/closure/bsdf_phong_ramp.h12
-rw-r--r--intern/cycles/kernel/closure/bsdf_reflection.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_refraction.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_toon.h24
-rw-r--r--intern/cycles/kernel/closure/bsdf_transparent.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_util.h8
-rw-r--r--intern/cycles/kernel/closure/bsdf_ward.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_westin.h20
-rw-r--r--intern/cycles/kernel/closure/bssrdf.h26
-rw-r--r--intern/cycles/kernel/closure/emissive.h6
-rw-r--r--intern/cycles/kernel/closure/volume.h10
-rw-r--r--intern/cycles/kernel/kernel.cl32
-rw-r--r--intern/cycles/kernel/kernel.h9
-rw-r--r--intern/cycles/kernel/kernel_accumulate.h28
-rw-r--r--intern/cycles/kernel/kernel_bvh.h40
-rw-r--r--intern/cycles/kernel/kernel_bvh_subsurface.h2
-rw-r--r--intern/cycles/kernel/kernel_bvh_traversal.h2
-rw-r--r--intern/cycles/kernel/kernel_camera.h16
-rw-r--r--intern/cycles/kernel/kernel_compat_cuda.h13
-rw-r--r--intern/cycles/kernel/kernel_compat_opencl.h14
-rw-r--r--intern/cycles/kernel/kernel_curve.h8
-rw-r--r--intern/cycles/kernel/kernel_differential.h10
-rw-r--r--intern/cycles/kernel/kernel_displace.h2
-rw-r--r--intern/cycles/kernel/kernel_emission.h10
-rw-r--r--intern/cycles/kernel/kernel_film.h33
-rw-r--r--intern/cycles/kernel/kernel_globals.h8
-rw-r--r--intern/cycles/kernel/kernel_jitter.h18
-rw-r--r--intern/cycles/kernel/kernel_light.h38
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h24
-rw-r--r--intern/cycles/kernel/kernel_object.h52
-rw-r--r--intern/cycles/kernel/kernel_passes.h16
-rw-r--r--intern/cycles/kernel/kernel_path.h24
-rw-r--r--intern/cycles/kernel/kernel_path_state.h8
-rw-r--r--intern/cycles/kernel/kernel_primitive.h12
-rw-r--r--intern/cycles/kernel/kernel_projection.h24
-rw-r--r--intern/cycles/kernel/kernel_random.h34
-rw-r--r--intern/cycles/kernel/kernel_shader.h58
-rw-r--r--intern/cycles/kernel/kernel_sse41.cpp76
-rw-r--r--intern/cycles/kernel/kernel_subsurface.h14
-rw-r--r--intern/cycles/kernel/kernel_triangle.h16
-rw-r--r--intern/cycles/kernel/shaders/node_math.osl2
-rw-r--r--intern/cycles/kernel/svm/svm.h28
-rw-r--r--intern/cycles/kernel/svm/svm_attribute.h8
-rw-r--r--intern/cycles/kernel/svm/svm_blackbody.h2
-rw-r--r--intern/cycles/kernel/svm/svm_brick.h6
-rw-r--r--intern/cycles/kernel/svm/svm_brightness.h2
-rw-r--r--intern/cycles/kernel/svm/svm_camera.h2
-rw-r--r--intern/cycles/kernel/svm/svm_checker.h4
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h34
-rw-r--r--intern/cycles/kernel/svm/svm_convert.h2
-rw-r--r--intern/cycles/kernel/svm/svm_displace.h4
-rw-r--r--intern/cycles/kernel/svm/svm_fresnel.h22
-rw-r--r--intern/cycles/kernel/svm/svm_gamma.h2
-rw-r--r--intern/cycles/kernel/svm/svm_geometry.h12
-rw-r--r--intern/cycles/kernel/svm/svm_gradient.h4
-rw-r--r--intern/cycles/kernel/svm/svm_hsv.h2
-rw-r--r--intern/cycles/kernel/svm/svm_image.h18
-rw-r--r--intern/cycles/kernel/svm/svm_invert.h4
-rw-r--r--intern/cycles/kernel/svm/svm_light_path.h4
-rw-r--r--intern/cycles/kernel/svm/svm_magic.h4
-rw-r--r--intern/cycles/kernel/svm/svm_mapping.h4
-rw-r--r--intern/cycles/kernel/svm/svm_math.h10
-rw-r--r--intern/cycles/kernel/svm/svm_mix.h42
-rw-r--r--intern/cycles/kernel/svm/svm_musgrave.h14
-rw-r--r--intern/cycles/kernel/svm/svm_noise.h36
-rw-r--r--intern/cycles/kernel/svm/svm_noisetex.h4
-rw-r--r--intern/cycles/kernel/svm/svm_normal.h2
-rw-r--r--intern/cycles/kernel/svm/svm_ramp.h8
-rw-r--r--intern/cycles/kernel/svm/svm_sepcomb_hsv.h4
-rw-r--r--intern/cycles/kernel/svm/svm_sepcomb_rgb.h4
-rw-r--r--intern/cycles/kernel/svm/svm_sky.h12
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h10
-rw-r--r--intern/cycles/kernel/svm/svm_texture.h34
-rw-r--r--intern/cycles/kernel/svm/svm_value.h4
-rw-r--r--intern/cycles/kernel/svm/svm_vector_transform.h2
-rw-r--r--intern/cycles/kernel/svm/svm_voronoi.h4
-rw-r--r--intern/cycles/kernel/svm/svm_wave.h4
-rw-r--r--intern/cycles/kernel/svm/svm_wavelength.h2
-rw-r--r--intern/cycles/kernel/svm/svm_wireframe.h2
-rw-r--r--intern/cycles/render/buffers.cpp6
-rw-r--r--intern/cycles/render/graph.h3
-rw-r--r--intern/cycles/render/nodes.cpp16
-rw-r--r--intern/cycles/render/object.cpp4
-rw-r--r--intern/cycles/render/shader.cpp3
-rw-r--r--intern/cycles/render/sky_model.h2
-rw-r--r--intern/cycles/util/util_color.h18
-rw-r--r--intern/cycles/util/util_math.h315
-rw-r--r--intern/cycles/util/util_system.cpp5
-rw-r--r--intern/cycles/util/util_system.h1
-rw-r--r--intern/cycles/util/util_task.cpp4
-rw-r--r--intern/cycles/util/util_task.h4
-rw-r--r--intern/cycles/util/util_transform.h60
-rw-r--r--intern/cycles/util/util_types.h116
-rw-r--r--intern/ffmpeg/ffmpeg_compat.h2
-rw-r--r--intern/ghost/CMakeLists.txt69
-rw-r--r--intern/ghost/SConscript37
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp175
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCarbon.h116
-rw-r--r--intern/ghost/intern/GHOST_ISystem.cpp10
-rw-r--r--intern/ghost/intern/GHOST_ISystemPaths.cpp8
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp1241
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.h298
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm256
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsCarbon.cpp88
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsCarbon.h87
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.cpp751
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.h321
-rw-r--r--intern/ghost/test/CMakeLists.txt1
-rw-r--r--intern/guardedalloc/CMakeLists.txt3
-rw-r--r--intern/guardedalloc/intern/mallocn_lockfree_impl.c13
-rw-r--r--intern/guardedalloc/intern/mmap_win.c14
-rw-r--r--intern/locale/CMakeLists.txt8
-rw-r--r--intern/locale/SConscript53
-rw-r--r--intern/locale/msgfmt.cc369
-rw-r--r--intern/rigidbody/CMakeLists.txt3
-rw-r--r--intern/rigidbody/rb_bullet_api.cpp6
-rwxr-xr-xrelease/bin/blender-softwaregl9
-rwxr-xr-xrelease/bin/blender-thumbnailer.py2
-rw-r--r--release/darwin/README_codesigning.txt25
-rw-r--r--release/darwin/codesigning_rules_blender.plist14
-rw-r--r--release/darwin/codesigning_rules_player.plist15
-rwxr-xr-xrelease/datafiles/blender_icons.sh6
-rw-r--r--release/datafiles/blender_icons.svg445
-rw-r--r--release/datafiles/blender_icons16.pngbin240983 -> 240844 bytes
-rw-r--r--release/datafiles/blender_icons32.pngbin605580 -> 605416 bytes
-rw-r--r--release/datafiles/fonts/droidsans.ttf.gzbin2644825 -> 2644887 bytes
m---------release/datafiles/locale0
-rwxr-xr-xrelease/datafiles/prvicons.sh4
-rw-r--r--release/datafiles/splash.pngbin256816 -> 220834 bytes
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/freestyle/style_modules/parameter_editor.py9
-rw-r--r--release/scripts/modules/addon_utils.py4
-rw-r--r--release/scripts/modules/animsys_refactor.py668
-rw-r--r--release/scripts/modules/bl_i18n_utils/bl_extract_messages.py4
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/merge_po.py2
-rw-r--r--release/scripts/modules/bl_i18n_utils/settings.py12
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils.py13
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/utils_rtl.py2
-rwxr-xr-xrelease/scripts/modules/blend_render_info.py2
-rw-r--r--release/scripts/modules/bpy/path.py2
-rw-r--r--release/scripts/modules/bpy/utils.py2
-rw-r--r--release/scripts/modules/bpy_extras/keyconfig_utils.py107
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py4
-rw-r--r--release/scripts/modules/rna_info.py1
-rw-r--r--release/scripts/modules/sys_info.py15
-rw-r--r--release/scripts/presets/keyconfig/3dsmax.py6
-rw-r--r--release/scripts/presets/keyconfig/maya.py12
-rw-r--r--release/scripts/startup/bl_operators/anim.py12
-rw-r--r--release/scripts/startup/bl_operators/node.py2
-rw-r--r--release/scripts/startup/bl_operators/presets.py28
-rw-r--r--release/scripts/startup/bl_operators/screen_play_rendered_anim.py10
-rw-r--r--release/scripts/startup/bl_operators/view3d.py46
-rw-r--r--release/scripts/startup/bl_operators/wm.py8
-rw-r--r--release/scripts/startup/bl_ui/properties_data_armature.py6
-rw-r--r--release/scripts/startup/bl_ui/properties_data_curve.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py16
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py9
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_mask_common.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py62
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py18
-rw-r--r--release/scripts/startup/bl_ui/properties_render_layer.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_scene.py6
-rw-r--r--release/scripts/startup/bl_ui/properties_world.py28
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py14
-rw-r--r--release/scripts/startup/bl_ui/space_graph.py5
-rw-r--r--release/scripts/startup/bl_ui/space_image.py3
-rw-r--r--release/scripts/startup/bl_ui/space_info.py163
-rw-r--r--release/scripts/startup/bl_ui/space_node.py6
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py4
-rw-r--r--release/scripts/startup/bl_ui/space_text.py2
-rw-r--r--release/scripts/startup/bl_ui/space_time.py9
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py12
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py186
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py10
-rw-r--r--release/scripts/startup/nodeitems_builtins.py2
-rw-r--r--release/scripts/templates_py/addon_add_object.py1
-rw-r--r--release/scripts/templates_py/custom_nodes.py5
-rw-r--r--release/scripts/templates_py/operator_mesh_uv.py (renamed from release/scripts/templates_py/operator_uv.py)0
-rw-r--r--release/scripts/templates_py/operator_modal_timer.py11
-rw-r--r--release/text/readme.html118
m---------scons0
-rw-r--r--source/blender/blenfont/intern/blf_font.c1
-rw-r--r--source/blender/blenkernel/BKE_action.h56
-rw-r--r--source/blender/blenkernel/BKE_animsys.h4
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h2
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h1
-rw-r--r--source/blender/blenkernel/BKE_curve.h1
-rw-r--r--source/blender/blenkernel/BKE_customdata.h4
-rw-r--r--source/blender/blenkernel/BKE_deform.h3
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h7
-rw-r--r--source/blender/blenkernel/BKE_editmesh_bvh.h6
-rw-r--r--source/blender/blenkernel/BKE_font.h2
-rw-r--r--source/blender/blenkernel/BKE_global.h1
-rw-r--r--source/blender/blenkernel/BKE_idprop.h3
-rw-r--r--source/blender/blenkernel/BKE_main.h3
-rw-r--r--source/blender/blenkernel/BKE_mask.h15
-rw-r--r--source/blender/blenkernel/BKE_modifier.h1
-rw-r--r--source/blender/blenkernel/BKE_node.h11
-rw-r--r--source/blender/blenkernel/BKE_object.h3
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h3
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h2
-rw-r--r--source/blender/blenkernel/BKE_texture.h3
-rw-r--r--source/blender/blenkernel/BKE_tracking.h2
-rw-r--r--source/blender/blenkernel/BKE_writeffmpeg.h47
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c73
-rw-r--r--source/blender/blenkernel/intern/action.c90
-rw-r--r--source/blender/blenkernel/intern/anim.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c58
-rw-r--r--source/blender/blenkernel/intern/armature.c8
-rw-r--r--source/blender/blenkernel/intern/bmfont.c2
-rw-r--r--source/blender/blenkernel/intern/brush.c2
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c7
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c153
-rw-r--r--source/blender/blenkernel/intern/cloth.c4
-rw-r--r--source/blender/blenkernel/intern/constraint.c6
-rw-r--r--source/blender/blenkernel/intern/curve.c27
-rw-r--r--source/blender/blenkernel/intern/deform.c38
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c109
-rw-r--r--source/blender/blenkernel/intern/editmesh.c152
-rw-r--r--source/blender/blenkernel/intern/editmesh_bvh.c48
-rw-r--r--source/blender/blenkernel/intern/fcurve.c32
-rw-r--r--source/blender/blenkernel/intern/font.c24
-rw-r--r--source/blender/blenkernel/intern/gpencil.c3
-rw-r--r--source/blender/blenkernel/intern/idprop.c12
-rw-r--r--source/blender/blenkernel/intern/image.c34
-rw-r--r--source/blender/blenkernel/intern/ipo.c11
-rw-r--r--source/blender/blenkernel/intern/mask.c22
-rw-r--r--source/blender/blenkernel/intern/mball.c16
-rw-r--r--source/blender/blenkernel/intern/mesh.c20
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c5
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c30
-rw-r--r--source/blender/blenkernel/intern/node.c18
-rw-r--r--source/blender/blenkernel/intern/object.c37
-rw-r--r--source/blender/blenkernel/intern/particle_system.c10
-rw-r--r--source/blender/blenkernel/intern/pbvh.c5
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c2
-rw-r--r--source/blender/blenkernel/intern/scene.c43
-rw-r--r--source/blender/blenkernel/intern/sequencer.c4
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c6
-rw-r--r--source/blender/blenkernel/intern/smoke.c36
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c115
-rw-r--r--source/blender/blenkernel/intern/texture.c27
-rw-r--r--source/blender/blenkernel/intern/tracking.c58
-rw-r--r--source/blender/blenkernel/intern/unit.c18
-rw-r--r--source/blender/blenkernel/intern/world.c2
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c22
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h5
-rw-r--r--source/blender/blenlib/BLI_math_vector.h6
-rw-r--r--source/blender/blenlib/BLI_rect.h2
-rw-r--r--source/blender/blenlib/BLI_sys_types.h2
-rw-r--r--source/blender/blenlib/BLI_task.h4
-rw-r--r--source/blender/blenlib/BLI_utildefines.h9
-rw-r--r--source/blender/blenlib/BLI_voronoi.h2
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c2
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c2
-rw-r--r--source/blender/blenlib/intern/convexhull2d.c4
-rw-r--r--source/blender/blenlib/intern/edgehash.c2
-rw-r--r--source/blender/blenlib/intern/math_matrix.c22
-rw-r--r--source/blender/blenlib/intern/math_rotation.c2
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c32
-rw-r--r--source/blender/blenlib/intern/rct.c26
-rw-r--r--source/blender/blenlib/intern/task.c2
-rw-r--r--source/blender/blenlib/intern/threads.c4
-rw-r--r--source/blender/blenlib/intern/voronoi.c10
-rw-r--r--source/blender/blenloader/CMakeLists.txt4
-rw-r--r--source/blender/blenloader/SConscript3
-rw-r--r--source/blender/blenloader/intern/readfile.c164
-rw-r--r--source/blender/blenloader/intern/versioning_250.c2
-rw-r--r--source/blender/blenloader/intern/writefile.c15
-rw-r--r--source/blender/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/bmesh/bmesh_class.h19
-rw-r--r--source/blender/bmesh/bmesh_tools.h1
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c15
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c192
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.h19
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c51
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.h8
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c338
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c2
-rw-r--r--source/blender/bmesh/operators/bmo_beautify.c412
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c9
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c9
-rw-r--r--source/blender/bmesh/operators/bmo_fill_grid.c13
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c6
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c12
-rw-r--r--source/blender/bmesh/operators/bmo_wireframe.c8
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.c445
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.h (renamed from source/gameengine/Ketsji/KX_IPhysicsController.cpp)39
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c223
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.h2
-rw-r--r--source/blender/bmesh/tools/bmesh_bisect_plane.c58
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c4
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.c12
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.h2
-rw-r--r--source/blender/collada/AnimationExporter.h4
-rw-r--r--source/blender/collada/ArmatureImporter.cpp2
-rw-r--r--source/blender/collada/DocumentExporter.cpp11
-rw-r--r--source/blender/collada/collada_utils.cpp8
-rw-r--r--source/blender/compositor/CMakeLists.txt3
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp5
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.h22
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp1
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.cpp24
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DespeckleNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp12
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h14
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cpp74
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.h34
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp150
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h7
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp1
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp108
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h38
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cpp160
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.h40
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp88
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp8
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.h6
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp40
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.h8
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c506
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c42
-rw-r--r--source/blender/editors/animation/anim_draw.c136
-rw-r--r--source/blender/editors/animation/anim_filter.c73
-rw-r--r--source/blender/editors/animation/anim_markers.c60
-rw-r--r--source/blender/editors/animation/anim_ops.c10
-rw-r--r--source/blender/editors/animation/drivers.c4
-rw-r--r--source/blender/editors/animation/keyframing.c6
-rw-r--r--source/blender/editors/armature/armature_add.c8
-rw-r--r--source/blender/editors/armature/armature_edit.c59
-rw-r--r--source/blender/editors/armature/armature_intern.h9
-rw-r--r--source/blender/editors/armature/armature_naming.c23
-rw-r--r--source/blender/editors/armature/armature_ops.c46
-rw-r--r--source/blender/editors/armature/armature_relations.c4
-rw-r--r--source/blender/editors/armature/armature_select.c235
-rw-r--r--source/blender/editors/armature/armature_skinning.c7
-rw-r--r--source/blender/editors/armature/armature_utils.c76
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c10
-rw-r--r--source/blender/editors/armature/pose_edit.c6
-rw-r--r--source/blender/editors/armature/pose_lib.c5
-rw-r--r--source/blender/editors/armature/pose_select.c152
-rw-r--r--source/blender/editors/armature/pose_slide.c3
-rw-r--r--source/blender/editors/armature/pose_transform.c4
-rw-r--r--source/blender/editors/curve/editcurve.c1162
-rw-r--r--source/blender/editors/curve/editcurve_add.c2
-rw-r--r--source/blender/editors/curve/editfont.c19
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c7
-rw-r--r--source/blender/editors/include/ED_anim_api.h20
-rw-r--r--source/blender/editors/include/ED_armature.h7
-rw-r--r--source/blender/editors/include/ED_mball.h1
-rw-r--r--source/blender/editors/include/ED_mesh.h22
-rw-r--r--source/blender/editors/include/ED_node.h3
-rw-r--r--source/blender/editors/include/ED_numinput.h7
-rw-r--r--source/blender/editors/include/ED_object.h3
-rw-r--r--source/blender/editors/include/ED_render.h1
-rw-r--r--source/blender/editors/include/ED_sculpt.h4
-rw-r--r--source/blender/editors/include/ED_transform.h4
-rw-r--r--source/blender/editors/include/ED_transverts.h70
-rw-r--r--source/blender/editors/include/ED_view3d.h6
-rw-r--r--source/blender/editors/include/UI_interface.h93
-rw-r--r--source/blender/editors/interface/interface.c67
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c16
-rw-r--r--source/blender/editors/interface/interface_handlers.c313
-rw-r--r--source/blender/editors/interface/interface_intern.h20
-rw-r--r--source/blender/editors/interface/interface_layout.c76
-rw-r--r--source/blender/editors/interface/interface_regions.c20
-rw-r--r--source/blender/editors/interface/interface_templates.c36
-rw-r--r--source/blender/editors/interface/interface_widgets.c116
-rw-r--r--source/blender/editors/interface/resources.c10
-rw-r--r--source/blender/editors/interface/view2d_ops.c11
-rw-r--r--source/blender/editors/mask/mask_add.c6
-rw-r--r--source/blender/editors/mask/mask_shapekey.c10
-rw-r--r--source/blender/editors/mesh/editface.c6
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c31
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c4
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c7
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c3
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c1786
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c9
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c15
-rw-r--r--source/blender/editors/mesh/editmesh_select.c12
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c30
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c201
-rw-r--r--source/blender/editors/mesh/mesh_data.c2
-rw-r--r--source/blender/editors/mesh/mesh_intern.h3
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c8
-rw-r--r--source/blender/editors/mesh/mesh_ops.c14
-rw-r--r--source/blender/editors/mesh/meshtools.c105
-rw-r--r--source/blender/editors/metaball/mball_edit.c204
-rw-r--r--source/blender/editors/metaball/mball_intern.h1
-rw-r--r--source/blender/editors/metaball/mball_ops.c18
-rw-r--r--source/blender/editors/object/CMakeLists.txt1
-rw-r--r--source/blender/editors/object/object_add.c19
-rw-r--r--source/blender/editors/object/object_bake.c39
-rw-r--r--source/blender/editors/object/object_constraint.c4
-rw-r--r--source/blender/editors/object/object_edit.c23
-rw-r--r--source/blender/editors/object/object_hook.c24
-rw-r--r--source/blender/editors/object/object_intern.h4
-rw-r--r--source/blender/editors/object/object_lattice.c2
-rw-r--r--source/blender/editors/object/object_modifier.c8
-rw-r--r--source/blender/editors/object/object_ops.c3
-rw-r--r--source/blender/editors/object/object_relations.c7
-rw-r--r--source/blender/editors/object/object_select.c8
-rw-r--r--source/blender/editors/object/object_shapekey.c12
-rw-r--r--source/blender/editors/object/object_transform.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c90
-rw-r--r--source/blender/editors/object/object_warp.c325
-rw-r--r--source/blender/editors/physics/particle_edit.c4
-rw-r--r--source/blender/editors/render/SConscript3
-rw-r--r--source/blender/editors/render/render_internal.c14
-rw-r--r--source/blender/editors/render/render_opengl.c4
-rw-r--r--source/blender/editors/render/render_ops.c8
-rw-r--r--source/blender/editors/render/render_shading.c4
-rw-r--r--source/blender/editors/screen/screen_ops.c116
-rw-r--r--source/blender/editors/screen/screendump.c5
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c35
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c102
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c270
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c14
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c20
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c19
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c14
-rw-r--r--source/blender/editors/sound/SConscript6
-rw-r--r--source/blender/editors/sound/sound_ops.c3
-rw-r--r--source/blender/editors/space_action/action_ops.c32
-rw-r--r--source/blender/editors/space_action/action_select.c80
-rw-r--r--source/blender/editors/space_action/space_action.c2
-rw-r--r--source/blender/editors/space_api/spacetypes.c1
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c4
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c4
-rw-r--r--source/blender/editors/space_clip/clip_editor.c7
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c22
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c24
-rw-r--r--source/blender/editors/space_clip/clip_intern.h4
-rw-r--r--source/blender/editors/space_clip/clip_ops.c16
-rw-r--r--source/blender/editors/space_clip/clip_utils.c13
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c88
-rw-r--r--source/blender/editors/space_console/console_ops.c3
-rw-r--r--source/blender/editors/space_file/file_draw.c5
-rw-r--r--source/blender/editors/space_file/file_intern.h1
-rw-r--r--source/blender/editors/space_file/file_ops.c59
-rw-r--r--source/blender/editors/space_file/file_panels.c2
-rw-r--r--source/blender/editors/space_file/filelist.c68
-rw-r--r--source/blender/editors/space_file/filesel.c20
-rw-r--r--source/blender/editors/space_file/fsmenu.c87
-rw-r--r--source/blender/editors/space_file/space_file.c1
-rw-r--r--source/blender/editors/space_graph/graph_draw.c65
-rw-r--r--source/blender/editors/space_graph/graph_edit.c67
-rw-r--r--source/blender/editors/space_graph/graph_ops.c17
-rw-r--r--source/blender/editors/space_graph/graph_select.c50
-rw-r--r--source/blender/editors/space_image/image_ops.c32
-rw-r--r--source/blender/editors/space_image/space_image.c12
-rw-r--r--source/blender/editors/space_info/space_info.c5
-rw-r--r--source/blender/editors/space_nla/nla_draw.c75
-rw-r--r--source/blender/editors/space_nla/space_nla.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c14
-rw-r--r--source/blender/editors/space_node/node_draw.c15
-rw-r--r--source/blender/editors/space_node/node_edit.c10
-rw-r--r--source/blender/editors/space_node/node_intern.h2
-rw-r--r--source/blender/editors/space_node/node_ops.c6
-rw-r--r--source/blender/editors/space_node/node_relationships.c130
-rw-r--r--source/blender/editors/space_node/node_select.c57
-rw-r--r--source/blender/editors/space_node/node_templates.c11
-rw-r--r--source/blender/editors/space_node/node_view.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c293
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c13
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c4
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c9
-rw-r--r--source/blender/editors/space_text/space_text.c29
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c3
-rw-r--r--source/blender/editors/space_text/text_ops.c20
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c16
-rw-r--r--source/blender/editors/space_view3d/drawobject.c578
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c66
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c37
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c26
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c13
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c20
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c570
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c34
-rw-r--r--source/blender/editors/transform/transform.c733
-rw-r--r--source/blender/editors/transform/transform.h117
-rw-r--r--source/blender/editors/transform/transform_constraints.c26
-rw-r--r--source/blender/editors/transform/transform_conversions.c105
-rw-r--r--source/blender/editors/transform/transform_generics.c16
-rw-r--r--source/blender/editors/transform/transform_input.c4
-rw-r--r--source/blender/editors/transform/transform_manipulator.c2
-rw-r--r--source/blender/editors/transform/transform_ops.c25
-rw-r--r--source/blender/editors/transform/transform_snap.c185
-rw-r--r--source/blender/editors/util/CMakeLists.txt2
-rw-r--r--source/blender/editors/util/ed_transverts.c462
-rw-r--r--source/blender/editors/util/numinput.c8
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c48
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c89
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c36
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp1
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.h2
-rw-r--r--source/blender/freestyle/intern/geometry/Noise.cpp6
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp202
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.h28
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.cpp27
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.cpp28
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp14
-rw-r--r--source/blender/freestyle/intern/python/Director.cpp28
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp8
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp8
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp9
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h4
-rw-r--r--source/blender/freestyle/intern/system/Id.h4
-rw-r--r--source/blender/freestyle/intern/system/TimeUtils.h2
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.h2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.h4
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl45
-rw-r--r--source/blender/imbuf/intern/anim_movie.c4
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c4
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c8
-rw-r--r--source/blender/imbuf/intern/indexer.c12
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp46
-rw-r--r--source/blender/imbuf/intern/util.c30
-rw-r--r--source/blender/makesdna/DNA_anim_types.h2
-rw-r--r--source/blender/makesdna/DNA_armature_types.h2
-rw-r--r--source/blender/makesdna/DNA_curve_types.h4
-rw-r--r--source/blender/makesdna/DNA_fileglobal_types.h4
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h1
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h27
-rw-r--r--source/blender/makesdna/DNA_node_types.h9
-rw-r--r--source/blender/makesdna/DNA_scene_types.h10
-rw-r--r--source/blender/makesdna/DNA_space_types.h8
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h16
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h1
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h3
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h322
-rw-r--r--source/blender/makesdna/DNA_world_types.h8
-rw-r--r--source/blender/makesrna/RNA_access.h2
-rw-r--r--source/blender/makesrna/RNA_enum_types.h4
-rw-r--r--source/blender/makesrna/intern/makesrna.c12
-rw-r--r--source/blender/makesrna/intern/rna_access.c23
-rw-r--r--source/blender/makesrna/intern/rna_curve.c1
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c4
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c157
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c5
-rw-r--r--source/blender/makesrna/intern/rna_key.c4
-rw-r--r--source/blender/makesrna/intern/rna_mask.c2
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c39
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c69
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c16
-rw-r--r--source/blender/makesrna/intern/rna_particle.c2
-rw-r--r--source/blender/makesrna/intern/rna_render.c2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c75
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c19
-rw-r--r--source/blender/makesrna/intern/rna_space.c40
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c45
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c14
-rw-r--r--source/blender/makesrna/intern/rna_wm.c24
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_world.c59
-rw-r--r--source/blender/modifiers/intern/MOD_array.c10
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c3
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c10
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c2
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c4
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c6
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c145
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c9
-rw-r--r--source/blender/modifiers/intern/MOD_util.c24
-rw-r--r--source/blender/modifiers/intern/MOD_util.h1
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c2
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorbalance.c34
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_moviedistortion.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switch.c2
-rw-r--r--source/blender/nodes/intern/node_common.c4
-rw-r--r--source/blender/nodes/intern/node_common.h2
-rw-r--r--source/blender/nodes/intern/node_exec.c6
-rw-r--r--source/blender/nodes/intern/node_exec.h2
-rw-r--r--source/blender/nodes/intern/node_util.c17
-rw-r--r--source/blender/nodes/intern/node_util.h8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_fresnel.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_layer_weight.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_material.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c30
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c41
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c14
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c110
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.h4
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_select.c3
-rw-r--r--source/blender/python/generic/idprop_py_api.c146
-rw-r--r--source/blender/python/generic/idprop_py_api.h2
-rw-r--r--source/blender/python/generic/py_capi_utils.c16
-rw-r--r--source/blender/python/generic/py_capi_utils.h4
-rw-r--r--source/blender/python/intern/bpy_app.c24
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.c4
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c2
-rw-r--r--source/blender/python/intern/bpy_operator.c2
-rw-r--r--source/blender/python/intern/bpy_rna.c2
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c2
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c2
-rw-r--r--source/blender/quicktime/CMakeLists.txt22
-rw-r--r--source/blender/quicktime/SConscript13
-rw-r--r--source/blender/quicktime/apple/quicktime_export.c927
-rw-r--r--source/blender/quicktime/apple/quicktime_import.c833
-rw-r--r--source/blender/quicktime/quicktime_export.h9
-rw-r--r--source/blender/quicktime/quicktime_import.h12
-rw-r--r--source/blender/render/CMakeLists.txt1
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h4
-rw-r--r--source/blender/render/intern/source/bake.c28
-rw-r--r--source/blender/render/intern/source/convertblender.c282
-rw-r--r--source/blender/render/intern/source/initrender.c4
-rw-r--r--source/blender/render/intern/source/multires_bake.c10
-rw-r--r--source/blender/render/intern/source/pipeline.c22
-rw-r--r--source/blender/render/intern/source/pixelshading.c1
-rw-r--r--source/blender/render/intern/source/render_result.c8
-rw-r--r--source/blender/render/intern/source/render_texture.c14
-rw-r--r--source/blender/render/intern/source/rendercore.c130
-rw-r--r--source/blender/render/intern/source/shadeoutput.c26
-rw-r--r--source/blender/render/intern/source/sss.c2
-rw-r--r--source/blender/render/intern/source/volume_precache.c4
-rw-r--r--source/blender/windowmanager/CMakeLists.txt8
-rw-r--r--source/blender/windowmanager/SConscript3
-rw-r--r--source/blender/windowmanager/WM_api.h15
-rw-r--r--source/blender/windowmanager/WM_keymap.h1
-rw-r--r--source/blender/windowmanager/WM_types.h3
-rw-r--r--source/blender/windowmanager/intern/wm_apple.c137
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c6
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c12
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c38
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c40
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c162
-rw-r--r--source/blender/windowmanager/intern/wm_window.c30
-rw-r--r--source/blenderplayer/CMakeLists.txt1
-rw-r--r--source/blenderplayer/bad_level_call_stubs/CMakeLists.txt7
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c11
-rw-r--r--source/creator/CMakeLists.txt52
-rw-r--r--source/creator/buildinfo.c6
-rw-r--r--source/creator/creator.c41
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp15
-rw-r--r--source/gameengine/BlenderRoutines/CMakeLists.txt4
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp93
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h8
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.cpp348
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.h70
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp410
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h122
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp5
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp224
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.h2
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.cpp2
-rw-r--r--source/gameengine/Converter/BlenderWorldInfo.cpp1
-rw-r--r--source/gameengine/Converter/BlenderWorldInfo.h1
-rw-r--r--source/gameengine/Converter/CMakeLists.txt1
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp39
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h2
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp1
-rw-r--r--source/gameengine/Converter/KX_SoftBodyDeformer.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.cpp1
-rw-r--r--source/gameengine/GamePlayer/common/CMakeLists.txt2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.cpp577
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.h115
-rw-r--r--source/gameengine/GamePlayer/common/SConscript1
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp20
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.h3
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp35
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp2
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt6
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.h4
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.cpp577
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.h102
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_CharacterWrapper.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp20
-rw-r--r--source/gameengine/Ketsji/KX_Dome.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_Dome.h3
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.cpp8
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.h6
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp193
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h37
-rw-r--r--source/gameengine/Ketsji/KX_IPO_SGController.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.h151
-rw-r--r--source/gameengine/Ketsji/KX_ISceneConverter.h2
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp69
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h3
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_Light.h9
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp11
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.cpp16
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.h16
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_NavMeshObject.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp16
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp23
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.cpp422
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.h156
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp44
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_PythonMain.h1
-rw-r--r--source/gameengine/Ketsji/KX_PythonSeq.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.h7
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp1
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp11
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp80
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h3
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp24
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.cpp28
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.h18
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp492
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h132
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp246
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h119
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp20
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h40
-rw-r--r--source/gameengine/Physics/common/PHY_IController.h4
-rw-r--r--source/gameengine/Physics/common/PHY_IGraphicController.h4
-rw-r--r--source/gameengine/Physics/common/PHY_IMotionState.h16
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h62
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h77
-rw-r--r--source/gameengine/Rasterizer/CMakeLists.txt2
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.h3
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.cpp43
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.h11
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp11
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.h3
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h83
-rw-r--r--source/gameengine/Rasterizer/RAS_IRenderTools.cpp59
-rw-r--r--source/gameengine/Rasterizer/RAS_IRenderTools.h227
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp19
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.h26
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp24
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.h17
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt6
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h17
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp482
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h78
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp5
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript6
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.cpp1
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.h8
-rw-r--r--source/gameengine/VideoTexture/ImageRender.cpp8
-rw-r--r--source/gameengine/VideoTexture/ImageRender.h3
-rw-r--r--source/gameengine/VideoTexture/ImageViewport.cpp1
-rw-r--r--source/gameengine/VideoTexture/Texture.cpp10
1107 files changed, 29702 insertions, 23956 deletions
diff --git a/.arcconfig b/.arcconfig
new file mode 100644
index 00000000000..57f6c39f1ea
--- /dev/null
+++ b/.arcconfig
@@ -0,0 +1,6 @@
+{
+ "project_id" : "Blender",
+ "conduit_uri" : "http://developer.blender.org/",
+ "git.default-relative-commit" : "origin/master",
+ "arc.land.update.default" : "rebase"
+}
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000000..e0228f27ced
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,25 @@
+# generic files to ignore
+.*
+
+# python temp paths
+__pycache__/
+*.py[cod]
+
+# editors
+*~
+*.swp
+*.swo
+*#
+
+# ms-windows
+Thumbs.db
+ehthumbs.db
+Desktop.ini
+
+# commonly used paths in blender
+/blender.bin
+/user-config.py
+
+# local patches
+/*.patch
+/*.diff
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000000..4ce5a2466e6
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,16 @@
+[submodule "release/scripts/addons"]
+ path = release/scripts/addons
+ url = ../blender-addons.git
+ ignore = all
+[submodule "release/scripts/addons_contrib"]
+ path = release/scripts/addons_contrib
+ url = ../blender-addons-contrib.git
+ ignore = all
+[submodule "release/datafiles/locale"]
+ path = release/datafiles/locale
+ url = ../blender-translations.git
+ ignore = all
+[submodule "scons"]
+ path = scons
+ url = ../scons.git
+ ignore = all
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fbb7c17e64b..a7f6b879555 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -216,15 +216,22 @@ option(WITH_IMAGE_FRAMESERVER "Enable image FrameServer Support for rendering"
# Audio/Video format support
option(WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg)" ON)
option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF)
-
option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
-if(APPLE OR (WIN32 AND NOT UNIX))
- option(WITH_CODEC_QUICKTIME "Enable Quicktime Support" OFF)
+
+if(APPLE)
+ option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" ON)
+ option(WITH_CODEC_QUICKTIME "Enable Quicktime Support" ON)
+else()
+ option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF)
endif()
# 3D format support
-# disable opencollada on non-apple unix because opencollada has no package for debian
-option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" OFF)
+# Disable opencollada when we don't have precompiled libs
+if(APPLE OR WIN32)
+ option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON)
+else()
+ option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" OFF)
+endif()
# Sound output
option(WITH_SDL "Enable SDL for sound and joystick support" ON)
@@ -290,7 +297,7 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC)
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
mark_as_advanced(WITH_ASSERT_ABORT)
-option(WITH_BOOST "Enable features depending no boost" ON)
+option(WITH_BOOST "Enable features depending on boost" ON)
if(CMAKE_COMPILER_IS_GNUCC)
option(WITH_GCC_MUDFLAP "Enable mudflap" OFF)
@@ -367,10 +374,17 @@ if(APPLE)
message(STATUS "OSX_SYSROOT_PREFIX: " ${OSX_SYSROOT_PREFIX})
set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk
set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT_PREFIX}/${OSX_DEVELOPER_PREFIX} CACHE PATH "" FORCE)
+ if(${CMAKE_GENERATOR} MATCHES "Xcode")
+ set(CMAKE_XCODE_ATTRIBUTE_SDKROOT macosx${OSX_SYSTEM}) # to silence sdk not found warning, just overrides CMAKE_OSX_SYSROOT
+ endif()
endif()
-
+
+ if(OSX_SYSTEM MATCHES 10.9)
+ set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT}) # make sure syslibs and headers are looked up in sdk ( expecially for 10.9 openGL atm. )
+ endif()
+
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our min. target, if you use higher sdk, weak linking happens
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE) # 10.6 is our min. target, if you use higher sdk, weak linking happens
endif()
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
@@ -380,12 +394,7 @@ if(APPLE)
add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
- option(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON)
- option(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
option(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF)
- if(CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
- set(USE_QTKIT ON CACHE BOOL "ON" FORCE) # no Quicktime in 64bit
- endif()
endif()
@@ -492,14 +501,6 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS)
set(WITH_X11_XINPUT OFF)
endif()
-if(MINGW)
- if(WITH_CODEC_QUICKTIME)
- message(FATAL_ERROR "MINGW requires WITH_CODEC_QUICKTIME to be OFF "
- "because it is currently unsupported, remove this "
- "line if youre a developer who wants to add support.")
- endif()
-endif()
-
TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
TEST_STDBOOL_SUPPORT()
@@ -1030,13 +1031,6 @@ elseif(WIN32)
set(SDL_LIBPATH ${SDL}/lib)
endif()
- if(WITH_CODEC_QUICKTIME)
- set(QUICKTIME ${LIBDIR}/QTDevWin)
- set(QUICKTIME_INCLUDE_DIRS ${QUICKTIME}/CIncludes)
- set(QUICKTIME_LIBRARIES qtmlClient)
- set(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
- endif()
-
if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
add_definitions(-D__SSE__ -D__MMX__)
endif()
@@ -1500,7 +1494,7 @@ elseif(WIN32)
elseif(APPLE)
if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")
- set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/10.7
+ set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/7/8/9
endif()
if(WITH_LIBS10.5)
@@ -1612,47 +1606,37 @@ elseif(APPLE)
set(PLATFORM_LINKLIBS stdc++)
endif()
- if(WITH_COCOA)
- set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
- set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
- if(USE_QTKIT)
- set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
- if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
- # libSDL still needs 32bit carbon quicktime
- endif()
- elseif(WITH_CODEC_QUICKTIME)
+ set(PLATFORM_CFLAGS "-pipe -funsigned-char")
+ set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
+ if(WITH_CODEC_QUICKTIME)
+ set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
+ if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
+ # libSDL still needs 32bit carbon quicktime
endif()
+ endif()
- # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
- # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
- if(WITH_INPUT_NDOF)
- # This thread it *should* work and check the framework - campbell
- # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
- find_library(3DCONNEXION_CLIENT_FRAMEWORK
- NAMES 3DconnexionClient
- )
- if(NOT 3DCONNEXION_CLIENT_FRAMEWORK)
- set(WITH_INPUT_NDOF OFF)
- endif()
+ # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
+ # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
+ if(WITH_INPUT_NDOF)
+ # This thread it *should* work and check the framework - campbell
+ # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
+ find_library(3DCONNEXION_CLIENT_FRAMEWORK
+ NAMES 3DconnexionClient
+ )
+ if(NOT 3DCONNEXION_CLIENT_FRAMEWORK)
+ set(WITH_INPUT_NDOF OFF)
+ endif()
- if(WITH_INPUT_NDOF)
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient")
- set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers )
- endif()
+ if(WITH_INPUT_NDOF)
+ set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient")
+ set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers )
endif()
+ endif()
if(WITH_JACK)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp")
endif()
-
- else()
- set(PLATFORM_CFLAGS "-pipe -funsigned-char")
- set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
- set(WITH_INPUT_NDOF OFF) # unsupported
- endif()
if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")# force cmake to link right framework
@@ -1805,13 +1789,9 @@ elseif(APPLE)
set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
endif()
- if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- if(${CMAKE_GENERATOR} MATCHES "Xcode")
- if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
- # Xcode 5 has too low template depth of 128 for libmv
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
- endif()
- endif()
+ if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
+ # Xcode 5 is always using CLANG, which has too low template depth of 128 for libmv
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
endif()
endif()
@@ -2078,6 +2058,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
+ ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
diff --git a/GNUmakefile b/GNUmakefile
index 417ff7770ed..e6998cf1c96 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -40,7 +40,7 @@ ifndef BUILD_CMAKE_ARGS
endif
ifndef BUILD_DIR
- BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build_$(OS_NCASE)
+ BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
endif
@@ -54,15 +54,15 @@ ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
endif
ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_lite
- BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake
+ BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
endif
ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_bpy
- BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake
+ BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
endif
ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_bpy
- BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake
+ BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
endif
@@ -87,8 +87,8 @@ endif
# Macro for configuring cmake
CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
- -H$(BLENDER_DIR) \
- -B$(BUILD_DIR) \
+ -H"$(BLENDER_DIR)" \
+ -B"$(BUILD_DIR)" \
-DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
@@ -118,7 +118,7 @@ all:
@echo
@echo Building Blender ...
- $(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install
+ $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
@echo
@echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
@echo blender installed, run from: "$(BUILD_DIR)/bin/blender"
@@ -133,7 +133,7 @@ bpy: all
# -----------------------------------------------------------------------------
# Configuration (save some cd'ing around)
config:
- $(CMAKE_CONFIG_TOOL) $(BUILD_DIR)
+ $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
# -----------------------------------------------------------------------------
@@ -205,7 +205,7 @@ package_pacman:
cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
package_archive:
- make -C $(BUILD_DIR) -s package_archive
+ make -C "$(BUILD_DIR)" -s package_archive
@echo archive in "$(BUILD_DIR)/release"
@@ -231,25 +231,25 @@ test_deprecated:
test_style_c:
# run our own checks on C/C++ style
- PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/source/blender $(BLENDER_DIR)/source/creator --no-length-check
+ PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/source/blender" "$(BLENDER_DIR)/source/creator" --no-length-check
test_style_c_qtc:
# run our own checks on C/C++ style
USE_QTC_TASK=1 \
- PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/source/blender $(BLENDER_DIR)/source/creator --no-length-check > \
+ PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/source/blender" "$(BLENDER_DIR)/source/creator" --no-length-check > \
test_style.tasks
@echo "written: test_style.tasks"
test_style_osl:
# run our own checks on C/C++ style
- PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/intern/cycles/kernel/shaders
+ PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
test_style_osl_qtc:
# run our own checks on C/C++ style
USE_QTC_TASK=1 \
- PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/intern/cycles/kernel/shaders > \
+ PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/intern/cycles/kernel/shaders" > \
test_style.tasks
@echo "written: test_style.tasks"
@@ -258,13 +258,13 @@ test_style_osl_qtc:
#
project_qtcreator:
- python3 build_files/cmake/cmake_qtcreator_project.py $(BUILD_DIR)
+ python3 build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
project_netbeans:
- python3 build_files/cmake/cmake_netbeans_project.py $(BUILD_DIR)
+ python3 build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
project_eclipse:
- cmake -G"Eclipse CDT4 - Unix Makefiles" -H$(BLENDER_DIR) -B$(BUILD_DIR)
+ cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
# -----------------------------------------------------------------------------
@@ -273,49 +273,49 @@ project_eclipse:
check_cppcheck:
$(CMAKE_CONFIG)
- cd $(BUILD_DIR) ; \
- python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py 2> \
- $(BLENDER_DIR)/check_cppcheck.txt
+ cd "$(BUILD_DIR)" ; \
+ python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
+ "$(BLENDER_DIR)/check_cppcheck.txt"
@echo "written: check_cppcheck.txt"
check_clang_array:
$(CMAKE_CONFIG)
- cd $(BUILD_DIR) ; \
- python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py
+ cd "$(BUILD_DIR)" ; \
+ python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
check_splint:
$(CMAKE_CONFIG)
- cd $(BUILD_DIR) ; \
- python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py
+ cd "$(BUILD_DIR)" ; \
+ python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
check_sparse:
$(CMAKE_CONFIG)
- cd $(BUILD_DIR) ; \
- python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py
+ cd "$(BUILD_DIR)" ; \
+ python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
check_smatch:
$(CMAKE_CONFIG)
- cd $(BUILD_DIR) ; \
- python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py
+ cd "$(BUILD_DIR)" ; \
+ python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
check_spelling_py:
- cd $(BUILD_DIR) ; \
- PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/release/scripts
+ cd "$(BUILD_DIR)" ; \
+ PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/release/scripts"
check_spelling_c:
- cd $(BUILD_DIR) ; \
- PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/source
+ cd "$(BUILD_DIR)" ; \
+ PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/source"
check_spelling_c_qtc:
- cd $(BUILD_DIR) ; USE_QTC_TASK=1 \
- PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/source > \
- $(BLENDER_DIR)/check_spelling_c.tasks
+ cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
+ PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/source" > \
+ "$(BLENDER_DIR)/check_spelling_c.tasks"
check_spelling_osl:
- cd $(BUILD_DIR) ; PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/intern/cycles/kernel/shaders
+ cd "$(BUILD_DIR)" ; PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
check_descriptions:
- $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python $(BLENDER_DIR)/source/tools/check_descriptions.py
+ "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
# -----------------------------------------------------------------------------
# Utilities
@@ -328,8 +328,8 @@ tbz:
@echo "blender_archive.tar.bz2 written"
icons:
- $(BLENDER_DIR)/release/datafiles/blender_icons.sh
- $(BLENDER_DIR)/release/datafiles/prvicons.sh
+ "$(BLENDER_DIR)/release/datafiles/blender_icons.sh"
+ "$(BLENDER_DIR)/release/datafiles/prvicons.sh"
# -----------------------------------------------------------------------------
@@ -338,7 +338,7 @@ icons:
# Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
doc_py:
- $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py
+ "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py
cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
@echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
@@ -347,14 +347,14 @@ doc_doxy:
@echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
doc_dna:
- $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py
+ "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py
@echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
doc_man:
- python3 doc/manpage/blender.1.py $(BUILD_DIR)/bin/blender
+ python3 doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
clean:
- $(MAKE) -C $(BUILD_DIR) clean
+ $(MAKE) -C "$(BUILD_DIR)" clean
.PHONY: all
diff --git a/SConstruct b/SConstruct
index 9f9eaa886a3..8c27424f617 100644
--- a/SConstruct
+++ b/SConstruct
@@ -285,52 +285,153 @@ if 'cudakernels' in B.targets:
env['WITH_BF_CYCLES_CUDA_BINARIES'] = True
env['WITH_BF_PYTHON'] = False
-# Extended OSX_SDK and 3D_CONNEXION_CLIENT_LIBRARY and JAckOSX detection for OSX
+
+#############################################################################
+################### Automatic configuration for OSX ##################
+#############################################################################
+
if env['OURPLATFORM']=='darwin':
+
+ import commands
+
+ cmd = 'sw_vers -productVersion'
+ MAC_CUR_VER=cmd_res=commands.getoutput(cmd)
+ cmd = 'xcodebuild -version'
+ cmd_xcode=commands.getoutput(cmd)
+ env['XCODE_CUR_VER']=cmd_xcode[6:][:3] # truncate output to major.minor version
+ cmd = 'xcodebuild -showsdks'
+ cmd_sdk=commands.getoutput(cmd)
+ MACOSX_SDK_CHECK=cmd_sdk
+ cmd = 'xcode-select --print-path'
+ XCODE_SELECT_PATH=commands.getoutput(cmd)
+ if XCODE_SELECT_PATH.endswith("/Contents/Developer"):
+ XCODE_BUNDLE=XCODE_SELECT_PATH[:-19]
+ else:
+ XCODE_BUNDLE=XCODE_SELECT_PATH
+
print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --"
- print "Available " + env['MACOSX_SDK_CHECK']
- if not 'Mac OS X 10.6' in env['MACOSX_SDK_CHECK']:
- print B.bc.OKGREEN + "Building with user-defined OS X SDK ( Xcode 4.4 or newer )"
- elif not 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
- print B.bc.OKGREEN + "Auto-setting available MacOSX SDK -> " + B.bc.ENDC + "MacOSX10.6.sdk"
+ print B.bc.OKGREEN + "Available SDK's: \n" + B.bc.ENDC + MACOSX_SDK_CHECK.replace('\t', '')
+
+ if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found
+ if 'OS X 10.9' in MACOSX_SDK_CHECK:
+ env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+ env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.9.sdk'
+ elif 'OS X 10.8' in MACOSX_SDK_CHECK:
+ env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+ env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.8.sdk'
+ elif 'OS X 10.7' in MACOSX_SDK_CHECK:
+ env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+ env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.7.sdk'
+ elif 'OS X 10.6' in MACOSX_SDK_CHECK:
+ env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+ env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.6.sdk'
+ elif 'OS X 10.5' in MACOSX_SDK_CHECK:
+ env['MACOSX_DEPLOYMENT_TARGET'] = '10.5'
+ env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.5.sdk'
else:
- print B.bc.OKGREEN + "Found recommended sdk :" + B.bc.ENDC + " using MacOSX10.5.sdk"
+ env['MACOSX_SDK']='/Developer/SDKs/MacOSX' + env['MACOSX_SDK'] + '.sdk'
+
+ if env['XCODE_CUR_VER'] >= '4.3': ## since version 4.3, XCode and developer dir are bundled ##
+ env['MACOSX_SDK'] = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' + env['MACOSX_SDK']
+
+ print B.bc.OKGREEN + "Using OSX SDK :" + B.bc.ENDC + env['MACOSX_SDK']
- if env['XCODE_CUR_VER'] >= '5' and not (env['CXX'][:-2].endswith('4.6') or env['CXX'][:-2].endswith('4.8')):
+ if not env['WITH_OSX_STATICPYTHON'] == 1:
+ # python 3.3 uses Python-framework additionally installed in /Library/Frameworks
+ env['BF_PYTHON'] = '/Library/Frameworks/Python.framework/Versions/'
+ env['BF_PYTHON_INC'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/include/python' + env['BF_PYTHON_VERSION'] + 'm'
+ env['BF_PYTHON_BINARY'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/bin/python' + env['BF_PYTHON_VERSION']
+ env['BF_PYTHON_LIB'] = ''
+ env['BF_PYTHON_LIBPATH'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/lib/python' + env['BF_PYTHON_VERSION'] + '/config-' + env['BF_PYTHON_VERSION'] +'m'
+ env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','Python'] # link to python framework
+
+ #Ray trace optimization
+ if env['WITH_BF_RAYOPTIMIZATION'] == 1:
+ if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'i386':
+ env['WITH_BF_RAYOPTIMIZATION'] = 1
+ else:
+ env['WITH_BF_RAYOPTIMIZATION'] = 0
+ if env['MACOSX_ARCHITECTURE'] == 'i386':
+ env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse']
+ elif env['MACOSX_ARCHITECTURE'] == 'x86_64':
+ env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse','-msse2']
+
+ if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'ppc64':
+ ARCH_FLAGS = ['-m64']
+ else:
+ ARCH_FLAGS = ['-m32']
+
+ env.Append(CPPFLAGS=ARCH_FLAGS)
+
+ SDK_FLAGS=['-isysroot', env['MACOSX_SDK'],'-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-arch',env['MACOSX_ARCHITECTURE']] # always used
+ env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+ARCH_FLAGS+env['PLATFORM_LINKFLAGS']
+ env['CCFLAGS']=SDK_FLAGS+env['CCFLAGS']
+ env['CXXFLAGS']=SDK_FLAGS+env['CXXFLAGS']
+
+ #Intel Macs are CoreDuo and Up
+ if env['MACOSX_ARCHITECTURE'] == 'i386' or env['MACOSX_ARCHITECTURE'] == 'x86_64':
+ env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-ftree-vectorize','-msse','-msse2','-msse3']
+ else:
+ env['CCFLAGS'] = env['CCFLAGS']+['-fno-strict-aliasing']
+
+ # Intel 64bit Macs are Core2Duo and up
+ if env['MACOSX_ARCHITECTURE'] == 'x86_64':
+ env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-mssse3']
+
+ if env['XCODE_CUR_VER'] >= '5' and not env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1':
env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5
- # for now, Mac builders must download and install the 3DxWare 10 Beta 4 driver framework from 3Dconnexion
- # necessary header file lives here when installed:
- # /Library/Frameworks/3DconnexionClient.framework/Versions/Current/Headers/ConnexionClientAPI.h
+ # 3DconnexionClient.framework, optionally install
if env['WITH_BF_3DMOUSE'] == 1:
if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
- print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
env['WITH_BF_3DMOUSE'] = 0
+ print B.bc.OKGREEN + "3DconnexionClient install not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
else:
env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','3DconnexionClient'])
env['BF_3DMOUSE_INC'] = '/Library/Frameworks/3DconnexionClient.framework/Headers'
+ print B.bc.OKGREEN + "Using 3Dconnexion"
- # for now, Mac builders must download and install the JackOSX framework
- # necessary header file lives here when installed:
- # /Library/Frameworks/Jackmp.framework/Versions/A/Headers/jack.h
+ # Jackmp.framework, optionally install
if env['WITH_BF_JACK'] == 1:
if not os.path.exists('/Library/Frameworks/Jackmp.framework'):
- print "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors !
env['WITH_BF_JACK'] = 0
+ print B.bc.OKGREEN + "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors !
else:
env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','Jackmp'])
+ print B.bc.OKGREEN + "Using Jack"
+
+ if env['WITH_BF_QUICKTIME'] == 1:
+ env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','QTKit']
+
+ #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
+ # if your compiler does not have accurate suffix you may have to enable it by hand !
+ if env['WITH_BF_OPENMP'] == 1:
+ if env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1':
+ env['WITH_BF_OPENMP'] = 1 # multithreading for fluids, cloth, sculpt and smoke
+ print B.bc.OKGREEN + "Using OpenMP"
+ else:
+ env['WITH_BF_OPENMP'] = 0
+ print B.bc.OKGREEN + "Disabled OpenMP, not supported by compiler"
if env['WITH_BF_CYCLES_OSL'] == 1:
OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath
# we need 2 variants of passing the oslexec with the force_load option, string and list type atm
- if env['CC'][:-2].endswith('4.8'):
- env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery'])
+ if env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.8':
+ env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery'])
else:
env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery'])
env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a'])
- # Trying to get rid of eventually clashes, we export some explicite as local symbols
+ # Trying to get rid of eventually clashes, we export some symbols explicite as local
env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map'])
+
+ #for < 10.7.sdk, SystemStubs needs to be linked
+ if env['MACOSX_SDK'].endswith("10.6.sdk") or env['MACOSX_SDK'].endswith("10.5.sdk"):
+ env['LLIBS'].append('SystemStubs')
+
+#############################################################################
+################### End Automatic configuration for OSX ##################
+#############################################################################
if env['WITH_BF_OPENMP'] == 1:
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
@@ -342,12 +443,6 @@ if env['WITH_BF_OPENMP'] == 1:
else:
env.Append(CCFLAGS=['-fopenmp'])
-if env['WITH_GHOST_COCOA'] == True:
- env.Append(CPPFLAGS=['-DGHOST_COCOA'])
-
-if env['USE_QTKIT'] == True:
- env.Append(CPPFLAGS=['-DUSE_QTKIT'])
-
#check for additional debug libnames
if env.has_key('BF_DEBUG_LIBS'):
@@ -689,6 +784,8 @@ if env['OURPLATFORM']=='darwin':
dn.remove('.svn')
if '_svn' in dn:
dn.remove('_svn')
+ if '.git' in df:
+ df.remove('.git')
dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
source=[dp+os.sep+f for f in df]
blenderinstall.append(env.Install(dir=dir,source=source))
@@ -718,10 +815,8 @@ if env['OURPLATFORM']!='darwin':
scriptpaths=['release/scripts']
for scriptpath in scriptpaths:
for dp, dn, df in os.walk(scriptpath):
- if '.svn' in dn:
- dn.remove('.svn')
- if '_svn' in dn:
- dn.remove('_svn')
+ if '.git' in df:
+ df.remove('.git')
if '__pycache__' in dn: # py3.2 cache dir
dn.remove('__pycache__')
@@ -745,8 +840,6 @@ if env['OURPLATFORM']!='darwin':
# cycles python code
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles')
source=os.listdir('intern/cycles/blender/addon')
- if '.svn' in source: source.remove('.svn')
- if '_svn' in source: source.remove('_svn')
if '__pycache__' in source: source.remove('__pycache__')
source=['intern/cycles/blender/addon/'+s for s in source]
scriptinstall.append(env.Install(dir=dir,source=source))
@@ -754,8 +847,6 @@ if env['OURPLATFORM']!='darwin':
# cycles kernel code
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel')
source=os.listdir('intern/cycles/kernel')
- if '.svn' in source: source.remove('.svn')
- if '_svn' in source: source.remove('_svn')
if '__pycache__' in source: source.remove('__pycache__')
source.remove('kernel.cpp')
source.remove('CMakeLists.txt')
@@ -772,16 +863,12 @@ if env['OURPLATFORM']!='darwin':
# svm
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'svm')
source=os.listdir('intern/cycles/kernel/svm')
- if '.svn' in source: source.remove('.svn')
- if '_svn' in source: source.remove('_svn')
if '__pycache__' in source: source.remove('__pycache__')
source=['intern/cycles/kernel/svm/'+s for s in source]
scriptinstall.append(env.Install(dir=dir,source=source))
# closure
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'closure')
source=os.listdir('intern/cycles/kernel/closure')
- if '.svn' in source: source.remove('.svn')
- if '_svn' in source: source.remove('_svn')
if '__pycache__' in source: source.remove('__pycache__')
source=['intern/cycles/kernel/closure/'+s for s in source]
scriptinstall.append(env.Install(dir=dir,source=source))
@@ -789,8 +876,6 @@ if env['OURPLATFORM']!='darwin':
# licenses
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'license')
source=os.listdir('intern/cycles/doc/license')
- if '.svn' in source: source.remove('.svn')
- if '_svn' in source: source.remove('_svn')
if '__pycache__' in source: source.remove('__pycache__')
source.remove('CMakeLists.txt')
source=['intern/cycles/doc/license/'+s for s in source]
@@ -825,11 +910,6 @@ if env['OURPLATFORM']!='darwin':
colormanagement = os.path.join('release', 'datafiles', 'colormanagement')
for dp, dn, df in os.walk(colormanagement):
- if '.svn' in dn:
- dn.remove('.svn')
- if '_svn' in dn:
- dn.remove('_svn')
-
dir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'datafiles')
dir += os.sep + os.path.basename(colormanagement) + dp[len(colormanagement):]
@@ -847,15 +927,15 @@ if env['OURPLATFORM']!='darwin':
def check_path(path, member):
return (member in path.split(os.sep))
+ po_dir = os.path.join("release", "datafiles", "locale", "po")
+
for intpath in internationalpaths:
for dp, dn, df in os.walk(intpath):
- if '.svn' in dn:
- dn.remove('.svn')
- if '_svn' in dn:
- dn.remove('_svn')
+ if '.git' in df:
+ df.remove('.git')
# we only care about release/datafiles/fonts, release/datafiles/locales
- if check_path(dp, "fonts") or check_path(dp, "locale"):
+ if check_path(dp, "fonts"):
pass
else:
continue
@@ -869,16 +949,24 @@ if env['OURPLATFORM']!='darwin':
env.Execute(Mkdir(dir))
scriptinstall.append(env.Install(dir=dir,source=source))
+ for f in os.listdir(po_dir):
+ if not f.endswith(".po"):
+ continue
+
+ locale_name = os.path.splitext(f)[0]
+
+ mo_file = os.path.join(B.root_build_dir, "locale", locale_name + ".mo")
+
+ dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
+ dir = os.path.join(dir, "datafiles", "locale", locale_name, "LC_MESSAGES")
+ scriptinstall.append(env.InstallAs(os.path.join(dir, "blender.mo"), mo_file))
+
#-- icons
if env['OURPLATFORM']=='linux':
iconlist = []
icontargetlist = []
for tp, tn, tf in os.walk('release/freedesktop/icons'):
- if '.svn' in tn:
- tn.remove('.svn')
- if '_svn' in tn:
- tn.remove('_svn')
for f in tf:
iconlist.append(os.path.join(tp, f))
icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
@@ -904,10 +992,6 @@ if env['OURPLATFORM']=='linuxcross':
textlist = []
texttargetlist = []
for tp, tn, tf in os.walk('release/text'):
- if '.svn' in tn:
- tn.remove('.svn')
- if '_svn' in tn:
- tn.remove('_svn')
for f in tf:
textlist.append(tp+os.sep+f)
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index dc21f85e85c..4ca7400fe44 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -200,10 +200,10 @@ OCIO_VERSION_MIN="1.0"
OCIO_FORCE_REBUILD=false
OCIO_SKIP=false
-OPENEXR_VERSION="2.0.0"
+OPENEXR_VERSION="2.0.1"
OPENEXR_SOURCE="http://download.savannah.nongnu.org/releases/openexr/openexr-$OPENEXR_VERSION.tar.gz"
OPENEXR_VERSION_MIN="2.0"
-ILMBASE_VERSION="2.0.0"
+ILMBASE_VERSION="2.0.1"
ILMBASE_SOURCE="http://download.savannah.nongnu.org/releases/openexr/ilmbase-$ILMBASE_VERSION.tar.gz"
OPENEXR_FORCE_REBUILD=false
OPENEXR_SKIP=false
@@ -855,7 +855,7 @@ clean_ILMBASE() {
compile_ILMBASE() {
# To be changed each time we make edits that would modify the compiled result!
- ilmbase_magic=5
+ ilmbase_magic=6
_init_ilmbase
# Clean install if needed!
@@ -958,7 +958,7 @@ clean_OPENEXR() {
compile_OPENEXR() {
# To be changed each time we make edits that would modify the compiled result!
- openexr_magic=10
+ openexr_magic=11
# Clean install if needed!
magic_compile_check openexr-$OPENEXR_VERSION $openexr_magic
@@ -1033,12 +1033,13 @@ compile_OPENEXR() {
TARGET_LINK_LIBRARIES ( IlmImfFuzzTest IlmImf Iex Imath Half IlmThread ${PTHREAD_LIB} ${Z_LIB})
--- a/IlmImfTest/CMakeLists.txt
+++ b/IlmImfTest/CMakeLists.txt
-@@ -19,22 +19,26 @@
+@@ -19,22 +19,28 @@
testCustomAttributes.cpp
testDeepScanLineBasic.cpp
testDeepScanLineHuge.cpp
+ testDeepScanLineMultipleRead.cpp
testDeepTiledBasic.cpp
++ testBadTypeAttributes.cpp
testExistingStreams.cpp
+ testFutureProofing.cpp
testHuf.cpp
@@ -1056,6 +1057,7 @@ compile_OPENEXR() {
testMultiView.cpp
testNativeFormat.cpp
+ testOptimized.cpp
++ testOptimizedInterleavePatterns.cpp
+ testPartHelper.cpp
testPreviewImage.cpp
testRgba.cpp
@@ -1089,11 +1091,12 @@ compile_OPENEXR() {
DESTINATION
\${CMAKE_INSTALL_PREFIX}/lib
)
-@@ -168,6 +167,7 @@
+@@ -168,6 +167,8 @@
INSTALL ( FILES
${CMAKE_SOURCE_DIR}/config/OpenEXRConfig.h
ImfForward.h
+ ImfNamespace.h
++ ImfPartHelper.h
ImfExport.h
ImfAttribute.h
ImfBoxAttribute.h
diff --git a/build_files/buildbot/config/user-config-mac-i386.py b/build_files/buildbot/config/user-config-mac-i386.py
index ad0fbcc78da..fa18b74cf87 100644
--- a/build_files/buildbot/config/user-config-mac-i386.py
+++ b/build_files/buildbot/config/user-config-mac-i386.py
@@ -1,425 +1,3 @@
-#
-# Note : if you want to alter this file
-# copy it as a whole in the upper folder
-# as user-config.py
-# dont create a new file with only some
-# vars changed.
-
-import commands
-
-# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs
-USE_SDK=True
-
-#############################################################################
-################### Cocoa & architecture settings ##################
-#############################################################################
-WITH_GHOST_COCOA=True
MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64
-
-
-cmd = 'uname -p'
-MAC_PROC=commands.getoutput(cmd)
-cmd = 'uname -r'
-cmd_res=commands.getoutput(cmd)
-
-if cmd_res[:1]=='7':
- MAC_CUR_VER='10.3'
-elif cmd_res[:1]=='8':
- MAC_CUR_VER='10.4'
-elif cmd_res[:1]=='9':
- MAC_CUR_VER='10.5'
-elif cmd_res[:2]=='10':
- MAC_CUR_VER='10.6'
-elif cmd_res[:2]=='11':
- MAC_CUR_VER='10.7'
-elif cmd_res[:2]=='12':
- MAC_CUR_VER='10.8'
-elif cmd_res[:2]=='13':
- MAC_CUR_VER='10.9'
-cmd = 'xcodebuild -version'
-cmd_xcode=commands.getoutput(cmd)
-XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version
-cmd = 'xcodebuild -showsdks'
-cmd_sdk=commands.getoutput(cmd)
-MACOSX_SDK_CHECK=cmd_sdk
-
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
- USE_QTKIT=True # Carbon quicktime is not available for 64bit
-
-
-# Default target OSX settings per architecture
-# Can be customized
-
-if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4':
-# all releases are now made for 10.5 !
-# MAC_MIN_VERS = '10.3'
-# MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
-# LCGDIR = '#../lib/darwin-6.1-powerpc'
-# CC = 'gcc-3.3'
-# CXX = 'g++-3.3'
- MAC_MIN_VERS = '10.4'
- MACOSX_DEPLOYMENT_TARGET = '10.4'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
- LCGDIR = '#../lib/darwin-8.0.0-powerpc'
- CC = 'gcc-4.0'
- CXX = 'g++-4.0'
-elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4':
- MAC_MIN_VERS = '10.4'
- MACOSX_DEPLOYMENT_TARGET = '10.4'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
- LCGDIR = '#../lib/darwin-8.x.i386'
- CC = 'gcc-4.0'
- CXX = 'g++-4.0'
-else :
- if 'Mac OS X 10.5' in MACOSX_SDK_CHECK:
- # OSX 10.5/6 with Xcode 3.x
- MAC_MIN_VERS = '10.5'
- MACOSX_DEPLOYMENT_TARGET = '10.5'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc-4.2'
- CXX = 'g++-4.2'
- elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK:
- # OSX 10.6/7 with Xcode 4.x
- MAC_MIN_VERS = '10.6'
- MACOSX_DEPLOYMENT_TARGET = '10.6'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc-4.2'
- CXX = 'g++-4.2'
- else:
- # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! )
- MAC_MIN_VERS = '10.6'
- MACOSX_DEPLOYMENT_TARGET = '10.6'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.7.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc'
- CXX = 'g++'
-
-LIBDIR = '${LCGDIR}'
-
-if XCODE_CUR_VER >= '4.3': ## since version 4.3, XCode and developer dir are bundled ##
- MACOSX_SDK = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK
-
-#############################################################################
-################### Dependency settings ##################
-#############################################################################
-
-#Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
-# if your compiler does not have accurate suffix you may have to enable it by hand !
-if CC[:-2].endswith('4.6'):
- WITH_BF_OPENMP = True # multithreading for fluids, cloth, sculpt and smoke
-else:
- WITH_BF_OPENMP = False
-
-# enable ffmpeg support
-WITH_BF_FFMPEG = True
-BF_FFMPEG = LIBDIR + '/ffmpeg'
-BF_FFMPEG_INC = "${BF_FFMPEG}/include"
-BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
-BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2'
-#bz2 is a standard osx dynlib
-
-BF_PYTHON_VERSION = '3.3'
-WITH_OSX_STATICPYTHON = True
-
-if WITH_OSX_STATICPYTHON:
- # python 3.3 uses precompiled libraries in bf svn /lib by default
-
- BF_PYTHON = LIBDIR + '/python'
- BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
- # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
- BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m'
- BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
- # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
-else:
- # python 3.2 uses Python-framework additionally installed in /Library/Frameworks
-
- BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
- BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m'
- BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
- #BF_PYTHON_LIB = ''
- BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m'
-
-WITH_BF_OPENAL = True
-#different lib must be used following version of gcc
-# for gcc 3.3
-#BF_OPENAL = LIBDIR + '/openal'
-# for gcc 3.4 and ulterior
-if MAC_PROC == 'powerpc':
- BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal'
-else :
- BF_OPENAL = LIBDIR + '/openal'
-
-WITH_BF_STATICOPENAL = False
-BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!!
-#BF_OPENAL_LIB = 'openal'
-#BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-#BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
-
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-BF_CXX = '/usr'
-WITH_BF_STATICCXX = False
-BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
-
-# we use simply jack framework
-WITH_BF_JACK = True
-BF_JACK = '/Library/Frameworks/Jackmp.framework'
-BF_JACK_INC = '${BF_JACK}/headers'
-#BF_JACK_LIB = 'jack' # not used due framework
-BF_JACK_LIBPATH = '${BF_JACK}'
-
-WITH_BF_SNDFILE = True
-BF_SNDFILE = LIBDIR + '/sndfile'
-BF_SNDFILE_INC = '${BF_SNDFILE}/include'
-BF_SNDFILE_LIB = 'sndfile FLAC ogg vorbis vorbisenc'
-BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib ${BF_FFMPEG}/lib' #ogg libs are stored in ffmpeg dir
-
-WITH_BF_SDL = True
-BF_SDL = LIBDIR + '/sdl' #$(shell sdl-config --prefix)
-BF_SDL_INC = '${BF_SDL}/include' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
-BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
-BF_SDL_LIBPATH = '${BF_SDL}/lib'
-
-WITH_BF_OPENEXR = True
-WITH_BF_STATICOPENEXR = False
-BF_OPENEXR = '${LCGDIR}/openexr'
-BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/OpenEXR'
-BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread'
-BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
-
-WITH_BF_DDS = True
-
-#Color Management System
-WITH_BF_LCMS = False
-BF_LCMS = LIBDIR + '/lcms'
-BF_LCMS_INC = '${BF_LCMS}/include'
-BF_LCMS_LIB = 'lcms'
-BF_LCMS_LIBPATH = '${BF_LCMS}/lib'
-
-WITH_BF_JPEG = True
-BF_JPEG = LIBDIR + '/jpeg'
-BF_JPEG_INC = '${BF_JPEG}/include'
-BF_JPEG_LIB = 'jpeg'
-BF_JPEG_LIBPATH = '${BF_JPEG}/lib'
-
-WITH_BF_PNG = True
-BF_PNG = LIBDIR + '/png'
-BF_PNG_INC = '${BF_PNG}/include'
-BF_PNG_LIB = 'png'
-BF_PNG_LIBPATH = '${BF_PNG}/lib'
-
-WITH_BF_TIFF = True
-BF_TIFF = LIBDIR + '/tiff'
-BF_TIFF_INC = '${BF_TIFF}/include'
-BF_TIFF_LIB = 'tiff'
-BF_TIFF_LIBPATH = '${BF_TIFF}/lib'
-
-WITH_BF_ZLIB = True
-BF_ZLIB = '/usr'
-BF_ZLIB_INC = '${BF_ZLIB}/include'
-BF_ZLIB_LIB = 'z'
-
-WITH_BF_INTERNATIONAL = True
-
-WITH_BF_GAMEENGINE = True
-WITH_BF_PLAYER = True
-WITH_BF_OCEANSIM = True
-
-WITH_BF_BULLET = True
-BF_BULLET = '#extern/bullet2/src'
-BF_BULLET_INC = '${BF_BULLET}'
-BF_BULLET_LIB = 'extern_bullet'
-
-WITH_BF_FFTW3 = True
-BF_FFTW3 = LIBDIR + '/fftw3'
-BF_FFTW3_INC = '${BF_FFTW3}/include'
-BF_FFTW3_LIB = 'libfftw3'
-BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
-
-BF_FREETYPE = LIBDIR + '/freetype'
-BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
-BF_FREETYPE_LIB = 'freetype'
-BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
-
-WITH_BF_QUICKTIME = True
-
-WITH_BF_ICONV = True
-BF_ICONV = '/usr'
-BF_ICONV_INC = '${BF_ICONV}/include'
-BF_ICONV_LIB = 'iconv'
-#BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
-
-# Mesa Libs should go here if your using them as well....
-WITH_BF_STATICOPENGL = True
-BF_OPENGL_LIB = 'GL GLU'
-BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries'
-BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL']
-
-#OpenCollada flags
-WITH_BF_COLLADA = True
-BF_COLLADA = '#source/blender/collada'
-BF_COLLADA_INC = '${BF_COLLADA}'
-BF_COLLADA_LIB = 'bf_collada'
-BF_OPENCOLLADA = LIBDIR + '/opencollada'
-BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
-BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 buffer ftoa'
-BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada'
-BF_PCRE = LIBDIR + '/opencollada'
-BF_PCRE_LIB = 'pcre'
-BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
-#BF_EXPAT = '/usr'
-#BF_EXPAT_LIB = 'expat'
-#BF_EXPAT_LIBPATH = '/usr/lib'
-
-# Cycles
-WITH_BF_CYCLES = True
-
-#OSL
-
-WITH_BF_CYCLES_OSL = True
-BF_OSL = LIBDIR + '/osl'
-BF_OSL_INC = '${BF_OSL}/include'
-# note oslexec would passed via program linkflags, which is needed to
-# make llvm happy with osl_allocate_closure_component
-#BF_OSL_LIB = 'oslcomp oslquery'
-BF_OSL_LIBPATH = '${BF_OSL}/lib'
-BF_OSL_COMPILER = '${BF_OSL}/bin/oslc'
-
-WITH_BF_LLVM = True
-BF_LLVM = LIBDIR + '/llvm'
-BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \
- 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \
- 'LLVMTarget LLVMMC LLVMCore LLVMSupport'
-BF_LLVM_LIBPATH = '${BF_LLVM}/lib'
-
-WITH_BF_OIIO = True
-BF_OIIO = LIBDIR + '/openimageio'
-BF_OIIO_INC = '${BF_OIIO}/include'
-BF_OIIO_LIB = 'OpenImageIO'
-BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
-
-WITH_BF_OCIO = True
-BF_OCIO = LIBDIR + '/opencolorio'
-BF_OCIO_INC = '${BF_OCIO}/include'
-BF_OCIO_LIB = 'OpenColorIO tinyxml yaml-cpp'
-BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
-
-WITH_BF_BOOST = True
-BF_BOOST = LIBDIR + '/boost'
-BF_BOOST_INC = '${BF_BOOST}/include'
-BF_BOOST_LIB = 'boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt'
-BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mt'
-BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
-
WITH_BF_CYCLES_CUDA_BINARIES = True
-BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
-
-#Freestyle
-WITH_BF_FREESTYLE = True
-
-#Ray trace optimization
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386':
- WITH_BF_RAYOPTIMIZATION = True
-else:
- WITH_BF_RAYOPTIMIZATION = False
-if MACOSX_ARCHITECTURE == 'i386':
- BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
-elif MACOSX_ARCHITECTURE == 'x86_64':
- BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
-
-# SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later !
-WITH_BF_3DMOUSE = True
-
-#############################################################################
-################### various compile settings and flags ##################
-#############################################################################
-
-BF_QUIET = '1' # suppress verbose output
-
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
- ARCH_FLAGS = ['-m64']
-else:
- ARCH_FLAGS = ['-m32']
-
-CFLAGS = []
-CXXFLAGS = []
-CCFLAGS = ['-pipe','-funsigned-char']
-
-CPPFLAGS = list(ARCH_FLAGS)
-
-if WITH_GHOST_COCOA:
- PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
-else:
- PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
-
-if WITH_BF_QUICKTIME:
- if USE_QTKIT:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit']
- else:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
-
-if not WITH_OSX_STATICPYTHON:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python']
-
-
-#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4
-#for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore)
-if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"):
- LLIBS = ['stdc++']
-else:
- LLIBS = ['stdc++', 'SystemStubs']
-
-# some flags shuffling for different OS versions
-if MAC_MIN_VERS == '10.3':
- CCFLAGS = ['-fuse-cxa-atexit'] + CCFLAGS
- PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit'] + PLATFORM_LINKFLAGS
- LLIBS.append('crt3.o')
-
-if USE_SDK:
- SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE]
- PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS
- CCFLAGS=SDK_FLAGS+CCFLAGS
- CXXFLAGS=SDK_FLAGS+CXXFLAGS
-
-#Intel Macs are CoreDuo and Up
-if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64':
- REL_CFLAGS = []
- REL_CXXFLAGS = []
- REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse']
-else:
- CCFLAGS += ['-fno-strict-aliasing']
- REL_CFLAGS = []
- REL_CXXFLAGS = []
- REL_CCFLAGS = ['-DNDEBUG', '-O2']
-
-# Intel 64bit Macs are Core2Duo and up
-if MACOSX_ARCHITECTURE == 'x86_64':
- REL_CCFLAGS += ['-march=core2','-mssse3','-with-tune=core2','-enable-threads']
-
-CC_WARN = ['-Wall']
-C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
-CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
-
-##FIX_STUBS_WARNINGS = -Wno-unused
-
-##LOPTS = --dynamic
-##DYNLDFLAGS = -shared $(LDFLAGS)
-
-BF_PROFILE_CCFLAGS = ['-pg', '-g ']
-BF_PROFILE_LINKFLAGS = ['-pg']
-BF_PROFILE = False
-
-BF_DEBUG = False
-BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG']
-
-#############################################################################
-################### Output directories ##################
-#############################################################################
-BF_BUILDDIR='../build/darwin'
-BF_INSTALLDIR='../install/darwin'
diff --git a/build_files/buildbot/config/user-config-mac-x86_64.py b/build_files/buildbot/config/user-config-mac-x86_64.py
index fb0a084cf4d..2b12762f934 100644
--- a/build_files/buildbot/config/user-config-mac-x86_64.py
+++ b/build_files/buildbot/config/user-config-mac-x86_64.py
@@ -1,425 +1,2 @@
-#
-# Note : if you want to alter this file
-# copy it as a whole in the upper folder
-# as user-config.py
-# dont create a new file with only some
-# vars changed.
-
-import commands
-
-# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs
-USE_SDK=True
-
-#############################################################################
-################### Cocoa & architecture settings ##################
-#############################################################################
-WITH_GHOST_COCOA=True
MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64
-
-
-cmd = 'uname -p'
-MAC_PROC=commands.getoutput(cmd)
-cmd = 'uname -r'
-cmd_res=commands.getoutput(cmd)
-
-if cmd_res[:1]=='7':
- MAC_CUR_VER='10.3'
-elif cmd_res[:1]=='8':
- MAC_CUR_VER='10.4'
-elif cmd_res[:1]=='9':
- MAC_CUR_VER='10.5'
-elif cmd_res[:2]=='10':
- MAC_CUR_VER='10.6'
-elif cmd_res[:2]=='11':
- MAC_CUR_VER='10.7'
-elif cmd_res[:2]=='12':
- MAC_CUR_VER='10.8'
-elif cmd_res[:2]=='13':
- MAC_CUR_VER='10.9'
-cmd = 'xcodebuild -version'
-cmd_xcode=commands.getoutput(cmd)
-XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version
-cmd = 'xcodebuild -showsdks'
-cmd_sdk=commands.getoutput(cmd)
-MACOSX_SDK_CHECK=cmd_sdk
-
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
- USE_QTKIT=True # Carbon quicktime is not available for 64bit
-
-
-# Default target OSX settings per architecture
-# Can be customized
-
-if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4':
-# all releases are now made for 10.5 !
-# MAC_MIN_VERS = '10.3'
-# MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
-# LCGDIR = '#../lib/darwin-6.1-powerpc'
-# CC = 'gcc-3.3'
-# CXX = 'g++-3.3'
- MAC_MIN_VERS = '10.4'
- MACOSX_DEPLOYMENT_TARGET = '10.4'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
- LCGDIR = '#../lib/darwin-8.0.0-powerpc'
- CC = 'gcc-4.0'
- CXX = 'g++-4.0'
-elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4':
- MAC_MIN_VERS = '10.4'
- MACOSX_DEPLOYMENT_TARGET = '10.4'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
- LCGDIR = '#../lib/darwin-8.x.i386'
- CC = 'gcc-4.0'
- CXX = 'g++-4.0'
-else :
- if 'Mac OS X 10.5' in MACOSX_SDK_CHECK:
- # OSX 10.5/6 with Xcode 3.x
- MAC_MIN_VERS = '10.5'
- MACOSX_DEPLOYMENT_TARGET = '10.5'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc-4.2'
- CXX = 'g++-4.2'
- elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK:
- # OSX 10.6/7 with Xcode 4.x
- MAC_MIN_VERS = '10.6'
- MACOSX_DEPLOYMENT_TARGET = '10.6'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc-4.2'
- CXX = 'g++-4.2'
- else:
- # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! )
- MAC_MIN_VERS = '10.6'
- MACOSX_DEPLOYMENT_TARGET = '10.6'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.7.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc'
- CXX = 'g++'
-
-LIBDIR = '${LCGDIR}'
-
-if XCODE_CUR_VER >= '4.3': ## since version 4.3, XCode and developer dir are bundled ##
- MACOSX_SDK = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK
-
-#############################################################################
-################### Dependency settings ##################
-#############################################################################
-
-#Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
-# if your compiler does not have accurate suffix you may have to enable it by hand !
-if CC[:-2].endswith('4.6'):
- WITH_BF_OPENMP = True # multithreading for fluids, cloth, sculpt and smoke
-else:
- WITH_BF_OPENMP = False
-
-# enable ffmpeg support
-WITH_BF_FFMPEG = True
-BF_FFMPEG = LIBDIR + '/ffmpeg'
-BF_FFMPEG_INC = "${BF_FFMPEG}/include"
-BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
-BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2'
-#bz2 is a standard osx dynlib
-
-BF_PYTHON_VERSION = '3.3'
-WITH_OSX_STATICPYTHON = True
-
-if WITH_OSX_STATICPYTHON:
- # python 3.3 uses precompiled libraries in bf svn /lib by default
-
- BF_PYTHON = LIBDIR + '/python'
- BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
- # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
- BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m'
- BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
- # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
-else:
- # python 3.2 uses Python-framework additionally installed in /Library/Frameworks
-
- BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
- BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m'
- BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
- #BF_PYTHON_LIB = ''
- BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m'
-
-WITH_BF_OPENAL = True
-#different lib must be used following version of gcc
-# for gcc 3.3
-#BF_OPENAL = LIBDIR + '/openal'
-# for gcc 3.4 and ulterior
-if MAC_PROC == 'powerpc':
- BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal'
-else :
- BF_OPENAL = LIBDIR + '/openal'
-
-WITH_BF_STATICOPENAL = False
-BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!!
-#BF_OPENAL_LIB = 'openal'
-#BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-#BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
-
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-BF_CXX = '/usr'
-WITH_BF_STATICCXX = False
-BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
-
-# we use simply jack framework
-WITH_BF_JACK = True
-BF_JACK = '/Library/Frameworks/Jackmp.framework'
-BF_JACK_INC = '${BF_JACK}/headers'
-#BF_JACK_LIB = 'jack' # not used due framework
-BF_JACK_LIBPATH = '${BF_JACK}'
-
-WITH_BF_SNDFILE = True
-BF_SNDFILE = LIBDIR + '/sndfile'
-BF_SNDFILE_INC = '${BF_SNDFILE}/include'
-BF_SNDFILE_LIB = 'sndfile FLAC ogg vorbis vorbisenc'
-BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib ${BF_FFMPEG}/lib' #ogg libs are stored in ffmpeg dir
-
-WITH_BF_SDL = True
-BF_SDL = LIBDIR + '/sdl' #$(shell sdl-config --prefix)
-BF_SDL_INC = '${BF_SDL}/include' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
-BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
-BF_SDL_LIBPATH = '${BF_SDL}/lib'
-
-WITH_BF_OPENEXR = True
-WITH_BF_STATICOPENEXR = False
-BF_OPENEXR = '${LCGDIR}/openexr'
-BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/OpenEXR'
-BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread'
-BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
-
-WITH_BF_DDS = True
-
-#Color Management System
-WITH_BF_LCMS = False
-BF_LCMS = LIBDIR + '/lcms'
-BF_LCMS_INC = '${BF_LCMS}/include'
-BF_LCMS_LIB = 'lcms'
-BF_LCMS_LIBPATH = '${BF_LCMS}/lib'
-
-WITH_BF_JPEG = True
-BF_JPEG = LIBDIR + '/jpeg'
-BF_JPEG_INC = '${BF_JPEG}/include'
-BF_JPEG_LIB = 'jpeg'
-BF_JPEG_LIBPATH = '${BF_JPEG}/lib'
-
-WITH_BF_PNG = True
-BF_PNG = LIBDIR + '/png'
-BF_PNG_INC = '${BF_PNG}/include'
-BF_PNG_LIB = 'png'
-BF_PNG_LIBPATH = '${BF_PNG}/lib'
-
-WITH_BF_TIFF = True
-BF_TIFF = LIBDIR + '/tiff'
-BF_TIFF_INC = '${BF_TIFF}/include'
-BF_TIFF_LIB = 'tiff'
-BF_TIFF_LIBPATH = '${BF_TIFF}/lib'
-
-WITH_BF_ZLIB = True
-BF_ZLIB = '/usr'
-BF_ZLIB_INC = '${BF_ZLIB}/include'
-BF_ZLIB_LIB = 'z'
-
-WITH_BF_INTERNATIONAL = True
-
-WITH_BF_GAMEENGINE = True
-WITH_BF_PLAYER = True
-WITH_BF_OCEANSIM = True
-
-WITH_BF_BULLET = True
-BF_BULLET = '#extern/bullet2/src'
-BF_BULLET_INC = '${BF_BULLET}'
-BF_BULLET_LIB = 'extern_bullet'
-
-WITH_BF_FFTW3 = True
-BF_FFTW3 = LIBDIR + '/fftw3'
-BF_FFTW3_INC = '${BF_FFTW3}/include'
-BF_FFTW3_LIB = 'libfftw3'
-BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
-
-BF_FREETYPE = LIBDIR + '/freetype'
-BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
-BF_FREETYPE_LIB = 'freetype'
-BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
-
-WITH_BF_QUICKTIME = True
-
-WITH_BF_ICONV = True
-BF_ICONV = '/usr'
-BF_ICONV_INC = '${BF_ICONV}/include'
-BF_ICONV_LIB = 'iconv'
-#BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
-
-# Mesa Libs should go here if your using them as well....
-WITH_BF_STATICOPENGL = True
-BF_OPENGL_LIB = 'GL GLU'
-BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries'
-BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL']
-
-#OpenCollada flags
-WITH_BF_COLLADA = True
-BF_COLLADA = '#source/blender/collada'
-BF_COLLADA_INC = '${BF_COLLADA}'
-BF_COLLADA_LIB = 'bf_collada'
-BF_OPENCOLLADA = LIBDIR + '/opencollada'
-BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
-BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 buffer ftoa'
-BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada'
-BF_PCRE = LIBDIR + '/opencollada'
-BF_PCRE_LIB = 'pcre'
-BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
-#BF_EXPAT = '/usr'
-#BF_EXPAT_LIB = 'expat'
-#BF_EXPAT_LIBPATH = '/usr/lib'
-
-# Cycles
-WITH_BF_CYCLES = True
-
-#OSL
-
-WITH_BF_CYCLES_OSL = True
-BF_OSL = LIBDIR + '/osl'
-BF_OSL_INC = '${BF_OSL}/include'
-# note oslexec would passed via program linkflags, which is needed to
-# make llvm happy with osl_allocate_closure_component
-#BF_OSL_LIB = 'oslcomp oslquery'
-BF_OSL_LIBPATH = '${BF_OSL}/lib'
-BF_OSL_COMPILER = '${BF_OSL}/bin/oslc'
-
-WITH_BF_LLVM = True
-BF_LLVM = LIBDIR + '/llvm'
-BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \
- 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \
- 'LLVMTarget LLVMMC LLVMCore LLVMSupport'
-BF_LLVM_LIBPATH = '${BF_LLVM}/lib'
-
-WITH_BF_OIIO = True
-BF_OIIO = LIBDIR + '/openimageio'
-BF_OIIO_INC = '${BF_OIIO}/include'
-BF_OIIO_LIB = 'OpenImageIO'
-BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
-
-WITH_BF_OCIO = True
-BF_OCIO = LIBDIR + '/opencolorio'
-BF_OCIO_INC = '${BF_OCIO}/include'
-BF_OCIO_LIB = 'OpenColorIO tinyxml yaml-cpp'
-BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
-
-WITH_BF_BOOST = True
-BF_BOOST = LIBDIR + '/boost'
-BF_BOOST_INC = '${BF_BOOST}/include'
-BF_BOOST_LIB = 'boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt'
-BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mt'
-BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
-
-WITH_BF_CYCLES_CUDA_BINARIES = True
-BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
-
-#Freestyle
-WITH_BF_FREESTYLE = True
-
-#Ray trace optimization
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386':
- WITH_BF_RAYOPTIMIZATION = True
-else:
- WITH_BF_RAYOPTIMIZATION = False
-if MACOSX_ARCHITECTURE == 'i386':
- BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
-elif MACOSX_ARCHITECTURE == 'x86_64':
- BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
-
-# SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later !
-WITH_BF_3DMOUSE = True
-
-#############################################################################
-################### various compile settings and flags ##################
-#############################################################################
-
-BF_QUIET = '1' # suppress verbose output
-
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
- ARCH_FLAGS = ['-m64']
-else:
- ARCH_FLAGS = ['-m32']
-
-CFLAGS = []
-CXXFLAGS = []
-CCFLAGS = ['-pipe','-funsigned-char']
-
-CPPFLAGS = list(ARCH_FLAGS)
-
-if WITH_GHOST_COCOA:
- PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
-else:
- PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
-
-if WITH_BF_QUICKTIME:
- if USE_QTKIT:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit']
- else:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
-
-if not WITH_OSX_STATICPYTHON:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python']
-
-
-#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4
-#for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore)
-if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"):
- LLIBS = ['stdc++']
-else:
- LLIBS = ['stdc++', 'SystemStubs']
-
-# some flags shuffling for different OS versions
-if MAC_MIN_VERS == '10.3':
- CCFLAGS = ['-fuse-cxa-atexit'] + CCFLAGS
- PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit'] + PLATFORM_LINKFLAGS
- LLIBS.append('crt3.o')
-
-if USE_SDK:
- SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE]
- PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS
- CCFLAGS=SDK_FLAGS+CCFLAGS
- CXXFLAGS=SDK_FLAGS+CXXFLAGS
-
-#Intel Macs are CoreDuo and Up
-if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64':
- REL_CFLAGS = []
- REL_CXXFLAGS = []
- REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse']
-else:
- CCFLAGS += ['-fno-strict-aliasing']
- REL_CFLAGS = []
- REL_CXXFLAGS = []
- REL_CCFLAGS = ['-DNDEBUG', '-O2']
-
-# Intel 64bit Macs are Core2Duo and up
-if MACOSX_ARCHITECTURE == 'x86_64':
- REL_CCFLAGS += ['-march=core2','-mssse3','-with-tune=core2','-enable-threads']
-
-CC_WARN = ['-Wall']
-C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
-CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
-
-##FIX_STUBS_WARNINGS = -Wno-unused
-
-##LOPTS = --dynamic
-##DYNLDFLAGS = -shared $(LDFLAGS)
-
-BF_PROFILE_CCFLAGS = ['-pg', '-g ']
-BF_PROFILE_LINKFLAGS = ['-pg']
-BF_PROFILE = False
-
-BF_DEBUG = False
-BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG']
-
-#############################################################################
-################### Output directories ##################
-#############################################################################
-
-BF_BUILDDIR='../build/darwin'
-BF_INSTALLDIR='../install/darwin'
+WITH_BF_CYCLES_CUDA_BINARIES = True \ No newline at end of file
diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg
index 529b4e483b4..220fa08b23a 100644
--- a/build_files/buildbot/master.cfg
+++ b/build_files/buildbot/master.cfg
@@ -26,9 +26,10 @@ c['slavePortnum'] = 9989
# CHANGE SOURCES
from buildbot.changes.svnpoller import SVNPoller
+from buildbot.changes.gitpoller import GitPoller
-c['change_source'] = SVNPoller(
- 'https://svn.blender.org/svnroot/bf-blender/trunk/',
+c['change_source'] = GitPoller(
+ 'git://git.blender.org/blender.git',
pollinterval=1200)
# SCHEDULERS
@@ -70,6 +71,7 @@ for i in range(0, schedule_cycle):
from buildbot.process.factory import BuildFactory
from buildbot.steps.source import SVN
+from buildbot.steps.source import Git
from buildbot.steps.shell import ShellCommand
from buildbot.steps.shell import Compile
from buildbot.steps.shell import Test
@@ -100,12 +102,18 @@ def add_builder(c, name, libdir, factory, branch='', rsync=False, hour=3, minute
# common steps
+def git_submodule_step(submodule):
+ return Git(name=submodule+'.git', repourl='git://git.blender.org/' + submodule + '.git', mode='update', workdir=submodule + '.git')
-def svn_step(branch=''):
+def git_step(branch=''):
if branch:
- return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/branches/%%BRANCH%%', mode='update', defaultBranch=branch, workdir='blender')
+ return Git(name='blender.git', repourl='git://git.blender.org/blender.git', mode='update', branch=branch, workdir='blender.git', submodules=True)
else:
- return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender')
+ return Git(name='blender.git', repourl='git://git.blender.org/blender.git', mode='update', workdir='blender.git', submodules=True)
+
+def git_submodules_update():
+ command = ['git', 'submodule', 'foreach', '--recursive', 'git', 'pull', 'origin', 'master']
+ return ShellCommand(name='Submodules Update', command=command, description='updating', descriptionDone='up to date', workdir='blender.git')
def lib_svn_step(dir):
return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir)
@@ -118,14 +126,17 @@ def rsync_step(id, branch, rsync_script):
def generic_builder(id, libdir='', branch='', rsync=False):
filename = 'uploaded/buildbot_upload_' + id + '.zip'
- compile_script = '../blender/build_files/buildbot/slave_compile.py'
- test_script = '../blender/build_files/buildbot/slave_test.py'
- pack_script = '../blender/build_files/buildbot/slave_pack.py'
- rsync_script = '../blender/build_files/buildbot/slave_rsync.py'
+ compile_script = '../blender.git/build_files/buildbot/slave_compile.py'
+ test_script = '../blender.git/build_files/buildbot/slave_test.py'
+ pack_script = '../blender.git/build_files/buildbot/slave_pack.py'
+ rsync_script = '../blender.git/build_files/buildbot/slave_rsync.py'
unpack_script = 'master_unpack.py'
f = BuildFactory()
- f.addStep(svn_step(branch))
+ for submodule in ('blender-translations', 'blender-addons', 'blender-addons-contrib', 'scons'):
+ f.addStep(git_submodule_step(submodule))
+ f.addStep(git_step(branch))
+ f.addStep(git_submodules_update())
if libdir != '':
f.addStep(lib_svn_step(libdir))
@@ -149,6 +160,8 @@ add_builder(c, 'linux_glibc211_i386_scons', '', generic_builder, hour=1)
add_builder(c, 'linux_glibc211_x86_64_scons', '', generic_builder, hour=2)
add_builder(c, 'win32_scons', 'windows', generic_builder, hour=1)
add_builder(c, 'win64_scons', 'win64', generic_builder, hour=2)
+add_builder(c, 'win32_scons_vc2012', 'windows_vc11', generic_builder, hour=1)
+add_builder(c, 'win64_scons_vc2012', 'win64_vc11', generic_builder, hour=2)
#add_builder(c, 'mingw_win32_scons', 'mingw32', generic_builder, hour=4)
add_builder(c, 'mingw_win64_scons', 'mingw64', generic_builder, hour=3)
#add_builder(c, 'freebsd_i386_cmake', '', generic_builder, hour=1)
diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py
index f9aa45a4023..e45b4f1971f 100644
--- a/build_files/buildbot/slave_compile.py
+++ b/build_files/buildbot/slave_compile.py
@@ -31,7 +31,7 @@ if len(sys.argv) < 2:
builder = sys.argv[1]
# we run from build/ directory
-blender_dir = '../blender'
+blender_dir = '../blender.git'
if builder.find('cmake') != -1:
# cmake
diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py
index 3e8ae939dd5..b6e817b2e6f 100644
--- a/build_files/buildbot/slave_pack.py
+++ b/build_files/buildbot/slave_pack.py
@@ -40,7 +40,7 @@ if len(sys.argv) >= 3:
# scons does own packaging
if builder.find('scons') != -1:
- os.chdir('../blender')
+ os.chdir('../blender.git')
scons_options = ['BF_QUICK=slnt', 'BUILDBOT_BRANCH=' + branch, 'buildslave', 'BF_FANCY=False']
buildbot_dir = os.path.dirname(os.path.realpath(__file__))
diff --git a/build_files/buildbot/slave_test.py b/build_files/buildbot/slave_test.py
index d5acc8fd7a6..ef7a4b23d04 100644
--- a/build_files/buildbot/slave_test.py
+++ b/build_files/buildbot/slave_test.py
@@ -29,7 +29,7 @@ if len(sys.argv) < 2:
builder = sys.argv[1]
# we run from build/ directory
-blender_dir = '../blender'
+blender_dir = '../blender.git'
if "cmake" in builder:
# cmake
diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake
index e68015e36d3..2cc92df15e7 100644
--- a/build_files/cmake/buildinfo.cmake
+++ b/build_files/cmake/buildinfo.cmake
@@ -1,16 +1,57 @@
# This is called by cmake as an extermal process from
# ./source/creator/CMakeLists.txt to write ./source/creator/buildinfo.h
-# The FindSubversion.cmake module is part of the standard distribution
-include(FindSubversion)
-
# Extract working copy information for SOURCE_DIR into MY_XXX variables
# with a default in case anything fails, for examble when using git-svn
-set(MY_WC_REVISION "unknown")
+set(MY_WC_HASH "unknown")
+set(MY_WC_BRANCH "unknown")
+set(MY_WC_COMMIT_TIMESTAMP 0)
+
# Guess if this is a SVN working copy and then look up the revision
-if(EXISTS ${SOURCE_DIR}/.svn/)
- if(Subversion_FOUND)
- Subversion_WC_INFO(${SOURCE_DIR} MY)
+if(EXISTS ${SOURCE_DIR}/.git/)
+ # The FindSubversion.cmake module is part of the standard distribution
+ include(FindGit)
+ if(GIT_FOUND)
+ execute_process(COMMAND git rev-parse --short HEAD
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ OUTPUT_VARIABLE MY_WC_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND git rev-parse --abbrev-ref HEAD
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ OUTPUT_VARIABLE MY_WC_BRANCH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND git log -1 --format=%ct
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ # Update GIT index before getting dirty files
+ execute_process(COMMAND git update-index -q --refresh
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND git diff-index --name-only HEAD --
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ OUTPUT_VARIABLE _git_changed_files
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(NOT _git_changed_files STREQUAL "")
+ set(MY_WC_BRANCH "${MY_WC_BRANCH} (modified)")
+ else()
+ # Unpushed commits are also considered local odifications
+ execute_process(COMMAND git log @{u}..
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ OUTPUT_VARIABLE _git_unpushed_log
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(NOT _git_unpushed_log STREQUAL "")
+ set(MY_WC_BRANCH "${MY_WC_BRANCH} (modified)")
+ endif()
+ unset(_git_unpushed_log)
+ endif()
+
+ unset(_git_changed_files)
endif()
endif()
@@ -27,7 +68,9 @@ endif()
# Write a file with the SVNVERSION define
file(WRITE buildinfo.h.txt
- "#define BUILD_REV \"${MY_WC_REVISION}\"\n"
+ "#define BUILD_HASH \"${MY_WC_HASH}\"\n"
+ "#define BUILD_COMMIT_TIMESTAMP ${MY_WC_COMMIT_TIMESTAMP}\n"
+ "#define BUILD_BRANCH \"${MY_WC_BRANCH}\"\n"
"#define BUILD_DATE \"${BUILD_DATE}\"\n"
"#define BUILD_TIME \"${BUILD_TIME}\"\n"
)
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 9ded803f45b..e7e88ad5703 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -48,6 +48,24 @@ macro(list_insert_before
unset(_index)
endmacro()
+function (list_assert_duplicates
+ list_id
+ )
+
+ # message(STATUS "list data: ${list_id}")
+
+ list(LENGTH list_id _len_before)
+ list(REMOVE_DUPLICATES list_id)
+ list(LENGTH list_id _len_after)
+ # message(STATUS "list size ${_len_before} -> ${_len_after}")
+ if(NOT _len_before EQUAL _len_after)
+ message(FATAL_ERROR "duplicate found in list which should not contain duplicates: ${list_id}")
+ endif()
+ unset(_len_before)
+ unset(_len_after)
+endfunction()
+
+
# foo_bar.spam --> foo_barMySuffix.spam
macro(file_suffix
file_name_new file_name file_suffix
@@ -177,6 +195,11 @@ macro(blender_add_lib_nolist
# listed is helpful for IDE's (QtCreator/MSVC)
blender_source_group("${sources}")
+ list_assert_duplicates("${sources}")
+ list_assert_duplicates("${includes}")
+ # Not for system includes because they can resolve to the same path
+ # list_assert_duplicates("${includes_sys}")
+
endmacro()
@@ -847,3 +870,31 @@ macro(svg_to_png
unset(_file_to)
endmacro()
+
+macro(msgfmt_simple
+ file_from
+ list_to_add)
+
+ # remove ../'s
+ get_filename_component(_file_from_we ${file_from} NAME_WE)
+
+ get_filename_component(_file_from ${file_from} REALPATH)
+ get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${_file_from_we}.mo REALPATH)
+
+ list(APPEND ${list_to_add} ${_file_to})
+
+ get_filename_component(_file_to_path ${_file_to} PATH)
+
+ add_custom_command(
+ OUTPUT ${_file_to}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
+ COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/msgfmt ${_file_from} ${_file_to}
+ DEPENDS msgfmt)
+
+ set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)
+
+ unset(_file_from_we)
+ unset(_file_from)
+ unset(_file_to)
+ unset(_file_to_path)
+endmacro()
diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py
index 5a1069618b9..09dc32f082a 100644
--- a/build_files/scons/config/darwin-config.py
+++ b/build_files/scons/config/darwin-config.py
@@ -1,123 +1,23 @@
-#
-# Note : if you want to alter this file
-# copy it as a whole in the upper folder
-# as user-config.py
-# dont create a new file with only some
-# vars changed.
-
import commands
-# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs
-USE_SDK=True
-
#############################################################################
-################### Cocoa & architecture settings ##################
+################### Compiler & architecture settings ##################
#############################################################################
-WITH_GHOST_COCOA=True
-MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64
-
-
-cmd = 'uname -p'
-MAC_PROC=commands.getoutput(cmd)
-cmd = 'uname -r'
-cmd_res=commands.getoutput(cmd)
-
-if cmd_res[:1]=='7':
- MAC_CUR_VER='10.3'
-elif cmd_res[:1]=='8':
- MAC_CUR_VER='10.4'
-elif cmd_res[:1]=='9':
- MAC_CUR_VER='10.5'
-elif cmd_res[:2]=='10':
- MAC_CUR_VER='10.6'
-elif cmd_res[:2]=='11':
- MAC_CUR_VER='10.7'
-elif cmd_res[:2]=='12':
- MAC_CUR_VER='10.8'
-elif cmd_res[:2]=='13':
- MAC_CUR_VER='10.9'
-cmd = 'xcodebuild -version'
-cmd_xcode=commands.getoutput(cmd)
-XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version
-cmd = 'xcodebuild -showsdks'
-cmd_sdk=commands.getoutput(cmd)
-MACOSX_SDK_CHECK=cmd_sdk
-cmd = 'xcode-select --print-path'
-XCODE_SELECT_PATH=commands.getoutput(cmd)
-if XCODE_SELECT_PATH.endswith("/Contents/Developer"):
- XCODE_BUNDLE=XCODE_SELECT_PATH[:-19]
-else:
- XCODE_BUNDLE=XCODE_SELECT_PATH
-
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
- USE_QTKIT=True # Carbon quicktime is not available for 64bit
-
-
-# Default target OSX settings per architecture
-# Can be customized
-
-if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4':
-# all releases are now made for 10.5 !
-# MAC_MIN_VERS = '10.3'
-# MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
-# LCGDIR = '#../lib/darwin-6.1-powerpc'
-# CC = 'gcc-3.3'
-# CXX = 'g++-3.3'
- MAC_MIN_VERS = '10.4'
- MACOSX_DEPLOYMENT_TARGET = '10.4'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
- LCGDIR = '#../lib/darwin-8.0.0-powerpc'
- CC = 'gcc-4.0'
- CXX = 'g++-4.0'
-elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4':
- MAC_MIN_VERS = '10.4'
- MACOSX_DEPLOYMENT_TARGET = '10.4'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
- LCGDIR = '#../lib/darwin-8.x.i386'
- CC = 'gcc-4.0'
- CXX = 'g++-4.0'
-else :
- if 'Mac OS X 10.5' in MACOSX_SDK_CHECK:
- # OSX 10.5/6 with Xcode 3.x
- MAC_MIN_VERS = '10.5'
- MACOSX_DEPLOYMENT_TARGET = '10.5'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc-4.2'
- CXX = 'g++-4.2'
- elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK:
- # OSX 10.6/7 with Xcode 4.x
- MAC_MIN_VERS = '10.6'
- MACOSX_DEPLOYMENT_TARGET = '10.6'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc-4.2'
- CXX = 'g++-4.2'
- else:
- # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! )
- MAC_MIN_VERS = '10.6'
- MACOSX_DEPLOYMENT_TARGET = '10.6'
- MACOSX_SDK='/Developer/SDKs/MacOSX10.7.sdk'
- LCGDIR = '#../lib/darwin-9.x.universal'
- CC = 'gcc'
- CXX = 'g++'
-LIBDIR = '${LCGDIR}'
+MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64
+MACOSX_SDK='' # set an sdk name like '10.7' or leave empty for automatic choosing highest available
+MACOSX_DEPLOYMENT_TARGET = '10.6'
-if XCODE_CUR_VER >= '4.3': ## since version 4.3, XCode and developer dir are bundled ##
- MACOSX_SDK = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK
+# gcc always defaults to the system standard compiler linked by a shim or symlink
+CC = 'gcc'
+CXX = 'g++'
+LCGDIR = '#../lib/darwin-9.x.universal'
+LIBDIR = '${LCGDIR}'
#############################################################################
################### Dependency settings ##################
#############################################################################
-#Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
-# if your compiler does not have accurate suffix you may have to enable it by hand !
-if CC[:-2].endswith('4.6') or CC[:-2].endswith('4.8'):
- WITH_BF_OPENMP = True # multithreading for fluids, cloth, sculpt and smoke
-else:
- WITH_BF_OPENMP = False
-
# enable ffmpeg support
WITH_BF_FFMPEG = True
BF_FFMPEG = LIBDIR + '/ffmpeg'
@@ -129,33 +29,16 @@ BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore
BF_PYTHON_VERSION = '3.3'
WITH_OSX_STATICPYTHON = True
-if WITH_OSX_STATICPYTHON:
- # python 3.3 uses precompiled libraries in bf svn /lib by default
-
- BF_PYTHON = LIBDIR + '/python'
- BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
- # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
- BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m'
- BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
- # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
-else:
- # python 3.2 uses Python-framework additionally installed in /Library/Frameworks
-
- BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
- BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m'
- BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
- #BF_PYTHON_LIB = ''
- BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m'
+# python 3.3 uses precompiled libraries in bf svn /lib by default
+BF_PYTHON = LIBDIR + '/python'
+BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
+# BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
+BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m'
+BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
+# BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
WITH_BF_OPENAL = True
-#different lib must be used following version of gcc
-# for gcc 3.3
-#BF_OPENAL = LIBDIR + '/openal'
-# for gcc 3.4 and ulterior
-if MAC_PROC == 'powerpc':
- BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal'
-else :
- BF_OPENAL = LIBDIR + '/openal'
+BF_OPENAL = LIBDIR + '/openal'
WITH_BF_STATICOPENAL = False
BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!!
@@ -328,15 +211,12 @@ BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
#Freestyle
WITH_BF_FREESTYLE = True
+#OpenMP ( will be checked for compiler support and turned off eventually )
+WITH_BF_OPENMP = True
+
#Ray trace optimization
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386':
- WITH_BF_RAYOPTIMIZATION = True
-else:
- WITH_BF_RAYOPTIMIZATION = False
-if MACOSX_ARCHITECTURE == 'i386':
- BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
-elif MACOSX_ARCHITECTURE == 'x86_64':
- BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
+WITH_BF_RAYOPTIMIZATION = True
+BF_RAYOPTIMIZATION_SSE_FLAGS = []
# SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later !
WITH_BF_3DMOUSE = True
@@ -347,66 +227,18 @@ WITH_BF_3DMOUSE = True
BF_QUIET = '1' # suppress verbose output
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
- ARCH_FLAGS = ['-m64']
-else:
- ARCH_FLAGS = ['-m32']
-
CFLAGS = []
CXXFLAGS = []
CCFLAGS = ['-pipe','-funsigned-char']
+CPPFLAGS = []
+
+PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']
+LLIBS = ['stdc++']
-CPPFLAGS = list(ARCH_FLAGS)
-
-if WITH_GHOST_COCOA:
- PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
-else:
- PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
-
-if WITH_BF_QUICKTIME:
- if USE_QTKIT:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit']
- else:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
-
-if not WITH_OSX_STATICPYTHON:
- PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python']
-
-
-#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4
-#for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore)
-if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"):
- LLIBS = ['stdc++']
-else:
- LLIBS = ['stdc++', 'SystemStubs']
-
-# some flags shuffling for different OS versions
-if MAC_MIN_VERS == '10.3':
- CCFLAGS = ['-fuse-cxa-atexit'] + CCFLAGS
- PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit'] + PLATFORM_LINKFLAGS
- LLIBS.append('crt3.o')
-
-if USE_SDK:
- SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE]
- PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS
- CCFLAGS=SDK_FLAGS+CCFLAGS
- CXXFLAGS=SDK_FLAGS+CXXFLAGS
-
-#Intel Macs are CoreDuo and Up
-if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64':
- REL_CFLAGS = []
- REL_CXXFLAGS = []
- REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse']
-else:
- CCFLAGS += ['-fno-strict-aliasing']
- REL_CFLAGS = []
- REL_CXXFLAGS = []
- REL_CCFLAGS = ['-DNDEBUG', '-O2']
-
-# Intel 64bit Macs are Core2Duo and up
-if MACOSX_ARCHITECTURE == 'x86_64':
- REL_CCFLAGS += ['-march=core2','-mssse3','-with-tune=core2','-enable-threads']
+REL_CFLAGS = []
+REL_CXXFLAGS = []
+REL_CCFLAGS = ['-DNDEBUG', '-O2']
CC_WARN = ['-Wall']
C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
diff --git a/build_files/scons/config/freebsd8-config.py b/build_files/scons/config/freebsd8-config.py
index e94f61f7819..b7c6fed45c2 100644
--- a/build_files/scons/config/freebsd8-config.py
+++ b/build_files/scons/config/freebsd8-config.py
@@ -90,11 +90,6 @@ BF_FREETYPE = '/usr/local'
BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
-### XXX Find what this actually wants; it doesn't want libquicktime.
-WITH_BF_QUICKTIME = False
-BF_QUICKTIME = '/usr/local'
-BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
-
WITH_BF_ICONV = True
BF_ICONV = LIBDIR + "/iconv"
BF_ICONV_INC = '${BF_ICONV}/include'
diff --git a/build_files/scons/config/linux-config.py b/build_files/scons/config/linux-config.py
index 93fa6137bb0..743131ab32e 100644
--- a/build_files/scons/config/linux-config.py
+++ b/build_files/scons/config/linux-config.py
@@ -100,10 +100,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
#BF_FREETYPE_LIB_STATIC = '${BF_FREETYPE}/lib/libfreetype.a'
-WITH_BF_QUICKTIME = False
-BF_QUICKTIME = '/usr/local'
-BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
-
WITH_BF_ICONV = False
BF_ICONV = "/usr"
BF_ICONV_INC = '${BF_ICONV}/include'
diff --git a/build_files/scons/config/linuxcross-config.py b/build_files/scons/config/linuxcross-config.py
index 5b958420f37..36b29a309af 100644
--- a/build_files/scons/config/linuxcross-config.py
+++ b/build_files/scons/config/linuxcross-config.py
@@ -101,10 +101,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
-WITH_BF_QUICKTIME = False
-BF_QUICKTIME = '/usr/local'
-BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
-
WITH_BF_ICONV = False
BF_ICONV = LIBDIR + "/gcc/iconv"
BF_ICONV_INC = '${BF_ICONV}/include'
diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py
index d71feb8d2e9..213efcbb2df 100644
--- a/build_files/scons/config/win32-mingw-config.py
+++ b/build_files/scons/config/win32-mingw-config.py
@@ -112,10 +112,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
-WITH_BF_QUICKTIME = False
-BF_QUICKTIME = '/usr/local'
-BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
-
WITH_BF_ICONV = False
BF_ICONV = LIBDIR + "/iconv"
BF_ICONV_INC = '${BF_ICONV}/include'
diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py
index f1597a66538..4eb6416ad59 100644
--- a/build_files/scons/config/win32-vc-config.py
+++ b/build_files/scons/config/win32-vc-config.py
@@ -133,12 +133,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype2ST'
BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
-WITH_BF_QUICKTIME = False
-BF_QUICKTIME = LIBDIR + '/QTDevWin'
-BF_QUICKTIME_INC = '${BF_QUICKTIME}/CIncludes'
-BF_QUICKTIME_LIB = 'qtmlClient'
-BF_QUICKTIME_LIBPATH = '${BF_QUICKTIME}/Libraries'
-
WITH_BF_OPENJPEG = True
BF_OPENJPEG = '#extern/libopenjpeg'
BF_OPENJPEG_LIB = ''
diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py
index e82b6e8a73f..bb55354d591 100644
--- a/build_files/scons/config/win64-mingw-config.py
+++ b/build_files/scons/config/win64-mingw-config.py
@@ -111,8 +111,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2/'
BF_FREETYPE_LIB = 'freetype'
BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
-WITH_BF_QUICKTIME = False
-
WITH_BF_ICONV = False
BF_ICONV = LIBDIR + "/iconv"
BF_ICONV_INC = '${BF_ICONV}/include'
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index f181f290104..894c8dbca25 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -410,9 +410,38 @@ def buildinfo(lenv, build_type):
"""
build_date = time.strftime ("%Y-%m-%d")
build_time = time.strftime ("%H:%M:%S")
- build_rev = os.popen('svnversion').read()[:-1] # remove \n
- if build_rev == '':
- build_rev = '-UNKNOWN-'
+
+ if os.path.isdir(os.path.abspath('.git')):
+ build_commit_timestamp = os.popen('git log -1 --format=%ct').read().strip()
+ if not build_commit_timestamp:
+ # Git command not found
+ build_hash = 'unknown'
+ build_commit_timestamp = '0'
+ build_branch = 'unknown'
+ else:
+ build_hash = os.popen('git rev-parse --short HEAD').read().strip()
+ build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip()
+
+ # ## Check for local modifications
+ has_local_changes = False
+
+ # Update GIT index before getting dirty files
+ os.system('git update-index -q --refresh')
+ changed_files = os.popen('git diff-index --name-only HEAD --').read().strip()
+
+ if changed_files:
+ has_local_changes = True
+ else:
+ unpushed_log = os.popen('git log @{u}..').read().strip()
+ has_local_changes = unpushed_log != ''
+
+ if has_local_changes:
+ build_branch += ' (modified)'
+ else:
+ build_hash = 'unknown'
+ build_commit_timestamp = '0'
+ build_branch = 'unknown'
+
if lenv['BF_DEBUG']:
build_type = "Debug"
build_cflags = ' '.join(lenv['CFLAGS'] + lenv['CCFLAGS'] + lenv['BF_DEBUG_CCFLAGS'] + lenv['CPPFLAGS'])
@@ -429,7 +458,9 @@ def buildinfo(lenv, build_type):
lenv.Append (CPPDEFINES = ['BUILD_TIME=\\"%s\\"'%(build_time),
'BUILD_DATE=\\"%s\\"'%(build_date),
'BUILD_TYPE=\\"%s\\"'%(build_type),
- 'BUILD_REV=\\"%s\\"'%(build_rev),
+ 'BUILD_HASH=\\"%s\\"'%(build_hash),
+ 'BUILD_COMMIT_TIMESTAMP=%s'%(build_commit_timestamp),
+ 'BUILD_BRANCH=\\"%s\\"'%(build_branch),
'WITH_BUILDINFO',
'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]),
'BUILD_CFLAGS=\\"%s\\"'%(build_cflags),
@@ -626,13 +657,19 @@ def AppIt(target=None, source=None, env=None):
if binary == 'blender':
cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles'%(installdir, binary, VERSION)
commands.getoutput(cmd)
- cmd = 'cp -R %s/release/datafiles/locale %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION)
- commands.getoutput(cmd)
cmd = 'cp -R %s/release/datafiles/fonts %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION)
commands.getoutput(cmd)
+ cmd = 'cp -R %s/release/datafiles/locale/languages %s/%s.app/Contents/MacOS/%s/datafiles/locale/'%(bldroot, installdir, binary, VERSION)
+ commands.getoutput(cmd)
+ mo_dir = os.path.join(builddir[:-4], "locale")
+ for f in os.listdir(mo_dir):
+ cmd = 'ditto %s/%s %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s/LC_MESSAGES/blender.mo'%(mo_dir, f, installdir, binary, VERSION, f[:-3])
+ commands.getoutput(cmd)
+
if env['WITH_BF_OCIO']:
cmd = 'cp -R %s/release/datafiles/colormanagement %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION)
commands.getoutput(cmd)
+
cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION)
commands.getoutput(cmd)
@@ -683,9 +720,8 @@ def AppIt(target=None, source=None, env=None):
commands.getoutput(cmd)
cmd = 'find %s/%s.app -name __MACOSX -exec rm -rf {} \;'%(installdir, binary)
commands.getoutput(cmd)
- if env['CC'][:-2].endswith('4.6') or env['CC'][:-2].endswith('4.8'): # for correct errorhandling with gcc 4.6/4.8.x we need the gcc.dylib and gomp.dylib to link, thus distribute in app-bundle
- cmd = 'mkdir %s/%s.app/Contents/MacOS/lib'%(installdir, binary)
- commands.getoutput(cmd)
+ if env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1': # for correct errorhandling with gcc <= 4.6.1 we need the gcc.dylib and gomp.dylib to link, thus distribute in app-bundle
+ print "Bundling libgcc and libgomp"
instname = env['BF_CXX']
cmd = 'ditto --arch %s %s/lib/libgcc_s.1.dylib %s/%s.app/Contents/MacOS/lib/'%(osxarch, instname, installdir, binary) # copy libgcc
commands.getoutput(cmd)
diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py
index 8f0d3ff590b..f7a5eb8cf06 100644
--- a/build_files/scons/tools/btools.py
+++ b/build_files/scons/tools/btools.py
@@ -55,12 +55,12 @@ def get_version():
raise Exception("%s: missing version string" % fname)
-def get_revision():
- build_rev = os.popen('svnversion').read()[:-1] # remove \n
- if build_rev == '' or build_rev==None:
- build_rev = 'UNKNOWN'
+def get_hash():
+ build_hash = os.popen('git rev-parse --short HEAD').read().strip()
+ if build_hash == '' or build_hash == None:
+ build_hash = 'UNKNOWN'
- return 'r' + build_rev
+ return build_hash
# copied from: http://www.scons.org/wiki/AutoconfRecipes
@@ -80,7 +80,7 @@ def checkEndian():
# This is used in creating the local config directories
VERSION, VERSION_DISPLAY, VERSION_RELEASE_CYCLE = get_version()
-REVISION = get_revision()
+HASH = get_hash()
ENDIAN = checkEndian()
@@ -138,13 +138,11 @@ def validate_arguments(args, bc):
'WITHOUT_BF_PYTHON_INSTALL', 'WITHOUT_BF_PYTHON_UNPACK', 'WITH_BF_PYTHON_INSTALL_NUMPY',
'WITHOUT_BF_OVERWRITE_INSTALL',
'WITH_BF_OPENMP', 'BF_OPENMP', 'BF_OPENMP_LIBPATH', 'WITH_BF_STATICOPENMP', 'BF_OPENMP_STATIC_STATIC',
- 'WITH_GHOST_COCOA',
'WITH_GHOST_SDL',
'WITH_GHOST_XDND',
'WITH_X11_XINPUT',
'WITH_X11_XF86VMODE',
'BF_GHOST_DEBUG',
- 'USE_QTKIT',
'BF_FANCY', 'BF_QUIET', 'BF_LINE_OVERWRITE',
'BF_X264_CONFIG',
'BF_XVIDCORE_CONFIG',
@@ -181,7 +179,7 @@ def validate_arguments(args, bc):
'BF_PROFILE_CFLAGS', 'BF_PROFILE_CCFLAGS', 'BF_PROFILE_CXXFLAGS', 'BF_PROFILE_LINKFLAGS',
'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS',
'C_WARN', 'CC_WARN', 'CXX_WARN',
- 'LLIBS', 'PLATFORM_LINKFLAGS','MACOSX_ARCHITECTURE', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER',
+ 'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'XCODE_CUR_VER',
'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET'
]
@@ -424,11 +422,9 @@ def read_opts(env, cfg, args):
('BF_OPENMP', 'Base path to OpenMP (used when cross-compiling with older versions of WinGW)', ''),
('BF_OPENMP_INC', 'Path to OpenMP includes (used when cross-compiling with older versions of WinGW)', ''),
('BF_OPENMP_LIBPATH', 'Path to OpenMP libraries (used when cross-compiling with older versions of WinGW)', ''),
- (BoolVariable('WITH_GHOST_COCOA', 'Use Cocoa-framework if true', False)),
(BoolVariable('WITH_GHOST_SDL', 'Enable building blender against SDL for windowing rather then the native APIs', False)),
(BoolVariable('WITH_X11_XINPUT', 'Enable X11 Xinput (tablet support and unicode input)', True)),
(BoolVariable('WITH_X11_XF86VMODE', 'Enable X11 video mode switching', True)),
- (BoolVariable('USE_QTKIT', 'Use QTKIT if true', False)),
('BF_OPENMP_LIB_STATIC', 'OpenMP static library', ''),
(BoolVariable('WITH_BF_QUICKTIME', 'Use QuickTime if true', False)),
@@ -505,7 +501,7 @@ def read_opts(env, cfg, args):
('LLIBS', 'Platform libs', []),
('PLATFORM_LINKFLAGS', 'Platform linkflags', []),
('MACOSX_ARCHITECTURE', 'python_arch.zip select', ''),
- ('MACOSX_SDK_CHECK', 'Detect available OS X SDK`s', ''),
+ ('MACOSX_SDK', 'Set OS X SDK', ''),
('XCODE_CUR_VER', 'Detect XCode version', ''),
('MACOSX_DEPLOYMENT_TARGET', 'Detect OS X target version', ''),
@@ -697,7 +693,7 @@ def buildslave(target=None, source=None, env=None):
branch = env['BUILDBOT_BRANCH']
outdir = os.path.abspath(env['BF_INSTALLDIR'])
- package_name = 'blender-' + VERSION+'-'+REVISION + '-' + platform
+ package_name = 'blender-' + VERSION+'-'+HASH + '-' + platform
if branch != '':
package_name = branch + '-' + package_name
package_dir = os.path.normpath(outdir + os.sep + '..' + os.sep + package_name)
diff --git a/doc/license/GPL3-license.txt b/doc/license/GPL3-license.txt
new file mode 100644
index 00000000000..94a9ed024d3
--- /dev/null
+++ b/doc/license/GPL3-license.txt
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py b/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py
index df591521440..8d2e101be5f 100644
--- a/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py
+++ b/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py
@@ -1,6 +1,4 @@
"""
-Popup Menus
-+++++++++++
Popup menus can be useful for creating menus without having to register menu classes.
Note that they will not block the scripts execution, so the caller can't wait for user input.
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index e661bb01e60..e95fa6fef35 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -466,7 +466,9 @@ ClassMethodDescriptorType = type(dict.__dict__['fromkeys'])
MethodDescriptorType = type(dict.get)
GetSetDescriptorType = type(int.real)
StaticMethodType = type(staticmethod(lambda: None))
-from types import MemberDescriptorType
+from types import (MemberDescriptorType,
+ MethodType,
+ )
_BPY_STRUCT_FAKE = "bpy_struct"
_BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection"
@@ -629,12 +631,12 @@ def pymethod2sphinx(ident, fw, identifier, py_func):
fw("\n")
-def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True):
+def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_class=True):
'''
function or class method to sphinx
'''
- if type(py_func) == type(bpy.types.Space.draw_handler_add):
+ if type(py_func) == MethodType:
return
arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
@@ -657,6 +659,11 @@ def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True):
write_indented_lines(ident + " ", fw, py_func.__doc__)
fw("\n")
+ if is_class:
+ write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier)
+ else:
+ write_example_ref(ident + " ", fw, module_name + "." + identifier)
+
def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier):
if identifier.startswith("_"):
@@ -867,7 +874,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
for attribute, value, value_type in module_dir_value_type:
if value_type == types.FunctionType:
- pyfunc2sphinx("", fw, attribute, value, is_class=False)
+ pyfunc2sphinx("", fw, module_name, None, attribute, value, is_class=False)
elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof
# note: can't get args from these, so dump the string as is
# this means any module used like this must have fully formatted docstrings.
@@ -1316,7 +1323,7 @@ def pyrna2sphinx(basepath):
py_func = None
for identifier, py_func in py_funcs:
- pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True)
+ pyfunc2sphinx(" ", fw, "bpy.types", struct_id, identifier, py_func, is_class=True)
del py_funcs, py_func
py_funcs = struct.get_py_c_functions()
diff --git a/extern/bullet2/CMakeLists.txt b/extern/bullet2/CMakeLists.txt
index 02ca2cd3755..2b2c18c0685 100644
--- a/extern/bullet2/CMakeLists.txt
+++ b/extern/bullet2/CMakeLists.txt
@@ -67,6 +67,8 @@ set(SRC
src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
src/BulletCollision/CollisionDispatch/btUnionFind.cpp
src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp
+ src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp
+ src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp
src/BulletCollision/CollisionShapes/btBoxShape.cpp
src/BulletCollision/CollisionShapes/btBox2dShape.cpp
src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
@@ -140,6 +142,7 @@ set(SRC
src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp
src/BulletDynamics/ConstraintSolver/btGearConstraint.cpp
+ src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp
src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
src/BulletDynamics/Dynamics/btRigidBody.cpp
src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
@@ -147,6 +150,15 @@ set(SRC
src/BulletDynamics/Vehicle/btRaycastVehicle.cpp
src/BulletDynamics/Vehicle/btWheelInfo.cpp
src/BulletDynamics/Character/btKinematicCharacterController.cpp
+ src/BulletDynamics/Featherstone/btMultiBody.cpp
+ src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
+ src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp
+ src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
+ src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp
+ src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
+ src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp
+ src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp
+ src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
src/BulletSoftBody/btSoftBody.cpp
src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp
@@ -204,6 +216,8 @@ set(SRC
src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h
src/BulletCollision/CollisionDispatch/btUnionFind.h
src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h
+ src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h
+ src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h
src/BulletCollision/CollisionShapes/btBoxShape.h
src/BulletCollision/CollisionShapes/btBox2dShape.h
src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
@@ -308,6 +322,7 @@ set(SRC
src/BulletDynamics/ConstraintSolver/btTypedConstraint.h
src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h
src/BulletDynamics/ConstraintSolver/btGearConstraint.h
+ src/BulletDynamics/ConstraintSolver/btFixedConstraint.h
src/BulletDynamics/Dynamics/btActionInterface.h
src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
src/BulletDynamics/Dynamics/btDynamicsWorld.h
@@ -318,6 +333,22 @@ set(SRC
src/BulletDynamics/Vehicle/btWheelInfo.h
src/BulletDynamics/Character/btCharacterControllerInterface.h
src/BulletDynamics/Character/btKinematicCharacterController.h
+ src/BulletDynamics/Featherstone/btMultiBody.h
+ src/BulletDynamics/Featherstone/btMultiBodyConstraint.h
+ src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h
+ src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h
+ src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h
+ src/BulletDynamics/Featherstone/btMultiBodyJointMotor.h
+ src/BulletDynamics/Featherstone/btMultiBodyLink.h
+ src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h
+ src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h
+ src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h
+ src/BulletDynamics/MLCPSolvers/btDantzigLCP.h
+ src/BulletDynamics/MLCPSolvers/btDantzigSolver.h
+ src/BulletDynamics/MLCPSolvers/btMLCPSolver.h
+ src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h
+ src/BulletDynamics/MLCPSolvers/btPATHSolver.h
+ src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h
src/BulletSoftBody/btSoftBody.h
src/BulletSoftBody/btSoftBodyInternals.h
@@ -359,6 +390,7 @@ set(SRC
src/LinearMath/btTransformUtil.h
src/LinearMath/btVector3.h
src/LinearMath/btPolarDecomposition.h
+ src/LinearMath/btMatrixX.h
src/btBulletCollisionCommon.h
diff --git a/extern/bullet2/patches/ghost_character.patch b/extern/bullet2/patches/ghost_character.patch
deleted file mode 100644
index d4098cb8bc2..00000000000
--- a/extern/bullet2/patches/ghost_character.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-Index: extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
-===================================================================
---- extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp (revision 49183)
-+++ extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp (working copy)
-@@ -77,6 +77,9 @@
- if (convexResult.m_hitCollisionObject == m_me)
- return btScalar(1.0);
-
-+ if (!convexResult.m_hitCollisionObject->hasContactResponse())
-+ return btScalar(1.0);
-+
- btVector3 hitNormalWorld;
- if (normalInWorldSpace)
- {
-@@ -173,7 +176,12 @@
- m_manifoldArray.resize(0);
-
- btBroadphasePair* collisionPair = &m_ghostObject->getOverlappingPairCache()->getOverlappingPairArray()[i];
--
-+ btCollisionObject* obj0 = static_cast<btCollisionObject*>(collisionPair->m_pProxy0->m_clientObject);
-+ btCollisionObject* obj1 = static_cast<btCollisionObject*>(collisionPair->m_pProxy1->m_clientObject);
-+
-+ if ((obj0 && !obj0->hasContactResponse()) || (obj1 && !obj1->hasContactResponse()))
-+ continue;
-+
- if (collisionPair->m_algorithm)
- collisionPair->m_algorithm->getAllContactManifolds(m_manifoldArray);
-
diff --git a/extern/bullet2/patches/ghost_softbody.patch b/extern/bullet2/patches/ghost_softbody.patch
deleted file mode 100644
index b150d57040d..00000000000
--- a/extern/bullet2/patches/ghost_softbody.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-Index: extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
-===================================================================
---- extern/bullet2/src/BulletSoftBody/btSoftBody.cpp (Revision 43904)
-+++ extern/bullet2/src/BulletSoftBody/btSoftBody.cpp (Revision 43905)
-@@ -2780,21 +2780,23 @@
- {
- const RContact& c = psb->m_rcontacts[i];
- const sCti& cti = c.m_cti;
-- btRigidBody* tmpRigid = btRigidBody::upcast(cti.m_colObj);
-
-- const btVector3 va = tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0);
-- const btVector3 vb = c.m_node->m_x-c.m_node->m_q;
-- const btVector3 vr = vb-va;
-- const btScalar dn = btDot(vr, cti.m_normal);
-- if(dn<=SIMD_EPSILON)
-- {
-- const btScalar dp = btMin( (btDot(c.m_node->m_x, cti.m_normal) + cti.m_offset), mrg );
-- const btVector3 fv = vr - (cti.m_normal * dn);
-- // c0 is the impulse matrix, c3 is 1 - the friction coefficient or 0, c4 is the contact hardness coefficient
-- const btVector3 impulse = c.m_c0 * ( (vr - (fv * c.m_c3) + (cti.m_normal * (dp * c.m_c4))) * kst );
-- c.m_node->m_x -= impulse * c.m_c2;
-- if (tmpRigid)
-- tmpRigid->applyImpulse(impulse,c.m_c1);
-+ if (cti.m_colObj->hasContactResponse()) {
-+ btRigidBody* tmpRigid = btRigidBody::upcast(cti.m_colObj);
-+ const btVector3 va = tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0);
-+ const btVector3 vb = c.m_node->m_x-c.m_node->m_q;
-+ const btVector3 vr = vb-va;
-+ const btScalar dn = btDot(vr, cti.m_normal);
-+ if(dn<=SIMD_EPSILON)
-+ {
-+ const btScalar dp = btMin( (btDot(c.m_node->m_x, cti.m_normal) + cti.m_offset), mrg );
-+ const btVector3 fv = vr - (cti.m_normal * dn);
-+ // c0 is the impulse matrix, c3 is 1 - the friction coefficient or 0, c4 is the contact hardness coefficient
-+ const btVector3 impulse = c.m_c0 * ( (vr - (fv * c.m_c3) + (cti.m_normal * (dp * c.m_c4))) * kst );
-+ c.m_node->m_x -= impulse * c.m_c2;
-+ if (tmpRigid)
-+ tmpRigid->applyImpulse(impulse,c.m_c1);
-+ }
- }
- }
- }
diff --git a/extern/bullet2/readme.txt b/extern/bullet2/readme.txt
index dd806d40fac..3c09dad1fbf 100644
--- a/extern/bullet2/readme.txt
+++ b/extern/bullet2/readme.txt
@@ -4,11 +4,5 @@ Questions? mail blender at erwincoumans.com, or check the bf-blender mailing lis
Thanks,
Erwin
-Apply patches/ghost_softbody.patch to prevent softbodies being hit by ghost objects.
-Originally committed in blender svn revision: 43905.
-
-Apply patches/ghost_character.patch to prevent characters from colliding with ghost objects.
-Mitchell
-
Apply patches/convex_hull.patch to add access to the convex hull
operation, used in the BMesh convex hull operator.
diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h
index 1ebb37797d9..89c307d14ca 100644
--- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h
+++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h
@@ -25,7 +25,6 @@ class btOverlappingPairCache;
struct btCollisionObjectWrapper;
class btPersistentManifold;
-class btStackAlloc;
class btPoolAllocator;
struct btDispatcherInfo
@@ -47,8 +46,7 @@ struct btDispatcherInfo
m_useEpa(true),
m_allowedCcdPenetration(btScalar(0.04)),
m_useConvexConservativeDistanceUtil(false),
- m_convexConservativeDistanceThreshold(0.0f),
- m_stackAllocator(0)
+ m_convexConservativeDistanceThreshold(0.0f)
{
}
@@ -64,7 +62,6 @@ struct btDispatcherInfo
btScalar m_allowedCcdPenetration;
bool m_useConvexConservativeDistanceUtil;
btScalar m_convexConservativeDistanceThreshold;
- btStackAlloc* m_stackAllocator;
};
///The btDispatcher interface class can be used in combination with broadphase to dispatch calculations for overlapping pairs.
diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
index 041bbe05ae2..ae22dadc73a 100644
--- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
+++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
@@ -53,7 +53,7 @@ btHashedOverlappingPairCache::~btHashedOverlappingPairCache()
void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher)
{
- if (pair.m_algorithm)
+ if (pair.m_algorithm && dispatcher)
{
{
pair.m_algorithm->~btCollisionAlgorithm();
diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
index 7a3806c1d28..eee90e473a9 100644
--- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
+++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
@@ -96,6 +96,12 @@ class btHashedOverlappingPairCache : public btOverlappingPairCache
btOverlapFilterCallback* m_overlapFilterCallback;
bool m_blockedForChanges;
+protected:
+
+ btAlignedObjectArray<int> m_hashTable;
+ btAlignedObjectArray<int> m_next;
+ btOverlappingPairCallback* m_ghostPairCallback;
+
public:
btHashedOverlappingPairCache();
@@ -265,11 +271,6 @@ private:
virtual void sortOverlappingPairs(btDispatcher* dispatcher);
-protected:
-
- btAlignedObjectArray<int> m_hashTable;
- btAlignedObjectArray<int> m_next;
- btOverlappingPairCallback* m_ghostPairCallback;
};
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
index f63e0923b78..66949849448 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
@@ -18,7 +18,6 @@ subject to the following restrictions:
struct btCollisionAlgorithmCreateFunc;
-class btStackAlloc;
class btPoolAllocator;
///btCollisionConfiguration allows to configure Bullet collision detection
@@ -38,7 +37,6 @@ public:
virtual btPoolAllocator* getCollisionAlgorithmPool() = 0;
- virtual btStackAlloc* getStackAllocator() = 0;
virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1) =0;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
index cf8ed59a541..d0924100058 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
@@ -38,7 +38,8 @@ btCollisionObject::btCollisionObject()
m_hitFraction(btScalar(1.)),
m_ccdSweptSphereRadius(btScalar(0.)),
m_ccdMotionThreshold(btScalar(0.)),
- m_checkCollideWith(false)
+ m_checkCollideWith(false),
+ m_updateRevision(0)
{
m_worldTransform.setIdentity();
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
index 2f17967fe0f..89cad168210 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
@@ -92,7 +92,11 @@ protected:
int m_internalType;
///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer
- void* m_userObjectPointer;
+ union
+ {
+ void* m_userObjectPointer;
+ int m_userIndex;
+ };
///time of impact calculation
btScalar m_hitFraction;
@@ -106,6 +110,9 @@ protected:
/// If some object should have elaborate collision filtering by sub-classes
int m_checkCollideWith;
+ ///internal update revision number. It will be increased when the object changes. This allows some subsystems to perform lazy evaluation.
+ int m_updateRevision;
+
virtual bool checkCollideWithOverride(const btCollisionObject* /* co */) const
{
return true;
@@ -135,7 +142,8 @@ public:
CO_GHOST_OBJECT=4,
CO_SOFT_BODY=8,
CO_HF_FLUID=16,
- CO_USER_TYPE=32
+ CO_USER_TYPE=32,
+ CO_FEATHERSTONE_LINK=64
};
enum AnisotropicFrictionFlags
@@ -202,6 +210,7 @@ public:
virtual void setCollisionShape(btCollisionShape* collisionShape)
{
+ m_updateRevision++;
m_collisionShape = collisionShape;
m_rootCollisionShape = collisionShape;
}
@@ -257,6 +266,7 @@ public:
void setRestitution(btScalar rest)
{
+ m_updateRevision++;
m_restitution = rest;
}
btScalar getRestitution() const
@@ -265,6 +275,7 @@ public:
}
void setFriction(btScalar frict)
{
+ m_updateRevision++;
m_friction = frict;
}
btScalar getFriction() const
@@ -274,6 +285,7 @@ public:
void setRollingFriction(btScalar frict)
{
+ m_updateRevision++;
m_rollingFriction = frict;
}
btScalar getRollingFriction() const
@@ -300,6 +312,7 @@ public:
void setWorldTransform(const btTransform& worldTrans)
{
+ m_updateRevision++;
m_worldTransform = worldTrans;
}
@@ -332,16 +345,19 @@ public:
void setInterpolationWorldTransform(const btTransform& trans)
{
+ m_updateRevision++;
m_interpolationWorldTransform = trans;
}
void setInterpolationLinearVelocity(const btVector3& linvel)
{
+ m_updateRevision++;
m_interpolationLinearVelocity = linvel;
}
void setInterpolationAngularVelocity(const btVector3& angvel)
{
+ m_updateRevision++;
m_interpolationAngularVelocity = angvel;
}
@@ -431,13 +447,28 @@ public:
{
return m_userObjectPointer;
}
-
+
+ int getUserIndex() const
+ {
+ return m_userIndex;
+ }
///users can point to their objects, userPointer is not used by Bullet
void setUserPointer(void* userPointer)
{
m_userObjectPointer = userPointer;
}
+ ///users can point to their objects, userPointer is not used by Bullet
+ void setUserIndex(int index)
+ {
+ m_userIndex = index;
+ }
+
+ int getUpdateRevisionInternal() const
+ {
+ return m_updateRevision;
+ }
+
inline bool checkCollideWith(const btCollisionObject* co) const
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
index 4c09291692d..093c6f9b200 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
@@ -31,11 +31,10 @@ subject to the following restrictions:
#include "BulletCollision/BroadphaseCollision/btDbvt.h"
#include "LinearMath/btAabbUtil2.h"
#include "LinearMath/btQuickprof.h"
-#include "LinearMath/btStackAlloc.h"
#include "LinearMath/btSerializer.h"
#include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
-
+#include "BulletCollision/Gimpact/btGImpactShape.h"
//#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
@@ -73,8 +72,6 @@ m_broadphasePairCache(pairCache),
m_debugDrawer(0),
m_forceUpdateAllAabbs(true)
{
- m_stackAlloc = collisionConfiguration->getStackAllocator();
- m_dispatchInfo.m_stackAllocator = m_stackAlloc;
}
@@ -290,13 +287,19 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,con
btConvexShape* convexShape = (btConvexShape*) collisionShape;
btVoronoiSimplexSolver simplexSolver;
-#define USE_SUBSIMPLEX_CONVEX_CAST 1
-#ifdef USE_SUBSIMPLEX_CONVEX_CAST
- btSubsimplexConvexCast convexCaster(castShape,convexShape,&simplexSolver);
-#else
- //btGjkConvexCast convexCaster(castShape,convexShape,&simplexSolver);
+ btSubsimplexConvexCast subSimplexConvexCaster(castShape,convexShape,&simplexSolver);
+
+ btGjkConvexCast gjkConvexCaster(castShape,convexShape,&simplexSolver);
+
//btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
-#endif //#USE_SUBSIMPLEX_CONVEX_CAST
+ bool condition = true;
+ btConvexCast* convexCasterPtr = 0;
+ if (resultCallback.m_flags & btTriangleRaycastCallback::kF_UseSubSimplexConvexCastRaytest)
+ convexCasterPtr = &subSimplexConvexCaster;
+ else
+ convexCasterPtr = &gjkConvexCaster;
+
+ btConvexCast& convexCaster = *convexCasterPtr;
if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
{
@@ -328,34 +331,26 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,con
} else {
if (collisionShape->isConcave())
{
- // BT_PROFILE("rayTestConcave");
- if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
- {
- ///optimized version for btBvhTriangleMeshShape
- btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
- btTransform worldTocollisionObject = colObjWorldTransform.inverse();
- btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
- btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
- //ConvexCast::CastResult
+ //ConvexCast::CastResult
struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
{
btCollisionWorld::RayResultCallback* m_resultCallback;
const btCollisionObject* m_collisionObject;
- btTriangleMeshShape* m_triangleMesh;
+ const btConcaveShape* m_triangleMesh;
btTransform m_colObjWorldTransform;
BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
- btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh,const btTransform& colObjWorldTransform):
- //@BP Mod
- btTriangleRaycastCallback(from,to, resultCallback->m_flags),
- m_resultCallback(resultCallback),
- m_collisionObject(collisionObject),
- m_triangleMesh(triangleMesh),
- m_colObjWorldTransform(colObjWorldTransform)
- {
- }
+ btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,const btConcaveShape* triangleMesh,const btTransform& colObjWorldTransform):
+ //@BP Mod
+ btTriangleRaycastCallback(from,to, resultCallback->m_flags),
+ m_resultCallback(resultCallback),
+ m_collisionObject(collisionObject),
+ m_triangleMesh(triangleMesh),
+ m_colObjWorldTransform(colObjWorldTransform)
+ {
+ }
virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
@@ -378,10 +373,28 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,con
};
+ btTransform worldTocollisionObject = colObjWorldTransform.inverse();
+ btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
+ btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
+
+ // BT_PROFILE("rayTestConcave");
+ if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
+ {
+ ///optimized version for btBvhTriangleMeshShape
+ btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
+
BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),triangleMesh,colObjWorldTransform);
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal);
- } else
+ }
+ else if(collisionShape->getShapeType()==GIMPACT_SHAPE_PROXYTYPE)
+ {
+ btGImpactMeshShape* concaveShape = (btGImpactMeshShape*)collisionShape;
+
+ BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),concaveShape, colObjWorldTransform);
+ rcb.m_hitFraction = resultCallback.m_closestHitFraction;
+ concaveShape->processAllTrianglesRay(&rcb,rayFromLocal,rayToLocal);
+ }else
{
//generic (slower) case
btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
index 9412242e8a3..b3fffdecd98 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
@@ -1,6 +1,6 @@
/*
Bullet Continuous Collision Detection and Physics Library
-Copyright (c) 2003-2006 Erwin Coumans http://bulletphysics.com/Bullet/
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
@@ -18,13 +18,11 @@ subject to the following restrictions:
* @mainpage Bullet Documentation
*
* @section intro_sec Introduction
- * Bullet Collision Detection & Physics SDK
- *
* Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ).
*
* The main documentation is Bullet_User_Manual.pdf, included in the source code distribution.
* There is the Physics Forum for feedback and general Collision Detection and Physics discussions.
- * Please visit http://www.bulletphysics.com
+ * Please visit http://www.bulletphysics.org
*
* @section install_sec Installation
*
@@ -32,7 +30,16 @@ subject to the following restrictions:
* You can download the Bullet Physics Library from the Google Code repository: http://code.google.com/p/bullet/downloads/list
*
* @subsection step2 Step 2: Building
- * Bullet main build system for all platforms is cmake, you can download http://www.cmake.org
+ * Bullet has multiple build systems, including premake, cmake and autotools. Premake and cmake support all platforms.
+ * Premake is included in the Bullet/build folder for Windows, Mac OSX and Linux.
+ * Under Windows you can click on Bullet/build/vs2010.bat to create Microsoft Visual Studio projects.
+ * On Mac OSX and Linux you can open a terminal and generate Makefile, codeblocks or Xcode4 projects:
+ * cd Bullet/build
+ * ./premake4_osx gmake or ./premake4_linux gmake or ./premake4_linux64 gmake or (for Mac) ./premake4_osx xcode4
+ * cd Bullet/build/gmake
+ * make
+ *
+ * An alternative to premake is cmake. You can download cmake from http://www.cmake.org
* cmake can autogenerate projectfiles for Microsoft Visual Studio, Apple Xcode, KDevelop and Unix Makefiles.
* The easiest is to run the CMake cmake-gui graphical user interface and choose the options and generate projectfiles.
* You can also use cmake in the command-line. Here are some examples for various platforms:
@@ -65,7 +72,6 @@ subject to the following restrictions:
#ifndef BT_COLLISION_WORLD_H
#define BT_COLLISION_WORLD_H
-class btStackAlloc;
class btCollisionShape;
class btConvexShape;
class btBroadphaseInterface;
@@ -91,8 +97,6 @@ protected:
btDispatcherInfo m_dispatchInfo;
- btStackAlloc* m_stackAlloc;
-
btBroadphaseInterface* m_broadphasePairCache;
btIDebugDraw* m_debugDrawer;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
index 39b86a28918..991841ee20b 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
@@ -11,6 +11,7 @@ subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
+
*/
#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"
@@ -22,6 +23,8 @@ subject to the following restrictions:
#include "btManifoldResult.h"
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
+btShapePairCallback gCompoundChildShapePairCallback = 0;
+
btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped)
:btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
m_isSwapped(isSwapped),
@@ -129,6 +132,12 @@ public:
childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
m_otherObjWrap->getCollisionShape()->getAabb(m_otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1);
+ if (gCompoundChildShapePairCallback)
+ {
+ if (!gCompoundChildShapePairCallback(m_otherObjWrap->getCollisionShape(), childShape))
+ return;
+ }
+
if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
index b16fc524672..53675145637 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
@@ -11,6 +11,7 @@ subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
+
*/
#ifndef BT_COMPOUND_COLLISION_ALGORITHM_H
@@ -28,6 +29,10 @@ class btDispatcher;
class btDispatcher;
class btCollisionObject;
+class btCollisionShape;
+typedef bool (*btShapePairCallback)(const btCollisionShape* pShape0, const btCollisionShape* pShape1);
+extern btShapePairCallback gCompoundChildShapePairCallback;
+
/// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes
class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm
{
@@ -37,6 +42,7 @@ class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm
class btPersistentManifold* m_sharedManifold;
bool m_ownsManifold;
+
int m_compoundShapeRevision;//to keep track of changes, so that childAlgorithm array can be updated
void removeChildAlgorithms();
@@ -49,6 +55,12 @@ public:
virtual ~btCompoundCollisionAlgorithm();
+ btCollisionAlgorithm* getChildAlgorithm (int n) const
+ {
+ return m_childCollisionAlgorithms[n];
+ }
+
+
virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
@@ -63,6 +75,7 @@ public:
}
}
+
struct CreateFunc :public btCollisionAlgorithmCreateFunc
{
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp
new file mode 100644
index 00000000000..a52dd34fe91
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp
@@ -0,0 +1,421 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+*/
+
+#include "btCompoundCompoundCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btCompoundShape.h"
+#include "BulletCollision/BroadphaseCollision/btDbvt.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "LinearMath/btAabbUtil2.h"
+#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
+
+
+btShapePairCallback gCompoundCompoundChildShapePairCallback = 0;
+
+btCompoundCompoundCollisionAlgorithm::btCompoundCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped)
+:btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
+m_sharedManifold(ci.m_manifold)
+{
+ m_ownsManifold = false;
+
+ void* ptr = btAlignedAlloc(sizeof(btHashedSimplePairCache),16);
+ m_childCollisionAlgorithmCache= new(ptr) btHashedSimplePairCache();
+
+ const btCollisionObjectWrapper* col0ObjWrap = body0Wrap;
+ btAssert (col0ObjWrap->getCollisionShape()->isCompound());
+
+ const btCollisionObjectWrapper* col1ObjWrap = body1Wrap;
+ btAssert (col1ObjWrap->getCollisionShape()->isCompound());
+
+ const btCompoundShape* compoundShape0 = static_cast<const btCompoundShape*>(col0ObjWrap->getCollisionShape());
+ m_compoundShapeRevision0 = compoundShape0->getUpdateRevision();
+
+ const btCompoundShape* compoundShape1 = static_cast<const btCompoundShape*>(col1ObjWrap->getCollisionShape());
+ m_compoundShapeRevision1 = compoundShape1->getUpdateRevision();
+
+
+}
+
+
+btCompoundCompoundCollisionAlgorithm::~btCompoundCompoundCollisionAlgorithm()
+{
+ removeChildAlgorithms();
+ m_childCollisionAlgorithmCache->~btHashedSimplePairCache();
+ btAlignedFree(m_childCollisionAlgorithmCache);
+}
+
+void btCompoundCompoundCollisionAlgorithm::getAllContactManifolds(btManifoldArray& manifoldArray)
+{
+ int i;
+ btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray();
+ for (i=0;i<pairs.size();i++)
+ {
+ if (pairs[i].m_userPointer)
+ {
+
+ ((btCollisionAlgorithm*)pairs[i].m_userPointer)->getAllContactManifolds(manifoldArray);
+ }
+ }
+}
+
+
+void btCompoundCompoundCollisionAlgorithm::removeChildAlgorithms()
+{
+ btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray();
+
+ int numChildren = pairs.size();
+ int i;
+ for (i=0;i<numChildren;i++)
+ {
+ if (pairs[i].m_userPointer)
+ {
+ btCollisionAlgorithm* algo = (btCollisionAlgorithm*) pairs[i].m_userPointer;
+ algo->~btCollisionAlgorithm();
+ m_dispatcher->freeCollisionAlgorithm(algo);
+ }
+ }
+ m_childCollisionAlgorithmCache->removeAllPairs();
+}
+
+struct btCompoundCompoundLeafCallback : btDbvt::ICollide
+{
+ int m_numOverlapPairs;
+
+
+ const btCollisionObjectWrapper* m_compound0ColObjWrap;
+ const btCollisionObjectWrapper* m_compound1ColObjWrap;
+ btDispatcher* m_dispatcher;
+ const btDispatcherInfo& m_dispatchInfo;
+ btManifoldResult* m_resultOut;
+
+
+ class btHashedSimplePairCache* m_childCollisionAlgorithmCache;
+
+ btPersistentManifold* m_sharedManifold;
+
+ btCompoundCompoundLeafCallback (const btCollisionObjectWrapper* compound1ObjWrap,
+ const btCollisionObjectWrapper* compound0ObjWrap,
+ btDispatcher* dispatcher,
+ const btDispatcherInfo& dispatchInfo,
+ btManifoldResult* resultOut,
+ btHashedSimplePairCache* childAlgorithmsCache,
+ btPersistentManifold* sharedManifold)
+ :m_compound0ColObjWrap(compound1ObjWrap),m_compound1ColObjWrap(compound0ObjWrap),m_dispatcher(dispatcher),m_dispatchInfo(dispatchInfo),m_resultOut(resultOut),
+ m_childCollisionAlgorithmCache(childAlgorithmsCache),
+ m_sharedManifold(sharedManifold),
+ m_numOverlapPairs(0)
+ {
+
+ }
+
+
+
+
+ void Process(const btDbvtNode* leaf0,const btDbvtNode* leaf1)
+ {
+ m_numOverlapPairs++;
+
+
+ int childIndex0 = leaf0->dataAsInt;
+ int childIndex1 = leaf1->dataAsInt;
+
+
+ btAssert(childIndex0>=0);
+ btAssert(childIndex1>=0);
+
+
+ const btCompoundShape* compoundShape0 = static_cast<const btCompoundShape*>(m_compound0ColObjWrap->getCollisionShape());
+ btAssert(childIndex0<compoundShape0->getNumChildShapes());
+
+ const btCompoundShape* compoundShape1 = static_cast<const btCompoundShape*>(m_compound1ColObjWrap->getCollisionShape());
+ btAssert(childIndex1<compoundShape1->getNumChildShapes());
+
+ const btCollisionShape* childShape0 = compoundShape0->getChildShape(childIndex0);
+ const btCollisionShape* childShape1 = compoundShape1->getChildShape(childIndex1);
+
+ //backup
+ btTransform orgTrans0 = m_compound0ColObjWrap->getWorldTransform();
+ const btTransform& childTrans0 = compoundShape0->getChildTransform(childIndex0);
+ btTransform newChildWorldTrans0 = orgTrans0*childTrans0 ;
+
+ btTransform orgTrans1 = m_compound1ColObjWrap->getWorldTransform();
+ const btTransform& childTrans1 = compoundShape1->getChildTransform(childIndex1);
+ btTransform newChildWorldTrans1 = orgTrans1*childTrans1 ;
+
+
+ //perform an AABB check first
+ btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
+ childShape0->getAabb(newChildWorldTrans0,aabbMin0,aabbMax0);
+ childShape1->getAabb(newChildWorldTrans1,aabbMin1,aabbMax1);
+
+ if (gCompoundCompoundChildShapePairCallback)
+ {
+ if (!gCompoundCompoundChildShapePairCallback(childShape0,childShape1))
+ return;
+ }
+
+ if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
+ {
+ btCollisionObjectWrapper compoundWrap0(this->m_compound0ColObjWrap,childShape0, m_compound0ColObjWrap->getCollisionObject(),newChildWorldTrans0,-1,childIndex0);
+ btCollisionObjectWrapper compoundWrap1(this->m_compound1ColObjWrap,childShape1,m_compound1ColObjWrap->getCollisionObject(),newChildWorldTrans1,-1,childIndex1);
+
+
+ btSimplePair* pair = m_childCollisionAlgorithmCache->findPair(childIndex0,childIndex1);
+
+ btCollisionAlgorithm* colAlgo = 0;
+
+ if (pair)
+ {
+ colAlgo = (btCollisionAlgorithm*)pair->m_userPointer;
+
+ } else
+ {
+ colAlgo = m_dispatcher->findAlgorithm(&compoundWrap0,&compoundWrap1,m_sharedManifold);
+ pair = m_childCollisionAlgorithmCache->addOverlappingPair(childIndex0,childIndex1);
+ btAssert(pair);
+ pair->m_userPointer = colAlgo;
+ }
+
+ btAssert(colAlgo);
+
+ const btCollisionObjectWrapper* tmpWrap0 = 0;
+ const btCollisionObjectWrapper* tmpWrap1 = 0;
+
+ tmpWrap0 = m_resultOut->getBody0Wrap();
+ tmpWrap1 = m_resultOut->getBody1Wrap();
+
+ m_resultOut->setBody0Wrap(&compoundWrap0);
+ m_resultOut->setBody1Wrap(&compoundWrap1);
+
+ m_resultOut->setShapeIdentifiersA(-1,childIndex0);
+ m_resultOut->setShapeIdentifiersB(-1,childIndex1);
+
+
+ colAlgo->processCollision(&compoundWrap0,&compoundWrap1,m_dispatchInfo,m_resultOut);
+
+ m_resultOut->setBody0Wrap(tmpWrap0);
+ m_resultOut->setBody1Wrap(tmpWrap1);
+
+
+
+ }
+ }
+};
+
+
+static DBVT_INLINE bool MyIntersect( const btDbvtAabbMm& a,
+ const btDbvtAabbMm& b, const btTransform& xform)
+{
+ btVector3 newmin,newmax;
+ btTransformAabb(b.Mins(),b.Maxs(),0.f,xform,newmin,newmax);
+ btDbvtAabbMm newb = btDbvtAabbMm::FromMM(newmin,newmax);
+ return Intersect(a,newb);
+}
+
+
+static inline void MycollideTT( const btDbvtNode* root0,
+ const btDbvtNode* root1,
+ const btTransform& xform,
+ btCompoundCompoundLeafCallback* callback)
+{
+
+ if(root0&&root1)
+ {
+ int depth=1;
+ int treshold=btDbvt::DOUBLE_STACKSIZE-4;
+ btAlignedObjectArray<btDbvt::sStkNN> stkStack;
+ stkStack.resize(btDbvt::DOUBLE_STACKSIZE);
+ stkStack[0]=btDbvt::sStkNN(root0,root1);
+ do {
+ btDbvt::sStkNN p=stkStack[--depth];
+ if(MyIntersect(p.a->volume,p.b->volume,xform))
+ {
+ if(depth>treshold)
+ {
+ stkStack.resize(stkStack.size()*2);
+ treshold=stkStack.size()-4;
+ }
+ if(p.a->isinternal())
+ {
+ if(p.b->isinternal())
+ {
+ stkStack[depth++]=btDbvt::sStkNN(p.a->childs[0],p.b->childs[0]);
+ stkStack[depth++]=btDbvt::sStkNN(p.a->childs[1],p.b->childs[0]);
+ stkStack[depth++]=btDbvt::sStkNN(p.a->childs[0],p.b->childs[1]);
+ stkStack[depth++]=btDbvt::sStkNN(p.a->childs[1],p.b->childs[1]);
+ }
+ else
+ {
+ stkStack[depth++]=btDbvt::sStkNN(p.a->childs[0],p.b);
+ stkStack[depth++]=btDbvt::sStkNN(p.a->childs[1],p.b);
+ }
+ }
+ else
+ {
+ if(p.b->isinternal())
+ {
+ stkStack[depth++]=btDbvt::sStkNN(p.a,p.b->childs[0]);
+ stkStack[depth++]=btDbvt::sStkNN(p.a,p.b->childs[1]);
+ }
+ else
+ {
+ callback->Process(p.a,p.b);
+ }
+ }
+ }
+ } while(depth);
+ }
+}
+
+void btCompoundCompoundCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+
+ const btCollisionObjectWrapper* col0ObjWrap = body0Wrap;
+ const btCollisionObjectWrapper* col1ObjWrap= body1Wrap;
+
+ btAssert (col0ObjWrap->getCollisionShape()->isCompound());
+ btAssert (col1ObjWrap->getCollisionShape()->isCompound());
+ const btCompoundShape* compoundShape0 = static_cast<const btCompoundShape*>(col0ObjWrap->getCollisionShape());
+ const btCompoundShape* compoundShape1 = static_cast<const btCompoundShape*>(col1ObjWrap->getCollisionShape());
+
+ ///btCompoundShape might have changed:
+ ////make sure the internal child collision algorithm caches are still valid
+ if ((compoundShape0->getUpdateRevision() != m_compoundShapeRevision0) || (compoundShape1->getUpdateRevision() != m_compoundShapeRevision1))
+ {
+ ///clear all
+ removeChildAlgorithms();
+ }
+
+
+ ///we need to refresh all contact manifolds
+ ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep
+ ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm
+ {
+ int i;
+ btManifoldArray manifoldArray;
+ btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray();
+ for (i=0;i<pairs.size();i++)
+ {
+ if (pairs[i].m_userPointer)
+ {
+ btCollisionAlgorithm* algo = (btCollisionAlgorithm*) pairs[i].m_userPointer;
+ algo->getAllContactManifolds(manifoldArray);
+ for (int m=0;m<manifoldArray.size();m++)
+ {
+ if (manifoldArray[m]->getNumContacts())
+ {
+ resultOut->setPersistentManifold(manifoldArray[m]);
+ resultOut->refreshContactPoints();
+ resultOut->setPersistentManifold(0);
+ }
+ }
+ manifoldArray.resize(0);
+ }
+ }
+ }
+
+
+ const btDbvt* tree0 = compoundShape0->getDynamicAabbTree();
+ const btDbvt* tree1 = compoundShape1->getDynamicAabbTree();
+
+ btCompoundCompoundLeafCallback callback(col0ObjWrap,col1ObjWrap,this->m_dispatcher,dispatchInfo,resultOut,this->m_childCollisionAlgorithmCache,m_sharedManifold);
+
+
+ const btTransform xform=col0ObjWrap->getWorldTransform().inverse()*col1ObjWrap->getWorldTransform();
+ MycollideTT(tree0->m_root,tree1->m_root,xform,&callback);
+
+ //printf("#compound-compound child/leaf overlap =%d \r",callback.m_numOverlapPairs);
+
+ //remove non-overlapping child pairs
+
+ {
+ btAssert(m_removePairs.size()==0);
+
+ //iterate over all children, perform an AABB check inside ProcessChildShape
+ btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray();
+
+ int i;
+ btManifoldArray manifoldArray;
+
+
+
+
+
+ btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
+
+ for (i=0;i<pairs.size();i++)
+ {
+ if (pairs[i].m_userPointer)
+ {
+ btCollisionAlgorithm* algo = (btCollisionAlgorithm*)pairs[i].m_userPointer;
+
+ {
+ btTransform orgTrans0;
+ const btCollisionShape* childShape0 = 0;
+
+ btTransform newChildWorldTrans0;
+ btTransform orgInterpolationTrans0;
+ childShape0 = compoundShape0->getChildShape(pairs[i].m_indexA);
+ orgTrans0 = col0ObjWrap->getWorldTransform();
+ orgInterpolationTrans0 = col0ObjWrap->getWorldTransform();
+ const btTransform& childTrans0 = compoundShape0->getChildTransform(pairs[i].m_indexA);
+ newChildWorldTrans0 = orgTrans0*childTrans0 ;
+ childShape0->getAabb(newChildWorldTrans0,aabbMin0,aabbMax0);
+ }
+
+ {
+ btTransform orgInterpolationTrans1;
+ const btCollisionShape* childShape1 = 0;
+ btTransform orgTrans1;
+ btTransform newChildWorldTrans1;
+
+ childShape1 = compoundShape1->getChildShape(pairs[i].m_indexB);
+ orgTrans1 = col1ObjWrap->getWorldTransform();
+ orgInterpolationTrans1 = col1ObjWrap->getWorldTransform();
+ const btTransform& childTrans1 = compoundShape1->getChildTransform(pairs[i].m_indexB);
+ newChildWorldTrans1 = orgTrans1*childTrans1 ;
+ childShape1->getAabb(newChildWorldTrans1,aabbMin1,aabbMax1);
+ }
+
+
+
+ if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
+ {
+ algo->~btCollisionAlgorithm();
+ m_dispatcher->freeCollisionAlgorithm(algo);
+ m_removePairs.push_back(btSimplePair(pairs[i].m_indexA,pairs[i].m_indexB));
+ }
+ }
+ }
+ for (int i=0;i<m_removePairs.size();i++)
+ {
+ m_childCollisionAlgorithmCache->removeOverlappingPair(m_removePairs[i].m_indexA,m_removePairs[i].m_indexB);
+ }
+ m_removePairs.clear();
+ }
+
+}
+
+btScalar btCompoundCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+ btAssert(0);
+ return 0.f;
+
+}
+
+
+
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h
new file mode 100644
index 00000000000..7e2d7ad7085
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h
@@ -0,0 +1,90 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+*/
+
+#ifndef BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H
+#define BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+class btDispatcher;
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+#include "LinearMath/btAlignedObjectArray.h"
+#include "BulletCollision/CollisionDispatch/btHashedSimplePairCache.h"
+class btDispatcher;
+class btCollisionObject;
+
+class btCollisionShape;
+typedef bool (*btShapePairCallback)(const btCollisionShape* pShape0, const btCollisionShape* pShape1);
+extern btShapePairCallback gCompoundCompoundChildShapePairCallback;
+
+/// btCompoundCompoundCollisionAlgorithm supports collision between two btCompoundCollisionShape shapes
+class btCompoundCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm
+{
+
+ class btHashedSimplePairCache* m_childCollisionAlgorithmCache;
+ btSimplePairArray m_removePairs;
+
+ class btPersistentManifold* m_sharedManifold;
+ bool m_ownsManifold;
+
+
+ int m_compoundShapeRevision0;//to keep track of changes, so that childAlgorithm array can be updated
+ int m_compoundShapeRevision1;
+
+ void removeChildAlgorithms();
+
+// void preallocateChildAlgorithms(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
+
+public:
+
+ btCompoundCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped);
+
+ virtual ~btCompoundCompoundCollisionAlgorithm();
+
+
+
+ virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+ btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+ virtual void getAllContactManifolds(btManifoldArray& manifoldArray);
+
+
+ struct CreateFunc :public btCollisionAlgorithmCreateFunc
+ {
+ virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
+ {
+ void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCompoundCollisionAlgorithm));
+ return new(mem) btCompoundCompoundCollisionAlgorithm(ci,body0Wrap,body1Wrap,false);
+ }
+ };
+
+ struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc
+ {
+ virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
+ {
+ void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCompoundCollisionAlgorithm));
+ return new(mem) btCompoundCompoundCollisionAlgorithm(ci,body0Wrap,body1Wrap,true);
+ }
+ };
+
+};
+
+#endif //BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp
index 3e1afede1bf..4ec9ae71386 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp
@@ -132,7 +132,6 @@ void btConvex2dConvex2dAlgorithm ::processCollision (const btCollisionObjectWrap
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
}
- input.m_stackAlloc = dispatchInfo.m_stackAllocator;
input.m_transformA = body0Wrap->getWorldTransform();
input.m_transformB = body1Wrap->getWorldTransform();
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
index 18fde771b14..e23f5f7a88d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
@@ -76,21 +76,27 @@ void btConvexTriangleCallback::clearCache()
}
-
-void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
+void btConvexTriangleCallback::processTriangle(btVector3* triangle,int
+partId, int triangleIndex)
{
-
- //just for debugging purposes
- //printf("triangle %d",m_triangleCount++);
+ if (!TestTriangleAgainstAabb2(triangle, m_aabbMin, m_aabbMax))
+ {
+ return;
+ }
+
+ //just for debugging purposes
+ //printf("triangle %d",m_triangleCount++);
- //aabb filter is already applied!
+ const btCollisionObject* ob = const_cast<btCollisionObject*>(m_triBodyWrap->getCollisionObject());
btCollisionAlgorithmConstructionInfo ci;
ci.m_dispatcher1 = m_dispatcher;
//const btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBodyWrap->getCollisionObject());
+
+
#if 0
///debug drawing of the overlapping triangles
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
index 62f98a846f4..7f2722aa463 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
@@ -373,7 +373,6 @@ void btConvexConvexAlgorithm ::processCollision (const btCollisionObjectWrapper*
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
}
- input.m_stackAlloc = dispatchInfo.m_stackAllocator;
input.m_transformA = body0Wrap->getWorldTransform();
input.m_transformB = body1Wrap->getWorldTransform();
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
index 7faee6faf50..c3cacec4a4f 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
@@ -19,6 +19,8 @@ subject to the following restrictions:
#include "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h"
+
#include "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h"
@@ -32,7 +34,6 @@ subject to the following restrictions:
-#include "LinearMath/btStackAlloc.h"
#include "LinearMath/btPoolAllocator.h"
@@ -65,6 +66,10 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault
m_swappedConvexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::SwappedCreateFunc;
mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::CreateFunc),16);
m_compoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::CreateFunc;
+
+ mem = btAlignedAlloc(sizeof(btCompoundCompoundCollisionAlgorithm::CreateFunc),16);
+ m_compoundCompoundCreateFunc = new (mem)btCompoundCompoundCollisionAlgorithm::CreateFunc;
+
mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::SwappedCreateFunc),16);
m_swappedCompoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::SwappedCreateFunc;
mem = btAlignedAlloc(sizeof(btEmptyAlgorithm::CreateFunc),16);
@@ -106,16 +111,6 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault
collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
- if (constructionInfo.m_stackAlloc)
- {
- m_ownsStackAllocator = false;
- this->m_stackAlloc = constructionInfo.m_stackAlloc;
- } else
- {
- m_ownsStackAllocator = true;
- void* mem = btAlignedAlloc(sizeof(btStackAlloc),16);
- m_stackAlloc = new(mem)btStackAlloc(constructionInfo.m_defaultStackAllocatorSize);
- }
if (constructionInfo.m_persistentManifoldPool)
{
@@ -144,12 +139,6 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault
btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration()
{
- if (m_ownsStackAllocator)
- {
- m_stackAlloc->destroy();
- m_stackAlloc->~btStackAlloc();
- btAlignedFree(m_stackAlloc);
- }
if (m_ownsCollisionAlgorithmPool)
{
m_collisionAlgorithmPool->~btPoolAllocator();
@@ -172,6 +161,9 @@ btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration()
m_compoundCreateFunc->~btCollisionAlgorithmCreateFunc();
btAlignedFree( m_compoundCreateFunc);
+ m_compoundCompoundCreateFunc->~btCollisionAlgorithmCreateFunc();
+ btAlignedFree(m_compoundCompoundCreateFunc);
+
m_swappedCompoundCreateFunc->~btCollisionAlgorithmCreateFunc();
btAlignedFree( m_swappedCompoundCreateFunc);
@@ -275,6 +267,12 @@ btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlg
return m_swappedConvexConcaveCreateFunc;
}
+
+ if (btBroadphaseProxy::isCompound(proxyType0) && btBroadphaseProxy::isCompound(proxyType1))
+ {
+ return m_compoundCompoundCreateFunc;
+ }
+
if (btBroadphaseProxy::isCompound(proxyType0))
{
return m_compoundCreateFunc;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
index 474785bfc7d..2078420e198 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
@@ -22,23 +22,19 @@ class btConvexPenetrationDepthSolver;
struct btDefaultCollisionConstructionInfo
{
- btStackAlloc* m_stackAlloc;
btPoolAllocator* m_persistentManifoldPool;
btPoolAllocator* m_collisionAlgorithmPool;
int m_defaultMaxPersistentManifoldPoolSize;
int m_defaultMaxCollisionAlgorithmPoolSize;
int m_customCollisionAlgorithmMaxElementSize;
- int m_defaultStackAllocatorSize;
int m_useEpaPenetrationAlgorithm;
btDefaultCollisionConstructionInfo()
- :m_stackAlloc(0),
- m_persistentManifoldPool(0),
+ :m_persistentManifoldPool(0),
m_collisionAlgorithmPool(0),
m_defaultMaxPersistentManifoldPoolSize(4096),
m_defaultMaxCollisionAlgorithmPoolSize(4096),
m_customCollisionAlgorithmMaxElementSize(0),
- m_defaultStackAllocatorSize(0),
m_useEpaPenetrationAlgorithm(true)
{
}
@@ -56,8 +52,6 @@ protected:
int m_persistentManifoldPoolSize;
- btStackAlloc* m_stackAlloc;
- bool m_ownsStackAllocator;
btPoolAllocator* m_persistentManifoldPool;
bool m_ownsPersistentManifoldPool;
@@ -75,6 +69,8 @@ protected:
btCollisionAlgorithmCreateFunc* m_convexConcaveCreateFunc;
btCollisionAlgorithmCreateFunc* m_swappedConvexConcaveCreateFunc;
btCollisionAlgorithmCreateFunc* m_compoundCreateFunc;
+ btCollisionAlgorithmCreateFunc* m_compoundCompoundCreateFunc;
+
btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc;
btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
btCollisionAlgorithmCreateFunc* m_sphereSphereCF;
@@ -105,10 +101,6 @@ public:
return m_collisionAlgorithmPool;
}
- virtual btStackAlloc* getStackAllocator()
- {
- return m_stackAlloc;
- }
virtual btVoronoiSimplexSolver* getSimplexSolver()
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp
new file mode 100644
index 00000000000..cfcca5654de
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp
@@ -0,0 +1,278 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#include "btHashedSimplePairCache.h"
+
+
+#include <stdio.h>
+
+int gOverlappingSimplePairs = 0;
+int gRemoveSimplePairs =0;
+int gAddedSimplePairs =0;
+int gFindSimplePairs =0;
+
+
+
+
+btHashedSimplePairCache::btHashedSimplePairCache():
+ m_blockedForChanges(false)
+{
+ int initialAllocatedSize= 2;
+ m_overlappingPairArray.reserve(initialAllocatedSize);
+ growTables();
+}
+
+
+
+
+btHashedSimplePairCache::~btHashedSimplePairCache()
+{
+}
+
+
+
+
+
+
+void btHashedSimplePairCache::removeAllPairs()
+{
+ m_overlappingPairArray.clear();
+ m_hashTable.clear();
+ m_next.clear();
+
+ int initialAllocatedSize= 2;
+ m_overlappingPairArray.reserve(initialAllocatedSize);
+ growTables();
+}
+
+
+
+btSimplePair* btHashedSimplePairCache::findPair(int indexA, int indexB)
+{
+ gFindSimplePairs++;
+
+
+ /*if (indexA > indexB)
+ btSwap(indexA, indexB);*/
+
+ int hash = static_cast<int>(getHash(static_cast<unsigned int>(indexA), static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.capacity()-1));
+
+ if (hash >= m_hashTable.size())
+ {
+ return NULL;
+ }
+
+ int index = m_hashTable[hash];
+ while (index != BT_SIMPLE_NULL_PAIR && equalsPair(m_overlappingPairArray[index], indexA, indexB) == false)
+ {
+ index = m_next[index];
+ }
+
+ if (index == BT_SIMPLE_NULL_PAIR)
+ {
+ return NULL;
+ }
+
+ btAssert(index < m_overlappingPairArray.size());
+
+ return &m_overlappingPairArray[index];
+}
+
+//#include <stdio.h>
+
+void btHashedSimplePairCache::growTables()
+{
+
+ int newCapacity = m_overlappingPairArray.capacity();
+
+ if (m_hashTable.size() < newCapacity)
+ {
+ //grow hashtable and next table
+ int curHashtableSize = m_hashTable.size();
+
+ m_hashTable.resize(newCapacity);
+ m_next.resize(newCapacity);
+
+
+ int i;
+
+ for (i= 0; i < newCapacity; ++i)
+ {
+ m_hashTable[i] = BT_SIMPLE_NULL_PAIR;
+ }
+ for (i = 0; i < newCapacity; ++i)
+ {
+ m_next[i] = BT_SIMPLE_NULL_PAIR;
+ }
+
+ for(i=0;i<curHashtableSize;i++)
+ {
+
+ const btSimplePair& pair = m_overlappingPairArray[i];
+ int indexA = pair.m_indexA;
+ int indexB = pair.m_indexB;
+
+ int hashValue = static_cast<int>(getHash(static_cast<unsigned int>(indexA),static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask
+ m_next[i] = m_hashTable[hashValue];
+ m_hashTable[hashValue] = i;
+ }
+
+
+ }
+}
+
+btSimplePair* btHashedSimplePairCache::internalAddPair(int indexA, int indexB)
+{
+
+ int hash = static_cast<int>(getHash(static_cast<unsigned int>(indexA),static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask
+
+
+ btSimplePair* pair = internalFindPair(indexA, indexB, hash);
+ if (pair != NULL)
+ {
+ return pair;
+ }
+
+ int count = m_overlappingPairArray.size();
+ int oldCapacity = m_overlappingPairArray.capacity();
+ void* mem = &m_overlappingPairArray.expandNonInitializing();
+
+ int newCapacity = m_overlappingPairArray.capacity();
+
+ if (oldCapacity < newCapacity)
+ {
+ growTables();
+ //hash with new capacity
+ hash = static_cast<int>(getHash(static_cast<unsigned int>(indexA),static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.capacity()-1));
+ }
+
+ pair = new (mem) btSimplePair(indexA,indexB);
+
+ pair->m_userPointer = 0;
+
+ m_next[count] = m_hashTable[hash];
+ m_hashTable[hash] = count;
+
+ return pair;
+}
+
+
+
+void* btHashedSimplePairCache::removeOverlappingPair(int indexA, int indexB)
+{
+ gRemoveSimplePairs++;
+
+
+ /*if (indexA > indexB)
+ btSwap(indexA, indexB);*/
+
+ int hash = static_cast<int>(getHash(static_cast<unsigned int>(indexA),static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.capacity()-1));
+
+ btSimplePair* pair = internalFindPair(indexA, indexB, hash);
+ if (pair == NULL)
+ {
+ return 0;
+ }
+
+
+ void* userData = pair->m_userPointer;
+
+
+ int pairIndex = int(pair - &m_overlappingPairArray[0]);
+ btAssert(pairIndex < m_overlappingPairArray.size());
+
+ // Remove the pair from the hash table.
+ int index = m_hashTable[hash];
+ btAssert(index != BT_SIMPLE_NULL_PAIR);
+
+ int previous = BT_SIMPLE_NULL_PAIR;
+ while (index != pairIndex)
+ {
+ previous = index;
+ index = m_next[index];
+ }
+
+ if (previous != BT_SIMPLE_NULL_PAIR)
+ {
+ btAssert(m_next[previous] == pairIndex);
+ m_next[previous] = m_next[pairIndex];
+ }
+ else
+ {
+ m_hashTable[hash] = m_next[pairIndex];
+ }
+
+ // We now move the last pair into spot of the
+ // pair being removed. We need to fix the hash
+ // table indices to support the move.
+
+ int lastPairIndex = m_overlappingPairArray.size() - 1;
+
+ // If the removed pair is the last pair, we are done.
+ if (lastPairIndex == pairIndex)
+ {
+ m_overlappingPairArray.pop_back();
+ return userData;
+ }
+
+ // Remove the last pair from the hash table.
+ const btSimplePair* last = &m_overlappingPairArray[lastPairIndex];
+ /* missing swap here too, Nat. */
+ int lastHash = static_cast<int>(getHash(static_cast<unsigned int>(last->m_indexA), static_cast<unsigned int>(last->m_indexB)) & (m_overlappingPairArray.capacity()-1));
+
+ index = m_hashTable[lastHash];
+ btAssert(index != BT_SIMPLE_NULL_PAIR);
+
+ previous = BT_SIMPLE_NULL_PAIR;
+ while (index != lastPairIndex)
+ {
+ previous = index;
+ index = m_next[index];
+ }
+
+ if (previous != BT_SIMPLE_NULL_PAIR)
+ {
+ btAssert(m_next[previous] == lastPairIndex);
+ m_next[previous] = m_next[lastPairIndex];
+ }
+ else
+ {
+ m_hashTable[lastHash] = m_next[lastPairIndex];
+ }
+
+ // Copy the last pair into the remove pair's spot.
+ m_overlappingPairArray[pairIndex] = m_overlappingPairArray[lastPairIndex];
+
+ // Insert the last pair into the hash table
+ m_next[pairIndex] = m_hashTable[lastHash];
+ m_hashTable[lastHash] = pairIndex;
+
+ m_overlappingPairArray.pop_back();
+
+ return userData;
+}
+//#include <stdio.h>
+
+
+
+
+
+
+
+
+
+
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h
new file mode 100644
index 00000000000..e88ef97e968
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h
@@ -0,0 +1,174 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_HASHED_SIMPLE_PAIR_CACHE_H
+#define BT_HASHED_SIMPLE_PAIR_CACHE_H
+
+
+
+#include "LinearMath/btAlignedObjectArray.h"
+
+const int BT_SIMPLE_NULL_PAIR=0xffffffff;
+
+struct btSimplePair
+{
+ btSimplePair(int indexA,int indexB)
+ :m_indexA(indexA),
+ m_indexB(indexB),
+ m_userPointer(0)
+ {
+ }
+
+ int m_indexA;
+ int m_indexB;
+ union
+ {
+ void* m_userPointer;
+ int m_userValue;
+ };
+};
+
+typedef btAlignedObjectArray<btSimplePair> btSimplePairArray;
+
+
+
+extern int gOverlappingSimplePairs;
+extern int gRemoveSimplePairs;
+extern int gAddedSimplePairs;
+extern int gFindSimplePairs;
+
+
+
+
+class btHashedSimplePairCache
+{
+ btSimplePairArray m_overlappingPairArray;
+
+ bool m_blockedForChanges;
+
+
+protected:
+
+ btAlignedObjectArray<int> m_hashTable;
+ btAlignedObjectArray<int> m_next;
+
+
+public:
+ btHashedSimplePairCache();
+ virtual ~btHashedSimplePairCache();
+
+ void removeAllPairs();
+
+ virtual void* removeOverlappingPair(int indexA,int indexB);
+
+ // Add a pair and return the new pair. If the pair already exists,
+ // no new pair is created and the old one is returned.
+ virtual btSimplePair* addOverlappingPair(int indexA,int indexB)
+ {
+ gAddedSimplePairs++;
+
+ return internalAddPair(indexA,indexB);
+ }
+
+
+ virtual btSimplePair* getOverlappingPairArrayPtr()
+ {
+ return &m_overlappingPairArray[0];
+ }
+
+ const btSimplePair* getOverlappingPairArrayPtr() const
+ {
+ return &m_overlappingPairArray[0];
+ }
+
+ btSimplePairArray& getOverlappingPairArray()
+ {
+ return m_overlappingPairArray;
+ }
+
+ const btSimplePairArray& getOverlappingPairArray() const
+ {
+ return m_overlappingPairArray;
+ }
+
+
+ btSimplePair* findPair(int indexA,int indexB);
+
+ int GetCount() const { return m_overlappingPairArray.size(); }
+
+ int getNumOverlappingPairs() const
+ {
+ return m_overlappingPairArray.size();
+ }
+private:
+
+ btSimplePair* internalAddPair(int indexA, int indexB);
+
+ void growTables();
+
+ SIMD_FORCE_INLINE bool equalsPair(const btSimplePair& pair, int indexA, int indexB)
+ {
+ return pair.m_indexA == indexA && pair.m_indexB == indexB;
+ }
+
+
+
+ SIMD_FORCE_INLINE unsigned int getHash(unsigned int indexA, unsigned int indexB)
+ {
+ int key = static_cast<int>(((unsigned int)indexA) | (((unsigned int)indexB) <<16));
+ // Thomas Wang's hash
+
+ key += ~(key << 15);
+ key ^= (key >> 10);
+ key += (key << 3);
+ key ^= (key >> 6);
+ key += ~(key << 11);
+ key ^= (key >> 16);
+ return static_cast<unsigned int>(key);
+ }
+
+
+
+
+
+ SIMD_FORCE_INLINE btSimplePair* internalFindPair(int proxyIdA , int proxyIdB, int hash)
+ {
+
+ int index = m_hashTable[hash];
+
+ while( index != BT_SIMPLE_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyIdA, proxyIdB) == false)
+ {
+ index = m_next[index];
+ }
+
+ if ( index == BT_SIMPLE_NULL_PAIR )
+ {
+ return NULL;
+ }
+
+ btAssert(index < m_overlappingPairArray.size());
+
+ return &m_overlappingPairArray[index];
+ }
+
+
+};
+
+
+
+
+#endif //BT_HASHED_SIMPLE_PAIR_CACHE_H
+
+
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
index 12f422f193f..0aa75f2bff3 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
@@ -273,6 +273,8 @@ void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransf
+
+
void btCompoundShape::setLocalScaling(const btVector3& scaling)
{
@@ -283,7 +285,7 @@ void btCompoundShape::setLocalScaling(const btVector3& scaling)
// childScale = childScale * (childTrans.getBasis() * scaling);
childScale = childScale * scaling / m_localScaling;
m_children[i].m_childShape->setLocalScaling(childScale);
- childTrans.setOrigin((childTrans.getOrigin())*scaling);
+ childTrans.setOrigin((childTrans.getOrigin()) * scaling / m_localScaling);
updateChildTransform(i, childTrans,false);
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
index 5e83087b320..2d83c8bfbac 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
@@ -62,6 +62,10 @@ void btConeShape::setConeUpIndex(int upIndex)
default:
btAssert(0);
};
+
+ m_implicitShapeDimensions[m_coneIndices[0]] = m_radius;
+ m_implicitShapeDimensions[m_coneIndices[1]] = m_height;
+ m_implicitShapeDimensions[m_coneIndices[2]] = m_radius;
}
btVector3 btConeShape::coneLocalSupport(const btVector3& v) const
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h
index 5966ae48f11..4a0df0d558b 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h
@@ -90,6 +90,13 @@ public:
}
virtual void setLocalScaling(const btVector3& scaling);
+
+
+ virtual int calculateSerializeBufferSize() const;
+
+ ///fills the dataBuffer and returns the struct name (and 0 on failure)
+ virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
+
};
@@ -104,19 +111,61 @@ class btConeShapeX : public btConeShape
return btVector3 (1,0,0);
}
+ //debugging
+ virtual const char* getName()const
+ {
+ return "ConeX";
+ }
+
+
};
///btConeShapeZ implements a Cone shape, around the Z axis
class btConeShapeZ : public btConeShape
{
- public:
- btConeShapeZ(btScalar radius,btScalar height);
+public:
+ btConeShapeZ(btScalar radius,btScalar height);
virtual btVector3 getAnisotropicRollingFrictionDirection() const
{
return btVector3 (0,0,1);
}
+ //debugging
+ virtual const char* getName()const
+ {
+ return "ConeZ";
+ }
+
+
};
+
+///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+struct btConeShapeData
+{
+ btConvexInternalShapeData m_convexInternalShapeData;
+
+ int m_upIndex;
+
+ char m_padding[4];
+};
+
+SIMD_FORCE_INLINE int btConeShape::calculateSerializeBufferSize() const
+{
+ return sizeof(btConeShapeData);
+}
+
+///fills the dataBuffer and returns the struct name (and 0 on failure)
+SIMD_FORCE_INLINE const char* btConeShape::serialize(void* dataBuffer, btSerializer* serializer) const
+{
+ btConeShapeData* shapeData = (btConeShapeData*) dataBuffer;
+
+ btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer);
+
+ shapeData->m_upIndex = m_coneIndices[1];
+
+ return "btConeShapeData";
+}
+
#endif //BT_CONE_MINKOWSKI_H
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
index 9d40dfdd0dd..fb0d9fdb75a 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
@@ -21,6 +21,7 @@ subject to the following restrictions:
#include "btTriangleShape.h"
#include "btSphereShape.h"
#include "btCylinderShape.h"
+#include "btConeShape.h"
#include "btCapsuleShape.h"
#include "btConvexHullShape.h"
#include "btConvexPointCloudShape.h"
@@ -336,6 +337,11 @@ btScalar btConvexShape::getMarginNonVirtual () const
btCylinderShape* cylShape = (btCylinderShape*)this;
return cylShape->getMarginNV();
}
+ case CONE_SHAPE_PROXYTYPE:
+ {
+ btConeShape* conShape = (btConeShape*)this;
+ return conShape->getMarginNV();
+ }
case CAPSULE_SHAPE_PROXYTYPE:
{
btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
index 8d4080a63a6..26322791d04 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
@@ -369,7 +369,7 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
getVertex(x+1,j+1,vertices[2]);
callback->processTriangle(vertices,x,j);
//second triangle
- getVertex(x,j,vertices[0]);
+ // getVertex(x,j,vertices[0]);//already got this vertex before, thanks to Danny Chapman
getVertex(x+1,j+1,vertices[1]);
getVertex(x,j+1,vertices[2]);
callback->processTriangle(vertices,x,j);
@@ -382,7 +382,7 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
callback->processTriangle(vertices,x,j);
//second triangle
getVertex(x+1,j,vertices[0]);
- getVertex(x,j+1,vertices[1]);
+ //getVertex(x,j+1,vertices[1]);
getVertex(x+1,j+1,vertices[2]);
callback->processTriangle(vertices,x,j);
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp
index 51a2f8a0739..5fbed334ec1 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp
@@ -111,10 +111,10 @@ int btTriangleMesh::findOrAddVertex(const btVector3& vertex, bool removeDuplicat
return i/3;
}
}
- }
- m_3componentVertices.push_back((float)vertex.getX());
- m_3componentVertices.push_back((float)vertex.getY());
- m_3componentVertices.push_back((float)vertex.getZ());
+ }
+ m_3componentVertices.push_back(vertex.getX());
+ m_3componentVertices.push_back(vertex.getY());
+ m_3componentVertices.push_back(vertex.getZ());
m_indexedMeshes[0].m_numVertices++;
m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
return (m_3componentVertices.size()/3)-1;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
index 29d1b5cdaa4..0afc2321ff0 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
@@ -27,7 +27,7 @@ subject to the following restrictions:
class btTriangleMesh : public btTriangleIndexVertexArray
{
btAlignedObjectArray<btVector3> m_4componentVertices;
- btAlignedObjectArray<float> m_3componentVertices;
+ btAlignedObjectArray<btScalar> m_3componentVertices;
btAlignedObjectArray<unsigned int> m_32bitIndices;
btAlignedObjectArray<unsigned short int> m_16bitIndices;
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
index 72eb5aec461..29620abffb9 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
@@ -17,7 +17,6 @@ subject to the following restrictions:
#ifndef BT_CONVEX_PENETRATION_DEPTH_H
#define BT_CONVEX_PENETRATION_DEPTH_H
-class btStackAlloc;
class btVector3;
#include "btSimplexSolverInterface.h"
class btConvexShape;
@@ -33,8 +32,7 @@ public:
const btConvexShape* convexA,const btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
- class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
- ) = 0;
+ class btIDebugDraw* debugDraw) = 0;
};
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
index f958cc523ef..46ce1ab75e7 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
@@ -19,7 +19,6 @@ subject to the following restrictions:
#include "LinearMath/btTransform.h"
#include "LinearMath/btVector3.h"
-class btStackAlloc;
/// This interface is made to be used by an iterative approach to do TimeOfImpact calculations
/// This interface allows to query for closest points and penetration depth between two (convex) objects
@@ -43,15 +42,13 @@ struct btDiscreteCollisionDetectorInterface
struct ClosestPointInput
{
ClosestPointInput()
- :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT)),
- m_stackAlloc(0)
+ :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT))
{
}
btTransform m_transformA;
btTransform m_transformB;
btScalar m_maximumDistanceSquared;
- btStackAlloc* m_stackAlloc;
};
virtual ~btDiscreteCollisionDetectorInterface() {};
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
index c6dc3f3a672..572ec36f563 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
@@ -25,7 +25,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB,
btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
- class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc )
+ class btIDebugDraw* debugDraw)
{
(void)debugDraw;
@@ -34,7 +34,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
// const btScalar radialmargin(btScalar(0.));
- btVector3 guessVector(transformA.getOrigin()-transformB.getOrigin());
+ btVector3 guessVector(transformB.getOrigin()-transformA.getOrigin());
btGjkEpaSolver2::sResults results;
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
index a49689a1501..1ed6340af3b 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
@@ -33,7 +33,7 @@ class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB,
btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
- class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
+ class btIDebugDraw* debugDraw);
private :
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
index 8af16b9cf6f..8877579496b 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
@@ -50,7 +50,8 @@ m_marginA(objectA->getMargin()),
m_marginB(objectB->getMargin()),
m_ignoreMargin(false),
m_lastUsedMethod(-1),
-m_catchDegeneracies(1)
+m_catchDegeneracies(1),
+m_fixContactNormalDirection(1)
{
}
btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver)
@@ -65,7 +66,8 @@ m_marginA(marginA),
m_marginB(marginB),
m_ignoreMargin(false),
m_lastUsedMethod(-1),
-m_catchDegeneracies(1)
+m_catchDegeneracies(1),
+m_fixContactNormalDirection(1)
{
}
@@ -353,7 +355,7 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu
m_minkowskiA,m_minkowskiB,
localTransA,localTransB,
m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB,
- debugDraw,input.m_stackAlloc
+ debugDraw
);
@@ -438,6 +440,27 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu
}
#endif
+ if (m_fixContactNormalDirection)
+ {
+ ///@workaround for sticky convex collisions
+ //in some degenerate cases (usually when the use uses very small margins)
+ //the contact normal is pointing the wrong direction
+ //so fix it now (until we can deal with all degenerate cases in GJK and EPA)
+ //contact normals need to point from B to A in all cases, so we can simply check if the contact normal really points from B to A
+ //We like to use a dot product of the normal against the difference of the centroids,
+ //once the centroid is available in the API
+ //until then we use the center of the aabb to approximate the centroid
+ btVector3 aabbMin,aabbMax;
+ m_minkowskiA->getAabb(localTransA,aabbMin,aabbMax);
+ btVector3 posA = (aabbMax+aabbMin)*btScalar(0.5);
+
+ m_minkowskiB->getAabb(localTransB,aabbMin,aabbMax);
+ btVector3 posB = (aabbMin+aabbMax)*btScalar(0.5);
+
+ btVector3 diff = posA-posB;
+ if (diff.dot(normalInB) < 0.f)
+ normalInB *= -1.f;
+ }
m_cachedSeparatingAxis = normalInB;
m_cachedSeparatingDistance = distance;
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h
index f0043b8b9f2..feeae686213 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h
@@ -52,7 +52,7 @@ public:
int m_curIter;
int m_degenerateSimplex;
int m_catchDegeneracies;
-
+ int m_fixContactNormalDirection;
btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
index fe31f08d61a..fa45f49037e 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
@@ -26,11 +26,10 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
const btConvexShape* convexA,const btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
- class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+ class btIDebugDraw* debugDraw
)
{
- (void)stackAlloc;
(void)v;
bool check2d= convexA->isConvex2d() && convexB->isConvex2d();
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
index 6a8fe52f36f..fd533b4fc33 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
@@ -32,7 +32,7 @@ public:
const btConvexShape* convexA,const btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
- class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+ class btIDebugDraw* debugDraw
);
};
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
index f012889a70e..3999d400503 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
@@ -35,7 +35,7 @@ public:
kF_None = 0,
kF_FilterBackfaces = 1 << 0,
kF_KeepUnflippedNormal = 1 << 1, // Prevents returned face normal getting flipped when a ray hits a back-facing triangle
-
+ kF_UseSubSimplexConvexCastRaytest = 1 << 2, // Uses an approximate but faster ray versus convex intersection algorithm
kF_Terminator = 0xFFFFFFFF
};
unsigned int m_flags;
diff --git a/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h b/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h
index c81813c92be..dffb06dfe94 100644
--- a/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h
+++ b/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h
@@ -31,7 +31,7 @@ public:
virtual void setWalkDirection(const btVector3& walkDirection) = 0;
virtual void setVelocityForTimeInterval(const btVector3& velocity, btScalar timeInterval) = 0;
- virtual void reset () = 0;
+ virtual void reset ( btCollisionWorld* collisionWorld ) = 0;
virtual void warp (const btVector3& origin) = 0;
virtual void preStep ( btCollisionWorld* collisionWorld) = 0;
@@ -40,6 +40,7 @@ public:
virtual void jump () = 0;
virtual bool onGround () const = 0;
+ virtual void setUpInterpolate (bool value) = 0;
};
#endif //BT_CHARACTER_CONTROLLER_INTERFACE_H
diff --git a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
index 9db909a5469..8f1cd20bf45 100644
--- a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
+++ b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
@@ -14,6 +14,7 @@ subject to the following restrictions:
*/
+#include <stdio.h>
#include "LinearMath/btIDebugDraw.h"
#include "BulletCollision/CollisionDispatch/btGhostObject.h"
#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
@@ -79,7 +80,7 @@ public:
if (!convexResult.m_hitCollisionObject->hasContactResponse())
return btScalar(1.0);
-
+
btVector3 hitNormalWorld;
if (normalInWorldSpace)
{
@@ -149,7 +150,11 @@ btKinematicCharacterController::btKinematicCharacterController (btPairCachingGho
m_jumpSpeed = 10.0; // ?
m_wasOnGround = false;
m_wasJumping = false;
+ m_interpolateUp = true;
setMaxSlope(btRadians(45.0));
+ m_currentStepOffset = 0;
+ full_drop = false;
+ bounce_fix = false;
}
btKinematicCharacterController::~btKinematicCharacterController ()
@@ -190,9 +195,10 @@ bool btKinematicCharacterController::recoverFromPenetration ( btCollisionWorld*
m_manifoldArray.resize(0);
btBroadphasePair* collisionPair = &m_ghostObject->getOverlappingPairCache()->getOverlappingPairArray()[i];
+
btCollisionObject* obj0 = static_cast<btCollisionObject*>(collisionPair->m_pProxy0->m_clientObject);
- btCollisionObject* obj1 = static_cast<btCollisionObject*>(collisionPair->m_pProxy1->m_clientObject);
-
+ btCollisionObject* obj1 = static_cast<btCollisionObject*>(collisionPair->m_pProxy1->m_clientObject);
+
if ((obj0 && !obj0->hasContactResponse()) || (obj1 && !obj1->hasContactResponse()))
continue;
@@ -268,7 +274,10 @@ void btKinematicCharacterController::stepUp ( btCollisionWorld* world)
{
// we moved up only a fraction of the step height
m_currentStepOffset = m_stepHeight * callback.m_closestHitFraction;
- m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction);
+ if (m_interpolateUp == true)
+ m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction);
+ else
+ m_currentPosition = m_targetPosition;
}
m_verticalVelocity = 0.0;
m_verticalOffset = 0.0;
@@ -333,7 +342,8 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co
{
if (m_normalizedDirection.dot(m_touchingNormal) > btScalar(0.0))
{
- updateTargetPositionBasedOnCollision (m_touchingNormal);
+ //interferes with step movement
+ //updateTargetPositionBasedOnCollision (m_touchingNormal);
}
}
@@ -405,7 +415,8 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co
void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld, btScalar dt)
{
- btTransform start, end;
+ btTransform start, end, end_double;
+ bool runonce = false;
// phase 3: down
/*btScalar additionalDownStep = (m_wasOnGround && !onGround()) ? m_stepHeight : 0.0;
@@ -414,44 +425,124 @@ void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld
btVector3 gravity_drop = getUpAxisDirections()[m_upAxis] * downVelocity;
m_targetPosition -= (step_drop + gravity_drop);*/
+ btVector3 orig_position = m_targetPosition;
+
btScalar downVelocity = (m_verticalVelocity<0.f?-m_verticalVelocity:0.f) * dt;
- if(downVelocity > 0.0 && downVelocity < m_stepHeight
+
+ if(downVelocity > 0.0 && downVelocity > m_fallSpeed
&& (m_wasOnGround || !m_wasJumping))
- {
- downVelocity = m_stepHeight;
- }
+ downVelocity = m_fallSpeed;
btVector3 step_drop = getUpAxisDirections()[m_upAxis] * (m_currentStepOffset + downVelocity);
m_targetPosition -= step_drop;
- start.setIdentity ();
- end.setIdentity ();
+ btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject, getUpAxisDirections()[m_upAxis], m_maxSlopeCosine);
+ callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup;
+ callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask;
- start.setOrigin (m_currentPosition);
- end.setOrigin (m_targetPosition);
+ btKinematicClosestNotMeConvexResultCallback callback2 (m_ghostObject, getUpAxisDirections()[m_upAxis], m_maxSlopeCosine);
+ callback2.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup;
+ callback2.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask;
- btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject, getUpAxisDirections()[m_upAxis], m_maxSlopeCosine);
- callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup;
- callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask;
-
- if (m_useGhostObjectSweepTest)
+ while (1)
{
- m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
- } else
- {
- collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
+ start.setIdentity ();
+ end.setIdentity ();
+
+ end_double.setIdentity ();
+
+ start.setOrigin (m_currentPosition);
+ end.setOrigin (m_targetPosition);
+
+ //set double test for 2x the step drop, to check for a large drop vs small drop
+ end_double.setOrigin (m_targetPosition - step_drop);
+
+ if (m_useGhostObjectSweepTest)
+ {
+ m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
+
+ if (!callback.hasHit())
+ {
+ //test a double fall height, to see if the character should interpolate it's fall (full) or not (partial)
+ m_ghostObject->convexSweepTest (m_convexShape, start, end_double, callback2, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
+ }
+ } else
+ {
+ collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
+
+ if (!callback.hasHit())
+ {
+ //test a double fall height, to see if the character should interpolate it's fall (large) or not (small)
+ collisionWorld->convexSweepTest (m_convexShape, start, end_double, callback2, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
+ }
+ }
+
+ btScalar downVelocity2 = (m_verticalVelocity<0.f?-m_verticalVelocity:0.f) * dt;
+ bool has_hit = false;
+ if (bounce_fix == true)
+ has_hit = callback.hasHit() || callback2.hasHit();
+ else
+ has_hit = callback2.hasHit();
+
+ if(downVelocity2 > 0.0 && downVelocity2 < m_stepHeight && has_hit == true && runonce == false
+ && (m_wasOnGround || !m_wasJumping))
+ {
+ //redo the velocity calculation when falling a small amount, for fast stairs motion
+ //for larger falls, use the smoother/slower interpolated movement by not touching the target position
+
+ m_targetPosition = orig_position;
+ downVelocity = m_stepHeight;
+
+ btVector3 step_drop = getUpAxisDirections()[m_upAxis] * (m_currentStepOffset + downVelocity);
+ m_targetPosition -= step_drop;
+ runonce = true;
+ continue; //re-run previous tests
+ }
+ break;
}
- if (callback.hasHit())
+ if (callback.hasHit() || runonce == true)
{
// we dropped a fraction of the height -> hit floor
- m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction);
+
+ btScalar fraction = (m_currentPosition.getY() - callback.m_hitPointWorld.getY()) / 2;
+
+ //printf("hitpoint: %g - pos %g\n", callback.m_hitPointWorld.getY(), m_currentPosition.getY());
+
+ if (bounce_fix == true)
+ {
+ if (full_drop == true)
+ m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction);
+ else
+ //due to errors in the closestHitFraction variable when used with large polygons, calculate the hit fraction manually
+ m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, fraction);
+ }
+ else
+ m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction);
+
+ full_drop = false;
+
m_verticalVelocity = 0.0;
m_verticalOffset = 0.0;
m_wasJumping = false;
} else {
// we dropped the full height
+ full_drop = true;
+
+ if (bounce_fix == true)
+ {
+ downVelocity = (m_verticalVelocity<0.f?-m_verticalVelocity:0.f) * dt;
+ if (downVelocity > m_fallSpeed && (m_wasOnGround || !m_wasJumping))
+ {
+ m_targetPosition += step_drop; //undo previous target change
+ downVelocity = m_fallSpeed;
+ step_drop = getUpAxisDirections()[m_upAxis] * (m_currentStepOffset + downVelocity);
+ m_targetPosition -= step_drop;
+ }
+ }
+ //printf("full drop - %g, %g\n", m_currentPosition.getY(), m_targetPosition.getY());
+
m_currentPosition = m_targetPosition;
}
}
@@ -484,13 +575,24 @@ btScalar timeInterval
m_useWalkDirection = false;
m_walkDirection = velocity;
m_normalizedDirection = getNormalizedVector(m_walkDirection);
- m_velocityTimeInterval = timeInterval;
+ m_velocityTimeInterval += timeInterval;
}
-
-
-void btKinematicCharacterController::reset ()
-{
+void btKinematicCharacterController::reset ( btCollisionWorld* collisionWorld )
+{
+ m_verticalVelocity = 0.0;
+ m_verticalOffset = 0.0;
+ m_wasOnGround = false;
+ m_wasJumping = false;
+ m_walkDirection.setValue(0,0,0);
+ m_velocityTimeInterval = 0.0;
+
+ //clear pair cache
+ btHashedOverlappingPairCache *cache = m_ghostObject->getOverlappingPairCache();
+ while (cache->getOverlappingPairArray().size() > 0)
+ {
+ cache->removeOverlappingPair(cache->getOverlappingPairArray()[0].m_pProxy0, cache->getOverlappingPairArray()[0].m_pProxy1, collisionWorld->getDispatcher());
+ }
}
void btKinematicCharacterController::warp (const btVector3& origin)
@@ -661,3 +763,8 @@ btVector3* btKinematicCharacterController::getUpAxisDirections()
void btKinematicCharacterController::debugDraw(btIDebugDraw* debugDrawer)
{
}
+
+void btKinematicCharacterController::setUpInterpolate(bool value)
+{
+ m_interpolateUp = value;
+}
diff --git a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h
index 8ec63735cd8..add6f30a687 100644
--- a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h
+++ b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h
@@ -81,6 +81,9 @@ protected:
int m_upAxis;
static btVector3* getUpAxisDirections();
+ bool m_interpolateUp;
+ bool full_drop;
+ bool bounce_fix;
btVector3 computeReflectionDirection (const btVector3& direction, const btVector3& normal);
btVector3 parallelComponent (const btVector3& direction, const btVector3& normal);
@@ -133,7 +136,7 @@ public:
virtual void setVelocityForTimeInterval(const btVector3& velocity,
btScalar timeInterval);
- void reset ();
+ void reset ( btCollisionWorld* collisionWorld );
void warp (const btVector3& origin);
void preStep ( btCollisionWorld* collisionWorld);
@@ -161,6 +164,7 @@ public:
}
bool onGround () const;
+ void setUpInterpolate (bool value);
};
#endif // BT_KINEMATIC_CHARACTER_CONTROLLER_H
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
index 09c048beda8..1735b524dba 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
@@ -40,6 +40,15 @@ and swing 1 and 2 are along the z and y axes respectively.
#include "btJacobianEntry.h"
#include "btTypedConstraint.h"
+#ifdef BT_USE_DOUBLE_PRECISION
+#define btConeTwistConstraintData2 btConeTwistConstraintDoubleData
+#define btConeTwistConstraintDataName "btConeTwistConstraintDoubleData"
+#else
+#define btConeTwistConstraintData2 btConeTwistConstraintData
+#define btConeTwistConstraintDataName "btConeTwistConstraintData"
+#endif //BT_USE_DOUBLE_PRECISION
+
+
class btRigidBody;
enum btConeTwistFlags
@@ -295,7 +304,30 @@ public:
};
-///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+
+
+struct btConeTwistConstraintDoubleData
+{
+ btTypedConstraintDoubleData m_typeConstraintData;
+ btTransformDoubleData m_rbAFrame;
+ btTransformDoubleData m_rbBFrame;
+
+ //limits
+ double m_swingSpan1;
+ double m_swingSpan2;
+ double m_twistSpan;
+ double m_limitSoftness;
+ double m_biasFactor;
+ double m_relaxationFactor;
+
+ double m_damping;
+
+
+
+};
+
+#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION
+///this structure is not used, except for loading pre-2.82 .bullet files
struct btConeTwistConstraintData
{
btTypedConstraintData m_typeConstraintData;
@@ -315,12 +347,12 @@ struct btConeTwistConstraintData
char m_pad[4];
};
-
-
+#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION
+//
SIMD_FORCE_INLINE int btConeTwistConstraint::calculateSerializeBufferSize() const
{
- return sizeof(btConeTwistConstraintData);
+ return sizeof(btConeTwistConstraintData2);
}
@@ -328,21 +360,21 @@ SIMD_FORCE_INLINE int btConeTwistConstraint::calculateSerializeBufferSize() cons
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btConeTwistConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
{
- btConeTwistConstraintData* cone = (btConeTwistConstraintData*) dataBuffer;
+ btConeTwistConstraintData2* cone = (btConeTwistConstraintData2*) dataBuffer;
btTypedConstraint::serialize(&cone->m_typeConstraintData,serializer);
- m_rbAFrame.serializeFloat(cone->m_rbAFrame);
- m_rbBFrame.serializeFloat(cone->m_rbBFrame);
+ m_rbAFrame.serialize(cone->m_rbAFrame);
+ m_rbBFrame.serialize(cone->m_rbBFrame);
- cone->m_swingSpan1 = float(m_swingSpan1);
- cone->m_swingSpan2 = float(m_swingSpan2);
- cone->m_twistSpan = float(m_twistSpan);
- cone->m_limitSoftness = float(m_limitSoftness);
- cone->m_biasFactor = float(m_biasFactor);
- cone->m_relaxationFactor = float(m_relaxationFactor);
- cone->m_damping = float(m_damping);
-
- return "btConeTwistConstraintData";
+ cone->m_swingSpan1 = m_swingSpan1;
+ cone->m_swingSpan2 = m_swingSpan2;
+ cone->m_twistSpan = m_twistSpan;
+ cone->m_limitSoftness = m_limitSoftness;
+ cone->m_biasFactor = m_biasFactor;
+ cone->m_relaxationFactor = m_relaxationFactor;
+ cone->m_damping = m_damping;
+
+ return btConeTwistConstraintDataName;
}
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h
index 6f673102be2..1ba1cd1e839 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h
@@ -28,6 +28,14 @@ class btIDebugDraw;
class btStackAlloc;
class btDispatcher;
/// btConstraintSolver provides solver interface
+
+
+enum btConstraintSolverType
+{
+ BT_SEQUENTIAL_IMPULSE_SOLVER=1,
+ BT_MLCP_SOLVER=2
+};
+
class btConstraintSolver
{
@@ -38,12 +46,16 @@ public:
virtual void prepareSolve (int /* numBodies */, int /* numManifolds */) {;}
///solve a group of constraints
- virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints, const btContactSolverInfo& info,class btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher) = 0;
+ virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints, const btContactSolverInfo& info,class btIDebugDraw* debugDrawer,btDispatcher* dispatcher) = 0;
- virtual void allSolved (const btContactSolverInfo& /* info */,class btIDebugDraw* /* debugDrawer */, btStackAlloc* /* stackAlloc */) {;}
+ virtual void allSolved (const btContactSolverInfo& /* info */,class btIDebugDraw* /* debugDrawer */) {;}
///clear internal cached data and reset random seed
virtual void reset() = 0;
+
+ virtual btConstraintSolverType getSolverType() const=0;
+
+
};
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp
new file mode 100644
index 00000000000..f93a3280f35
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp
@@ -0,0 +1,129 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btFixedConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btTransformUtil.h"
+#include <new>
+
+
+btFixedConstraint::btFixedConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& frameInA,const btTransform& frameInB)
+:btTypedConstraint(FIXED_CONSTRAINT_TYPE,rbA,rbB)
+{
+ m_pivotInA = frameInA.getOrigin();
+ m_pivotInB = frameInB.getOrigin();
+ m_relTargetAB = frameInA.getRotation()*frameInB.getRotation().inverse();
+
+}
+
+btFixedConstraint::~btFixedConstraint ()
+{
+}
+
+
+void btFixedConstraint::getInfo1 (btConstraintInfo1* info)
+{
+ info->m_numConstraintRows = 6;
+ info->nub = 6;
+}
+
+void btFixedConstraint::getInfo2 (btConstraintInfo2* info)
+{
+ //fix the 3 linear degrees of freedom
+
+
+ const btVector3& worldPosA = m_rbA.getCenterOfMassTransform().getOrigin();
+ const btMatrix3x3& worldOrnA = m_rbA.getCenterOfMassTransform().getBasis();
+ const btVector3& worldPosB= m_rbB.getCenterOfMassTransform().getOrigin();
+ const btMatrix3x3& worldOrnB = m_rbB.getCenterOfMassTransform().getBasis();
+
+
+ info->m_J1linearAxis[0] = 1;
+ info->m_J1linearAxis[info->rowskip+1] = 1;
+ info->m_J1linearAxis[2*info->rowskip+2] = 1;
+
+ btVector3 a1 = worldOrnA*m_pivotInA;
+ {
+ btVector3* angular0 = (btVector3*)(info->m_J1angularAxis);
+ btVector3* angular1 = (btVector3*)(info->m_J1angularAxis+info->rowskip);
+ btVector3* angular2 = (btVector3*)(info->m_J1angularAxis+2*info->rowskip);
+ btVector3 a1neg = -a1;
+ a1neg.getSkewSymmetricMatrix(angular0,angular1,angular2);
+ }
+
+ if (info->m_J2linearAxis)
+ {
+ info->m_J2linearAxis[0] = -1;
+ info->m_J2linearAxis[info->rowskip+1] = -1;
+ info->m_J2linearAxis[2*info->rowskip+2] = -1;
+ }
+
+ btVector3 a2 = worldOrnB*m_pivotInB;
+
+ {
+ // btVector3 a2n = -a2;
+ btVector3* angular0 = (btVector3*)(info->m_J2angularAxis);
+ btVector3* angular1 = (btVector3*)(info->m_J2angularAxis+info->rowskip);
+ btVector3* angular2 = (btVector3*)(info->m_J2angularAxis+2*info->rowskip);
+ a2.getSkewSymmetricMatrix(angular0,angular1,angular2);
+ }
+
+ // set right hand side for the linear dofs
+ btScalar k = info->fps * info->erp;
+
+ btVector3 linearError = k*(a2+worldPosB-a1-worldPosA);
+ int j;
+ for (j=0; j<3; j++)
+ {
+
+
+
+ info->m_constraintError[j*info->rowskip] = linearError[j];
+ //printf("info->m_constraintError[%d]=%f\n",j,info->m_constraintError[j]);
+ }
+
+ //fix the 3 angular degrees of freedom
+
+ int start_row = 3;
+ int s = info->rowskip;
+ int start_index = start_row * s;
+
+ // 3 rows to make body rotations equal
+ info->m_J1angularAxis[start_index] = 1;
+ info->m_J1angularAxis[start_index + s + 1] = 1;
+ info->m_J1angularAxis[start_index + s*2+2] = 1;
+ if ( info->m_J2angularAxis)
+ {
+ info->m_J2angularAxis[start_index] = -1;
+ info->m_J2angularAxis[start_index + s+1] = -1;
+ info->m_J2angularAxis[start_index + s*2+2] = -1;
+ }
+
+ // set right hand side for the angular dofs
+
+ btVector3 diff;
+ btScalar angle;
+ btMatrix3x3 mrelCur = worldOrnA *worldOrnB.inverse();
+ btQuaternion qrelCur;
+ mrelCur.getRotation(qrelCur);
+ btTransformUtil::calculateDiffAxisAngleQuaternion(m_relTargetAB,qrelCur,diff,angle);
+ diff*=-angle;
+ for (j=0; j<3; j++)
+ {
+ info->m_constraintError[(3+j)*info->rowskip] = k * diff[j];
+ }
+
+} \ No newline at end of file
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h
new file mode 100644
index 00000000000..697e319e2ce
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h
@@ -0,0 +1,49 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_FIXED_CONSTRAINT_H
+#define BT_FIXED_CONSTRAINT_H
+
+#include "btTypedConstraint.h"
+
+ATTRIBUTE_ALIGNED16(class) btFixedConstraint : public btTypedConstraint
+{
+ btVector3 m_pivotInA;
+ btVector3 m_pivotInB;
+ btQuaternion m_relTargetAB;
+
+public:
+ btFixedConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& frameInA,const btTransform& frameInB);
+
+ virtual ~btFixedConstraint();
+
+
+ virtual void getInfo1 (btConstraintInfo1* info);
+
+ virtual void getInfo2 (btConstraintInfo2* info);
+
+ virtual void setParam(int num, btScalar value, int axis = -1)
+ {
+ btAssert(0);
+ }
+ virtual btScalar getParam(int num, int axis = -1) const
+ {
+ btAssert(0);
+ return 0.f;
+ }
+
+};
+
+#endif //BT_FIXED_CONSTRAINT_H
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h
index 60f60094843..f9afcb91211 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h
@@ -19,6 +19,18 @@ subject to the following restrictions:
#define BT_GEAR_CONSTRAINT_H
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
+
+
+#ifdef BT_USE_DOUBLE_PRECISION
+#define btGearConstraintData btGearConstraintDoubleData
+#define btGearConstraintDataName "btGearConstraintDoubleData"
+#else
+#define btGearConstraintData btGearConstraintFloatData
+#define btGearConstraintDataName "btGearConstraintFloatData"
+#endif //BT_USE_DOUBLE_PRECISION
+
+
+
///The btGeatConstraint will couple the angular velocity for two bodies around given local axis and ratio.
///See Bullet/Demos/ConstraintDemo for an example use.
class btGearConstraint : public btTypedConstraint
@@ -39,18 +51,102 @@ public:
///internal method used by the constraint solver, don't use them directly
virtual void getInfo2 (btConstraintInfo2* info);
+ void setAxisA(btVector3& axisA)
+ {
+ m_axisInA = axisA;
+ }
+ void setAxisB(btVector3& axisB)
+ {
+ m_axisInB = axisB;
+ }
+ void setRatio(btScalar ratio)
+ {
+ m_ratio = ratio;
+ }
+ const btVector3& getAxisA() const
+ {
+ return m_axisInA;
+ }
+ const btVector3& getAxisB() const
+ {
+ return m_axisInB;
+ }
+ btScalar getRatio() const
+ {
+ return m_ratio;
+ }
+
+
virtual void setParam(int num, btScalar value, int axis = -1)
{
+ (void) num;
+ (void) value;
+ (void) axis;
btAssert(0);
- };
+ }
///return the local value of parameter
virtual btScalar getParam(int num, int axis = -1) const
{
+ (void) num;
+ (void) axis;
btAssert(0);
return 0.f;
}
+ virtual int calculateSerializeBufferSize() const;
+
+ ///fills the dataBuffer and returns the struct name (and 0 on failure)
+ virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
+};
+
+
+
+
+///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+struct btGearConstraintFloatData
+{
+ btTypedConstraintFloatData m_typeConstraintData;
+
+ btVector3FloatData m_axisInA;
+ btVector3FloatData m_axisInB;
+
+ float m_ratio;
+ char m_padding[4];
};
+struct btGearConstraintDoubleData
+{
+ btTypedConstraintDoubleData m_typeConstraintData;
+
+ btVector3DoubleData m_axisInA;
+ btVector3DoubleData m_axisInB;
+
+ double m_ratio;
+};
+
+SIMD_FORCE_INLINE int btGearConstraint::calculateSerializeBufferSize() const
+{
+ return sizeof(btGearConstraintData);
+}
+
+ ///fills the dataBuffer and returns the struct name (and 0 on failure)
+SIMD_FORCE_INLINE const char* btGearConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
+{
+ btGearConstraintData* gear = (btGearConstraintData*)dataBuffer;
+ btTypedConstraint::serialize(&gear->m_typeConstraintData,serializer);
+
+ m_axisInA.serialize( gear->m_axisInA );
+ m_axisInB.serialize( gear->m_axisInB );
+
+ gear->m_ratio = m_ratio;
+
+ return btGearConstraintDataName;
+}
+
+
+
+
+
+
#endif //BT_GEAR_CONSTRAINT_H
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
index 0409f95379b..431a524169e 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
@@ -35,6 +35,14 @@ class btRigidBody;
+#ifdef BT_USE_DOUBLE_PRECISION
+#define btGeneric6DofConstraintData2 btGeneric6DofConstraintDoubleData2
+#define btGeneric6DofConstraintDataName "btGeneric6DofConstraintDoubleData2"
+#else
+#define btGeneric6DofConstraintData2 btGeneric6DofConstraintData
+#define btGeneric6DofConstraintDataName "btGeneric6DofConstraintData"
+#endif //BT_USE_DOUBLE_PRECISION
+
//! Rotation Limit structure for generic joints
class btRotationalLimitMotor
@@ -561,7 +569,7 @@ public:
};
-///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+
struct btGeneric6DofConstraintData
{
btTypedConstraintData m_typeConstraintData;
@@ -578,35 +586,51 @@ struct btGeneric6DofConstraintData
int m_useOffsetForConstraintFrame;
};
+struct btGeneric6DofConstraintDoubleData2
+{
+ btTypedConstraintDoubleData m_typeConstraintData;
+ btTransformDoubleData m_rbAFrame; // constraint axii. Assumes z is hinge axis.
+ btTransformDoubleData m_rbBFrame;
+
+ btVector3DoubleData m_linearUpperLimit;
+ btVector3DoubleData m_linearLowerLimit;
+
+ btVector3DoubleData m_angularUpperLimit;
+ btVector3DoubleData m_angularLowerLimit;
+
+ int m_useLinearReferenceFrameA;
+ int m_useOffsetForConstraintFrame;
+};
+
SIMD_FORCE_INLINE int btGeneric6DofConstraint::calculateSerializeBufferSize() const
{
- return sizeof(btGeneric6DofConstraintData);
+ return sizeof(btGeneric6DofConstraintData2);
}
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btGeneric6DofConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
{
- btGeneric6DofConstraintData* dof = (btGeneric6DofConstraintData*)dataBuffer;
+ btGeneric6DofConstraintData2* dof = (btGeneric6DofConstraintData2*)dataBuffer;
btTypedConstraint::serialize(&dof->m_typeConstraintData,serializer);
- m_frameInA.serializeFloat(dof->m_rbAFrame);
- m_frameInB.serializeFloat(dof->m_rbBFrame);
+ m_frameInA.serialize(dof->m_rbAFrame);
+ m_frameInB.serialize(dof->m_rbBFrame);
int i;
for (i=0;i<3;i++)
{
- dof->m_angularLowerLimit.m_floats[i] = float(m_angularLimits[i].m_loLimit);
- dof->m_angularUpperLimit.m_floats[i] = float(m_angularLimits[i].m_hiLimit);
- dof->m_linearLowerLimit.m_floats[i] = float(m_linearLimits.m_lowerLimit[i]);
- dof->m_linearUpperLimit.m_floats[i] = float(m_linearLimits.m_upperLimit[i]);
+ dof->m_angularLowerLimit.m_floats[i] = m_angularLimits[i].m_loLimit;
+ dof->m_angularUpperLimit.m_floats[i] = m_angularLimits[i].m_hiLimit;
+ dof->m_linearLowerLimit.m_floats[i] = m_linearLimits.m_lowerLimit[i];
+ dof->m_linearUpperLimit.m_floats[i] = m_linearLimits.m_upperLimit[i];
}
dof->m_useLinearReferenceFrameA = m_useLinearReferenceFrameA? 1 : 0;
dof->m_useOffsetForConstraintFrame = m_useOffsetForConstraintFrame ? 1 : 0;
- return "btGeneric6DofConstraintData";
+ return btGeneric6DofConstraintDataName;
}
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h
index 6fabb30369b..1b2e0f62ca8 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h
@@ -21,6 +21,15 @@ subject to the following restrictions:
#include "btTypedConstraint.h"
#include "btGeneric6DofConstraint.h"
+#ifdef BT_USE_DOUBLE_PRECISION
+#define btGeneric6DofSpringConstraintData2 btGeneric6DofSpringConstraintDoubleData2
+#define btGeneric6DofSpringConstraintDataName "btGeneric6DofSpringConstraintDoubleData2"
+#else
+#define btGeneric6DofSpringConstraintData2 btGeneric6DofSpringConstraintData
+#define btGeneric6DofSpringConstraintDataName "btGeneric6DofSpringConstraintData"
+#endif //BT_USE_DOUBLE_PRECISION
+
+
/// Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF
@@ -65,7 +74,6 @@ public:
};
-///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btGeneric6DofSpringConstraintData
{
btGeneric6DofConstraintData m_6dofData;
@@ -76,26 +84,37 @@ struct btGeneric6DofSpringConstraintData
float m_springDamping[6];
};
+struct btGeneric6DofSpringConstraintDoubleData2
+{
+ btGeneric6DofConstraintDoubleData2 m_6dofData;
+
+ int m_springEnabled[6];
+ double m_equilibriumPoint[6];
+ double m_springStiffness[6];
+ double m_springDamping[6];
+};
+
+
SIMD_FORCE_INLINE int btGeneric6DofSpringConstraint::calculateSerializeBufferSize() const
{
- return sizeof(btGeneric6DofSpringConstraintData);
+ return sizeof(btGeneric6DofSpringConstraintData2);
}
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btGeneric6DofSpringConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
{
- btGeneric6DofSpringConstraintData* dof = (btGeneric6DofSpringConstraintData*)dataBuffer;
+ btGeneric6DofSpringConstraintData2* dof = (btGeneric6DofSpringConstraintData2*)dataBuffer;
btGeneric6DofConstraint::serialize(&dof->m_6dofData,serializer);
int i;
for (i=0;i<6;i++)
{
- dof->m_equilibriumPoint[i] = (float)m_equilibriumPoint[i];
- dof->m_springDamping[i] = (float)m_springDamping[i];
+ dof->m_equilibriumPoint[i] = m_equilibriumPoint[i];
+ dof->m_springDamping[i] = m_springDamping[i];
dof->m_springEnabled[i] = m_springEnabled[i]? 1 : 0;
- dof->m_springStiffness[i] = (float)m_springStiffness[i];
+ dof->m_springStiffness[i] = m_springStiffness[i];
}
- return "btGeneric6DofSpringConstraintData";
+ return btGeneric6DofSpringConstraintDataName;
}
#endif // BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h
index a7f2cca5500..7c33ac24e05 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h
@@ -28,8 +28,8 @@ subject to the following restrictions:
class btRigidBody;
#ifdef BT_USE_DOUBLE_PRECISION
-#define btHingeConstraintData btHingeConstraintDoubleData
-#define btHingeConstraintDataName "btHingeConstraintDoubleData"
+#define btHingeConstraintData btHingeConstraintDoubleData2 //rename to 2 for backwards compatibility, so we can still load the 'btHingeConstraintDoubleData' version
+#define btHingeConstraintDataName "btHingeConstraintDoubleData2"
#else
#define btHingeConstraintData btHingeConstraintFloatData
#define btHingeConstraintDataName "btHingeConstraintFloatData"
@@ -302,7 +302,10 @@ public:
};
-///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+
+//only for backward compatibility
+#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION
+///this structure is not used, except for loading pre-2.82 .bullet files
struct btHingeConstraintDoubleData
{
btTypedConstraintData m_typeConstraintData;
@@ -321,7 +324,9 @@ struct btHingeConstraintDoubleData
float m_relaxationFactor;
};
-///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION
+
+
struct btHingeConstraintFloatData
{
btTypedConstraintData m_typeConstraintData;
@@ -344,6 +349,30 @@ struct btHingeConstraintFloatData
+///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+struct btHingeConstraintDoubleData2
+{
+ btTypedConstraintDoubleData m_typeConstraintData;
+ btTransformDoubleData m_rbAFrame; // constraint axii. Assumes z is hinge axis.
+ btTransformDoubleData m_rbBFrame;
+ int m_useReferenceFrameA;
+ int m_angularOnly;
+ int m_enableAngularMotor;
+ double m_motorTargetVelocity;
+ double m_maxMotorImpulse;
+
+ double m_lowerLimit;
+ double m_upperLimit;
+ double m_limitSoftness;
+ double m_biasFactor;
+ double m_relaxationFactor;
+ char m_padding1[4];
+
+};
+
+
+
+
SIMD_FORCE_INLINE int btHingeConstraint::calculateSerializeBufferSize() const
{
return sizeof(btHingeConstraintData);
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h
index 1e13416dfeb..91218949498 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h
@@ -24,10 +24,10 @@ class btRigidBody;
#ifdef BT_USE_DOUBLE_PRECISION
-#define btPoint2PointConstraintData btPoint2PointConstraintDoubleData
-#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData"
+#define btPoint2PointConstraintData2 btPoint2PointConstraintDoubleData2
+#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData2"
#else
-#define btPoint2PointConstraintData btPoint2PointConstraintFloatData
+#define btPoint2PointConstraintData2 btPoint2PointConstraintFloatData
#define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData"
#endif //BT_USE_DOUBLE_PRECISION
@@ -134,24 +134,36 @@ struct btPoint2PointConstraintFloatData
};
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+struct btPoint2PointConstraintDoubleData2
+{
+ btTypedConstraintDoubleData m_typeConstraintData;
+ btVector3DoubleData m_pivotInA;
+ btVector3DoubleData m_pivotInB;
+};
+
+#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION
+///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+///this structure is not used, except for loading pre-2.82 .bullet files
+///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btPoint2PointConstraintDoubleData
{
btTypedConstraintData m_typeConstraintData;
btVector3DoubleData m_pivotInA;
btVector3DoubleData m_pivotInB;
};
+#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION
SIMD_FORCE_INLINE int btPoint2PointConstraint::calculateSerializeBufferSize() const
{
- return sizeof(btPoint2PointConstraintData);
+ return sizeof(btPoint2PointConstraintData2);
}
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btPoint2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
{
- btPoint2PointConstraintData* p2pData = (btPoint2PointConstraintData*)dataBuffer;
+ btPoint2PointConstraintData2* p2pData = (btPoint2PointConstraintData2*)dataBuffer;
btTypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer);
m_pivotInA.serialize(p2pData->m_pivotInA);
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
index 5f9437b7add..be93e35434c 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
@@ -152,7 +152,7 @@ void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(
#endif
}
-// Project Gauss Seidel or the equivalent Sequential Impulse
+// Projected Gauss Seidel or the equivalent Sequential Impulse
void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c)
{
btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm;
@@ -280,7 +280,7 @@ int btSequentialImpulseConstraintSolver::btRandInt2 (int n)
-void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject)
+void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep)
{
btRigidBody* rb = collisionObject? btRigidBody::upcast(collisionObject) : 0;
@@ -299,6 +299,9 @@ void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBod
solverBody->m_linearFactor = rb->getLinearFactor();
solverBody->m_linearVelocity = rb->getLinearVelocity();
solverBody->m_angularVelocity = rb->getAngularVelocity();
+ solverBody->m_externalForceImpulse = rb->getTotalForce()*rb->getInvMass()*timeStep;
+ solverBody->m_externalTorqueImpulse = rb->getTotalTorque()*rb->getInvInertiaTensorWorld()*timeStep ;
+
} else
{
solverBody->m_worldTransform.setIdentity();
@@ -308,6 +311,8 @@ void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBod
solverBody->m_linearFactor.setValue(1,1,1);
solverBody->m_linearVelocity.setValue(0,0,0);
solverBody->m_angularVelocity.setValue(0,0,0);
+ solverBody->m_externalForceImpulse.setValue(0,0,0);
+ solverBody->m_externalTorqueImpulse.setValue(0,0,0);
}
@@ -326,8 +331,7 @@ btScalar btSequentialImpulseConstraintSolver::restitutionCurve(btScalar rel_vel,
-static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode);
-static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode)
+void btSequentialImpulseConstraintSolver::applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode)
{
@@ -351,8 +355,6 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr
{
- solverConstraint.m_contactNormal1 = normalAxis;
- solverConstraint.m_contactNormal2 = -normalAxis;
btSolverBody& solverBodyA = m_tmpSolverBodyPool[solverBodyIdA];
btSolverBody& solverBodyB = m_tmpSolverBodyPool[solverBodyIdB];
@@ -368,15 +370,30 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr
solverConstraint.m_appliedImpulse = 0.f;
solverConstraint.m_appliedPushImpulse = 0.f;
+ if (body0)
{
+ solverConstraint.m_contactNormal1 = normalAxis;
btVector3 ftorqueAxis1 = rel_pos1.cross(solverConstraint.m_contactNormal1);
solverConstraint.m_relpos1CrossNormal = ftorqueAxis1;
- solverConstraint.m_angularComponentA = body0 ? body0->getInvInertiaTensorWorld()*ftorqueAxis1*body0->getAngularFactor() : btVector3(0,0,0);
+ solverConstraint.m_angularComponentA = body0->getInvInertiaTensorWorld()*ftorqueAxis1*body0->getAngularFactor();
+ }else
+ {
+ solverConstraint.m_contactNormal1.setZero();
+ solverConstraint.m_relpos1CrossNormal.setZero();
+ solverConstraint.m_angularComponentA .setZero();
}
+
+ if (body1)
{
+ solverConstraint.m_contactNormal2 = -normalAxis;
btVector3 ftorqueAxis1 = rel_pos2.cross(solverConstraint.m_contactNormal2);
solverConstraint.m_relpos2CrossNormal = ftorqueAxis1;
- solverConstraint.m_angularComponentB = body1 ? body1->getInvInertiaTensorWorld()*ftorqueAxis1*body1->getAngularFactor() : btVector3(0,0,0);
+ solverConstraint.m_angularComponentB = body1->getInvInertiaTensorWorld()*ftorqueAxis1*body1->getAngularFactor();
+ } else
+ {
+ solverConstraint.m_contactNormal2.setZero();
+ solverConstraint.m_relpos2CrossNormal.setZero();
+ solverConstraint.m_angularComponentB.setZero();
}
{
@@ -401,9 +418,9 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr
btScalar rel_vel;
- btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity:btVector3(0,0,0))
+ btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity+solverBodyA.m_externalForceImpulse:btVector3(0,0,0))
+ solverConstraint.m_relpos1CrossNormal.dot(body0?solverBodyA.m_angularVelocity:btVector3(0,0,0));
- btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity:btVector3(0,0,0))
+ btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity+solverBodyB.m_externalForceImpulse:btVector3(0,0,0))
+ solverConstraint.m_relpos2CrossNormal.dot(body1?solverBodyB.m_angularVelocity:btVector3(0,0,0));
rel_vel = vel1Dotn+vel2Dotn;
@@ -414,8 +431,8 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr
btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv);
solverConstraint.m_rhs = velocityImpulse;
solverConstraint.m_cfm = cfmSlip;
- solverConstraint.m_lowerLimit = 0;
- solverConstraint.m_upperLimit = 1e10f;
+ solverConstraint.m_lowerLimit = -solverConstraint.m_friction;
+ solverConstraint.m_upperLimit = solverConstraint.m_friction;
}
}
@@ -481,9 +498,9 @@ void btSequentialImpulseConstraintSolver::setupRollingFrictionConstraint( btSolv
btScalar rel_vel;
- btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity:btVector3(0,0,0))
+ btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity+solverBodyA.m_externalForceImpulse:btVector3(0,0,0))
+ solverConstraint.m_relpos1CrossNormal.dot(body0?solverBodyA.m_angularVelocity:btVector3(0,0,0));
- btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity:btVector3(0,0,0))
+ btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity+solverBodyB.m_externalForceImpulse:btVector3(0,0,0))
+ solverConstraint.m_relpos2CrossNormal.dot(body1?solverBodyB.m_angularVelocity:btVector3(0,0,0));
rel_vel = vel1Dotn+vel2Dotn;
@@ -494,8 +511,8 @@ void btSequentialImpulseConstraintSolver::setupRollingFrictionConstraint( btSolv
btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv);
solverConstraint.m_rhs = velocityImpulse;
solverConstraint.m_cfm = cfmSlip;
- solverConstraint.m_lowerLimit = 0;
- solverConstraint.m_upperLimit = 1e10f;
+ solverConstraint.m_lowerLimit = -solverConstraint.m_friction;
+ solverConstraint.m_upperLimit = solverConstraint.m_friction;
}
}
@@ -517,7 +534,7 @@ btSolverConstraint& btSequentialImpulseConstraintSolver::addRollingFrictionConst
}
-int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& body)
+int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& body,btScalar timeStep)
{
int solverBodyIdA = -1;
@@ -535,11 +552,19 @@ int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject&
{
solverBodyIdA = m_tmpSolverBodyPool.size();
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
- initSolverBody(&solverBody,&body);
+ initSolverBody(&solverBody,&body,timeStep);
body.setCompanionId(solverBodyIdA);
} else
{
- return 0;//assume first one is a fixed solver body
+
+ if (m_fixedBodyId<0)
+ {
+ m_fixedBodyId = m_tmpSolverBodyPool.size();
+ btSolverBody& fixedBody = m_tmpSolverBodyPool.expand();
+ initSolverBody(&fixedBody,0,timeStep);
+ }
+ return m_fixedBodyId;
+// return 0;//assume first one is a fixed solver body
}
}
@@ -552,8 +577,8 @@ int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject&
void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstraint& solverConstraint,
int solverBodyIdA, int solverBodyIdB,
btManifoldPoint& cp, const btContactSolverInfo& infoGlobal,
- btVector3& vel, btScalar& rel_vel, btScalar& relaxation,
- btVector3& rel_pos1, btVector3& rel_pos2)
+ btScalar& relaxation,
+ const btVector3& rel_pos1, const btVector3& rel_pos2)
{
const btVector3& pos1 = cp.getPositionWorldOnA();
@@ -567,8 +592,8 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra
// btVector3 rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin();
// btVector3 rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin();
- rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin();
- rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin();
+ //rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin();
+ //rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin();
relaxation = 1.f;
@@ -601,10 +626,24 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra
solverConstraint.m_jacDiagABInv = denom;
}
- solverConstraint.m_contactNormal1 = cp.m_normalWorldOnB;
- solverConstraint.m_contactNormal2 = -cp.m_normalWorldOnB;
- solverConstraint.m_relpos1CrossNormal = torqueAxis0;
- solverConstraint.m_relpos2CrossNormal = -torqueAxis1;
+ if (rb0)
+ {
+ solverConstraint.m_contactNormal1 = cp.m_normalWorldOnB;
+ solverConstraint.m_relpos1CrossNormal = torqueAxis0;
+ } else
+ {
+ solverConstraint.m_contactNormal1.setZero();
+ solverConstraint.m_relpos1CrossNormal.setZero();
+ }
+ if (rb1)
+ {
+ solverConstraint.m_contactNormal2 = -cp.m_normalWorldOnB;
+ solverConstraint.m_relpos2CrossNormal = -torqueAxis1;
+ }else
+ {
+ solverConstraint.m_contactNormal2.setZero();
+ solverConstraint.m_relpos2CrossNormal.setZero();
+ }
btScalar restitution = 0.f;
btScalar penetration = cp.getDistance()+infoGlobal.m_linearSlop;
@@ -616,8 +655,8 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra
vel2 = rb1? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0);
// btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0);
- vel = vel1 - vel2;
- rel_vel = cp.m_normalWorldOnB.dot(vel);
+ btVector3 vel = vel1 - vel2;
+ btScalar rel_vel = cp.m_normalWorldOnB.dot(vel);
@@ -648,10 +687,17 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra
solverConstraint.m_appliedPushImpulse = 0.f;
{
- btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(rb0?bodyA->m_linearVelocity:btVector3(0,0,0))
- + solverConstraint.m_relpos1CrossNormal.dot(rb0?bodyA->m_angularVelocity:btVector3(0,0,0));
- btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(rb1?bodyB->m_linearVelocity:btVector3(0,0,0))
- + solverConstraint.m_relpos2CrossNormal.dot(rb1?bodyB->m_angularVelocity:btVector3(0,0,0));
+
+ btVector3 externalForceImpulseA = bodyA->m_originalBody ? bodyA->m_externalForceImpulse: btVector3(0,0,0);
+ btVector3 externalTorqueImpulseA = bodyA->m_originalBody ? bodyA->m_externalTorqueImpulse: btVector3(0,0,0);
+ btVector3 externalForceImpulseB = bodyB->m_originalBody ? bodyB->m_externalForceImpulse: btVector3(0,0,0);
+ btVector3 externalTorqueImpulseB = bodyB->m_originalBody ?bodyB->m_externalTorqueImpulse : btVector3(0,0,0);
+
+
+ btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(bodyA->m_linearVelocity+externalForceImpulseA)
+ + solverConstraint.m_relpos1CrossNormal.dot(bodyA->m_angularVelocity+externalTorqueImpulseA);
+ btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(bodyB->m_linearVelocity+externalForceImpulseB)
+ + solverConstraint.m_relpos2CrossNormal.dot(bodyB->m_angularVelocity+externalTorqueImpulseB);
btScalar rel_vel = vel1Dotn+vel2Dotn;
btScalar positionalError = 0.f;
@@ -680,7 +726,7 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra
if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold))
{
//combine position and velocity into rhs
- solverConstraint.m_rhs = penetrationImpulse+velocityImpulse;
+ solverConstraint.m_rhs = penetrationImpulse+velocityImpulse;//-solverConstraint.m_contactNormal1.dot(bodyA->m_externalForce*bodyA->m_invMass-bodyB->m_externalForce/bodyB->m_invMass)*solverConstraint.m_jacDiagABInv;
solverConstraint.m_rhsPenetration = 0.f;
} else
@@ -754,8 +800,8 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
colObj0 = (btCollisionObject*)manifold->getBody0();
colObj1 = (btCollisionObject*)manifold->getBody1();
- int solverBodyIdA = getOrInitSolverBody(*colObj0);
- int solverBodyIdB = getOrInitSolverBody(*colObj1);
+ int solverBodyIdA = getOrInitSolverBody(*colObj0,infoGlobal.m_timeStep);
+ int solverBodyIdB = getOrInitSolverBody(*colObj1,infoGlobal.m_timeStep);
// btRigidBody* bodyA = btRigidBody::upcast(colObj0);
// btRigidBody* bodyB = btRigidBody::upcast(colObj1);
@@ -780,19 +826,35 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
btVector3 rel_pos1;
btVector3 rel_pos2;
btScalar relaxation;
- btScalar rel_vel;
- btVector3 vel;
+
int frictionIndex = m_tmpSolverContactConstraintPool.size();
btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expandNonInitializing();
-// btRigidBody* rb0 = btRigidBody::upcast(colObj0);
-// btRigidBody* rb1 = btRigidBody::upcast(colObj1);
+ btRigidBody* rb0 = btRigidBody::upcast(colObj0);
+ btRigidBody* rb1 = btRigidBody::upcast(colObj1);
solverConstraint.m_solverBodyIdA = solverBodyIdA;
solverConstraint.m_solverBodyIdB = solverBodyIdB;
solverConstraint.m_originalContactPoint = &cp;
- setupContactConstraint(solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal, vel, rel_vel, relaxation, rel_pos1, rel_pos2);
+ const btVector3& pos1 = cp.getPositionWorldOnA();
+ const btVector3& pos2 = cp.getPositionWorldOnB();
+
+ rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin();
+ rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin();
+
+ btVector3 vel1;// = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0);
+ btVector3 vel2;// = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0);
+
+ solverBodyA->getVelocityInLocalPointNoDelta(rel_pos1,vel1);
+ solverBodyB->getVelocityInLocalPointNoDelta(rel_pos2,vel2 );
+
+ btVector3 vel = vel1 - vel2;
+ btScalar rel_vel = cp.m_normalWorldOnB.dot(vel);
+
+ setupContactConstraint(solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal, relaxation, rel_pos1, rel_pos2);
+
+
// const btVector3& pos1 = cp.getPositionWorldOnA();
// const btVector3& pos2 = cp.getPositionWorldOnB();
@@ -801,9 +863,11 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
solverConstraint.m_frictionIndex = m_tmpSolverContactFrictionConstraintPool.size();
- btVector3 angVelA,angVelB;
- solverBodyA->getAngularVelocity(angVelA);
- solverBodyB->getAngularVelocity(angVelB);
+ btVector3 angVelA(0,0,0),angVelB(0,0,0);
+ if (rb0)
+ angVelA = rb0->getAngularVelocity();
+ if (rb1)
+ angVelB = rb1->getAngularVelocity();
btVector3 relAngVel = angVelB-angVelA;
if ((cp.m_combinedRollingFriction>0.f) && (rollingFriction>0))
@@ -857,6 +921,10 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON)
{
cp.m_lateralFrictionDir1 *= 1.f/btSqrt(lat_rel_vel);
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+
if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
{
cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
@@ -864,17 +932,16 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION);
applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION);
addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
-
}
- applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
- applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
- addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
-
} else
{
btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2);
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+
if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
{
applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION);
@@ -882,9 +949,6 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
}
- applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
- applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
- addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION))
{
@@ -899,8 +963,8 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation, cp.m_contactMotion2, cp.m_contactCFM2);
- setFrictionConstraintImpulse( solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal);
}
+ setFrictionConstraintImpulse( solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal);
@@ -909,10 +973,24 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
}
}
-btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc)
+void btSequentialImpulseConstraintSolver::convertContacts(btPersistentManifold** manifoldPtr,int numManifolds, const btContactSolverInfo& infoGlobal)
+{
+ int i;
+ btPersistentManifold* manifold = 0;
+// btCollisionObject* colObj0=0,*colObj1=0;
+
+
+ for (i=0;i<numManifolds;i++)
+ {
+ manifold = manifoldPtr[i];
+ convertContact(manifold,infoGlobal);
+ }
+}
+
+btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
{
+ m_fixedBodyId = -1;
BT_PROFILE("solveGroupCacheFriendlySetup");
- (void)stackAlloc;
(void)debugDrawer;
m_maxOverrideNumSolverIterations = 0;
@@ -996,14 +1074,15 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
m_tmpSolverBodyPool.reserve(numBodies+1);
m_tmpSolverBodyPool.resize(0);
- btSolverBody& fixedBody = m_tmpSolverBodyPool.expand();
- initSolverBody(&fixedBody,0);
+ //btSolverBody& fixedBody = m_tmpSolverBodyPool.expand();
+ //initSolverBody(&fixedBody,0);
//convert all bodies
for (int i=0;i<numBodies;i++)
{
- int bodyId = getOrInitSolverBody(*bodies[i]);
+ int bodyId = getOrInitSolverBody(*bodies[i],infoGlobal.m_timeStep);
+
btRigidBody* body = btRigidBody::upcast(bodies[i]);
if (body && body->getInvMass())
{
@@ -1012,9 +1091,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
if (body->getFlags()&BT_ENABLE_GYROPSCOPIC_FORCE)
{
gyroForce = body->computeGyroscopicForce(infoGlobal.m_maxGyroscopicForce);
+ solverBody.m_externalTorqueImpulse -= gyroForce*body->getInvInertiaTensorWorld()*infoGlobal.m_timeStep;
}
- solverBody.m_linearVelocity += body->getTotalForce()*body->getInvMass()*infoGlobal.m_timeStep;
- solverBody.m_angularVelocity += (body->getTotalTorque()-gyroForce)*body->getInvInertiaTensorWorld()*infoGlobal.m_timeStep;
}
}
@@ -1084,8 +1162,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
btRigidBody& rbA = constraint->getRigidBodyA();
btRigidBody& rbB = constraint->getRigidBodyB();
- int solverBodyIdA = getOrInitSolverBody(rbA);
- int solverBodyIdB = getOrInitSolverBody(rbB);
+ int solverBodyIdA = getOrInitSolverBody(rbA,infoGlobal.m_timeStep);
+ int solverBodyIdB = getOrInitSolverBody(rbB,infoGlobal.m_timeStep);
btSolverBody* bodyAPtr = &m_tmpSolverBodyPool[solverBodyIdA];
btSolverBody* bodyBPtr = &m_tmpSolverBodyPool[solverBodyIdB];
@@ -1182,15 +1260,22 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
}
- ///fix rhs
- ///todo: add force/torque accelerators
+
{
btScalar rel_vel;
- btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(rbA.getLinearVelocity()) + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity());
- btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(rbB.getLinearVelocity()) + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity());
+ btVector3 externalForceImpulseA = bodyAPtr->m_originalBody ? bodyAPtr->m_externalForceImpulse : btVector3(0,0,0);
+ btVector3 externalTorqueImpulseA = bodyAPtr->m_originalBody ? bodyAPtr->m_externalTorqueImpulse : btVector3(0,0,0);
+
+ btVector3 externalForceImpulseB = bodyBPtr->m_originalBody ? bodyBPtr->m_externalForceImpulse : btVector3(0,0,0);
+ btVector3 externalTorqueImpulseB = bodyBPtr->m_originalBody ?bodyBPtr->m_externalTorqueImpulse : btVector3(0,0,0);
+
+ btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(rbA.getLinearVelocity()+externalForceImpulseA)
+ + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity()+externalTorqueImpulseA);
+
+ btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(rbB.getLinearVelocity()+externalForceImpulseB)
+ + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity()+externalTorqueImpulseB);
rel_vel = vel1Dotn+vel2Dotn;
-
btScalar restitution = 0.f;
btScalar positionalError = solverConstraint.m_rhs;//already filled in by getConstraintInfo2
btScalar velocityError = restitution - rel_vel * info2.m_damping;
@@ -1199,6 +1284,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
solverConstraint.m_rhs = penetrationImpulse+velocityImpulse;
solverConstraint.m_appliedImpulse = 0.f;
+
}
}
}
@@ -1206,18 +1292,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
}
}
- {
- int i;
- btPersistentManifold* manifold = 0;
-// btCollisionObject* colObj0=0,*colObj1=0;
-
+ convertContacts(manifoldPtr,numManifolds,infoGlobal);
- for (i=0;i<numManifolds;i++)
- {
- manifold = manifoldPtr[i];
- convertContact(manifold,infoGlobal);
- }
- }
}
// btContactSolverInfo info = infoGlobal;
@@ -1256,7 +1332,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
}
-btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration, btCollisionObject** /*bodies */,int /*numBodies*/,btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* /*debugDrawer*/,btStackAlloc* /*stackAlloc*/)
+btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration, btCollisionObject** /*bodies */,int /*numBodies*/,btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* /*debugDrawer*/)
{
int numNonContactPool = m_tmpSolverNonContactConstraintPool.size();
@@ -1309,14 +1385,14 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
{
for (int j=0;j<numConstraints;j++)
{
- if (constraints[j]->isEnabled())
- {
- int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA());
- int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB());
- btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid];
- btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid];
- constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep);
- }
+ if (constraints[j]->isEnabled())
+ {
+ int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA(),infoGlobal.m_timeStep);
+ int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep);
+ btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid];
+ btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid];
+ constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep);
+ }
}
///solve all contact constraints using SIMD, if available
@@ -1376,7 +1452,8 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
for (j=0;j<numPoolConstraints;j++)
{
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]];
- resolveSingleConstraintRowLowerLimitSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
+ //resolveSingleConstraintRowLowerLimitSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
+ resolveSingleConstraintRowLowerLimit(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
}
@@ -1395,7 +1472,8 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse);
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
- resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
+ //resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
+ resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
}
}
@@ -1437,14 +1515,14 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
{
for (int j=0;j<numConstraints;j++)
{
- if (constraints[j]->isEnabled())
- {
- int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA());
- int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB());
- btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid];
- btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid];
- constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep);
- }
+ if (constraints[j]->isEnabled())
+ {
+ int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA(),infoGlobal.m_timeStep);
+ int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep);
+ btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid];
+ btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid];
+ constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep);
+ }
}
///solve all contact constraints
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
@@ -1492,7 +1570,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
}
-void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc)
+void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
{
int iteration;
if (infoGlobal.m_splitImpulse)
@@ -1532,20 +1610,20 @@ void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIte
}
}
-btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc)
+btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
{
BT_PROFILE("solveGroupCacheFriendlyIterations");
{
///this is a special step to resolve penetrations (just for contacts)
- solveGroupCacheFriendlySplitImpulseIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc);
+ solveGroupCacheFriendlySplitImpulseIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer);
int maxIterations = m_maxOverrideNumSolverIterations > infoGlobal.m_numIterations? m_maxOverrideNumSolverIterations : infoGlobal.m_numIterations;
for ( int iteration = 0 ; iteration< maxIterations ; iteration++)
//for ( int iteration = maxIterations-1 ; iteration >= 0;iteration--)
{
- solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc);
+ solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer);
}
}
@@ -1610,9 +1688,15 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinish(btCo
m_tmpSolverBodyPool[i].writebackVelocityAndTransform(infoGlobal.m_timeStep, infoGlobal.m_splitImpulseTurnErp);
else
m_tmpSolverBodyPool[i].writebackVelocity();
+
+ m_tmpSolverBodyPool[i].m_originalBody->setLinearVelocity(
+ m_tmpSolverBodyPool[i].m_linearVelocity+
+ m_tmpSolverBodyPool[i].m_externalForceImpulse);
+
+ m_tmpSolverBodyPool[i].m_originalBody->setAngularVelocity(
+ m_tmpSolverBodyPool[i].m_angularVelocity+
+ m_tmpSolverBodyPool[i].m_externalTorqueImpulse);
- m_tmpSolverBodyPool[i].m_originalBody->setLinearVelocity(m_tmpSolverBodyPool[i].m_linearVelocity);
- m_tmpSolverBodyPool[i].m_originalBody->setAngularVelocity(m_tmpSolverBodyPool[i].m_angularVelocity);
if (infoGlobal.m_splitImpulse)
m_tmpSolverBodyPool[i].m_originalBody->setWorldTransform(m_tmpSolverBodyPool[i].m_worldTransform);
@@ -1632,15 +1716,15 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinish(btCo
/// btSequentialImpulseConstraintSolver Sequentially applies impulses
-btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/)
+btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btDispatcher* /*dispatcher*/)
{
BT_PROFILE("solveGroup");
//you need to provide at least some bodies
- solveGroupCacheFriendlySetup( bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc);
+ solveGroupCacheFriendlySetup( bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer);
- solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc);
+ solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer);
solveGroupCacheFriendlyFinish(bodies, numBodies, infoGlobal);
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
index 2eea6be0db2..180d2a385d3 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
@@ -18,7 +18,6 @@ subject to the following restrictions:
class btIDebugDraw;
class btPersistentManifold;
-class btStackAlloc;
class btDispatcher;
class btCollisionObject;
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
@@ -43,7 +42,7 @@ protected:
btAlignedObjectArray<int> m_orderFrictionConstraintPool;
btAlignedObjectArray<btTypedConstraint::btConstraintInfo1> m_tmpConstraintSizesPool;
int m_maxOverrideNumSolverIterations;
-
+ int m_fixedBodyId;
void setupFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,
btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,
btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation,
@@ -57,10 +56,11 @@ protected:
btSolverConstraint& addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0., btScalar cfmSlip=0.);
btSolverConstraint& addRollingFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0, btScalar cfmSlip=0.f);
-
+
void setupContactConstraint(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp,
- const btContactSolverInfo& infoGlobal, btVector3& vel, btScalar& rel_vel, btScalar& relaxation,
- btVector3& rel_pos1, btVector3& rel_pos2);
+ const btContactSolverInfo& infoGlobal,btScalar& relaxation, const btVector3& rel_pos1, const btVector3& rel_pos2);
+
+ static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode);
void setFrictionConstraintImpulse( btSolverConstraint& solverConstraint, int solverBodyIdA,int solverBodyIdB,
btManifoldPoint& cp, const btContactSolverInfo& infoGlobal);
@@ -71,6 +71,8 @@ protected:
btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
+ virtual void convertContacts(btPersistentManifold** manifoldPtr, int numManifolds, const btContactSolverInfo& infoGlobal);
+
void convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
@@ -83,8 +85,8 @@ protected:
const btSolverConstraint& contactConstraint);
//internal method
- int getOrInitSolverBody(btCollisionObject& body);
- void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject);
+ int getOrInitSolverBody(btCollisionObject& body,btScalar timeStep);
+ void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep);
void resolveSingleConstraintRowGeneric(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
@@ -97,12 +99,12 @@ protected:
protected:
- virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
+ virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject** bodies,int numBodies,const btContactSolverInfo& infoGlobal);
- btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
+ virtual btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
- virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
- virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
+ virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
+ virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
public:
@@ -112,7 +114,7 @@ public:
btSequentialImpulseConstraintSolver();
virtual ~btSequentialImpulseConstraintSolver();
- virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
+ virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher);
@@ -132,6 +134,11 @@ public:
return m_btSeed2;
}
+
+ virtual btConstraintSolverType getSolverType() const
+ {
+ return BT_SEQUENTIAL_IMPULSE_SOLVER;
+ }
};
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
index ca8e715bc47..57ebb47d8e7 100755
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
@@ -25,7 +25,13 @@ TODO:
#ifndef BT_SLIDER_CONSTRAINT_H
#define BT_SLIDER_CONSTRAINT_H
-
+#ifdef BT_USE_DOUBLE_PRECISION
+#define btSliderConstraintData2 btSliderConstraintDoubleData
+#define btSliderConstraintDataName "btSliderConstraintDoubleData"
+#else
+#define btSliderConstraintData2 btSliderConstraintData
+#define btSliderConstraintDataName "btSliderConstraintData"
+#endif //BT_USE_DOUBLE_PRECISION
#include "LinearMath/btVector3.h"
#include "btJacobianEntry.h"
@@ -283,7 +289,10 @@ public:
};
+
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+
+
struct btSliderConstraintData
{
btTypedConstraintData m_typeConstraintData;
@@ -302,31 +311,48 @@ struct btSliderConstraintData
};
+struct btSliderConstraintDoubleData
+{
+ btTypedConstraintDoubleData m_typeConstraintData;
+ btTransformDoubleData m_rbAFrame; // constraint axii. Assumes z is hinge axis.
+ btTransformDoubleData m_rbBFrame;
+
+ double m_linearUpperLimit;
+ double m_linearLowerLimit;
+
+ double m_angularUpperLimit;
+ double m_angularLowerLimit;
+
+ int m_useLinearReferenceFrameA;
+ int m_useOffsetForConstraintFrame;
+
+};
+
SIMD_FORCE_INLINE int btSliderConstraint::calculateSerializeBufferSize() const
{
- return sizeof(btSliderConstraintData);
+ return sizeof(btSliderConstraintData2);
}
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btSliderConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
{
- btSliderConstraintData* sliderData = (btSliderConstraintData*) dataBuffer;
+ btSliderConstraintData2* sliderData = (btSliderConstraintData2*) dataBuffer;
btTypedConstraint::serialize(&sliderData->m_typeConstraintData,serializer);
- m_frameInA.serializeFloat(sliderData->m_rbAFrame);
- m_frameInB.serializeFloat(sliderData->m_rbBFrame);
+ m_frameInA.serialize(sliderData->m_rbAFrame);
+ m_frameInB.serialize(sliderData->m_rbBFrame);
- sliderData->m_linearUpperLimit = float(m_upperLinLimit);
- sliderData->m_linearLowerLimit = float(m_lowerLinLimit);
+ sliderData->m_linearUpperLimit = m_upperLinLimit;
+ sliderData->m_linearLowerLimit = m_lowerLinLimit;
- sliderData->m_angularUpperLimit = float(m_upperAngLimit);
- sliderData->m_angularLowerLimit = float(m_lowerAngLimit);
+ sliderData->m_angularUpperLimit = m_upperAngLimit;
+ sliderData->m_angularLowerLimit = m_lowerAngLimit;
sliderData->m_useLinearReferenceFrameA = m_useLinearReferenceFrameA;
sliderData->m_useOffsetForConstraintFrame = m_useOffsetForConstraintFrame;
- return "btSliderConstraintData";
+ return btSliderConstraintDataName;
}
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
index ccc45996c8b..27ccefe4169 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
@@ -118,6 +118,8 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverBody
btVector3 m_turnVelocity;
btVector3 m_linearVelocity;
btVector3 m_angularVelocity;
+ btVector3 m_externalForceImpulse;
+ btVector3 m_externalTorqueImpulse;
btRigidBody* m_originalBody;
void setWorldTransform(const btTransform& worldTransform)
@@ -130,6 +132,17 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverBody
return m_worldTransform;
}
+
+
+ SIMD_FORCE_INLINE void getVelocityInLocalPointNoDelta(const btVector3& rel_pos, btVector3& velocity ) const
+ {
+ if (m_originalBody)
+ velocity = m_linearVelocity + m_externalForceImpulse + (m_angularVelocity+m_externalTorqueImpulse).cross(rel_pos);
+ else
+ velocity.setValue(0,0,0);
+ }
+
+
SIMD_FORCE_INLINE void getVelocityInLocalPointObsolete(const btVector3& rel_pos, btVector3& velocity ) const
{
if (m_originalBody)
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h
index 2ade61b2f69..5515e6b311c 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h
@@ -55,6 +55,7 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverConstraint
{
void* m_originalContactPoint;
btScalar m_unusedPadding4;
+ int m_numRowsForNonContactConstraint;
};
int m_overrideNumSolverIterations;
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
index 465c0746c58..27fdd9d3df8 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
@@ -109,7 +109,7 @@ btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScal
///fills the dataBuffer and returns the struct name (and 0 on failure)
const char* btTypedConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
{
- btTypedConstraintData* tcd = (btTypedConstraintData*) dataBuffer;
+ btTypedConstraintData2* tcd = (btTypedConstraintData2*) dataBuffer;
tcd->m_rbA = (btRigidBodyData*)serializer->getUniquePointer(&m_rbA);
tcd->m_rbB = (btRigidBodyData*)serializer->getUniquePointer(&m_rbB);
@@ -123,14 +123,14 @@ const char* btTypedConstraint::serialize(void* dataBuffer, btSerializer* seriali
tcd->m_objectType = m_objectType;
tcd->m_needsFeedback = m_needsFeedback;
tcd->m_overrideNumSolverIterations = m_overrideNumSolverIterations;
- tcd->m_breakingImpulseThreshold = float(m_breakingImpulseThreshold);
+ tcd->m_breakingImpulseThreshold = m_breakingImpulseThreshold;
tcd->m_isEnabled = m_isEnabled? 1: 0;
tcd->m_userConstraintId =m_userConstraintId;
tcd->m_userConstraintType =m_userConstraintType;
- tcd->m_appliedImpulse = float(m_appliedImpulse);
- tcd->m_dbgDrawSize = float(m_dbgDrawSize );
+ tcd->m_appliedImpulse = m_appliedImpulse;
+ tcd->m_dbgDrawSize = m_dbgDrawSize;
tcd->m_disableCollisionsBetweenLinkedBodies = false;
@@ -142,7 +142,7 @@ const char* btTypedConstraint::serialize(void* dataBuffer, btSerializer* seriali
if (m_rbB.getConstraintRef(i) == this)
tcd->m_disableCollisionsBetweenLinkedBodies = true;
- return "btTypedConstraintData";
+ return btTypedConstraintDataName;
}
btRigidBody& btTypedConstraint::getFixedBody()
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h
index 441fa375050..b58f984d0fb 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h
@@ -21,6 +21,15 @@ subject to the following restrictions:
#include "btSolverConstraint.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
+#ifdef BT_USE_DOUBLE_PRECISION
+#define btTypedConstraintData2 btTypedConstraintDoubleData
+#define btTypedConstraintDataName "btTypedConstraintDoubleData"
+#else
+#define btTypedConstraintData2 btTypedConstraintFloatData
+#define btTypedConstraintDataName "btTypedConstraintFloatData"
+#endif //BT_USE_DOUBLE_PRECISION
+
+
class btSerializer;
//Don't change any of the existing enum values, so add enum types at the end for serialization compatibility
@@ -34,6 +43,7 @@ enum btTypedConstraintType
CONTACT_CONSTRAINT_TYPE,
D6_SPRING_CONSTRAINT_TYPE,
GEAR_CONSTRAINT_TYPE,
+ FIXED_CONSTRAINT_TYPE,
MAX_CONSTRAINT_TYPE
};
@@ -356,6 +366,33 @@ SIMD_FORCE_INLINE btScalar btAdjustAngleToLimits(btScalar angleInRadians, btScal
}
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+struct btTypedConstraintFloatData
+{
+ btRigidBodyFloatData *m_rbA;
+ btRigidBodyFloatData *m_rbB;
+ char *m_name;
+
+ int m_objectType;
+ int m_userConstraintType;
+ int m_userConstraintId;
+ int m_needsFeedback;
+
+ float m_appliedImpulse;
+ float m_dbgDrawSize;
+
+ int m_disableCollisionsBetweenLinkedBodies;
+ int m_overrideNumSolverIterations;
+
+ float m_breakingImpulseThreshold;
+ int m_isEnabled;
+
+};
+
+///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
+
+#define BT_BACKWARDS_COMPATIBLE_SERIALIZATION
+#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION
+///this structure is not used, except for loading pre-2.82 .bullet files
struct btTypedConstraintData
{
btRigidBodyData *m_rbA;
@@ -377,10 +414,35 @@ struct btTypedConstraintData
int m_isEnabled;
};
+#endif //BACKWARDS_COMPATIBLE
+
+struct btTypedConstraintDoubleData
+{
+ btRigidBodyDoubleData *m_rbA;
+ btRigidBodyDoubleData *m_rbB;
+ char *m_name;
+
+ int m_objectType;
+ int m_userConstraintType;
+ int m_userConstraintId;
+ int m_needsFeedback;
+
+ double m_appliedImpulse;
+ double m_dbgDrawSize;
+
+ int m_disableCollisionsBetweenLinkedBodies;
+ int m_overrideNumSolverIterations;
+
+ double m_breakingImpulseThreshold;
+ int m_isEnabled;
+ char padding[4];
+
+};
+
SIMD_FORCE_INLINE int btTypedConstraint::calculateSerializeBufferSize() const
{
- return sizeof(btTypedConstraintData);
+ return sizeof(btTypedConstraintData2);
}
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
index 9ff2d9f1173..fb8a4068e23 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
@@ -87,7 +87,6 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal
btTypedConstraint** m_sortedConstraints;
int m_numConstraints;
btIDebugDraw* m_debugDrawer;
- btStackAlloc* m_stackAlloc;
btDispatcher* m_dispatcher;
btAlignedObjectArray<btCollisionObject*> m_bodies;
@@ -104,7 +103,6 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal
m_sortedConstraints(NULL),
m_numConstraints(0),
m_debugDrawer(NULL),
- m_stackAlloc(stackAlloc),
m_dispatcher(dispatcher)
{
@@ -135,7 +133,7 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal
if (islandId<0)
{
///we don't split islands, so all constraints/contact manifolds/bodies are passed into the solver regardless the island id
- m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,&m_sortedConstraints[0],m_numConstraints,*m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher);
+ m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,&m_sortedConstraints[0],m_numConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher);
} else
{
//also add all non-contact constraints/joints for this island
@@ -163,7 +161,7 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal
if (m_solverInfo->m_minimumSolverBatchSize<=1)
{
- m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher);
+ m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher);
} else
{
@@ -190,7 +188,7 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal
btPersistentManifold** manifold = m_manifolds.size()?&m_manifolds[0]:0;
btTypedConstraint** constraints = m_constraints.size()?&m_constraints[0]:0;
- m_solver->solveGroup( bodies,m_bodies.size(),manifold, m_manifolds.size(),constraints, m_constraints.size() ,*m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher);
+ m_solver->solveGroup( bodies,m_bodies.size(),manifold, m_manifolds.size(),constraints, m_constraints.size() ,*m_solverInfo,m_debugDrawer,m_dispatcher);
m_bodies.resize(0);
m_manifolds.resize(0);
m_constraints.resize(0);
@@ -210,7 +208,9 @@ m_gravity(0,-10,0),
m_localTime(0),
m_synchronizeAllMotionStates(false),
m_applySpeculativeContactRestitution(false),
-m_profileTimings(0)
+m_profileTimings(0),
+m_fixedTimeStep(0),
+m_latencyMotionStateInterpolation(true)
{
if (!m_constraintSolver)
@@ -232,7 +232,7 @@ m_profileTimings(0)
{
void* mem = btAlignedAlloc(sizeof(InplaceSolverIslandCallback),16);
- m_solverIslandCallback = new (mem) InplaceSolverIslandCallback (m_constraintSolver, m_stackAlloc, dispatcher);
+ m_solverIslandCallback = new (mem) InplaceSolverIslandCallback (m_constraintSolver, 0, dispatcher);
}
}
@@ -359,7 +359,9 @@ void btDiscreteDynamicsWorld::synchronizeSingleMotionState(btRigidBody* body)
{
btTransform interpolatedTransform;
btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(),
- body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),m_localTime*body->getHitFraction(),interpolatedTransform);
+ body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),
+ (m_latencyMotionStateInterpolation && m_fixedTimeStep) ? m_localTime - m_fixedTimeStep : m_localTime*body->getHitFraction(),
+ interpolatedTransform);
body->getMotionState()->setWorldTransform(interpolatedTransform);
}
}
@@ -403,6 +405,7 @@ int btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps,
if (maxSubSteps)
{
//fixed timestep with interpolation
+ m_fixedTimeStep = fixedTimeStep;
m_localTime += timeStep;
if (m_localTime >= fixedTimeStep)
{
@@ -413,7 +416,8 @@ int btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps,
{
//variable timestep
fixedTimeStep = timeStep;
- m_localTime = timeStep;
+ m_localTime = m_latencyMotionStateInterpolation ? 0 : timeStep;
+ m_fixedTimeStep = 0;
if (btFuzzyZero(timeStep))
{
numSimulationSubSteps = 0;
@@ -724,7 +728,7 @@ void btDiscreteDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
m_solverIslandCallback->processConstraints();
- m_constraintSolver->allSolved(solverInfo, m_debugDrawer, m_stackAlloc);
+ m_constraintSolver->allSolved(solverInfo, m_debugDrawer);
}
@@ -746,12 +750,7 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands()
if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
{
- if (colObj0->isActive() || colObj1->isActive())
- {
-
- getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),
- (colObj1)->getIslandTag());
- }
+ getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag());
}
}
}
@@ -770,12 +769,7 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands()
if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
{
- if (colObj0->isActive() || colObj1->isActive())
- {
-
- getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),
- (colObj1)->getIslandTag());
- }
+ getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag());
}
}
}
@@ -1131,7 +1125,6 @@ void btDiscreteDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
{
//don't integrate/update velocities here, it happens in the constraint solver
- //damping
body->applyDamping(timeStep);
body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform());
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
index fa934c49d2b..d8a34b7da3d 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
@@ -53,6 +53,7 @@ protected:
//for variable timesteps
btScalar m_localTime;
+ btScalar m_fixedTimeStep;
//for variable timesteps
bool m_ownsIslandManager;
@@ -64,6 +65,8 @@ protected:
int m_profileTimings;
+ bool m_latencyMotionStateInterpolation;
+
btAlignedObjectArray<btPersistentManifold*> m_predictiveManifolds;
virtual void predictUnconstraintMotion(btScalar timeStep);
@@ -74,7 +77,7 @@ protected:
virtual void solveConstraints(btContactSolverInfo& solverInfo);
- void updateActivationState(btScalar timeStep);
+ virtual void updateActivationState(btScalar timeStep);
void updateActions(btScalar timeStep);
@@ -216,6 +219,16 @@ public:
///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see Bullet/Demos/SerializeDemo)
virtual void serialize(btSerializer* serializer);
+ ///Interpolate motion state between previous and current transform, instead of current and next transform.
+ ///This can relieve discontinuities in the rendering, due to penetrations
+ void setLatencyMotionStateInterpolation(bool latencyInterpolation )
+ {
+ m_latencyMotionStateInterpolation = latencyInterpolation;
+ }
+ bool getLatencyMotionStateInterpolation() const
+ {
+ return m_latencyMotionStateInterpolation;
+ }
};
#endif //BT_DISCRETE_DYNAMICS_WORLD_H
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h
index 7d5c621f850..35dd1400fe7 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h
@@ -33,7 +33,8 @@ enum btDynamicsWorldType
BT_SIMPLE_DYNAMICS_WORLD=1,
BT_DISCRETE_DYNAMICS_WORLD=2,
BT_CONTINUOUS_DYNAMICS_WORLD=3,
- BT_SOFT_RIGID_DYNAMICS_WORLD=4
+ BT_SOFT_RIGID_DYNAMICS_WORLD=4,
+ BT_GPU_DYNAMICS_WORLD=5
};
///The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc.
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h
index f0e07f942af..ed90fb44115 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h
@@ -363,11 +363,13 @@ public:
inline void setLinearVelocity(const btVector3& lin_vel)
{
+ m_updateRevision++;
m_linearVelocity = lin_vel;
}
inline void setAngularVelocity(const btVector3& ang_vel)
{
+ m_updateRevision++;
m_angularVelocity = ang_vel;
}
@@ -484,11 +486,13 @@ public:
void setAngularFactor(const btVector3& angFac)
{
+ m_updateRevision++;
m_angularFactor = angFac;
}
void setAngularFactor(btScalar angFac)
{
+ m_updateRevision++;
m_angularFactor.setValue(angFac,angFac,angFac);
}
const btVector3& getAngularFactor() const
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
index 5fc2f3cf8f7..35dd38840f6 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
@@ -78,8 +78,8 @@ int btSimpleDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, b
btContactSolverInfo infoGlobal;
infoGlobal.m_timeStep = timeStep;
m_constraintSolver->prepareSolve(0,numManifolds);
- m_constraintSolver->solveGroup(&getCollisionObjectArray()[0],getNumCollisionObjects(),manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_stackAlloc,m_dispatcher1);
- m_constraintSolver->allSolved(infoGlobal,m_debugDrawer, m_stackAlloc);
+ m_constraintSolver->solveGroup(&getCollisionObjectArray()[0],getNumCollisionObjects(),manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_dispatcher1);
+ m_constraintSolver->allSolved(infoGlobal,m_debugDrawer);
}
///integrate transforms
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp
new file mode 100644
index 00000000000..56a1c55d9ae
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp
@@ -0,0 +1,1009 @@
+/*
+ * PURPOSE:
+ * Class representing an articulated rigid body. Stores the body's
+ * current state, allows forces and torques to be set, handles
+ * timestepping and implements Featherstone's algorithm.
+ *
+ * COPYRIGHT:
+ * Copyright (C) Stephen Thompson, <stephen@solarflare.org.uk>, 2011-2013
+ * Portions written By Erwin Coumans: replacing Eigen math library by Bullet LinearMath and a dedicated 6x6 matrix inverse (solveImatrix)
+
+ This software is provided 'as-is', without any express or implied warranty.
+ In no event will the authors be held liable for any damages arising from the use of this software.
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it freely,
+ subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ */
+
+
+#include "btMultiBody.h"
+#include "btMultiBodyLink.h"
+#include "btMultiBodyLinkCollider.h"
+
+// #define INCLUDE_GYRO_TERM
+
+namespace {
+ const btScalar SLEEP_EPSILON = btScalar(0.05); // this is a squared velocity (m^2 s^-2)
+ const btScalar SLEEP_TIMEOUT = btScalar(2); // in seconds
+}
+
+
+
+
+//
+// Various spatial helper functions
+//
+
+namespace {
+ void SpatialTransform(const btMatrix3x3 &rotation_matrix, // rotates vectors in 'from' frame to vectors in 'to' frame
+ const btVector3 &displacement, // vector from origin of 'from' frame to origin of 'to' frame, in 'to' coordinates
+ const btVector3 &top_in, // top part of input vector
+ const btVector3 &bottom_in, // bottom part of input vector
+ btVector3 &top_out, // top part of output vector
+ btVector3 &bottom_out) // bottom part of output vector
+ {
+ top_out = rotation_matrix * top_in;
+ bottom_out = -displacement.cross(top_out) + rotation_matrix * bottom_in;
+ }
+
+ void InverseSpatialTransform(const btMatrix3x3 &rotation_matrix,
+ const btVector3 &displacement,
+ const btVector3 &top_in,
+ const btVector3 &bottom_in,
+ btVector3 &top_out,
+ btVector3 &bottom_out)
+ {
+ top_out = rotation_matrix.transpose() * top_in;
+ bottom_out = rotation_matrix.transpose() * (bottom_in + displacement.cross(top_in));
+ }
+
+ btScalar SpatialDotProduct(const btVector3 &a_top,
+ const btVector3 &a_bottom,
+ const btVector3 &b_top,
+ const btVector3 &b_bottom)
+ {
+ return a_bottom.dot(b_top) + a_top.dot(b_bottom);
+ }
+}
+
+
+//
+// Implementation of class btMultiBody
+//
+
+btMultiBody::btMultiBody(int n_links,
+ btScalar mass,
+ const btVector3 &inertia,
+ bool fixed_base_,
+ bool can_sleep_)
+ : base_quat(0, 0, 0, 1),
+ base_mass(mass),
+ base_inertia(inertia),
+
+ fixed_base(fixed_base_),
+ awake(true),
+ can_sleep(can_sleep_),
+ sleep_timer(0),
+ m_baseCollider(0),
+ m_linearDamping(0.04f),
+ m_angularDamping(0.04f),
+ m_useGyroTerm(true),
+ m_maxAppliedImpulse(1000.f),
+ m_hasSelfCollision(true)
+{
+ links.resize(n_links);
+
+ vector_buf.resize(2*n_links);
+ matrix_buf.resize(n_links + 1);
+ m_real_buf.resize(6 + 2*n_links);
+ base_pos.setValue(0, 0, 0);
+ base_force.setValue(0, 0, 0);
+ base_torque.setValue(0, 0, 0);
+}
+
+btMultiBody::~btMultiBody()
+{
+}
+
+void btMultiBody::setupPrismatic(int i,
+ btScalar mass,
+ const btVector3 &inertia,
+ int parent,
+ const btQuaternion &rot_parent_to_this,
+ const btVector3 &joint_axis,
+ const btVector3 &r_vector_when_q_zero,
+ bool disableParentCollision)
+{
+ links[i].mass = mass;
+ links[i].inertia = inertia;
+ links[i].parent = parent;
+ links[i].zero_rot_parent_to_this = rot_parent_to_this;
+ links[i].axis_top.setValue(0,0,0);
+ links[i].axis_bottom = joint_axis;
+ links[i].e_vector = r_vector_when_q_zero;
+ links[i].is_revolute = false;
+ links[i].cached_rot_parent_to_this = rot_parent_to_this;
+ if (disableParentCollision)
+ links[i].m_flags |=BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION;
+
+ links[i].updateCache();
+}
+
+void btMultiBody::setupRevolute(int i,
+ btScalar mass,
+ const btVector3 &inertia,
+ int parent,
+ const btQuaternion &zero_rot_parent_to_this,
+ const btVector3 &joint_axis,
+ const btVector3 &parent_axis_position,
+ const btVector3 &my_axis_position,
+ bool disableParentCollision)
+{
+ links[i].mass = mass;
+ links[i].inertia = inertia;
+ links[i].parent = parent;
+ links[i].zero_rot_parent_to_this = zero_rot_parent_to_this;
+ links[i].axis_top = joint_axis;
+ links[i].axis_bottom = joint_axis.cross(my_axis_position);
+ links[i].d_vector = my_axis_position;
+ links[i].e_vector = parent_axis_position;
+ links[i].is_revolute = true;
+ if (disableParentCollision)
+ links[i].m_flags |=BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION;
+ links[i].updateCache();
+}
+
+
+
+
+
+int btMultiBody::getParent(int i) const
+{
+ return links[i].parent;
+}
+
+btScalar btMultiBody::getLinkMass(int i) const
+{
+ return links[i].mass;
+}
+
+const btVector3 & btMultiBody::getLinkInertia(int i) const
+{
+ return links[i].inertia;
+}
+
+btScalar btMultiBody::getJointPos(int i) const
+{
+ return links[i].joint_pos;
+}
+
+btScalar btMultiBody::getJointVel(int i) const
+{
+ return m_real_buf[6 + i];
+}
+
+void btMultiBody::setJointPos(int i, btScalar q)
+{
+ links[i].joint_pos = q;
+ links[i].updateCache();
+}
+
+void btMultiBody::setJointVel(int i, btScalar qdot)
+{
+ m_real_buf[6 + i] = qdot;
+}
+
+const btVector3 & btMultiBody::getRVector(int i) const
+{
+ return links[i].cached_r_vector;
+}
+
+const btQuaternion & btMultiBody::getParentToLocalRot(int i) const
+{
+ return links[i].cached_rot_parent_to_this;
+}
+
+btVector3 btMultiBody::localPosToWorld(int i, const btVector3 &local_pos) const
+{
+ btVector3 result = local_pos;
+ while (i != -1) {
+ // 'result' is in frame i. transform it to frame parent(i)
+ result += getRVector(i);
+ result = quatRotate(getParentToLocalRot(i).inverse(),result);
+ i = getParent(i);
+ }
+
+ // 'result' is now in the base frame. transform it to world frame
+ result = quatRotate(getWorldToBaseRot().inverse() ,result);
+ result += getBasePos();
+
+ return result;
+}
+
+btVector3 btMultiBody::worldPosToLocal(int i, const btVector3 &world_pos) const
+{
+ if (i == -1) {
+ // world to base
+ return quatRotate(getWorldToBaseRot(),(world_pos - getBasePos()));
+ } else {
+ // find position in parent frame, then transform to current frame
+ return quatRotate(getParentToLocalRot(i),worldPosToLocal(getParent(i), world_pos)) - getRVector(i);
+ }
+}
+
+btVector3 btMultiBody::localDirToWorld(int i, const btVector3 &local_dir) const
+{
+ btVector3 result = local_dir;
+ while (i != -1) {
+ result = quatRotate(getParentToLocalRot(i).inverse() , result);
+ i = getParent(i);
+ }
+ result = quatRotate(getWorldToBaseRot().inverse() , result);
+ return result;
+}
+
+btVector3 btMultiBody::worldDirToLocal(int i, const btVector3 &world_dir) const
+{
+ if (i == -1) {
+ return quatRotate(getWorldToBaseRot(), world_dir);
+ } else {
+ return quatRotate(getParentToLocalRot(i) ,worldDirToLocal(getParent(i), world_dir));
+ }
+}
+
+void btMultiBody::compTreeLinkVelocities(btVector3 *omega, btVector3 *vel) const
+{
+ int num_links = getNumLinks();
+ // Calculates the velocities of each link (and the base) in its local frame
+ omega[0] = quatRotate(base_quat ,getBaseOmega());
+ vel[0] = quatRotate(base_quat ,getBaseVel());
+
+ for (int i = 0; i < num_links; ++i) {
+ const int parent = links[i].parent;
+
+ // transform parent vel into this frame, store in omega[i+1], vel[i+1]
+ SpatialTransform(btMatrix3x3(links[i].cached_rot_parent_to_this), links[i].cached_r_vector,
+ omega[parent+1], vel[parent+1],
+ omega[i+1], vel[i+1]);
+
+ // now add qidot * shat_i
+ omega[i+1] += getJointVel(i) * links[i].axis_top;
+ vel[i+1] += getJointVel(i) * links[i].axis_bottom;
+ }
+}
+
+btScalar btMultiBody::getKineticEnergy() const
+{
+ int num_links = getNumLinks();
+ // TODO: would be better not to allocate memory here
+ btAlignedObjectArray<btVector3> omega;omega.resize(num_links+1);
+ btAlignedObjectArray<btVector3> vel;vel.resize(num_links+1);
+ compTreeLinkVelocities(&omega[0], &vel[0]);
+
+ // we will do the factor of 0.5 at the end
+ btScalar result = base_mass * vel[0].dot(vel[0]);
+ result += omega[0].dot(base_inertia * omega[0]);
+
+ for (int i = 0; i < num_links; ++i) {
+ result += links[i].mass * vel[i+1].dot(vel[i+1]);
+ result += omega[i+1].dot(links[i].inertia * omega[i+1]);
+ }
+
+ return 0.5f * result;
+}
+
+btVector3 btMultiBody::getAngularMomentum() const
+{
+ int num_links = getNumLinks();
+ // TODO: would be better not to allocate memory here
+ btAlignedObjectArray<btVector3> omega;omega.resize(num_links+1);
+ btAlignedObjectArray<btVector3> vel;vel.resize(num_links+1);
+ btAlignedObjectArray<btQuaternion> rot_from_world;rot_from_world.resize(num_links+1);
+ compTreeLinkVelocities(&omega[0], &vel[0]);
+
+ rot_from_world[0] = base_quat;
+ btVector3 result = quatRotate(rot_from_world[0].inverse() , (base_inertia * omega[0]));
+
+ for (int i = 0; i < num_links; ++i) {
+ rot_from_world[i+1] = links[i].cached_rot_parent_to_this * rot_from_world[links[i].parent+1];
+ result += (quatRotate(rot_from_world[i+1].inverse() , (links[i].inertia * omega[i+1])));
+ }
+
+ return result;
+}
+
+
+void btMultiBody::clearForcesAndTorques()
+{
+ base_force.setValue(0, 0, 0);
+ base_torque.setValue(0, 0, 0);
+
+ for (int i = 0; i < getNumLinks(); ++i) {
+ links[i].applied_force.setValue(0, 0, 0);
+ links[i].applied_torque.setValue(0, 0, 0);
+ links[i].joint_torque = 0;
+ }
+}
+
+void btMultiBody::clearVelocities()
+{
+ for (int i = 0; i < 6 + getNumLinks(); ++i)
+ {
+ m_real_buf[i] = 0.f;
+ }
+}
+void btMultiBody::addLinkForce(int i, const btVector3 &f)
+{
+ links[i].applied_force += f;
+}
+
+void btMultiBody::addLinkTorque(int i, const btVector3 &t)
+{
+ links[i].applied_torque += t;
+}
+
+void btMultiBody::addJointTorque(int i, btScalar Q)
+{
+ links[i].joint_torque += Q;
+}
+
+const btVector3 & btMultiBody::getLinkForce(int i) const
+{
+ return links[i].applied_force;
+}
+
+const btVector3 & btMultiBody::getLinkTorque(int i) const
+{
+ return links[i].applied_torque;
+}
+
+btScalar btMultiBody::getJointTorque(int i) const
+{
+ return links[i].joint_torque;
+}
+
+
+inline btMatrix3x3 vecMulVecTranspose(const btVector3& v0, const btVector3& v1Transposed)
+{
+ btVector3 row0 = btVector3(
+ v0.x() * v1Transposed.x(),
+ v0.x() * v1Transposed.y(),
+ v0.x() * v1Transposed.z());
+ btVector3 row1 = btVector3(
+ v0.y() * v1Transposed.x(),
+ v0.y() * v1Transposed.y(),
+ v0.y() * v1Transposed.z());
+ btVector3 row2 = btVector3(
+ v0.z() * v1Transposed.x(),
+ v0.z() * v1Transposed.y(),
+ v0.z() * v1Transposed.z());
+
+ btMatrix3x3 m(row0[0],row0[1],row0[2],
+ row1[0],row1[1],row1[2],
+ row2[0],row2[1],row2[2]);
+ return m;
+}
+
+
+void btMultiBody::stepVelocities(btScalar dt,
+ btAlignedObjectArray<btScalar> &scratch_r,
+ btAlignedObjectArray<btVector3> &scratch_v,
+ btAlignedObjectArray<btMatrix3x3> &scratch_m)
+{
+ // Implement Featherstone's algorithm to calculate joint accelerations (q_double_dot)
+ // and the base linear & angular accelerations.
+
+ // We apply damping forces in this routine as well as any external forces specified by the
+ // caller (via addBaseForce etc).
+
+ // output should point to an array of 6 + num_links reals.
+ // Format is: 3 angular accelerations (in world frame), 3 linear accelerations (in world frame),
+ // num_links joint acceleration values.
+
+ int num_links = getNumLinks();
+
+ const btScalar DAMPING_K1_LINEAR = m_linearDamping;
+ const btScalar DAMPING_K2_LINEAR = m_linearDamping;
+
+ const btScalar DAMPING_K1_ANGULAR = m_angularDamping;
+ const btScalar DAMPING_K2_ANGULAR= m_angularDamping;
+
+ btVector3 base_vel = getBaseVel();
+ btVector3 base_omega = getBaseOmega();
+
+ // Temporary matrices/vectors -- use scratch space from caller
+ // so that we don't have to keep reallocating every frame
+
+ scratch_r.resize(2*num_links + 6);
+ scratch_v.resize(8*num_links + 6);
+ scratch_m.resize(4*num_links + 4);
+
+ btScalar * r_ptr = &scratch_r[0];
+ btScalar * output = &scratch_r[num_links]; // "output" holds the q_double_dot results
+ btVector3 * v_ptr = &scratch_v[0];
+
+ // vhat_i (top = angular, bottom = linear part)
+ btVector3 * vel_top_angular = v_ptr; v_ptr += num_links + 1;
+ btVector3 * vel_bottom_linear = v_ptr; v_ptr += num_links + 1;
+
+ // zhat_i^A
+ btVector3 * zero_acc_top_angular = v_ptr; v_ptr += num_links + 1;
+ btVector3 * zero_acc_bottom_linear = v_ptr; v_ptr += num_links + 1;
+
+ // chat_i (note NOT defined for the base)
+ btVector3 * coriolis_top_angular = v_ptr; v_ptr += num_links;
+ btVector3 * coriolis_bottom_linear = v_ptr; v_ptr += num_links;
+
+ // top left, top right and bottom left blocks of Ihat_i^A.
+ // bottom right block = transpose of top left block and is not stored.
+ // Note: the top right and bottom left blocks are always symmetric matrices, but we don't make use of this fact currently.
+ btMatrix3x3 * inertia_top_left = &scratch_m[num_links + 1];
+ btMatrix3x3 * inertia_top_right = &scratch_m[2*num_links + 2];
+ btMatrix3x3 * inertia_bottom_left = &scratch_m[3*num_links + 3];
+
+ // Cached 3x3 rotation matrices from parent frame to this frame.
+ btMatrix3x3 * rot_from_parent = &matrix_buf[0];
+ btMatrix3x3 * rot_from_world = &scratch_m[0];
+
+ // hhat_i, ahat_i
+ // hhat is NOT stored for the base (but ahat is)
+ btVector3 * h_top = num_links > 0 ? &vector_buf[0] : 0;
+ btVector3 * h_bottom = num_links > 0 ? &vector_buf[num_links] : 0;
+ btVector3 * accel_top = v_ptr; v_ptr += num_links + 1;
+ btVector3 * accel_bottom = v_ptr; v_ptr += num_links + 1;
+
+ // Y_i, D_i
+ btScalar * Y = r_ptr; r_ptr += num_links;
+ btScalar * D = num_links > 0 ? &m_real_buf[6 + num_links] : 0;
+
+ // ptr to the joint accel part of the output
+ btScalar * joint_accel = output + 6;
+
+
+ // Start of the algorithm proper.
+
+ // First 'upward' loop.
+ // Combines CompTreeLinkVelocities and InitTreeLinks from Mirtich.
+
+ rot_from_parent[0] = btMatrix3x3(base_quat);
+
+ vel_top_angular[0] = rot_from_parent[0] * base_omega;
+ vel_bottom_linear[0] = rot_from_parent[0] * base_vel;
+
+ if (fixed_base) {
+ zero_acc_top_angular[0] = zero_acc_bottom_linear[0] = btVector3(0,0,0);
+ } else {
+ zero_acc_top_angular[0] = - (rot_from_parent[0] * (base_force
+ - base_mass*(DAMPING_K1_LINEAR+DAMPING_K2_LINEAR*base_vel.norm())*base_vel));
+
+ zero_acc_bottom_linear[0] =
+ - (rot_from_parent[0] * base_torque);
+
+ if (m_useGyroTerm)
+ zero_acc_bottom_linear[0]+=vel_top_angular[0].cross( base_inertia * vel_top_angular[0] );
+
+ zero_acc_bottom_linear[0] += base_inertia * vel_top_angular[0] * (DAMPING_K1_ANGULAR + DAMPING_K2_ANGULAR*vel_top_angular[0].norm());
+
+ }
+
+
+
+ inertia_top_left[0] = btMatrix3x3(0,0,0,0,0,0,0,0,0);//::Zero();
+
+
+ inertia_top_right[0].setValue(base_mass, 0, 0,
+ 0, base_mass, 0,
+ 0, 0, base_mass);
+ inertia_bottom_left[0].setValue(base_inertia[0], 0, 0,
+ 0, base_inertia[1], 0,
+ 0, 0, base_inertia[2]);
+
+ rot_from_world[0] = rot_from_parent[0];
+
+ for (int i = 0; i < num_links; ++i) {
+ const int parent = links[i].parent;
+ rot_from_parent[i+1] = btMatrix3x3(links[i].cached_rot_parent_to_this);
+
+
+ rot_from_world[i+1] = rot_from_parent[i+1] * rot_from_world[parent+1];
+
+ // vhat_i = i_xhat_p(i) * vhat_p(i)
+ SpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector,
+ vel_top_angular[parent+1], vel_bottom_linear[parent+1],
+ vel_top_angular[i+1], vel_bottom_linear[i+1]);
+
+ // we can now calculate chat_i
+ // remember vhat_i is really vhat_p(i) (but in current frame) at this point
+ coriolis_bottom_linear[i] = vel_top_angular[i+1].cross(vel_top_angular[i+1].cross(links[i].cached_r_vector))
+ + 2 * vel_top_angular[i+1].cross(links[i].axis_bottom) * getJointVel(i);
+ if (links[i].is_revolute) {
+ coriolis_top_angular[i] = vel_top_angular[i+1].cross(links[i].axis_top) * getJointVel(i);
+ coriolis_bottom_linear[i] += (getJointVel(i) * getJointVel(i)) * links[i].axis_top.cross(links[i].axis_bottom);
+ } else {
+ coriolis_top_angular[i] = btVector3(0,0,0);
+ }
+
+ // now set vhat_i to its true value by doing
+ // vhat_i += qidot * shat_i
+ vel_top_angular[i+1] += getJointVel(i) * links[i].axis_top;
+ vel_bottom_linear[i+1] += getJointVel(i) * links[i].axis_bottom;
+
+ // calculate zhat_i^A
+ zero_acc_top_angular[i+1] = - (rot_from_world[i+1] * (links[i].applied_force));
+ zero_acc_top_angular[i+1] += links[i].mass * (DAMPING_K1_LINEAR + DAMPING_K2_LINEAR*vel_bottom_linear[i+1].norm()) * vel_bottom_linear[i+1];
+
+ zero_acc_bottom_linear[i+1] =
+ - (rot_from_world[i+1] * links[i].applied_torque);
+ if (m_useGyroTerm)
+ {
+ zero_acc_bottom_linear[i+1] += vel_top_angular[i+1].cross( links[i].inertia * vel_top_angular[i+1] );
+ }
+
+ zero_acc_bottom_linear[i+1] += links[i].inertia * vel_top_angular[i+1] * (DAMPING_K1_ANGULAR + DAMPING_K2_ANGULAR*vel_top_angular[i+1].norm());
+
+ // calculate Ihat_i^A
+ inertia_top_left[i+1] = btMatrix3x3(0,0,0,0,0,0,0,0,0);//::Zero();
+ inertia_top_right[i+1].setValue(links[i].mass, 0, 0,
+ 0, links[i].mass, 0,
+ 0, 0, links[i].mass);
+ inertia_bottom_left[i+1].setValue(links[i].inertia[0], 0, 0,
+ 0, links[i].inertia[1], 0,
+ 0, 0, links[i].inertia[2]);
+ }
+
+
+ // 'Downward' loop.
+ // (part of TreeForwardDynamics in Mirtich.)
+ for (int i = num_links - 1; i >= 0; --i) {
+
+ h_top[i] = inertia_top_left[i+1] * links[i].axis_top + inertia_top_right[i+1] * links[i].axis_bottom;
+ h_bottom[i] = inertia_bottom_left[i+1] * links[i].axis_top + inertia_top_left[i+1].transpose() * links[i].axis_bottom;
+ btScalar val = SpatialDotProduct(links[i].axis_top, links[i].axis_bottom, h_top[i], h_bottom[i]);
+ D[i] = val;
+ Y[i] = links[i].joint_torque
+ - SpatialDotProduct(links[i].axis_top, links[i].axis_bottom, zero_acc_top_angular[i+1], zero_acc_bottom_linear[i+1])
+ - SpatialDotProduct(h_top[i], h_bottom[i], coriolis_top_angular[i], coriolis_bottom_linear[i]);
+
+ const int parent = links[i].parent;
+
+
+ // Ip += pXi * (Ii - hi hi' / Di) * iXp
+ const btScalar one_over_di = 1.0f / D[i];
+
+
+
+
+ const btMatrix3x3 TL = inertia_top_left[i+1] - vecMulVecTranspose(one_over_di * h_top[i] , h_bottom[i]);
+ const btMatrix3x3 TR = inertia_top_right[i+1] - vecMulVecTranspose(one_over_di * h_top[i] , h_top[i]);
+ const btMatrix3x3 BL = inertia_bottom_left[i+1]- vecMulVecTranspose(one_over_di * h_bottom[i] , h_bottom[i]);
+
+
+ btMatrix3x3 r_cross;
+ r_cross.setValue(
+ 0, -links[i].cached_r_vector[2], links[i].cached_r_vector[1],
+ links[i].cached_r_vector[2], 0, -links[i].cached_r_vector[0],
+ -links[i].cached_r_vector[1], links[i].cached_r_vector[0], 0);
+
+ inertia_top_left[parent+1] += rot_from_parent[i+1].transpose() * ( TL - TR * r_cross ) * rot_from_parent[i+1];
+ inertia_top_right[parent+1] += rot_from_parent[i+1].transpose() * TR * rot_from_parent[i+1];
+ inertia_bottom_left[parent+1] += rot_from_parent[i+1].transpose() *
+ (r_cross * (TL - TR * r_cross) + BL - TL.transpose() * r_cross) * rot_from_parent[i+1];
+
+
+ // Zp += pXi * (Zi + Ii*ci + hi*Yi/Di)
+ btVector3 in_top, in_bottom, out_top, out_bottom;
+ const btScalar Y_over_D = Y[i] * one_over_di;
+ in_top = zero_acc_top_angular[i+1]
+ + inertia_top_left[i+1] * coriolis_top_angular[i]
+ + inertia_top_right[i+1] * coriolis_bottom_linear[i]
+ + Y_over_D * h_top[i];
+ in_bottom = zero_acc_bottom_linear[i+1]
+ + inertia_bottom_left[i+1] * coriolis_top_angular[i]
+ + inertia_top_left[i+1].transpose() * coriolis_bottom_linear[i]
+ + Y_over_D * h_bottom[i];
+ InverseSpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector,
+ in_top, in_bottom, out_top, out_bottom);
+ zero_acc_top_angular[parent+1] += out_top;
+ zero_acc_bottom_linear[parent+1] += out_bottom;
+ }
+
+
+ // Second 'upward' loop
+ // (part of TreeForwardDynamics in Mirtich)
+
+ if (fixed_base)
+ {
+ accel_top[0] = accel_bottom[0] = btVector3(0,0,0);
+ }
+ else
+ {
+ if (num_links > 0)
+ {
+ //Matrix<btScalar, 6, 6> Imatrix;
+ //Imatrix.block<3,3>(0,0) = inertia_top_left[0];
+ //Imatrix.block<3,3>(3,0) = inertia_bottom_left[0];
+ //Imatrix.block<3,3>(0,3) = inertia_top_right[0];
+ //Imatrix.block<3,3>(3,3) = inertia_top_left[0].transpose();
+ //cached_imatrix_lu.reset(new Eigen::LU<Matrix<btScalar, 6, 6> >(Imatrix)); // TODO: Avoid memory allocation here?
+
+ cached_inertia_top_left = inertia_top_left[0];
+ cached_inertia_top_right = inertia_top_right[0];
+ cached_inertia_lower_left = inertia_bottom_left[0];
+ cached_inertia_lower_right= inertia_top_left[0].transpose();
+
+ }
+ btVector3 rhs_top (zero_acc_top_angular[0][0], zero_acc_top_angular[0][1], zero_acc_top_angular[0][2]);
+ btVector3 rhs_bot (zero_acc_bottom_linear[0][0], zero_acc_bottom_linear[0][1], zero_acc_bottom_linear[0][2]);
+ float result[6];
+
+ solveImatrix(rhs_top, rhs_bot, result);
+// printf("result=%f,%f,%f,%f,%f,%f\n",result[0],result[0],result[0],result[0],result[0],result[0]);
+ for (int i = 0; i < 3; ++i) {
+ accel_top[0][i] = -result[i];
+ accel_bottom[0][i] = -result[i+3];
+ }
+
+ }
+
+ // now do the loop over the links
+ for (int i = 0; i < num_links; ++i) {
+ const int parent = links[i].parent;
+ SpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector,
+ accel_top[parent+1], accel_bottom[parent+1],
+ accel_top[i+1], accel_bottom[i+1]);
+ joint_accel[i] = (Y[i] - SpatialDotProduct(h_top[i], h_bottom[i], accel_top[i+1], accel_bottom[i+1])) / D[i];
+ accel_top[i+1] += coriolis_top_angular[i] + joint_accel[i] * links[i].axis_top;
+ accel_bottom[i+1] += coriolis_bottom_linear[i] + joint_accel[i] * links[i].axis_bottom;
+ }
+
+ // transform base accelerations back to the world frame.
+ btVector3 omegadot_out = rot_from_parent[0].transpose() * accel_top[0];
+ output[0] = omegadot_out[0];
+ output[1] = omegadot_out[1];
+ output[2] = omegadot_out[2];
+
+ btVector3 vdot_out = rot_from_parent[0].transpose() * accel_bottom[0];
+ output[3] = vdot_out[0];
+ output[4] = vdot_out[1];
+ output[5] = vdot_out[2];
+ // Final step: add the accelerations (times dt) to the velocities.
+ applyDeltaVee(output, dt);
+
+
+}
+
+
+
+void btMultiBody::solveImatrix(const btVector3& rhs_top, const btVector3& rhs_bot, float result[6]) const
+{
+ int num_links = getNumLinks();
+ ///solve I * x = rhs, so the result = invI * rhs
+ if (num_links == 0)
+ {
+ // in the case of 0 links (i.e. a plain rigid body, not a multibody) rhs * invI is easier
+ result[0] = rhs_bot[0] / base_inertia[0];
+ result[1] = rhs_bot[1] / base_inertia[1];
+ result[2] = rhs_bot[2] / base_inertia[2];
+ result[3] = rhs_top[0] / base_mass;
+ result[4] = rhs_top[1] / base_mass;
+ result[5] = rhs_top[2] / base_mass;
+ } else
+ {
+ /// Special routine for calculating the inverse of a spatial inertia matrix
+ ///the 6x6 matrix is stored as 4 blocks of 3x3 matrices
+ btMatrix3x3 Binv = cached_inertia_top_right.inverse()*-1.f;
+ btMatrix3x3 tmp = cached_inertia_lower_right * Binv;
+ btMatrix3x3 invIupper_right = (tmp * cached_inertia_top_left + cached_inertia_lower_left).inverse();
+ tmp = invIupper_right * cached_inertia_lower_right;
+ btMatrix3x3 invI_upper_left = (tmp * Binv);
+ btMatrix3x3 invI_lower_right = (invI_upper_left).transpose();
+ tmp = cached_inertia_top_left * invI_upper_left;
+ tmp[0][0]-= 1.0;
+ tmp[1][1]-= 1.0;
+ tmp[2][2]-= 1.0;
+ btMatrix3x3 invI_lower_left = (Binv * tmp);
+
+ //multiply result = invI * rhs
+ {
+ btVector3 vtop = invI_upper_left*rhs_top;
+ btVector3 tmp;
+ tmp = invIupper_right * rhs_bot;
+ vtop += tmp;
+ btVector3 vbot = invI_lower_left*rhs_top;
+ tmp = invI_lower_right * rhs_bot;
+ vbot += tmp;
+ result[0] = vtop[0];
+ result[1] = vtop[1];
+ result[2] = vtop[2];
+ result[3] = vbot[0];
+ result[4] = vbot[1];
+ result[5] = vbot[2];
+ }
+
+ }
+}
+
+
+void btMultiBody::calcAccelerationDeltas(const btScalar *force, btScalar *output,
+ btAlignedObjectArray<btScalar> &scratch_r, btAlignedObjectArray<btVector3> &scratch_v) const
+{
+ // Temporary matrices/vectors -- use scratch space from caller
+ // so that we don't have to keep reallocating every frame
+ int num_links = getNumLinks();
+ scratch_r.resize(num_links);
+ scratch_v.resize(4*num_links + 4);
+
+ btScalar * r_ptr = num_links == 0 ? 0 : &scratch_r[0];
+ btVector3 * v_ptr = &scratch_v[0];
+
+ // zhat_i^A (scratch space)
+ btVector3 * zero_acc_top_angular = v_ptr; v_ptr += num_links + 1;
+ btVector3 * zero_acc_bottom_linear = v_ptr; v_ptr += num_links + 1;
+
+ // rot_from_parent (cached from calcAccelerations)
+ const btMatrix3x3 * rot_from_parent = &matrix_buf[0];
+
+ // hhat (cached), accel (scratch)
+ const btVector3 * h_top = num_links > 0 ? &vector_buf[0] : 0;
+ const btVector3 * h_bottom = num_links > 0 ? &vector_buf[num_links] : 0;
+ btVector3 * accel_top = v_ptr; v_ptr += num_links + 1;
+ btVector3 * accel_bottom = v_ptr; v_ptr += num_links + 1;
+
+ // Y_i (scratch), D_i (cached)
+ btScalar * Y = r_ptr; r_ptr += num_links;
+ const btScalar * D = num_links > 0 ? &m_real_buf[6 + num_links] : 0;
+
+ btAssert(num_links == 0 || r_ptr - &scratch_r[0] == scratch_r.size());
+ btAssert(v_ptr - &scratch_v[0] == scratch_v.size());
+
+
+
+ // First 'upward' loop.
+ // Combines CompTreeLinkVelocities and InitTreeLinks from Mirtich.
+
+ btVector3 input_force(force[3],force[4],force[5]);
+ btVector3 input_torque(force[0],force[1],force[2]);
+
+ // Fill in zero_acc
+ // -- set to force/torque on the base, zero otherwise
+ if (fixed_base)
+ {
+ zero_acc_top_angular[0] = zero_acc_bottom_linear[0] = btVector3(0,0,0);
+ } else
+ {
+ zero_acc_top_angular[0] = - (rot_from_parent[0] * input_force);
+ zero_acc_bottom_linear[0] = - (rot_from_parent[0] * input_torque);
+ }
+ for (int i = 0; i < num_links; ++i)
+ {
+ zero_acc_top_angular[i+1] = zero_acc_bottom_linear[i+1] = btVector3(0,0,0);
+ }
+
+ // 'Downward' loop.
+ for (int i = num_links - 1; i >= 0; --i)
+ {
+
+ Y[i] = - SpatialDotProduct(links[i].axis_top, links[i].axis_bottom, zero_acc_top_angular[i+1], zero_acc_bottom_linear[i+1]);
+ Y[i] += force[6 + i]; // add joint torque
+
+ const int parent = links[i].parent;
+
+ // Zp += pXi * (Zi + hi*Yi/Di)
+ btVector3 in_top, in_bottom, out_top, out_bottom;
+ const btScalar Y_over_D = Y[i] / D[i];
+ in_top = zero_acc_top_angular[i+1] + Y_over_D * h_top[i];
+ in_bottom = zero_acc_bottom_linear[i+1] + Y_over_D * h_bottom[i];
+ InverseSpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector,
+ in_top, in_bottom, out_top, out_bottom);
+ zero_acc_top_angular[parent+1] += out_top;
+ zero_acc_bottom_linear[parent+1] += out_bottom;
+ }
+
+ // ptr to the joint accel part of the output
+ btScalar * joint_accel = output + 6;
+
+ // Second 'upward' loop
+ if (fixed_base)
+ {
+ accel_top[0] = accel_bottom[0] = btVector3(0,0,0);
+ } else
+ {
+ btVector3 rhs_top (zero_acc_top_angular[0][0], zero_acc_top_angular[0][1], zero_acc_top_angular[0][2]);
+ btVector3 rhs_bot (zero_acc_bottom_linear[0][0], zero_acc_bottom_linear[0][1], zero_acc_bottom_linear[0][2]);
+
+ float result[6];
+ solveImatrix(rhs_top,rhs_bot, result);
+ // printf("result=%f,%f,%f,%f,%f,%f\n",result[0],result[0],result[0],result[0],result[0],result[0]);
+
+ for (int i = 0; i < 3; ++i) {
+ accel_top[0][i] = -result[i];
+ accel_bottom[0][i] = -result[i+3];
+ }
+
+ }
+
+ // now do the loop over the links
+ for (int i = 0; i < num_links; ++i) {
+ const int parent = links[i].parent;
+ SpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector,
+ accel_top[parent+1], accel_bottom[parent+1],
+ accel_top[i+1], accel_bottom[i+1]);
+ joint_accel[i] = (Y[i] - SpatialDotProduct(h_top[i], h_bottom[i], accel_top[i+1], accel_bottom[i+1])) / D[i];
+ accel_top[i+1] += joint_accel[i] * links[i].axis_top;
+ accel_bottom[i+1] += joint_accel[i] * links[i].axis_bottom;
+ }
+
+ // transform base accelerations back to the world frame.
+ btVector3 omegadot_out;
+ omegadot_out = rot_from_parent[0].transpose() * accel_top[0];
+ output[0] = omegadot_out[0];
+ output[1] = omegadot_out[1];
+ output[2] = omegadot_out[2];
+
+ btVector3 vdot_out;
+ vdot_out = rot_from_parent[0].transpose() * accel_bottom[0];
+
+ output[3] = vdot_out[0];
+ output[4] = vdot_out[1];
+ output[5] = vdot_out[2];
+}
+
+void btMultiBody::stepPositions(btScalar dt)
+{
+ int num_links = getNumLinks();
+ // step position by adding dt * velocity
+ btVector3 v = getBaseVel();
+ base_pos += dt * v;
+
+ // "exponential map" method for the rotation
+ btVector3 base_omega = getBaseOmega();
+ const btScalar omega_norm = base_omega.norm();
+ const btScalar omega_times_dt = omega_norm * dt;
+ const btScalar SMALL_ROTATION_ANGLE = 0.02f; // Theoretically this should be ~ pow(FLT_EPSILON,0.25) which is ~ 0.0156
+ if (fabs(omega_times_dt) < SMALL_ROTATION_ANGLE)
+ {
+ const btScalar xsq = omega_times_dt * omega_times_dt; // |omega|^2 * dt^2
+ const btScalar sin_term = dt * (xsq / 48.0f - 0.5f); // -sin(0.5*dt*|omega|) / |omega|
+ const btScalar cos_term = 1.0f - xsq / 8.0f; // cos(0.5*dt*|omega|)
+ base_quat = base_quat * btQuaternion(sin_term * base_omega[0],sin_term * base_omega[1],sin_term * base_omega[2],cos_term);
+ } else
+ {
+ base_quat = base_quat * btQuaternion(base_omega / omega_norm,-omega_times_dt);
+ }
+
+ // Make sure the quaternion represents a valid rotation.
+ // (Not strictly necessary, but helps prevent any round-off errors from building up.)
+ base_quat.normalize();
+
+ // Finally we can update joint_pos for each of the links
+ for (int i = 0; i < num_links; ++i)
+ {
+ float jointVel = getJointVel(i);
+ links[i].joint_pos += dt * jointVel;
+ links[i].updateCache();
+ }
+}
+
+void btMultiBody::fillContactJacobian(int link,
+ const btVector3 &contact_point,
+ const btVector3 &normal,
+ btScalar *jac,
+ btAlignedObjectArray<btScalar> &scratch_r,
+ btAlignedObjectArray<btVector3> &scratch_v,
+ btAlignedObjectArray<btMatrix3x3> &scratch_m) const
+{
+ // temporary space
+ int num_links = getNumLinks();
+ scratch_v.resize(2*num_links + 2);
+ scratch_m.resize(num_links + 1);
+
+ btVector3 * v_ptr = &scratch_v[0];
+ btVector3 * p_minus_com = v_ptr; v_ptr += num_links + 1;
+ btVector3 * n_local = v_ptr; v_ptr += num_links + 1;
+ btAssert(v_ptr - &scratch_v[0] == scratch_v.size());
+
+ scratch_r.resize(num_links);
+ btScalar * results = num_links > 0 ? &scratch_r[0] : 0;
+
+ btMatrix3x3 * rot_from_world = &scratch_m[0];
+
+ const btVector3 p_minus_com_world = contact_point - base_pos;
+
+ rot_from_world[0] = btMatrix3x3(base_quat);
+
+ p_minus_com[0] = rot_from_world[0] * p_minus_com_world;
+ n_local[0] = rot_from_world[0] * normal;
+
+ // omega coeffients first.
+ btVector3 omega_coeffs;
+ omega_coeffs = p_minus_com_world.cross(normal);
+ jac[0] = omega_coeffs[0];
+ jac[1] = omega_coeffs[1];
+ jac[2] = omega_coeffs[2];
+ // then v coefficients
+ jac[3] = normal[0];
+ jac[4] = normal[1];
+ jac[5] = normal[2];
+
+ // Set remaining jac values to zero for now.
+ for (int i = 6; i < 6 + num_links; ++i) {
+ jac[i] = 0;
+ }
+
+ // Qdot coefficients, if necessary.
+ if (num_links > 0 && link > -1) {
+
+ // TODO: speed this up -- don't calculate for links we don't need.
+ // (Also, we are making 3 separate calls to this function, for the normal & the 2 friction directions,
+ // which is resulting in repeated work being done...)
+
+ // calculate required normals & positions in the local frames.
+ for (int i = 0; i < num_links; ++i) {
+
+ // transform to local frame
+ const int parent = links[i].parent;
+ const btMatrix3x3 mtx(links[i].cached_rot_parent_to_this);
+ rot_from_world[i+1] = mtx * rot_from_world[parent+1];
+
+ n_local[i+1] = mtx * n_local[parent+1];
+ p_minus_com[i+1] = mtx * p_minus_com[parent+1] - links[i].cached_r_vector;
+
+ // calculate the jacobian entry
+ if (links[i].is_revolute) {
+ results[i] = n_local[i+1].dot( links[i].axis_top.cross(p_minus_com[i+1]) + links[i].axis_bottom );
+ } else {
+ results[i] = n_local[i+1].dot( links[i].axis_bottom );
+ }
+ }
+
+ // Now copy through to output.
+ while (link != -1) {
+ jac[6 + link] = results[link];
+ link = links[link].parent;
+ }
+ }
+}
+
+void btMultiBody::wakeUp()
+{
+ awake = true;
+}
+
+void btMultiBody::goToSleep()
+{
+ awake = false;
+}
+
+void btMultiBody::checkMotionAndSleepIfRequired(btScalar timestep)
+{
+ int num_links = getNumLinks();
+ extern bool gDisableDeactivation;
+ if (!can_sleep || gDisableDeactivation)
+ {
+ awake = true;
+ sleep_timer = 0;
+ return;
+ }
+
+ // motion is computed as omega^2 + v^2 + (sum of squares of joint velocities)
+ btScalar motion = 0;
+ for (int i = 0; i < 6 + num_links; ++i) {
+ motion += m_real_buf[i] * m_real_buf[i];
+ }
+
+ if (motion < SLEEP_EPSILON) {
+ sleep_timer += timestep;
+ if (sleep_timer > SLEEP_TIMEOUT) {
+ goToSleep();
+ }
+ } else {
+ sleep_timer = 0;
+ if (!awake)
+ wakeUp();
+ }
+}
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h
new file mode 100644
index 00000000000..7177bebbff5
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h
@@ -0,0 +1,466 @@
+/*
+ * PURPOSE:
+ * Class representing an articulated rigid body. Stores the body's
+ * current state, allows forces and torques to be set, handles
+ * timestepping and implements Featherstone's algorithm.
+ *
+ * COPYRIGHT:
+ * Copyright (C) Stephen Thompson, <stephen@solarflare.org.uk>, 2011-2013
+ * Portions written By Erwin Coumans: replacing Eigen math library by Bullet LinearMath and a dedicated 6x6 matrix inverse (solveImatrix)
+
+ This software is provided 'as-is', without any express or implied warranty.
+ In no event will the authors be held liable for any damages arising from the use of this software.
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it freely,
+ subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ */
+
+
+#ifndef BT_MULTIBODY_H
+#define BT_MULTIBODY_H
+
+#include "LinearMath/btScalar.h"
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btQuaternion.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+
+#include "btMultiBodyLink.h"
+class btMultiBodyLinkCollider;
+
+class btMultiBody
+{
+public:
+
+
+ BT_DECLARE_ALIGNED_ALLOCATOR();
+
+ //
+ // initialization
+ //
+
+ btMultiBody(int n_links, // NOT including the base
+ btScalar mass, // mass of base
+ const btVector3 &inertia, // inertia of base, in base frame; assumed diagonal
+ bool fixed_base_, // whether the base is fixed (true) or can move (false)
+ bool can_sleep_);
+
+ ~btMultiBody();
+
+ void setupPrismatic(int i, // 0 to num_links-1
+ btScalar mass,
+ const btVector3 &inertia, // in my frame; assumed diagonal
+ int parent,
+ const btQuaternion &rot_parent_to_this, // rotate points in parent frame to my frame.
+ const btVector3 &joint_axis, // in my frame
+ const btVector3 &r_vector_when_q_zero, // vector from parent COM to my COM, in my frame, when q = 0.
+ bool disableParentCollision=false
+ );
+
+ void setupRevolute(int i, // 0 to num_links-1
+ btScalar mass,
+ const btVector3 &inertia,
+ int parent,
+ const btQuaternion &zero_rot_parent_to_this, // rotate points in parent frame to this frame, when q = 0
+ const btVector3 &joint_axis, // in my frame
+ const btVector3 &parent_axis_position, // vector from parent COM to joint axis, in PARENT frame
+ const btVector3 &my_axis_position, // vector from joint axis to my COM, in MY frame
+ bool disableParentCollision=false);
+
+ const btMultibodyLink& getLink(int index) const
+ {
+ return links[index];
+ }
+
+ btMultibodyLink& getLink(int index)
+ {
+ return links[index];
+ }
+
+
+ void setBaseCollider(btMultiBodyLinkCollider* collider)//collider can be NULL to disable collision for the base
+ {
+ m_baseCollider = collider;
+ }
+ const btMultiBodyLinkCollider* getBaseCollider() const
+ {
+ return m_baseCollider;
+ }
+ btMultiBodyLinkCollider* getBaseCollider()
+ {
+ return m_baseCollider;
+ }
+
+ //
+ // get parent
+ // input: link num from 0 to num_links-1
+ // output: link num from 0 to num_links-1, OR -1 to mean the base.
+ //
+ int getParent(int link_num) const;
+
+
+ //
+ // get number of links, masses, moments of inertia
+ //
+
+ int getNumLinks() const { return links.size(); }
+ btScalar getBaseMass() const { return base_mass; }
+ const btVector3 & getBaseInertia() const { return base_inertia; }
+ btScalar getLinkMass(int i) const;
+ const btVector3 & getLinkInertia(int i) const;
+
+
+ //
+ // change mass (incomplete: can only change base mass and inertia at present)
+ //
+
+ void setBaseMass(btScalar mass) { base_mass = mass; }
+ void setBaseInertia(const btVector3 &inertia) { base_inertia = inertia; }
+
+
+ //
+ // get/set pos/vel/rot/omega for the base link
+ //
+
+ const btVector3 & getBasePos() const { return base_pos; } // in world frame
+ const btVector3 getBaseVel() const
+ {
+ return btVector3(m_real_buf[3],m_real_buf[4],m_real_buf[5]);
+ } // in world frame
+ const btQuaternion & getWorldToBaseRot() const
+ {
+ return base_quat;
+ } // rotates world vectors into base frame
+ btVector3 getBaseOmega() const { return btVector3(m_real_buf[0],m_real_buf[1],m_real_buf[2]); } // in world frame
+
+ void setBasePos(const btVector3 &pos)
+ {
+ base_pos = pos;
+ }
+ void setBaseVel(const btVector3 &vel)
+ {
+
+ m_real_buf[3]=vel[0]; m_real_buf[4]=vel[1]; m_real_buf[5]=vel[2];
+ }
+ void setWorldToBaseRot(const btQuaternion &rot)
+ {
+ base_quat = rot;
+ }
+ void setBaseOmega(const btVector3 &omega)
+ {
+ m_real_buf[0]=omega[0];
+ m_real_buf[1]=omega[1];
+ m_real_buf[2]=omega[2];
+ }
+
+
+ //
+ // get/set pos/vel for child links (i = 0 to num_links-1)
+ //
+
+ btScalar getJointPos(int i) const;
+ btScalar getJointVel(int i) const;
+
+ void setJointPos(int i, btScalar q);
+ void setJointVel(int i, btScalar qdot);
+
+ //
+ // direct access to velocities as a vector of 6 + num_links elements.
+ // (omega first, then v, then joint velocities.)
+ //
+ const btScalar * getVelocityVector() const
+ {
+ return &m_real_buf[0];
+ }
+/* btScalar * getVelocityVector()
+ {
+ return &real_buf[0];
+ }
+ */
+
+ //
+ // get the frames of reference (positions and orientations) of the child links
+ // (i = 0 to num_links-1)
+ //
+
+ const btVector3 & getRVector(int i) const; // vector from COM(parent(i)) to COM(i), in frame i's coords
+ const btQuaternion & getParentToLocalRot(int i) const; // rotates vectors in frame parent(i) to vectors in frame i.
+
+
+ //
+ // transform vectors in local frame of link i to world frame (or vice versa)
+ //
+ btVector3 localPosToWorld(int i, const btVector3 &vec) const;
+ btVector3 localDirToWorld(int i, const btVector3 &vec) const;
+ btVector3 worldPosToLocal(int i, const btVector3 &vec) const;
+ btVector3 worldDirToLocal(int i, const btVector3 &vec) const;
+
+
+ //
+ // calculate kinetic energy and angular momentum
+ // useful for debugging.
+ //
+
+ btScalar getKineticEnergy() const;
+ btVector3 getAngularMomentum() const;
+
+
+ //
+ // set external forces and torques. Note all external forces/torques are given in the WORLD frame.
+ //
+
+ void clearForcesAndTorques();
+ void clearVelocities();
+
+ void addBaseForce(const btVector3 &f)
+ {
+ base_force += f;
+ }
+ void addBaseTorque(const btVector3 &t) { base_torque += t; }
+ void addLinkForce(int i, const btVector3 &f);
+ void addLinkTorque(int i, const btVector3 &t);
+ void addJointTorque(int i, btScalar Q);
+
+ const btVector3 & getBaseForce() const { return base_force; }
+ const btVector3 & getBaseTorque() const { return base_torque; }
+ const btVector3 & getLinkForce(int i) const;
+ const btVector3 & getLinkTorque(int i) const;
+ btScalar getJointTorque(int i) const;
+
+
+ //
+ // dynamics routines.
+ //
+
+ // timestep the velocities (given the external forces/torques set using addBaseForce etc).
+ // also sets up caches for calcAccelerationDeltas.
+ //
+ // Note: the caller must provide three vectors which are used as
+ // temporary scratch space. The idea here is to reduce dynamic
+ // memory allocation: the same scratch vectors can be re-used
+ // again and again for different Multibodies, instead of each
+ // btMultiBody allocating (and then deallocating) their own
+ // individual scratch buffers. This gives a considerable speed
+ // improvement, at least on Windows (where dynamic memory
+ // allocation appears to be fairly slow).
+ //
+ void stepVelocities(btScalar dt,
+ btAlignedObjectArray<btScalar> &scratch_r,
+ btAlignedObjectArray<btVector3> &scratch_v,
+ btAlignedObjectArray<btMatrix3x3> &scratch_m);
+
+ // calcAccelerationDeltas
+ // input: force vector (in same format as jacobian, i.e.:
+ // 3 torque values, 3 force values, num_links joint torque values)
+ // output: 3 omegadot values, 3 vdot values, num_links q_double_dot values
+ // (existing contents of output array are replaced)
+ // stepVelocities must have been called first.
+ void calcAccelerationDeltas(const btScalar *force, btScalar *output,
+ btAlignedObjectArray<btScalar> &scratch_r,
+ btAlignedObjectArray<btVector3> &scratch_v) const;
+
+ // apply a delta-vee directly. used in sequential impulses code.
+ void applyDeltaVee(const btScalar * delta_vee)
+ {
+
+ for (int i = 0; i < 6 + getNumLinks(); ++i)
+ {
+ m_real_buf[i] += delta_vee[i];
+ }
+
+ }
+ void applyDeltaVee(const btScalar * delta_vee, btScalar multiplier)
+ {
+ btScalar sum = 0;
+ for (int i = 0; i < 6 + getNumLinks(); ++i)
+ {
+ sum += delta_vee[i]*multiplier*delta_vee[i]*multiplier;
+ }
+ btScalar l = btSqrt(sum);
+ /*
+ static btScalar maxl = -1e30f;
+ if (l>maxl)
+ {
+ maxl=l;
+ // printf("maxl=%f\n",maxl);
+ }
+ */
+ if (l>m_maxAppliedImpulse)
+ {
+// printf("exceeds 100: l=%f\n",maxl);
+ multiplier *= m_maxAppliedImpulse/l;
+ }
+
+ for (int i = 0; i < 6 + getNumLinks(); ++i)
+ {
+ sum += delta_vee[i]*multiplier*delta_vee[i]*multiplier;
+ m_real_buf[i] += delta_vee[i] * multiplier;
+ }
+ }
+
+ // timestep the positions (given current velocities).
+ void stepPositions(btScalar dt);
+
+
+ //
+ // contacts
+ //
+
+ // This routine fills out a contact constraint jacobian for this body.
+ // the 'normal' supplied must be -n for body1 or +n for body2 of the contact.
+ // 'normal' & 'contact_point' are both given in world coordinates.
+ void fillContactJacobian(int link,
+ const btVector3 &contact_point,
+ const btVector3 &normal,
+ btScalar *jac,
+ btAlignedObjectArray<btScalar> &scratch_r,
+ btAlignedObjectArray<btVector3> &scratch_v,
+ btAlignedObjectArray<btMatrix3x3> &scratch_m) const;
+
+
+ //
+ // sleeping
+ //
+ void setCanSleep(bool canSleep)
+ {
+ can_sleep = canSleep;
+ }
+
+ bool isAwake() const { return awake; }
+ void wakeUp();
+ void goToSleep();
+ void checkMotionAndSleepIfRequired(btScalar timestep);
+
+ bool hasFixedBase() const
+ {
+ return fixed_base;
+ }
+
+ int getCompanionId() const
+ {
+ return m_companionId;
+ }
+ void setCompanionId(int id)
+ {
+ //printf("for %p setCompanionId(%d)\n",this, id);
+ m_companionId = id;
+ }
+
+ void setNumLinks(int numLinks)//careful: when changing the number of links, make sure to re-initialize or update existing links
+ {
+ links.resize(numLinks);
+ }
+
+ btScalar getLinearDamping() const
+ {
+ return m_linearDamping;
+ }
+ void setLinearDamping( btScalar damp)
+ {
+ m_linearDamping = damp;
+ }
+ btScalar getAngularDamping() const
+ {
+ return m_angularDamping;
+ }
+
+ bool getUseGyroTerm() const
+ {
+ return m_useGyroTerm;
+ }
+ void setUseGyroTerm(bool useGyro)
+ {
+ m_useGyroTerm = useGyro;
+ }
+ btScalar getMaxAppliedImpulse() const
+ {
+ return m_maxAppliedImpulse;
+ }
+ void setMaxAppliedImpulse(btScalar maxImp)
+ {
+ m_maxAppliedImpulse = maxImp;
+ }
+
+ void setHasSelfCollision(bool hasSelfCollision)
+ {
+ m_hasSelfCollision = hasSelfCollision;
+ }
+ bool hasSelfCollision() const
+ {
+ return m_hasSelfCollision;
+ }
+
+private:
+ btMultiBody(const btMultiBody &); // not implemented
+ void operator=(const btMultiBody &); // not implemented
+
+ void compTreeLinkVelocities(btVector3 *omega, btVector3 *vel) const;
+
+ void solveImatrix(const btVector3& rhs_top, const btVector3& rhs_bot, float result[6]) const;
+
+
+private:
+
+ btMultiBodyLinkCollider* m_baseCollider;//can be NULL
+
+ btVector3 base_pos; // position of COM of base (world frame)
+ btQuaternion base_quat; // rotates world points into base frame
+
+ btScalar base_mass; // mass of the base
+ btVector3 base_inertia; // inertia of the base (in local frame; diagonal)
+
+ btVector3 base_force; // external force applied to base. World frame.
+ btVector3 base_torque; // external torque applied to base. World frame.
+
+ btAlignedObjectArray<btMultibodyLink> links; // array of links, excluding the base. index from 0 to num_links-1.
+ btAlignedObjectArray<btMultiBodyLinkCollider*> m_colliders;
+
+ //
+ // real_buf:
+ // offset size array
+ // 0 6 + num_links v (base_omega; base_vel; joint_vels)
+ // 6+num_links num_links D
+ //
+ // vector_buf:
+ // offset size array
+ // 0 num_links h_top
+ // num_links num_links h_bottom
+ //
+ // matrix_buf:
+ // offset size array
+ // 0 num_links+1 rot_from_parent
+ //
+
+ btAlignedObjectArray<btScalar> m_real_buf;
+ btAlignedObjectArray<btVector3> vector_buf;
+ btAlignedObjectArray<btMatrix3x3> matrix_buf;
+
+ //std::auto_ptr<Eigen::LU<Eigen::Matrix<btScalar, 6, 6> > > cached_imatrix_lu;
+
+ btMatrix3x3 cached_inertia_top_left;
+ btMatrix3x3 cached_inertia_top_right;
+ btMatrix3x3 cached_inertia_lower_left;
+ btMatrix3x3 cached_inertia_lower_right;
+
+ bool fixed_base;
+
+ // Sleep parameters.
+ bool awake;
+ bool can_sleep;
+ btScalar sleep_timer;
+
+ int m_companionId;
+ btScalar m_linearDamping;
+ btScalar m_angularDamping;
+ bool m_useGyroTerm;
+ btScalar m_maxAppliedImpulse;
+ bool m_hasSelfCollision;
+};
+
+#endif
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
new file mode 100644
index 00000000000..44e04c3a132
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
@@ -0,0 +1,527 @@
+#include "btMultiBodyConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+btMultiBodyConstraint::btMultiBodyConstraint(btMultiBody* bodyA,btMultiBody* bodyB,int linkA, int linkB, int numRows, bool isUnilateral)
+ :m_bodyA(bodyA),
+ m_bodyB(bodyB),
+ m_linkA(linkA),
+ m_linkB(linkB),
+ m_num_rows(numRows),
+ m_isUnilateral(isUnilateral),
+ m_maxAppliedImpulse(100)
+{
+ m_jac_size_A = (6 + bodyA->getNumLinks());
+ m_jac_size_both = (m_jac_size_A + (bodyB ? 6 + bodyB->getNumLinks() : 0));
+ m_pos_offset = ((1 + m_jac_size_both)*m_num_rows);
+ m_data.resize((2 + m_jac_size_both) * m_num_rows);
+}
+
+btMultiBodyConstraint::~btMultiBodyConstraint()
+{
+}
+
+
+
+btScalar btMultiBodyConstraint::fillConstraintRowMultiBodyMultiBody(btMultiBodySolverConstraint& constraintRow,
+ btMultiBodyJacobianData& data,
+ btScalar* jacOrgA,btScalar* jacOrgB,
+ const btContactSolverInfo& infoGlobal,
+ btScalar desiredVelocity,
+ btScalar lowerLimit,
+ btScalar upperLimit)
+{
+
+
+
+ constraintRow.m_multiBodyA = m_bodyA;
+ constraintRow.m_multiBodyB = m_bodyB;
+
+ btMultiBody* multiBodyA = constraintRow.m_multiBodyA;
+ btMultiBody* multiBodyB = constraintRow.m_multiBodyB;
+
+ if (multiBodyA)
+ {
+
+ const int ndofA = multiBodyA->getNumLinks() + 6;
+
+ constraintRow.m_deltaVelAindex = multiBodyA->getCompanionId();
+
+ if (constraintRow.m_deltaVelAindex <0)
+ {
+ constraintRow.m_deltaVelAindex = data.m_deltaVelocities.size();
+ multiBodyA->setCompanionId(constraintRow.m_deltaVelAindex);
+ data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofA);
+ } else
+ {
+ btAssert(data.m_deltaVelocities.size() >= constraintRow.m_deltaVelAindex+ndofA);
+ }
+
+ constraintRow.m_jacAindex = data.m_jacobians.size();
+ data.m_jacobians.resize(data.m_jacobians.size()+ndofA);
+ data.m_deltaVelocitiesUnitImpulse.resize(data.m_deltaVelocitiesUnitImpulse.size()+ndofA);
+ btAssert(data.m_jacobians.size() == data.m_deltaVelocitiesUnitImpulse.size());
+ for (int i=0;i<ndofA;i++)
+ data.m_jacobians[constraintRow.m_jacAindex+i] = jacOrgA[i];
+
+ btScalar* delta = &data.m_deltaVelocitiesUnitImpulse[constraintRow.m_jacAindex];
+ multiBodyA->calcAccelerationDeltas(&data.m_jacobians[constraintRow.m_jacAindex],delta,data.scratch_r, data.scratch_v);
+ }
+
+ if (multiBodyB)
+ {
+ const int ndofB = multiBodyB->getNumLinks() + 6;
+
+ constraintRow.m_deltaVelBindex = multiBodyB->getCompanionId();
+ if (constraintRow.m_deltaVelBindex <0)
+ {
+ constraintRow.m_deltaVelBindex = data.m_deltaVelocities.size();
+ multiBodyB->setCompanionId(constraintRow.m_deltaVelBindex);
+ data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofB);
+ }
+
+ constraintRow.m_jacBindex = data.m_jacobians.size();
+ data.m_jacobians.resize(data.m_jacobians.size()+ndofB);
+
+ for (int i=0;i<ndofB;i++)
+ data.m_jacobians[constraintRow.m_jacBindex+i] = jacOrgB[i];
+
+ data.m_deltaVelocitiesUnitImpulse.resize(data.m_deltaVelocitiesUnitImpulse.size()+ndofB);
+ btAssert(data.m_jacobians.size() == data.m_deltaVelocitiesUnitImpulse.size());
+ multiBodyB->calcAccelerationDeltas(&data.m_jacobians[constraintRow.m_jacBindex],&data.m_deltaVelocitiesUnitImpulse[constraintRow.m_jacBindex],data.scratch_r, data.scratch_v);
+ }
+ {
+
+ btVector3 vec;
+ btScalar denom0 = 0.f;
+ btScalar denom1 = 0.f;
+ btScalar* jacB = 0;
+ btScalar* jacA = 0;
+ btScalar* lambdaA =0;
+ btScalar* lambdaB =0;
+ int ndofA = 0;
+ if (multiBodyA)
+ {
+ ndofA = multiBodyA->getNumLinks() + 6;
+ jacA = &data.m_jacobians[constraintRow.m_jacAindex];
+ lambdaA = &data.m_deltaVelocitiesUnitImpulse[constraintRow.m_jacAindex];
+ for (int i = 0; i < ndofA; ++i)
+ {
+ btScalar j = jacA[i] ;
+ btScalar l =lambdaA[i];
+ denom0 += j*l;
+ }
+ }
+ if (multiBodyB)
+ {
+ const int ndofB = multiBodyB->getNumLinks() + 6;
+ jacB = &data.m_jacobians[constraintRow.m_jacBindex];
+ lambdaB = &data.m_deltaVelocitiesUnitImpulse[constraintRow.m_jacBindex];
+ for (int i = 0; i < ndofB; ++i)
+ {
+ btScalar j = jacB[i] ;
+ btScalar l =lambdaB[i];
+ denom1 += j*l;
+ }
+
+ }
+
+ if (multiBodyA && (multiBodyA==multiBodyB))
+ {
+ // ndof1 == ndof2 in this case
+ for (int i = 0; i < ndofA; ++i)
+ {
+ denom1 += jacB[i] * lambdaA[i];
+ denom1 += jacA[i] * lambdaB[i];
+ }
+ }
+
+ btScalar d = denom0+denom1;
+ if (btFabs(d)>SIMD_EPSILON)
+ {
+
+ constraintRow.m_jacDiagABInv = 1.f/(d);
+ } else
+ {
+ constraintRow.m_jacDiagABInv = 1.f;
+ }
+
+ }
+
+
+ //compute rhs and remaining constraintRow fields
+
+
+
+
+ btScalar rel_vel = 0.f;
+ int ndofA = 0;
+ int ndofB = 0;
+ {
+
+ btVector3 vel1,vel2;
+ if (multiBodyA)
+ {
+ ndofA = multiBodyA->getNumLinks() + 6;
+ btScalar* jacA = &data.m_jacobians[constraintRow.m_jacAindex];
+ for (int i = 0; i < ndofA ; ++i)
+ rel_vel += multiBodyA->getVelocityVector()[i] * jacA[i];
+ }
+ if (multiBodyB)
+ {
+ ndofB = multiBodyB->getNumLinks() + 6;
+ btScalar* jacB = &data.m_jacobians[constraintRow.m_jacBindex];
+ for (int i = 0; i < ndofB ; ++i)
+ rel_vel += multiBodyB->getVelocityVector()[i] * jacB[i];
+
+ }
+
+ constraintRow.m_friction = 0.f;
+
+ constraintRow.m_appliedImpulse = 0.f;
+ constraintRow.m_appliedPushImpulse = 0.f;
+
+ btScalar velocityError = desiredVelocity - rel_vel;// * damping;
+
+ btScalar erp = infoGlobal.m_erp2;
+
+ btScalar velocityImpulse = velocityError *constraintRow.m_jacDiagABInv;
+
+ if (!infoGlobal.m_splitImpulse)
+ {
+ //combine position and velocity into rhs
+ constraintRow.m_rhs = velocityImpulse;
+ constraintRow.m_rhsPenetration = 0.f;
+
+ } else
+ {
+ //split position and velocity into rhs and m_rhsPenetration
+ constraintRow.m_rhs = velocityImpulse;
+ constraintRow.m_rhsPenetration = 0.f;
+ }
+
+
+ constraintRow.m_cfm = 0.f;
+ constraintRow.m_lowerLimit = lowerLimit;
+ constraintRow.m_upperLimit = upperLimit;
+
+ }
+ return rel_vel;
+}
+
+
+void btMultiBodyConstraint::applyDeltaVee(btMultiBodyJacobianData& data, btScalar* delta_vee, btScalar impulse, int velocityIndex, int ndof)
+{
+ for (int i = 0; i < ndof; ++i)
+ data.m_deltaVelocities[velocityIndex+i] += delta_vee[i] * impulse;
+}
+
+
+void btMultiBodyConstraint::fillMultiBodyConstraintMixed(btMultiBodySolverConstraint& solverConstraint,
+ btMultiBodyJacobianData& data,
+ const btVector3& contactNormalOnB,
+ const btVector3& posAworld, const btVector3& posBworld,
+ btScalar position,
+ const btContactSolverInfo& infoGlobal,
+ btScalar& relaxation,
+ bool isFriction, btScalar desiredVelocity, btScalar cfmSlip)
+{
+
+
+ btVector3 rel_pos1 = posAworld;
+ btVector3 rel_pos2 = posBworld;
+
+ solverConstraint.m_multiBodyA = m_bodyA;
+ solverConstraint.m_multiBodyB = m_bodyB;
+ solverConstraint.m_linkA = m_linkA;
+ solverConstraint.m_linkB = m_linkB;
+
+
+ btMultiBody* multiBodyA = solverConstraint.m_multiBodyA;
+ btMultiBody* multiBodyB = solverConstraint.m_multiBodyB;
+
+ const btVector3& pos1 = posAworld;
+ const btVector3& pos2 = posBworld;
+
+ btSolverBody* bodyA = multiBodyA ? 0 : &data.m_solverBodyPool->at(solverConstraint.m_solverBodyIdA);
+ btSolverBody* bodyB = multiBodyB ? 0 : &data.m_solverBodyPool->at(solverConstraint.m_solverBodyIdB);
+
+ btRigidBody* rb0 = multiBodyA ? 0 : bodyA->m_originalBody;
+ btRigidBody* rb1 = multiBodyB ? 0 : bodyB->m_originalBody;
+
+ if (bodyA)
+ rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin();
+ if (bodyB)
+ rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin();
+
+ relaxation = 1.f;
+
+ if (multiBodyA)
+ {
+ const int ndofA = multiBodyA->getNumLinks() + 6;
+
+ solverConstraint.m_deltaVelAindex = multiBodyA->getCompanionId();
+
+ if (solverConstraint.m_deltaVelAindex <0)
+ {
+ solverConstraint.m_deltaVelAindex = data.m_deltaVelocities.size();
+ multiBodyA->setCompanionId(solverConstraint.m_deltaVelAindex);
+ data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofA);
+ } else
+ {
+ btAssert(data.m_deltaVelocities.size() >= solverConstraint.m_deltaVelAindex+ndofA);
+ }
+
+ solverConstraint.m_jacAindex = data.m_jacobians.size();
+ data.m_jacobians.resize(data.m_jacobians.size()+ndofA);
+ data.m_deltaVelocitiesUnitImpulse.resize(data.m_deltaVelocitiesUnitImpulse.size()+ndofA);
+ btAssert(data.m_jacobians.size() == data.m_deltaVelocitiesUnitImpulse.size());
+
+ btScalar* jac1=&data.m_jacobians[solverConstraint.m_jacAindex];
+ multiBodyA->fillContactJacobian(solverConstraint.m_linkA, posAworld, contactNormalOnB, jac1, data.scratch_r, data.scratch_v, data.scratch_m);
+ btScalar* delta = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex];
+ multiBodyA->calcAccelerationDeltas(&data.m_jacobians[solverConstraint.m_jacAindex],delta,data.scratch_r, data.scratch_v);
+ } else
+ {
+ btVector3 torqueAxis0 = rel_pos1.cross(contactNormalOnB);
+ solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0);
+ solverConstraint.m_relpos1CrossNormal = torqueAxis0;
+ solverConstraint.m_contactNormal1 = contactNormalOnB;
+ }
+
+ if (multiBodyB)
+ {
+ const int ndofB = multiBodyB->getNumLinks() + 6;
+
+ solverConstraint.m_deltaVelBindex = multiBodyB->getCompanionId();
+ if (solverConstraint.m_deltaVelBindex <0)
+ {
+ solverConstraint.m_deltaVelBindex = data.m_deltaVelocities.size();
+ multiBodyB->setCompanionId(solverConstraint.m_deltaVelBindex);
+ data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofB);
+ }
+
+ solverConstraint.m_jacBindex = data.m_jacobians.size();
+
+ data.m_jacobians.resize(data.m_jacobians.size()+ndofB);
+ data.m_deltaVelocitiesUnitImpulse.resize(data.m_deltaVelocitiesUnitImpulse.size()+ndofB);
+ btAssert(data.m_jacobians.size() == data.m_deltaVelocitiesUnitImpulse.size());
+
+ multiBodyB->fillContactJacobian(solverConstraint.m_linkB, posBworld, -contactNormalOnB, &data.m_jacobians[solverConstraint.m_jacBindex], data.scratch_r, data.scratch_v, data.scratch_m);
+ multiBodyB->calcAccelerationDeltas(&data.m_jacobians[solverConstraint.m_jacBindex],&data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex],data.scratch_r, data.scratch_v);
+ } else
+ {
+ btVector3 torqueAxis1 = rel_pos2.cross(contactNormalOnB);
+ solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0);
+ solverConstraint.m_relpos2CrossNormal = -torqueAxis1;
+ solverConstraint.m_contactNormal2 = -contactNormalOnB;
+ }
+
+ {
+
+ btVector3 vec;
+ btScalar denom0 = 0.f;
+ btScalar denom1 = 0.f;
+ btScalar* jacB = 0;
+ btScalar* jacA = 0;
+ btScalar* lambdaA =0;
+ btScalar* lambdaB =0;
+ int ndofA = 0;
+ if (multiBodyA)
+ {
+ ndofA = multiBodyA->getNumLinks() + 6;
+ jacA = &data.m_jacobians[solverConstraint.m_jacAindex];
+ lambdaA = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex];
+ for (int i = 0; i < ndofA; ++i)
+ {
+ btScalar j = jacA[i] ;
+ btScalar l =lambdaA[i];
+ denom0 += j*l;
+ }
+ } else
+ {
+ if (rb0)
+ {
+ vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1);
+ denom0 = rb0->getInvMass() + contactNormalOnB.dot(vec);
+ }
+ }
+ if (multiBodyB)
+ {
+ const int ndofB = multiBodyB->getNumLinks() + 6;
+ jacB = &data.m_jacobians[solverConstraint.m_jacBindex];
+ lambdaB = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex];
+ for (int i = 0; i < ndofB; ++i)
+ {
+ btScalar j = jacB[i] ;
+ btScalar l =lambdaB[i];
+ denom1 += j*l;
+ }
+
+ } else
+ {
+ if (rb1)
+ {
+ vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2);
+ denom1 = rb1->getInvMass() + contactNormalOnB.dot(vec);
+ }
+ }
+
+ if (multiBodyA && (multiBodyA==multiBodyB))
+ {
+ // ndof1 == ndof2 in this case
+ for (int i = 0; i < ndofA; ++i)
+ {
+ denom1 += jacB[i] * lambdaA[i];
+ denom1 += jacA[i] * lambdaB[i];
+ }
+ }
+
+ btScalar d = denom0+denom1;
+ if (btFabs(d)>SIMD_EPSILON)
+ {
+
+ solverConstraint.m_jacDiagABInv = relaxation/(d);
+ } else
+ {
+ solverConstraint.m_jacDiagABInv = 1.f;
+ }
+
+ }
+
+
+ //compute rhs and remaining solverConstraint fields
+
+
+
+ btScalar restitution = 0.f;
+ btScalar penetration = isFriction? 0 : position+infoGlobal.m_linearSlop;
+
+ btScalar rel_vel = 0.f;
+ int ndofA = 0;
+ int ndofB = 0;
+ {
+
+ btVector3 vel1,vel2;
+ if (multiBodyA)
+ {
+ ndofA = multiBodyA->getNumLinks() + 6;
+ btScalar* jacA = &data.m_jacobians[solverConstraint.m_jacAindex];
+ for (int i = 0; i < ndofA ; ++i)
+ rel_vel += multiBodyA->getVelocityVector()[i] * jacA[i];
+ } else
+ {
+ if (rb0)
+ {
+ rel_vel += rb0->getVelocityInLocalPoint(rel_pos1).dot(solverConstraint.m_contactNormal1);
+ }
+ }
+ if (multiBodyB)
+ {
+ ndofB = multiBodyB->getNumLinks() + 6;
+ btScalar* jacB = &data.m_jacobians[solverConstraint.m_jacBindex];
+ for (int i = 0; i < ndofB ; ++i)
+ rel_vel += multiBodyB->getVelocityVector()[i] * jacB[i];
+
+ } else
+ {
+ if (rb1)
+ {
+ rel_vel += rb1->getVelocityInLocalPoint(rel_pos2).dot(solverConstraint.m_contactNormal2);
+ }
+ }
+
+ solverConstraint.m_friction = 0.f;//cp.m_combinedFriction;
+
+
+ restitution = restitution * -rel_vel;//restitutionCurve(rel_vel, cp.m_combinedRestitution);
+ if (restitution <= btScalar(0.))
+ {
+ restitution = 0.f;
+ };
+ }
+
+
+ ///warm starting (or zero if disabled)
+ /*
+ if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
+ {
+ solverConstraint.m_appliedImpulse = isFriction ? 0 : cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor;
+
+ if (solverConstraint.m_appliedImpulse)
+ {
+ if (multiBodyA)
+ {
+ btScalar impulse = solverConstraint.m_appliedImpulse;
+ btScalar* deltaV = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex];
+ multiBodyA->applyDeltaVee(deltaV,impulse);
+ applyDeltaVee(data,deltaV,impulse,solverConstraint.m_deltaVelAindex,ndofA);
+ } else
+ {
+ if (rb0)
+ bodyA->internalApplyImpulse(solverConstraint.m_contactNormal1*bodyA->internalGetInvMass()*rb0->getLinearFactor(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse);
+ }
+ if (multiBodyB)
+ {
+ btScalar impulse = solverConstraint.m_appliedImpulse;
+ btScalar* deltaV = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex];
+ multiBodyB->applyDeltaVee(deltaV,impulse);
+ applyDeltaVee(data,deltaV,impulse,solverConstraint.m_deltaVelBindex,ndofB);
+ } else
+ {
+ if (rb1)
+ bodyB->internalApplyImpulse(-solverConstraint.m_contactNormal2*bodyB->internalGetInvMass()*rb1->getLinearFactor(),-solverConstraint.m_angularComponentB,-(btScalar)solverConstraint.m_appliedImpulse);
+ }
+ }
+ } else
+ */
+ {
+ solverConstraint.m_appliedImpulse = 0.f;
+ }
+
+ solverConstraint.m_appliedPushImpulse = 0.f;
+
+ {
+
+
+ btScalar positionalError = 0.f;
+ btScalar velocityError = restitution - rel_vel;// * damping;
+
+
+ btScalar erp = infoGlobal.m_erp2;
+ if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold))
+ {
+ erp = infoGlobal.m_erp;
+ }
+
+ if (penetration>0)
+ {
+ positionalError = 0;
+ velocityError = -penetration / infoGlobal.m_timeStep;
+
+ } else
+ {
+ positionalError = -penetration * erp/infoGlobal.m_timeStep;
+ }
+
+ btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv;
+ btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv;
+
+ if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold))
+ {
+ //combine position and velocity into rhs
+ solverConstraint.m_rhs = penetrationImpulse+velocityImpulse;
+ solverConstraint.m_rhsPenetration = 0.f;
+
+ } else
+ {
+ //split position and velocity into rhs and m_rhsPenetration
+ solverConstraint.m_rhs = velocityImpulse;
+ solverConstraint.m_rhsPenetration = penetrationImpulse;
+ }
+
+ solverConstraint.m_cfm = 0.f;
+ solverConstraint.m_lowerLimit = -m_maxAppliedImpulse;
+ solverConstraint.m_upperLimit = m_maxAppliedImpulse;
+ }
+
+}
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h
new file mode 100644
index 00000000000..9fa317330b3
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h
@@ -0,0 +1,166 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_MULTIBODY_CONSTRAINT_H
+#define BT_MULTIBODY_CONSTRAINT_H
+
+#include "LinearMath/btScalar.h"
+#include "LinearMath/btAlignedObjectArray.h"
+#include "btMultiBody.h"
+
+class btMultiBody;
+struct btSolverInfo;
+
+#include "btMultiBodySolverConstraint.h"
+
+struct btMultiBodyJacobianData
+{
+ btAlignedObjectArray<btScalar> m_jacobians;
+ btAlignedObjectArray<btScalar> m_deltaVelocitiesUnitImpulse;
+ btAlignedObjectArray<btScalar> m_deltaVelocities;
+ btAlignedObjectArray<btScalar> scratch_r;
+ btAlignedObjectArray<btVector3> scratch_v;
+ btAlignedObjectArray<btMatrix3x3> scratch_m;
+ btAlignedObjectArray<btSolverBody>* m_solverBodyPool;
+ int m_fixedBodyId;
+
+};
+
+
+class btMultiBodyConstraint
+{
+protected:
+
+ btMultiBody* m_bodyA;
+ btMultiBody* m_bodyB;
+ int m_linkA;
+ int m_linkB;
+
+ int m_num_rows;
+ int m_jac_size_A;
+ int m_jac_size_both;
+ int m_pos_offset;
+
+ bool m_isUnilateral;
+
+ btScalar m_maxAppliedImpulse;
+
+
+ // data block laid out as follows:
+ // cached impulses. (one per row.)
+ // jacobians. (interleaved, row1 body1 then row1 body2 then row2 body 1 etc)
+ // positions. (one per row.)
+ btAlignedObjectArray<btScalar> m_data;
+
+ void applyDeltaVee(btMultiBodyJacobianData& data, btScalar* delta_vee, btScalar impulse, int velocityIndex, int ndof);
+
+ void fillMultiBodyConstraintMixed(btMultiBodySolverConstraint& solverConstraint,
+ btMultiBodyJacobianData& data,
+ const btVector3& contactNormalOnB,
+ const btVector3& posAworld, const btVector3& posBworld,
+ btScalar position,
+ const btContactSolverInfo& infoGlobal,
+ btScalar& relaxation,
+ bool isFriction, btScalar desiredVelocity=0, btScalar cfmSlip=0);
+
+ btScalar fillConstraintRowMultiBodyMultiBody(btMultiBodySolverConstraint& constraintRow,
+ btMultiBodyJacobianData& data,
+ btScalar* jacOrgA,btScalar* jacOrgB,
+ const btContactSolverInfo& infoGlobal,
+ btScalar desiredVelocity,
+ btScalar lowerLimit,
+ btScalar upperLimit);
+
+public:
+
+ btMultiBodyConstraint(btMultiBody* bodyA,btMultiBody* bodyB,int linkA, int linkB, int numRows, bool isUnilateral);
+ virtual ~btMultiBodyConstraint();
+
+
+
+ virtual int getIslandIdA() const =0;
+ virtual int getIslandIdB() const =0;
+
+ virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
+ btMultiBodyJacobianData& data,
+ const btContactSolverInfo& infoGlobal)=0;
+
+ int getNumRows() const
+ {
+ return m_num_rows;
+ }
+
+ btMultiBody* getMultiBodyA()
+ {
+ return m_bodyA;
+ }
+ btMultiBody* getMultiBodyB()
+ {
+ return m_bodyB;
+ }
+
+ // current constraint position
+ // constraint is pos >= 0 for unilateral, or pos = 0 for bilateral
+ // NOTE: ignored position for friction rows.
+ btScalar getPosition(int row) const
+ {
+ return m_data[m_pos_offset + row];
+ }
+
+ void setPosition(int row, btScalar pos)
+ {
+ m_data[m_pos_offset + row] = pos;
+ }
+
+
+ bool isUnilateral() const
+ {
+ return m_isUnilateral;
+ }
+
+ // jacobian blocks.
+ // each of size 6 + num_links. (jacobian2 is null if no body2.)
+ // format: 3 'omega' coefficients, 3 'v' coefficients, then the 'qdot' coefficients.
+ btScalar* jacobianA(int row)
+ {
+ return &m_data[m_num_rows + row * m_jac_size_both];
+ }
+ const btScalar* jacobianA(int row) const
+ {
+ return &m_data[m_num_rows + (row * m_jac_size_both)];
+ }
+ btScalar* jacobianB(int row)
+ {
+ return &m_data[m_num_rows + (row * m_jac_size_both) + m_jac_size_A];
+ }
+ const btScalar* jacobianB(int row) const
+ {
+ return &m_data[m_num_rows + (row * m_jac_size_both) + m_jac_size_A];
+ }
+
+ btScalar getMaxAppliedImpulse() const
+ {
+ return m_maxAppliedImpulse;
+ }
+ void setMaxAppliedImpulse(btScalar maxImp)
+ {
+ m_maxAppliedImpulse = maxImp;
+ }
+
+
+};
+
+#endif //BT_MULTIBODY_CONSTRAINT_H
+
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp
new file mode 100644
index 00000000000..577f846225b
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp
@@ -0,0 +1,795 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btMultiBodyConstraintSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+#include "btMultiBodyLinkCollider.h"
+
+#include "BulletDynamics/ConstraintSolver/btSolverBody.h"
+#include "btMultiBodyConstraint.h"
+#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
+
+#include "LinearMath/btQuickprof.h"
+
+btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
+{
+ btScalar val = btSequentialImpulseConstraintSolver::solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer);
+
+ //solve featherstone non-contact constraints
+
+ //printf("m_multiBodyNonContactConstraints = %d\n",m_multiBodyNonContactConstraints.size());
+ for (int j=0;j<m_multiBodyNonContactConstraints.size();j++)
+ {
+ btMultiBodySolverConstraint& constraint = m_multiBodyNonContactConstraints[j];
+ //if (iteration < constraint.m_overrideNumSolverIterations)
+ //resolveSingleConstraintRowGenericMultiBody(constraint);
+ resolveSingleConstraintRowGeneric(constraint);
+ }
+
+ //solve featherstone normal contact
+ for (int j=0;j<m_multiBodyNormalContactConstraints.size();j++)
+ {
+ btMultiBodySolverConstraint& constraint = m_multiBodyNormalContactConstraints[j];
+ if (iteration < infoGlobal.m_numIterations)
+ resolveSingleConstraintRowGeneric(constraint);
+ }
+
+ //solve featherstone frictional contact
+
+ for (int j=0;j<this->m_multiBodyFrictionContactConstraints.size();j++)
+ {
+ if (iteration < infoGlobal.m_numIterations)
+ {
+ btMultiBodySolverConstraint& frictionConstraint = m_multiBodyFrictionContactConstraints[j];
+ btScalar totalImpulse = m_multiBodyNormalContactConstraints[frictionConstraint.m_frictionIndex].m_appliedImpulse;
+ //adjust friction limits here
+ if (totalImpulse>btScalar(0))
+ {
+ frictionConstraint.m_lowerLimit = -(frictionConstraint.m_friction*totalImpulse);
+ frictionConstraint.m_upperLimit = frictionConstraint.m_friction*totalImpulse;
+ resolveSingleConstraintRowGeneric(frictionConstraint);
+ }
+ }
+ }
+ return val;
+}
+
+btScalar btMultiBodyConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
+{
+ m_multiBodyNonContactConstraints.resize(0);
+ m_multiBodyNormalContactConstraints.resize(0);
+ m_multiBodyFrictionContactConstraints.resize(0);
+ m_data.m_jacobians.resize(0);
+ m_data.m_deltaVelocitiesUnitImpulse.resize(0);
+ m_data.m_deltaVelocities.resize(0);
+
+ for (int i=0;i<numBodies;i++)
+ {
+ const btMultiBodyLinkCollider* fcA = btMultiBodyLinkCollider::upcast(bodies[i]);
+ if (fcA)
+ {
+ fcA->m_multiBody->setCompanionId(-1);
+ }
+ }
+
+ btScalar val = btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup( bodies,numBodies,manifoldPtr, numManifolds, constraints,numConstraints,infoGlobal,debugDrawer);
+
+ return val;
+}
+
+void btMultiBodyConstraintSolver::applyDeltaVee(btScalar* delta_vee, btScalar impulse, int velocityIndex, int ndof)
+{
+ for (int i = 0; i < ndof; ++i)
+ m_data.m_deltaVelocities[velocityIndex+i] += delta_vee[i] * impulse;
+}
+
+void btMultiBodyConstraintSolver::resolveSingleConstraintRowGeneric(const btMultiBodySolverConstraint& c)
+{
+
+ btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm;
+ btScalar deltaVelADotn=0;
+ btScalar deltaVelBDotn=0;
+ btSolverBody* bodyA = 0;
+ btSolverBody* bodyB = 0;
+ int ndofA=0;
+ int ndofB=0;
+
+ if (c.m_multiBodyA)
+ {
+ ndofA = c.m_multiBodyA->getNumLinks() + 6;
+ for (int i = 0; i < ndofA; ++i)
+ deltaVelADotn += m_data.m_jacobians[c.m_jacAindex+i] * m_data.m_deltaVelocities[c.m_deltaVelAindex+i];
+ } else
+ {
+ bodyA = &m_tmpSolverBodyPool[c.m_solverBodyIdA];
+ deltaVelADotn += c.m_contactNormal1.dot(bodyA->internalGetDeltaLinearVelocity()) + c.m_relpos1CrossNormal.dot(bodyA->internalGetDeltaAngularVelocity());
+ }
+
+ if (c.m_multiBodyB)
+ {
+ ndofB = c.m_multiBodyB->getNumLinks() + 6;
+ for (int i = 0; i < ndofB; ++i)
+ deltaVelBDotn += m_data.m_jacobians[c.m_jacBindex+i] * m_data.m_deltaVelocities[c.m_deltaVelBindex+i];
+ } else
+ {
+ bodyB = &m_tmpSolverBodyPool[c.m_solverBodyIdB];
+ deltaVelBDotn += c.m_contactNormal2.dot(bodyB->internalGetDeltaLinearVelocity()) + c.m_relpos2CrossNormal.dot(bodyB->internalGetDeltaAngularVelocity());
+ }
+
+
+ deltaImpulse -= deltaVelADotn*c.m_jacDiagABInv;//m_jacDiagABInv = 1./denom
+ deltaImpulse -= deltaVelBDotn*c.m_jacDiagABInv;
+ const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse;
+
+ if (sum < c.m_lowerLimit)
+ {
+ deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse;
+ c.m_appliedImpulse = c.m_lowerLimit;
+ }
+ else if (sum > c.m_upperLimit)
+ {
+ deltaImpulse = c.m_upperLimit-c.m_appliedImpulse;
+ c.m_appliedImpulse = c.m_upperLimit;
+ }
+ else
+ {
+ c.m_appliedImpulse = sum;
+ }
+
+ if (c.m_multiBodyA)
+ {
+ applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse,c.m_deltaVelAindex,ndofA);
+ c.m_multiBodyA->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse);
+ } else
+ {
+ bodyA->internalApplyImpulse(c.m_contactNormal1*bodyA->internalGetInvMass(),c.m_angularComponentA,deltaImpulse);
+
+ }
+ if (c.m_multiBodyB)
+ {
+ applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse,c.m_deltaVelBindex,ndofB);
+ c.m_multiBodyB->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse);
+ } else
+ {
+ bodyB->internalApplyImpulse(c.m_contactNormal2*bodyB->internalGetInvMass(),c.m_angularComponentB,deltaImpulse);
+ }
+
+}
+
+
+void btMultiBodyConstraintSolver::resolveSingleConstraintRowGenericMultiBody(const btMultiBodySolverConstraint& c)
+{
+
+ btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm;
+ btScalar deltaVelADotn=0;
+ btScalar deltaVelBDotn=0;
+ int ndofA=0;
+ int ndofB=0;
+
+ if (c.m_multiBodyA)
+ {
+ ndofA = c.m_multiBodyA->getNumLinks() + 6;
+ for (int i = 0; i < ndofA; ++i)
+ deltaVelADotn += m_data.m_jacobians[c.m_jacAindex+i] * m_data.m_deltaVelocities[c.m_deltaVelAindex+i];
+ }
+
+ if (c.m_multiBodyB)
+ {
+ ndofB = c.m_multiBodyB->getNumLinks() + 6;
+ for (int i = 0; i < ndofB; ++i)
+ deltaVelBDotn += m_data.m_jacobians[c.m_jacBindex+i] * m_data.m_deltaVelocities[c.m_deltaVelBindex+i];
+ }
+
+
+ deltaImpulse -= deltaVelADotn*c.m_jacDiagABInv;//m_jacDiagABInv = 1./denom
+ deltaImpulse -= deltaVelBDotn*c.m_jacDiagABInv;
+ const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse;
+
+ if (sum < c.m_lowerLimit)
+ {
+ deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse;
+ c.m_appliedImpulse = c.m_lowerLimit;
+ }
+ else if (sum > c.m_upperLimit)
+ {
+ deltaImpulse = c.m_upperLimit-c.m_appliedImpulse;
+ c.m_appliedImpulse = c.m_upperLimit;
+ }
+ else
+ {
+ c.m_appliedImpulse = sum;
+ }
+
+ if (c.m_multiBodyA)
+ {
+ applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse,c.m_deltaVelAindex,ndofA);
+ c.m_multiBodyA->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse);
+ }
+ if (c.m_multiBodyB)
+ {
+ applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse,c.m_deltaVelBindex,ndofB);
+ c.m_multiBodyB->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse);
+ }
+}
+
+
+void btMultiBodyConstraintSolver::setupMultiBodyContactConstraint(btMultiBodySolverConstraint& solverConstraint,
+ const btVector3& contactNormal,
+ btManifoldPoint& cp, const btContactSolverInfo& infoGlobal,
+ btScalar& relaxation,
+ bool isFriction, btScalar desiredVelocity, btScalar cfmSlip)
+{
+
+ BT_PROFILE("setupMultiBodyContactConstraint");
+ btVector3 rel_pos1;
+ btVector3 rel_pos2;
+
+ btMultiBody* multiBodyA = solverConstraint.m_multiBodyA;
+ btMultiBody* multiBodyB = solverConstraint.m_multiBodyB;
+
+ const btVector3& pos1 = cp.getPositionWorldOnA();
+ const btVector3& pos2 = cp.getPositionWorldOnB();
+
+ btSolverBody* bodyA = multiBodyA ? 0 : &m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA];
+ btSolverBody* bodyB = multiBodyB ? 0 : &m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB];
+
+ btRigidBody* rb0 = multiBodyA ? 0 : bodyA->m_originalBody;
+ btRigidBody* rb1 = multiBodyB ? 0 : bodyB->m_originalBody;
+
+ if (bodyA)
+ rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin();
+ if (bodyB)
+ rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin();
+
+ relaxation = 1.f;
+
+ if (multiBodyA)
+ {
+ const int ndofA = multiBodyA->getNumLinks() + 6;
+
+ solverConstraint.m_deltaVelAindex = multiBodyA->getCompanionId();
+
+ if (solverConstraint.m_deltaVelAindex <0)
+ {
+ solverConstraint.m_deltaVelAindex = m_data.m_deltaVelocities.size();
+ multiBodyA->setCompanionId(solverConstraint.m_deltaVelAindex);
+ m_data.m_deltaVelocities.resize(m_data.m_deltaVelocities.size()+ndofA);
+ } else
+ {
+ btAssert(m_data.m_deltaVelocities.size() >= solverConstraint.m_deltaVelAindex+ndofA);
+ }
+
+ solverConstraint.m_jacAindex = m_data.m_jacobians.size();
+ m_data.m_jacobians.resize(m_data.m_jacobians.size()+ndofA);
+ m_data.m_deltaVelocitiesUnitImpulse.resize(m_data.m_deltaVelocitiesUnitImpulse.size()+ndofA);
+ btAssert(m_data.m_jacobians.size() == m_data.m_deltaVelocitiesUnitImpulse.size());
+
+ btScalar* jac1=&m_data.m_jacobians[solverConstraint.m_jacAindex];
+ multiBodyA->fillContactJacobian(solverConstraint.m_linkA, cp.getPositionWorldOnA(), contactNormal, jac1, m_data.scratch_r, m_data.scratch_v, m_data.scratch_m);
+ btScalar* delta = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex];
+ multiBodyA->calcAccelerationDeltas(&m_data.m_jacobians[solverConstraint.m_jacAindex],delta,m_data.scratch_r, m_data.scratch_v);
+ } else
+ {
+ btVector3 torqueAxis0 = rel_pos1.cross(contactNormal);
+ solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0);
+ solverConstraint.m_relpos1CrossNormal = torqueAxis0;
+ solverConstraint.m_contactNormal1 = contactNormal;
+ }
+
+ if (multiBodyB)
+ {
+ const int ndofB = multiBodyB->getNumLinks() + 6;
+
+ solverConstraint.m_deltaVelBindex = multiBodyB->getCompanionId();
+ if (solverConstraint.m_deltaVelBindex <0)
+ {
+ solverConstraint.m_deltaVelBindex = m_data.m_deltaVelocities.size();
+ multiBodyB->setCompanionId(solverConstraint.m_deltaVelBindex);
+ m_data.m_deltaVelocities.resize(m_data.m_deltaVelocities.size()+ndofB);
+ }
+
+ solverConstraint.m_jacBindex = m_data.m_jacobians.size();
+
+ m_data.m_jacobians.resize(m_data.m_jacobians.size()+ndofB);
+ m_data.m_deltaVelocitiesUnitImpulse.resize(m_data.m_deltaVelocitiesUnitImpulse.size()+ndofB);
+ btAssert(m_data.m_jacobians.size() == m_data.m_deltaVelocitiesUnitImpulse.size());
+
+ multiBodyB->fillContactJacobian(solverConstraint.m_linkB, cp.getPositionWorldOnB(), -contactNormal, &m_data.m_jacobians[solverConstraint.m_jacBindex], m_data.scratch_r, m_data.scratch_v, m_data.scratch_m);
+ multiBodyB->calcAccelerationDeltas(&m_data.m_jacobians[solverConstraint.m_jacBindex],&m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex],m_data.scratch_r, m_data.scratch_v);
+ } else
+ {
+ btVector3 torqueAxis1 = rel_pos2.cross(contactNormal);
+ solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0);
+ solverConstraint.m_relpos2CrossNormal = -torqueAxis1;
+ solverConstraint.m_contactNormal2 = -contactNormal;
+ }
+
+ {
+
+ btVector3 vec;
+ btScalar denom0 = 0.f;
+ btScalar denom1 = 0.f;
+ btScalar* jacB = 0;
+ btScalar* jacA = 0;
+ btScalar* lambdaA =0;
+ btScalar* lambdaB =0;
+ int ndofA = 0;
+ if (multiBodyA)
+ {
+ ndofA = multiBodyA->getNumLinks() + 6;
+ jacA = &m_data.m_jacobians[solverConstraint.m_jacAindex];
+ lambdaA = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex];
+ for (int i = 0; i < ndofA; ++i)
+ {
+ btScalar j = jacA[i] ;
+ btScalar l =lambdaA[i];
+ denom0 += j*l;
+ }
+ } else
+ {
+ if (rb0)
+ {
+ vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1);
+ denom0 = rb0->getInvMass() + contactNormal.dot(vec);
+ }
+ }
+ if (multiBodyB)
+ {
+ const int ndofB = multiBodyB->getNumLinks() + 6;
+ jacB = &m_data.m_jacobians[solverConstraint.m_jacBindex];
+ lambdaB = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex];
+ for (int i = 0; i < ndofB; ++i)
+ {
+ btScalar j = jacB[i] ;
+ btScalar l =lambdaB[i];
+ denom1 += j*l;
+ }
+
+ } else
+ {
+ if (rb1)
+ {
+ vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2);
+ denom1 = rb1->getInvMass() + contactNormal.dot(vec);
+ }
+ }
+
+ if (multiBodyA && (multiBodyA==multiBodyB))
+ {
+ // ndof1 == ndof2 in this case
+ for (int i = 0; i < ndofA; ++i)
+ {
+ denom1 += jacB[i] * lambdaA[i];
+ denom1 += jacA[i] * lambdaB[i];
+ }
+ }
+
+ btScalar d = denom0+denom1;
+ if (btFabs(d)>SIMD_EPSILON)
+ {
+
+ solverConstraint.m_jacDiagABInv = relaxation/(d);
+ } else
+ {
+ solverConstraint.m_jacDiagABInv = 1.f;
+ }
+
+ }
+
+
+ //compute rhs and remaining solverConstraint fields
+
+
+
+ btScalar restitution = 0.f;
+ btScalar penetration = isFriction? 0 : cp.getDistance()+infoGlobal.m_linearSlop;
+
+ btScalar rel_vel = 0.f;
+ int ndofA = 0;
+ int ndofB = 0;
+ {
+
+ btVector3 vel1,vel2;
+ if (multiBodyA)
+ {
+ ndofA = multiBodyA->getNumLinks() + 6;
+ btScalar* jacA = &m_data.m_jacobians[solverConstraint.m_jacAindex];
+ for (int i = 0; i < ndofA ; ++i)
+ rel_vel += multiBodyA->getVelocityVector()[i] * jacA[i];
+ } else
+ {
+ if (rb0)
+ {
+ rel_vel += rb0->getVelocityInLocalPoint(rel_pos1).dot(solverConstraint.m_contactNormal1);
+ }
+ }
+ if (multiBodyB)
+ {
+ ndofB = multiBodyB->getNumLinks() + 6;
+ btScalar* jacB = &m_data.m_jacobians[solverConstraint.m_jacBindex];
+ for (int i = 0; i < ndofB ; ++i)
+ rel_vel += multiBodyB->getVelocityVector()[i] * jacB[i];
+
+ } else
+ {
+ if (rb1)
+ {
+ rel_vel += rb1->getVelocityInLocalPoint(rel_pos2).dot(solverConstraint.m_contactNormal2);
+ }
+ }
+
+ solverConstraint.m_friction = cp.m_combinedFriction;
+
+
+ restitution = restitutionCurve(rel_vel, cp.m_combinedRestitution);
+ if (restitution <= btScalar(0.))
+ {
+ restitution = 0.f;
+ };
+ }
+
+
+ ///warm starting (or zero if disabled)
+ if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
+ {
+ solverConstraint.m_appliedImpulse = isFriction ? 0 : cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor;
+
+ if (solverConstraint.m_appliedImpulse)
+ {
+ if (multiBodyA)
+ {
+ btScalar impulse = solverConstraint.m_appliedImpulse;
+ btScalar* deltaV = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex];
+ multiBodyA->applyDeltaVee(deltaV,impulse);
+ applyDeltaVee(deltaV,impulse,solverConstraint.m_deltaVelAindex,ndofA);
+ } else
+ {
+ if (rb0)
+ bodyA->internalApplyImpulse(solverConstraint.m_contactNormal1*bodyA->internalGetInvMass()*rb0->getLinearFactor(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse);
+ }
+ if (multiBodyB)
+ {
+ btScalar impulse = solverConstraint.m_appliedImpulse;
+ btScalar* deltaV = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex];
+ multiBodyB->applyDeltaVee(deltaV,impulse);
+ applyDeltaVee(deltaV,impulse,solverConstraint.m_deltaVelBindex,ndofB);
+ } else
+ {
+ if (rb1)
+ bodyB->internalApplyImpulse(-solverConstraint.m_contactNormal2*bodyB->internalGetInvMass()*rb1->getLinearFactor(),-solverConstraint.m_angularComponentB,-(btScalar)solverConstraint.m_appliedImpulse);
+ }
+ }
+ } else
+ {
+ solverConstraint.m_appliedImpulse = 0.f;
+ }
+
+ solverConstraint.m_appliedPushImpulse = 0.f;
+
+ {
+
+
+ btScalar positionalError = 0.f;
+ btScalar velocityError = restitution - rel_vel;// * damping;
+
+
+ btScalar erp = infoGlobal.m_erp2;
+ if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold))
+ {
+ erp = infoGlobal.m_erp;
+ }
+
+ if (penetration>0)
+ {
+ positionalError = 0;
+ velocityError = -penetration / infoGlobal.m_timeStep;
+
+ } else
+ {
+ positionalError = -penetration * erp/infoGlobal.m_timeStep;
+ }
+
+ btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv;
+ btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv;
+
+ if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold))
+ {
+ //combine position and velocity into rhs
+ solverConstraint.m_rhs = penetrationImpulse+velocityImpulse;
+ solverConstraint.m_rhsPenetration = 0.f;
+
+ } else
+ {
+ //split position and velocity into rhs and m_rhsPenetration
+ solverConstraint.m_rhs = velocityImpulse;
+ solverConstraint.m_rhsPenetration = penetrationImpulse;
+ }
+
+ solverConstraint.m_cfm = 0.f;
+ solverConstraint.m_lowerLimit = 0;
+ solverConstraint.m_upperLimit = 1e10f;
+ }
+
+}
+
+
+
+
+btMultiBodySolverConstraint& btMultiBodyConstraintSolver::addMultiBodyFrictionConstraint(const btVector3& normalAxis,btPersistentManifold* manifold,int frictionIndex,btManifoldPoint& cp,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity, btScalar cfmSlip)
+{
+ BT_PROFILE("addMultiBodyFrictionConstraint");
+ btMultiBodySolverConstraint& solverConstraint = m_multiBodyFrictionContactConstraints.expandNonInitializing();
+ solverConstraint.m_frictionIndex = frictionIndex;
+ bool isFriction = true;
+
+ const btMultiBodyLinkCollider* fcA = btMultiBodyLinkCollider::upcast(manifold->getBody0());
+ const btMultiBodyLinkCollider* fcB = btMultiBodyLinkCollider::upcast(manifold->getBody1());
+
+ btMultiBody* mbA = fcA? fcA->m_multiBody : 0;
+ btMultiBody* mbB = fcB? fcB->m_multiBody : 0;
+
+ int solverBodyIdA = mbA? -1 : getOrInitSolverBody(*colObj0,infoGlobal.m_timeStep);
+ int solverBodyIdB = mbB ? -1 : getOrInitSolverBody(*colObj1,infoGlobal.m_timeStep);
+
+ solverConstraint.m_solverBodyIdA = solverBodyIdA;
+ solverConstraint.m_solverBodyIdB = solverBodyIdB;
+ solverConstraint.m_multiBodyA = mbA;
+ if (mbA)
+ solverConstraint.m_linkA = fcA->m_link;
+
+ solverConstraint.m_multiBodyB = mbB;
+ if (mbB)
+ solverConstraint.m_linkB = fcB->m_link;
+
+ solverConstraint.m_originalContactPoint = &cp;
+
+ setupMultiBodyContactConstraint(solverConstraint, normalAxis, cp, infoGlobal,relaxation,isFriction, desiredVelocity, cfmSlip);
+ return solverConstraint;
+}
+
+void btMultiBodyConstraintSolver::convertMultiBodyContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal)
+{
+ const btMultiBodyLinkCollider* fcA = btMultiBodyLinkCollider::upcast(manifold->getBody0());
+ const btMultiBodyLinkCollider* fcB = btMultiBodyLinkCollider::upcast(manifold->getBody1());
+
+ btMultiBody* mbA = fcA? fcA->m_multiBody : 0;
+ btMultiBody* mbB = fcB? fcB->m_multiBody : 0;
+
+ btCollisionObject* colObj0=0,*colObj1=0;
+
+ colObj0 = (btCollisionObject*)manifold->getBody0();
+ colObj1 = (btCollisionObject*)manifold->getBody1();
+
+ int solverBodyIdA = mbA? -1 : getOrInitSolverBody(*colObj0,infoGlobal.m_timeStep);
+ int solverBodyIdB = mbB ? -1 : getOrInitSolverBody(*colObj1,infoGlobal.m_timeStep);
+
+ btSolverBody* solverBodyA = mbA ? 0 : &m_tmpSolverBodyPool[solverBodyIdA];
+ btSolverBody* solverBodyB = mbB ? 0 : &m_tmpSolverBodyPool[solverBodyIdB];
+
+
+ ///avoid collision response between two static objects
+// if (!solverBodyA || (solverBodyA->m_invMass.isZero() && (!solverBodyB || solverBodyB->m_invMass.isZero())))
+ // return;
+
+ int rollingFriction=1;
+
+ for (int j=0;j<manifold->getNumContacts();j++)
+ {
+
+ btManifoldPoint& cp = manifold->getContactPoint(j);
+
+ if (cp.getDistance() <= manifold->getContactProcessingThreshold())
+ {
+
+ btScalar relaxation;
+
+ int frictionIndex = m_multiBodyNormalContactConstraints.size();
+
+ btMultiBodySolverConstraint& solverConstraint = m_multiBodyNormalContactConstraints.expandNonInitializing();
+
+ btRigidBody* rb0 = btRigidBody::upcast(colObj0);
+ btRigidBody* rb1 = btRigidBody::upcast(colObj1);
+ solverConstraint.m_solverBodyIdA = solverBodyIdA;
+ solverConstraint.m_solverBodyIdB = solverBodyIdB;
+ solverConstraint.m_multiBodyA = mbA;
+ if (mbA)
+ solverConstraint.m_linkA = fcA->m_link;
+
+ solverConstraint.m_multiBodyB = mbB;
+ if (mbB)
+ solverConstraint.m_linkB = fcB->m_link;
+
+ solverConstraint.m_originalContactPoint = &cp;
+
+ bool isFriction = false;
+ setupMultiBodyContactConstraint(solverConstraint, cp.m_normalWorldOnB,cp, infoGlobal, relaxation, isFriction);
+
+// const btVector3& pos1 = cp.getPositionWorldOnA();
+// const btVector3& pos2 = cp.getPositionWorldOnB();
+
+ /////setup the friction constraints
+#define ENABLE_FRICTION
+#ifdef ENABLE_FRICTION
+ solverConstraint.m_frictionIndex = frictionIndex;
+#if ROLLING_FRICTION
+ btVector3 angVelA(0,0,0),angVelB(0,0,0);
+ if (rb0)
+ angVelA = rb0->getAngularVelocity();
+ if (rb1)
+ angVelB = rb1->getAngularVelocity();
+ btVector3 relAngVel = angVelB-angVelA;
+
+ if ((cp.m_combinedRollingFriction>0.f) && (rollingFriction>0))
+ {
+ //only a single rollingFriction per manifold
+ rollingFriction--;
+ if (relAngVel.length()>infoGlobal.m_singleAxisRollingFrictionThreshold)
+ {
+ relAngVel.normalize();
+ applyAnisotropicFriction(colObj0,relAngVel,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION);
+ applyAnisotropicFriction(colObj1,relAngVel,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION);
+ if (relAngVel.length()>0.001)
+ addRollingFrictionConstraint(relAngVel,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+
+ } else
+ {
+ addRollingFrictionConstraint(cp.m_normalWorldOnB,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+ btVector3 axis0,axis1;
+ btPlaneSpace1(cp.m_normalWorldOnB,axis0,axis1);
+ applyAnisotropicFriction(colObj0,axis0,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION);
+ applyAnisotropicFriction(colObj1,axis0,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION);
+ applyAnisotropicFriction(colObj0,axis1,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION);
+ applyAnisotropicFriction(colObj1,axis1,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION);
+ if (axis0.length()>0.001)
+ addRollingFrictionConstraint(axis0,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+ if (axis1.length()>0.001)
+ addRollingFrictionConstraint(axis1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+
+ }
+ }
+#endif //ROLLING_FRICTION
+
+ ///Bullet has several options to set the friction directions
+ ///By default, each contact has only a single friction direction that is recomputed automatically very frame
+ ///based on the relative linear velocity.
+ ///If the relative velocity it zero, it will automatically compute a friction direction.
+
+ ///You can also enable two friction directions, using the SOLVER_USE_2_FRICTION_DIRECTIONS.
+ ///In that case, the second friction direction will be orthogonal to both contact normal and first friction direction.
+ ///
+ ///If you choose SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION, then the friction will be independent from the relative projected velocity.
+ ///
+ ///The user can manually override the friction directions for certain contacts using a contact callback,
+ ///and set the cp.m_lateralFrictionInitialized to true
+ ///In that case, you can set the target relative motion in each friction direction (cp.m_contactMotion1 and cp.m_contactMotion2)
+ ///this will give a conveyor belt effect
+ ///
+ if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized)
+ {/*
+ cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel;
+ btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2();
+ if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON)
+ {
+ cp.m_lateralFrictionDir1 *= 1.f/btSqrt(lat_rel_vel);
+ if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
+ {
+ cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
+ cp.m_lateralFrictionDir2.normalize();//??
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+
+ }
+
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+
+ } else
+ */
+ {
+ btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2);
+
+ if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
+ {
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2,manifold,frictionIndex,cp,colObj0,colObj1, relaxation,infoGlobal);
+ }
+
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION);
+ addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1,manifold,frictionIndex,cp,colObj0,colObj1, relaxation,infoGlobal);
+
+ if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION))
+ {
+ cp.m_lateralFrictionInitialized = true;
+ }
+ }
+
+ } else
+ {
+ addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1,manifold,frictionIndex,cp,colObj0,colObj1, relaxation,infoGlobal,cp.m_contactMotion1, cp.m_contactCFM1);
+
+ if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
+ addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2,manifold,frictionIndex,cp,colObj0,colObj1, relaxation, infoGlobal,cp.m_contactMotion2, cp.m_contactCFM2);
+
+ //setMultiBodyFrictionConstraintImpulse( solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal);
+ //todo:
+ solverConstraint.m_appliedImpulse = 0.f;
+ solverConstraint.m_appliedPushImpulse = 0.f;
+ }
+
+
+#endif //ENABLE_FRICTION
+
+ }
+ }
+}
+
+void btMultiBodyConstraintSolver::convertContacts(btPersistentManifold** manifoldPtr,int numManifolds, const btContactSolverInfo& infoGlobal)
+{
+ btPersistentManifold* manifold = 0;
+
+ for (int i=0;i<numManifolds;i++)
+ {
+ btPersistentManifold* manifold= manifoldPtr[i];
+ const btMultiBodyLinkCollider* fcA = btMultiBodyLinkCollider::upcast(manifold->getBody0());
+ const btMultiBodyLinkCollider* fcB = btMultiBodyLinkCollider::upcast(manifold->getBody1());
+ if (!fcA && !fcB)
+ {
+ //the contact doesn't involve any Featherstone btMultiBody, so deal with the regular btRigidBody/btCollisionObject case
+ convertContact(manifold,infoGlobal);
+ } else
+ {
+ convertMultiBodyContact(manifold,infoGlobal);
+ }
+ }
+
+ //also convert the multibody constraints, if any
+
+
+ for (int i=0;i<m_tmpNumMultiBodyConstraints;i++)
+ {
+ btMultiBodyConstraint* c = m_tmpMultiBodyConstraints[i];
+ m_data.m_solverBodyPool = &m_tmpSolverBodyPool;
+ m_data.m_fixedBodyId = m_fixedBodyId;
+
+ c->createConstraintRows(m_multiBodyNonContactConstraints,m_data, infoGlobal);
+ }
+
+}
+
+
+
+btScalar btMultiBodyConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher)
+{
+ return btSequentialImpulseConstraintSolver::solveGroup(bodies,numBodies,manifold,numManifolds,constraints,numConstraints,info,debugDrawer,dispatcher);
+}
+
+
+void btMultiBodyConstraintSolver::solveMultiBodyGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,btMultiBodyConstraint** multiBodyConstraints, int numMultiBodyConstraints, const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher)
+{
+ //printf("solveMultiBodyGroup start\n");
+ m_tmpMultiBodyConstraints = multiBodyConstraints;
+ m_tmpNumMultiBodyConstraints = numMultiBodyConstraints;
+
+ btSequentialImpulseConstraintSolver::solveGroup(bodies,numBodies,manifold,numManifolds,constraints,numConstraints,info,debugDrawer,dispatcher);
+
+ m_tmpMultiBodyConstraints = 0;
+ m_tmpNumMultiBodyConstraints = 0;
+
+
+}
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h
new file mode 100644
index 00000000000..0f4cd69c029
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h
@@ -0,0 +1,85 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_MULTIBODY_CONSTRAINT_SOLVER_H
+#define BT_MULTIBODY_CONSTRAINT_SOLVER_H
+
+#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
+#include "btMultiBodySolverConstraint.h"
+
+
+class btMultiBody;
+
+#include "btMultiBodyConstraint.h"
+
+
+
+ATTRIBUTE_ALIGNED16(class) btMultiBodyConstraintSolver : public btSequentialImpulseConstraintSolver
+{
+
+protected:
+
+ btMultiBodyConstraintArray m_multiBodyNonContactConstraints;
+
+ btMultiBodyConstraintArray m_multiBodyNormalContactConstraints;
+ btMultiBodyConstraintArray m_multiBodyFrictionContactConstraints;
+
+ btMultiBodyJacobianData m_data;
+
+ //temp storage for multi body constraints for a specific island/group called by 'solveGroup'
+ btMultiBodyConstraint** m_tmpMultiBodyConstraints;
+ int m_tmpNumMultiBodyConstraints;
+
+ void resolveSingleConstraintRowGeneric(const btMultiBodySolverConstraint& c);
+ void resolveSingleConstraintRowGenericMultiBody(const btMultiBodySolverConstraint& c);
+
+ void convertContacts(btPersistentManifold** manifoldPtr,int numManifolds, const btContactSolverInfo& infoGlobal);
+ btMultiBodySolverConstraint& addMultiBodyFrictionConstraint(const btVector3& normalAxis,btPersistentManifold* manifold,int frictionIndex,btManifoldPoint& cp,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity=0, btScalar cfmSlip=0);
+
+
+ void setupMultiBodyJointLimitConstraint(btMultiBodySolverConstraint& constraintRow,
+ btScalar* jacA,btScalar* jacB,
+ btScalar penetration,btScalar combinedFrictionCoeff, btScalar combinedRestitutionCoeff,
+ const btContactSolverInfo& infoGlobal);
+
+ void setupMultiBodyContactConstraint(btMultiBodySolverConstraint& solverConstraint,
+ const btVector3& contactNormal,
+ btManifoldPoint& cp, const btContactSolverInfo& infoGlobal,
+ btScalar& relaxation,
+ bool isFriction, btScalar desiredVelocity=0, btScalar cfmSlip=0);
+
+ void convertMultiBodyContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
+ virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
+// virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
+
+ virtual btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
+ void applyDeltaVee(btScalar* deltaV, btScalar impulse, int velocityIndex, int ndof);
+
+public:
+
+ BT_DECLARE_ALIGNED_ALLOCATOR();
+
+ ///this method should not be called, it was just used during porting/integration of Featherstone btMultiBody, providing backwards compatibility but no support for btMultiBodyConstraint (only contact constraints)
+ virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher);
+
+ virtual void solveMultiBodyGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,btMultiBodyConstraint** multiBodyConstraints, int numMultiBodyConstraints, const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher);
+};
+
+
+
+
+
+#endif //BT_MULTIBODY_CONSTRAINT_SOLVER_H
+
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
new file mode 100644
index 00000000000..0910f8f6abb
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
@@ -0,0 +1,578 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btMultiBodyDynamicsWorld.h"
+#include "btMultiBodyConstraintSolver.h"
+#include "btMultiBody.h"
+#include "btMultiBodyLinkCollider.h"
+#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
+#include "LinearMath/btQuickprof.h"
+#include "btMultiBodyConstraint.h"
+
+
+
+
+void btMultiBodyDynamicsWorld::addMultiBody(btMultiBody* body, short group, short mask)
+{
+ m_multiBodies.push_back(body);
+
+}
+
+void btMultiBodyDynamicsWorld::removeMultiBody(btMultiBody* body)
+{
+ m_multiBodies.remove(body);
+}
+
+void btMultiBodyDynamicsWorld::calculateSimulationIslands()
+{
+ BT_PROFILE("calculateSimulationIslands");
+
+ getSimulationIslandManager()->updateActivationState(getCollisionWorld(),getCollisionWorld()->getDispatcher());
+
+ {
+ //merge islands based on speculative contact manifolds too
+ for (int i=0;i<this->m_predictiveManifolds.size();i++)
+ {
+ btPersistentManifold* manifold = m_predictiveManifolds[i];
+
+ const btCollisionObject* colObj0 = manifold->getBody0();
+ const btCollisionObject* colObj1 = manifold->getBody1();
+
+ if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
+ ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
+ {
+ getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag());
+ }
+ }
+ }
+
+ {
+ int i;
+ int numConstraints = int(m_constraints.size());
+ for (i=0;i< numConstraints ; i++ )
+ {
+ btTypedConstraint* constraint = m_constraints[i];
+ if (constraint->isEnabled())
+ {
+ const btRigidBody* colObj0 = &constraint->getRigidBodyA();
+ const btRigidBody* colObj1 = &constraint->getRigidBodyB();
+
+ if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
+ ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
+ {
+ getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag());
+ }
+ }
+ }
+ }
+
+ //merge islands linked by Featherstone link colliders
+ for (int i=0;i<m_multiBodies.size();i++)
+ {
+ btMultiBody* body = m_multiBodies[i];
+ {
+ btMultiBodyLinkCollider* prev = body->getBaseCollider();
+
+ for (int b=0;b<body->getNumLinks();b++)
+ {
+ btMultiBodyLinkCollider* cur = body->getLink(b).m_collider;
+
+ if (((cur) && (!(cur)->isStaticOrKinematicObject())) &&
+ ((prev) && (!(prev)->isStaticOrKinematicObject())))
+ {
+ int tagPrev = prev->getIslandTag();
+ int tagCur = cur->getIslandTag();
+ getSimulationIslandManager()->getUnionFind().unite(tagPrev, tagCur);
+ }
+ if (cur && !cur->isStaticOrKinematicObject())
+ prev = cur;
+
+ }
+ }
+ }
+
+ //merge islands linked by multibody constraints
+ {
+ for (int i=0;i<this->m_multiBodyConstraints.size();i++)
+ {
+ btMultiBodyConstraint* c = m_multiBodyConstraints[i];
+ int tagA = c->getIslandIdA();
+ int tagB = c->getIslandIdB();
+ if (tagA>=0 && tagB>=0)
+ getSimulationIslandManager()->getUnionFind().unite(tagA, tagB);
+ }
+ }
+
+ //Store the island id in each body
+ getSimulationIslandManager()->storeIslandActivationState(getCollisionWorld());
+
+}
+
+
+void btMultiBodyDynamicsWorld::updateActivationState(btScalar timeStep)
+{
+ BT_PROFILE("btMultiBodyDynamicsWorld::updateActivationState");
+
+
+
+ for ( int i=0;i<m_multiBodies.size();i++)
+ {
+ btMultiBody* body = m_multiBodies[i];
+ if (body)
+ {
+ body->checkMotionAndSleepIfRequired(timeStep);
+ if (!body->isAwake())
+ {
+ btMultiBodyLinkCollider* col = body->getBaseCollider();
+ if (col && col->getActivationState() == ACTIVE_TAG)
+ {
+ col->setActivationState( WANTS_DEACTIVATION);
+ col->setDeactivationTime(0.f);
+ }
+ for (int b=0;b<body->getNumLinks();b++)
+ {
+ btMultiBodyLinkCollider* col = body->getLink(b).m_collider;
+ if (col && col->getActivationState() == ACTIVE_TAG)
+ {
+ col->setActivationState( WANTS_DEACTIVATION);
+ col->setDeactivationTime(0.f);
+ }
+ }
+ } else
+ {
+ btMultiBodyLinkCollider* col = body->getBaseCollider();
+ if (col && col->getActivationState() != DISABLE_DEACTIVATION)
+ col->setActivationState( ACTIVE_TAG );
+
+ for (int b=0;b<body->getNumLinks();b++)
+ {
+ btMultiBodyLinkCollider* col = body->getLink(b).m_collider;
+ if (col && col->getActivationState() != DISABLE_DEACTIVATION)
+ col->setActivationState( ACTIVE_TAG );
+ }
+ }
+
+ }
+ }
+
+ btDiscreteDynamicsWorld::updateActivationState(timeStep);
+}
+
+
+SIMD_FORCE_INLINE int btGetConstraintIslandId2(const btTypedConstraint* lhs)
+{
+ int islandId;
+
+ const btCollisionObject& rcolObj0 = lhs->getRigidBodyA();
+ const btCollisionObject& rcolObj1 = lhs->getRigidBodyB();
+ islandId= rcolObj0.getIslandTag()>=0?rcolObj0.getIslandTag():rcolObj1.getIslandTag();
+ return islandId;
+
+}
+
+
+class btSortConstraintOnIslandPredicate2
+{
+ public:
+
+ bool operator() ( const btTypedConstraint* lhs, const btTypedConstraint* rhs ) const
+ {
+ int rIslandId0,lIslandId0;
+ rIslandId0 = btGetConstraintIslandId2(rhs);
+ lIslandId0 = btGetConstraintIslandId2(lhs);
+ return lIslandId0 < rIslandId0;
+ }
+};
+
+
+
+SIMD_FORCE_INLINE int btGetMultiBodyConstraintIslandId(const btMultiBodyConstraint* lhs)
+{
+ int islandId;
+
+ int islandTagA = lhs->getIslandIdA();
+ int islandTagB = lhs->getIslandIdB();
+ islandId= islandTagA>=0?islandTagA:islandTagB;
+ return islandId;
+
+}
+
+
+class btSortMultiBodyConstraintOnIslandPredicate
+{
+ public:
+
+ bool operator() ( const btMultiBodyConstraint* lhs, const btMultiBodyConstraint* rhs ) const
+ {
+ int rIslandId0,lIslandId0;
+ rIslandId0 = btGetMultiBodyConstraintIslandId(rhs);
+ lIslandId0 = btGetMultiBodyConstraintIslandId(lhs);
+ return lIslandId0 < rIslandId0;
+ }
+};
+
+struct MultiBodyInplaceSolverIslandCallback : public btSimulationIslandManager::IslandCallback
+{
+ btContactSolverInfo* m_solverInfo;
+ btMultiBodyConstraintSolver* m_solver;
+ btMultiBodyConstraint** m_multiBodySortedConstraints;
+ int m_numMultiBodyConstraints;
+
+ btTypedConstraint** m_sortedConstraints;
+ int m_numConstraints;
+ btIDebugDraw* m_debugDrawer;
+ btDispatcher* m_dispatcher;
+
+ btAlignedObjectArray<btCollisionObject*> m_bodies;
+ btAlignedObjectArray<btPersistentManifold*> m_manifolds;
+ btAlignedObjectArray<btTypedConstraint*> m_constraints;
+ btAlignedObjectArray<btMultiBodyConstraint*> m_multiBodyConstraints;
+
+
+ MultiBodyInplaceSolverIslandCallback( btMultiBodyConstraintSolver* solver,
+ btDispatcher* dispatcher)
+ :m_solverInfo(NULL),
+ m_solver(solver),
+ m_multiBodySortedConstraints(NULL),
+ m_numConstraints(0),
+ m_debugDrawer(NULL),
+ m_dispatcher(dispatcher)
+ {
+
+ }
+
+ MultiBodyInplaceSolverIslandCallback& operator=(MultiBodyInplaceSolverIslandCallback& other)
+ {
+ btAssert(0);
+ (void)other;
+ return *this;
+ }
+
+ SIMD_FORCE_INLINE void setup ( btContactSolverInfo* solverInfo, btTypedConstraint** sortedConstraints, int numConstraints, btMultiBodyConstraint** sortedMultiBodyConstraints, int numMultiBodyConstraints, btIDebugDraw* debugDrawer)
+ {
+ btAssert(solverInfo);
+ m_solverInfo = solverInfo;
+
+ m_multiBodySortedConstraints = sortedMultiBodyConstraints;
+ m_numMultiBodyConstraints = numMultiBodyConstraints;
+ m_sortedConstraints = sortedConstraints;
+ m_numConstraints = numConstraints;
+
+ m_debugDrawer = debugDrawer;
+ m_bodies.resize (0);
+ m_manifolds.resize (0);
+ m_constraints.resize (0);
+ m_multiBodyConstraints.resize(0);
+ }
+
+
+ virtual void processIsland(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifolds,int numManifolds, int islandId)
+ {
+ if (islandId<0)
+ {
+ ///we don't split islands, so all constraints/contact manifolds/bodies are passed into the solver regardless the island id
+ m_solver->solveMultiBodyGroup( bodies,numBodies,manifolds, numManifolds,m_sortedConstraints, m_numConstraints, &m_multiBodySortedConstraints[0],m_numConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher);
+ } else
+ {
+ //also add all non-contact constraints/joints for this island
+ btTypedConstraint** startConstraint = 0;
+ btMultiBodyConstraint** startMultiBodyConstraint = 0;
+
+ int numCurConstraints = 0;
+ int numCurMultiBodyConstraints = 0;
+
+ int i;
+
+ //find the first constraint for this island
+
+ for (i=0;i<m_numConstraints;i++)
+ {
+ if (btGetConstraintIslandId2(m_sortedConstraints[i]) == islandId)
+ {
+ startConstraint = &m_sortedConstraints[i];
+ break;
+ }
+ }
+ //count the number of constraints in this island
+ for (;i<m_numConstraints;i++)
+ {
+ if (btGetConstraintIslandId2(m_sortedConstraints[i]) == islandId)
+ {
+ numCurConstraints++;
+ }
+ }
+
+ for (i=0;i<m_numMultiBodyConstraints;i++)
+ {
+ if (btGetMultiBodyConstraintIslandId(m_multiBodySortedConstraints[i]) == islandId)
+ {
+
+ startMultiBodyConstraint = &m_multiBodySortedConstraints[i];
+ break;
+ }
+ }
+ //count the number of multi body constraints in this island
+ for (;i<m_numMultiBodyConstraints;i++)
+ {
+ if (btGetMultiBodyConstraintIslandId(m_multiBodySortedConstraints[i]) == islandId)
+ {
+ numCurMultiBodyConstraints++;
+ }
+ }
+
+ if (m_solverInfo->m_minimumSolverBatchSize<=1)
+ {
+ m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher);
+ } else
+ {
+
+ for (i=0;i<numBodies;i++)
+ m_bodies.push_back(bodies[i]);
+ for (i=0;i<numManifolds;i++)
+ m_manifolds.push_back(manifolds[i]);
+ for (i=0;i<numCurConstraints;i++)
+ m_constraints.push_back(startConstraint[i]);
+
+ for (i=0;i<numCurMultiBodyConstraints;i++)
+ m_multiBodyConstraints.push_back(startMultiBodyConstraint[i]);
+
+ if ((m_constraints.size()+m_manifolds.size())>m_solverInfo->m_minimumSolverBatchSize)
+ {
+ processConstraints();
+ } else
+ {
+ //printf("deferred\n");
+ }
+ }
+ }
+ }
+ void processConstraints()
+ {
+
+ btCollisionObject** bodies = m_bodies.size()? &m_bodies[0]:0;
+ btPersistentManifold** manifold = m_manifolds.size()?&m_manifolds[0]:0;
+ btTypedConstraint** constraints = m_constraints.size()?&m_constraints[0]:0;
+ btMultiBodyConstraint** multiBodyConstraints = m_multiBodyConstraints.size() ? &m_multiBodyConstraints[0] : 0;
+
+ m_solver->solveMultiBodyGroup( bodies,m_bodies.size(),manifold, m_manifolds.size(),constraints, m_constraints.size() ,multiBodyConstraints, m_multiBodyConstraints.size(), *m_solverInfo,m_debugDrawer,m_dispatcher);
+ m_bodies.resize(0);
+ m_manifolds.resize(0);
+ m_constraints.resize(0);
+ m_multiBodyConstraints.resize(0);
+ }
+
+};
+
+
+
+btMultiBodyDynamicsWorld::btMultiBodyDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btMultiBodyConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
+ :btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration),
+ m_multiBodyConstraintSolver(constraintSolver)
+{
+ //split impulse is not yet supported for Featherstone hierarchies
+ getSolverInfo().m_splitImpulse = false;
+ getSolverInfo().m_solverMode |=SOLVER_USE_2_FRICTION_DIRECTIONS;
+ m_solverMultiBodyIslandCallback = new MultiBodyInplaceSolverIslandCallback(constraintSolver,dispatcher);
+}
+
+btMultiBodyDynamicsWorld::~btMultiBodyDynamicsWorld ()
+{
+ delete m_solverMultiBodyIslandCallback;
+}
+
+
+
+
+void btMultiBodyDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
+{
+
+ btAlignedObjectArray<btScalar> scratch_r;
+ btAlignedObjectArray<btVector3> scratch_v;
+ btAlignedObjectArray<btMatrix3x3> scratch_m;
+
+
+ BT_PROFILE("solveConstraints");
+
+ m_sortedConstraints.resize( m_constraints.size());
+ int i;
+ for (i=0;i<getNumConstraints();i++)
+ {
+ m_sortedConstraints[i] = m_constraints[i];
+ }
+ m_sortedConstraints.quickSort(btSortConstraintOnIslandPredicate2());
+ btTypedConstraint** constraintsPtr = getNumConstraints() ? &m_sortedConstraints[0] : 0;
+
+ m_sortedMultiBodyConstraints.resize(m_multiBodyConstraints.size());
+ for (i=0;i<m_multiBodyConstraints.size();i++)
+ {
+ m_sortedMultiBodyConstraints[i] = m_multiBodyConstraints[i];
+ }
+ m_sortedMultiBodyConstraints.quickSort(btSortMultiBodyConstraintOnIslandPredicate());
+
+ btMultiBodyConstraint** sortedMultiBodyConstraints = m_sortedMultiBodyConstraints.size() ? &m_sortedMultiBodyConstraints[0] : 0;
+
+
+ m_solverMultiBodyIslandCallback->setup(&solverInfo,constraintsPtr,m_sortedConstraints.size(),sortedMultiBodyConstraints,m_sortedMultiBodyConstraints.size(), getDebugDrawer());
+ m_constraintSolver->prepareSolve(getCollisionWorld()->getNumCollisionObjects(), getCollisionWorld()->getDispatcher()->getNumManifolds());
+
+ /// solve all the constraints for this island
+ m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(),getCollisionWorld(),m_solverMultiBodyIslandCallback);
+
+
+ {
+ BT_PROFILE("btMultiBody addForce and stepVelocities");
+ for (int i=0;i<this->m_multiBodies.size();i++)
+ {
+ btMultiBody* bod = m_multiBodies[i];
+
+ bool isSleeping = false;
+
+ if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
+ {
+ isSleeping = true;
+ }
+ for (int b=0;b<bod->getNumLinks();b++)
+ {
+ if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState()==ISLAND_SLEEPING)
+ isSleeping = true;
+ }
+
+ if (!isSleeping)
+ {
+ scratch_r.resize(bod->getNumLinks()+1);
+ scratch_v.resize(bod->getNumLinks()+1);
+ scratch_m.resize(bod->getNumLinks()+1);
+
+ bod->clearForcesAndTorques();
+ bod->addBaseForce(m_gravity * bod->getBaseMass());
+
+ for (int j = 0; j < bod->getNumLinks(); ++j)
+ {
+ bod->addLinkForce(j, m_gravity * bod->getLinkMass(j));
+ }
+
+ bod->stepVelocities(solverInfo.m_timeStep, scratch_r, scratch_v, scratch_m);
+ }
+ }
+ }
+
+ m_solverMultiBodyIslandCallback->processConstraints();
+
+ m_constraintSolver->allSolved(solverInfo, m_debugDrawer);
+
+}
+
+void btMultiBodyDynamicsWorld::integrateTransforms(btScalar timeStep)
+{
+ btDiscreteDynamicsWorld::integrateTransforms(timeStep);
+
+ {
+ BT_PROFILE("btMultiBody stepPositions");
+ //integrate and update the Featherstone hierarchies
+ btAlignedObjectArray<btQuaternion> world_to_local;
+ btAlignedObjectArray<btVector3> local_origin;
+
+ for (int b=0;b<m_multiBodies.size();b++)
+ {
+ btMultiBody* bod = m_multiBodies[b];
+ bool isSleeping = false;
+ if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
+ {
+ isSleeping = true;
+ }
+ for (int b=0;b<bod->getNumLinks();b++)
+ {
+ if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState()==ISLAND_SLEEPING)
+ isSleeping = true;
+ }
+
+
+ if (!isSleeping)
+ {
+ int nLinks = bod->getNumLinks();
+
+ ///base + num links
+ world_to_local.resize(nLinks+1);
+ local_origin.resize(nLinks+1);
+
+ bod->stepPositions(timeStep);
+
+
+
+ world_to_local[0] = bod->getWorldToBaseRot();
+ local_origin[0] = bod->getBasePos();
+
+ if (bod->getBaseCollider())
+ {
+ btVector3 posr = local_origin[0];
+ float pos[4]={posr.x(),posr.y(),posr.z(),1};
+ float quat[4]={-world_to_local[0].x(),-world_to_local[0].y(),-world_to_local[0].z(),world_to_local[0].w()};
+ btTransform tr;
+ tr.setIdentity();
+ tr.setOrigin(posr);
+ tr.setRotation(btQuaternion(quat[0],quat[1],quat[2],quat[3]));
+
+ bod->getBaseCollider()->setWorldTransform(tr);
+
+ }
+
+ for (int k=0;k<bod->getNumLinks();k++)
+ {
+ const int parent = bod->getParent(k);
+ world_to_local[k+1] = bod->getParentToLocalRot(k) * world_to_local[parent+1];
+ local_origin[k+1] = local_origin[parent+1] + (quatRotate(world_to_local[k+1].inverse() , bod->getRVector(k)));
+ }
+
+
+ for (int m=0;m<bod->getNumLinks();m++)
+ {
+ btMultiBodyLinkCollider* col = bod->getLink(m).m_collider;
+ if (col)
+ {
+ int link = col->m_link;
+ btAssert(link == m);
+
+ int index = link+1;
+
+ btVector3 posr = local_origin[index];
+ float pos[4]={posr.x(),posr.y(),posr.z(),1};
+ float quat[4]={-world_to_local[index].x(),-world_to_local[index].y(),-world_to_local[index].z(),world_to_local[index].w()};
+ btTransform tr;
+ tr.setIdentity();
+ tr.setOrigin(posr);
+ tr.setRotation(btQuaternion(quat[0],quat[1],quat[2],quat[3]));
+
+ col->setWorldTransform(tr);
+ }
+ }
+ } else
+ {
+ bod->clearVelocities();
+ }
+ }
+ }
+}
+
+
+
+void btMultiBodyDynamicsWorld::addMultiBodyConstraint( btMultiBodyConstraint* constraint)
+{
+ m_multiBodyConstraints.push_back(constraint);
+}
+
+void btMultiBodyDynamicsWorld::removeMultiBodyConstraint( btMultiBodyConstraint* constraint)
+{
+ m_multiBodyConstraints.remove(constraint);
+}
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h
new file mode 100644
index 00000000000..ad57a346dcc
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h
@@ -0,0 +1,56 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_MULTIBODY_DYNAMICS_WORLD_H
+#define BT_MULTIBODY_DYNAMICS_WORLD_H
+
+#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
+
+
+class btMultiBody;
+class btMultiBodyConstraint;
+class btMultiBodyConstraintSolver;
+struct MultiBodyInplaceSolverIslandCallback;
+
+///The btMultiBodyDynamicsWorld adds Featherstone multi body dynamics to Bullet
+///This implementation is still preliminary/experimental.
+class btMultiBodyDynamicsWorld : public btDiscreteDynamicsWorld
+{
+protected:
+ btAlignedObjectArray<btMultiBody*> m_multiBodies;
+ btAlignedObjectArray<btMultiBodyConstraint*> m_multiBodyConstraints;
+ btAlignedObjectArray<btMultiBodyConstraint*> m_sortedMultiBodyConstraints;
+ btMultiBodyConstraintSolver* m_multiBodyConstraintSolver;
+ MultiBodyInplaceSolverIslandCallback* m_solverMultiBodyIslandCallback;
+
+ virtual void calculateSimulationIslands();
+ virtual void updateActivationState(btScalar timeStep);
+ virtual void solveConstraints(btContactSolverInfo& solverInfo);
+ virtual void integrateTransforms(btScalar timeStep);
+public:
+
+ btMultiBodyDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btMultiBodyConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
+
+ virtual ~btMultiBodyDynamicsWorld ();
+
+ virtual void addMultiBody(btMultiBody* body, short group= btBroadphaseProxy::DefaultFilter, short mask=btBroadphaseProxy::AllFilter);
+
+ virtual void removeMultiBody(btMultiBody* body);
+
+ virtual void addMultiBodyConstraint( btMultiBodyConstraint* constraint);
+
+ virtual void removeMultiBodyConstraint( btMultiBodyConstraint* constraint);
+};
+#endif //BT_MULTIBODY_DYNAMICS_WORLD_H
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp
new file mode 100644
index 00000000000..ea309e8857d
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp
@@ -0,0 +1,133 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///This file was written by Erwin Coumans
+
+#include "btMultiBodyJointLimitConstraint.h"
+#include "btMultiBody.h"
+#include "btMultiBodyLinkCollider.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+
+btMultiBodyJointLimitConstraint::btMultiBodyJointLimitConstraint(btMultiBody* body, int link, btScalar lower, btScalar upper)
+ :btMultiBodyConstraint(body,body,link,link,2,true),
+ m_lowerBound(lower),
+ m_upperBound(upper)
+{
+ // the data.m_jacobians never change, so may as well
+ // initialize them here
+
+ // note: we rely on the fact that data.m_jacobians are
+ // always initialized to zero by the Constraint ctor
+
+ // row 0: the lower bound
+ jacobianA(0)[6 + link] = 1;
+
+ // row 1: the upper bound
+ jacobianB(1)[6 + link] = -1;
+}
+btMultiBodyJointLimitConstraint::~btMultiBodyJointLimitConstraint()
+{
+}
+
+int btMultiBodyJointLimitConstraint::getIslandIdA() const
+{
+ btMultiBodyLinkCollider* col = m_bodyA->getBaseCollider();
+ if (col)
+ return col->getIslandTag();
+ for (int i=0;i<m_bodyA->getNumLinks();i++)
+ {
+ if (m_bodyA->getLink(i).m_collider)
+ return m_bodyA->getLink(i).m_collider->getIslandTag();
+ }
+ return -1;
+}
+
+int btMultiBodyJointLimitConstraint::getIslandIdB() const
+{
+ btMultiBodyLinkCollider* col = m_bodyB->getBaseCollider();
+ if (col)
+ return col->getIslandTag();
+
+ for (int i=0;i<m_bodyB->getNumLinks();i++)
+ {
+ col = m_bodyB->getLink(i).m_collider;
+ if (col)
+ return col->getIslandTag();
+ }
+ return -1;
+}
+
+
+void btMultiBodyJointLimitConstraint::createConstraintRows(btMultiBodyConstraintArray& constraintRows,
+ btMultiBodyJacobianData& data,
+ const btContactSolverInfo& infoGlobal)
+{
+ // only positions need to be updated -- data.m_jacobians and force
+ // directions were set in the ctor and never change.
+
+ // row 0: the lower bound
+ setPosition(0, m_bodyA->getJointPos(m_linkA) - m_lowerBound);
+
+ // row 1: the upper bound
+ setPosition(1, m_upperBound - m_bodyA->getJointPos(m_linkA));
+
+ for (int row=0;row<getNumRows();row++)
+ {
+ btMultiBodySolverConstraint& constraintRow = constraintRows.expandNonInitializing();
+ constraintRow.m_multiBodyA = m_bodyA;
+ constraintRow.m_multiBodyB = m_bodyB;
+
+ btScalar rel_vel = fillConstraintRowMultiBodyMultiBody(constraintRow,data,jacobianA(row),jacobianB(row),infoGlobal,0,-m_maxAppliedImpulse,m_maxAppliedImpulse);
+ {
+ btScalar penetration = getPosition(row);
+ btScalar positionalError = 0.f;
+ btScalar velocityError = - rel_vel;// * damping;
+ btScalar erp = infoGlobal.m_erp2;
+ if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold))
+ {
+ erp = infoGlobal.m_erp;
+ }
+ if (penetration>0)
+ {
+ positionalError = 0;
+ velocityError = -penetration / infoGlobal.m_timeStep;
+ } else
+ {
+ positionalError = -penetration * erp/infoGlobal.m_timeStep;
+ }
+
+ btScalar penetrationImpulse = positionalError*constraintRow.m_jacDiagABInv;
+ btScalar velocityImpulse = velocityError *constraintRow.m_jacDiagABInv;
+ if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold))
+ {
+ //combine position and velocity into rhs
+ constraintRow.m_rhs = penetrationImpulse+velocityImpulse;
+ constraintRow.m_rhsPenetration = 0.f;
+
+ } else
+ {
+ //split position and velocity into rhs and m_rhsPenetration
+ constraintRow.m_rhs = velocityImpulse;
+ constraintRow.m_rhsPenetration = penetrationImpulse;
+ }
+ }
+ }
+
+}
+
+
+
+
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h
new file mode 100644
index 00000000000..0c7fc170822
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h
@@ -0,0 +1,44 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_MULTIBODY_JOINT_LIMIT_CONSTRAINT_H
+#define BT_MULTIBODY_JOINT_LIMIT_CONSTRAINT_H
+
+#include "btMultiBodyConstraint.h"
+struct btSolverInfo;
+
+class btMultiBodyJointLimitConstraint : public btMultiBodyConstraint
+{
+protected:
+
+ btScalar m_lowerBound;
+ btScalar m_upperBound;
+public:
+
+ btMultiBodyJointLimitConstraint(btMultiBody* body, int link, btScalar lower, btScalar upper);
+ virtual ~btMultiBodyJointLimitConstraint();
+
+ virtual int getIslandIdA() const;
+ virtual int getIslandIdB() const;
+
+ virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
+ btMultiBodyJacobianData& data,
+ const btContactSolverInfo& infoGlobal);
+
+
+};
+
+#endif //BT_MULTIBODY_JOINT_LIMIT_CONSTRAINT_H
+
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
new file mode 100644
index 00000000000..ab5a430231b
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
@@ -0,0 +1,89 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///This file was written by Erwin Coumans
+
+#include "btMultiBodyJointMotor.h"
+#include "btMultiBody.h"
+#include "btMultiBodyLinkCollider.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+
+btMultiBodyJointMotor::btMultiBodyJointMotor(btMultiBody* body, int link, btScalar desiredVelocity, btScalar maxMotorImpulse)
+ :btMultiBodyConstraint(body,body,link,link,1,true),
+ m_desiredVelocity(desiredVelocity)
+{
+ m_maxAppliedImpulse = maxMotorImpulse;
+ // the data.m_jacobians never change, so may as well
+ // initialize them here
+
+ // note: we rely on the fact that data.m_jacobians are
+ // always initialized to zero by the Constraint ctor
+
+ // row 0: the lower bound
+ jacobianA(0)[6 + link] = 1;
+}
+btMultiBodyJointMotor::~btMultiBodyJointMotor()
+{
+}
+
+int btMultiBodyJointMotor::getIslandIdA() const
+{
+ btMultiBodyLinkCollider* col = m_bodyA->getBaseCollider();
+ if (col)
+ return col->getIslandTag();
+ for (int i=0;i<m_bodyA->getNumLinks();i++)
+ {
+ if (m_bodyA->getLink(i).m_collider)
+ return m_bodyA->getLink(i).m_collider->getIslandTag();
+ }
+ return -1;
+}
+
+int btMultiBodyJointMotor::getIslandIdB() const
+{
+ btMultiBodyLinkCollider* col = m_bodyB->getBaseCollider();
+ if (col)
+ return col->getIslandTag();
+
+ for (int i=0;i<m_bodyB->getNumLinks();i++)
+ {
+ col = m_bodyB->getLink(i).m_collider;
+ if (col)
+ return col->getIslandTag();
+ }
+ return -1;
+}
+
+
+void btMultiBodyJointMotor::createConstraintRows(btMultiBodyConstraintArray& constraintRows,
+ btMultiBodyJacobianData& data,
+ const btContactSolverInfo& infoGlobal)
+{
+ // only positions need to be updated -- data.m_jacobians and force
+ // directions were set in the ctor and never change.
+
+
+
+ for (int row=0;row<getNumRows();row++)
+ {
+ btMultiBodySolverConstraint& constraintRow = constraintRows.expandNonInitializing();
+
+ btScalar penetration = 0;
+ fillConstraintRowMultiBodyMultiBody(constraintRow,data,jacobianA(row),jacobianB(row),infoGlobal,m_desiredVelocity,-m_maxAppliedImpulse,m_maxAppliedImpulse);
+ }
+
+}
+
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.h
new file mode 100644
index 00000000000..43869348141
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.h
@@ -0,0 +1,47 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///This file was written by Erwin Coumans
+
+#ifndef BT_MULTIBODY_JOINT_MOTOR_H
+#define BT_MULTIBODY_JOINT_MOTOR_H
+
+#include "btMultiBodyConstraint.h"
+struct btSolverInfo;
+
+class btMultiBodyJointMotor : public btMultiBodyConstraint
+{
+protected:
+
+
+ btScalar m_desiredVelocity;
+
+public:
+
+ btMultiBodyJointMotor(btMultiBody* body, int link, btScalar desiredVelocity, btScalar maxMotorImpulse);
+ virtual ~btMultiBodyJointMotor();
+
+ virtual int getIslandIdA() const;
+ virtual int getIslandIdB() const;
+
+ virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
+ btMultiBodyJacobianData& data,
+ const btContactSolverInfo& infoGlobal);
+
+
+};
+
+#endif //BT_MULTIBODY_JOINT_MOTOR_H
+
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLink.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLink.h
new file mode 100644
index 00000000000..fbd54c45db3
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLink.h
@@ -0,0 +1,110 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_MULTIBODY_LINK_H
+#define BT_MULTIBODY_LINK_H
+
+#include "LinearMath/btQuaternion.h"
+#include "LinearMath/btVector3.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+enum btMultiBodyLinkFlags
+{
+ BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION = 1
+};
+//
+// Link struct
+//
+
+struct btMultibodyLink
+{
+
+ BT_DECLARE_ALIGNED_ALLOCATOR();
+
+ btScalar joint_pos; // qi
+
+ btScalar mass; // mass of link
+ btVector3 inertia; // inertia of link (local frame; diagonal)
+
+ int parent; // index of the parent link (assumed to be < index of this link), or -1 if parent is the base link.
+
+ btQuaternion zero_rot_parent_to_this; // rotates vectors in parent-frame to vectors in local-frame (when q=0). constant.
+
+ // "axis" = spatial joint axis (Mirtich Defn 9 p104). (expressed in local frame.) constant.
+ // for prismatic: axis_top = zero;
+ // axis_bottom = unit vector along the joint axis.
+ // for revolute: axis_top = unit vector along the rotation axis (u);
+ // axis_bottom = u cross d_vector.
+ btVector3 axis_top;
+ btVector3 axis_bottom;
+
+ btVector3 d_vector; // vector from the inboard joint pos to this link's COM. (local frame.) constant. set for revolute joints only.
+
+ // e_vector is constant, but depends on the joint type
+ // prismatic: vector from COM of parent to COM of this link, WHEN Q = 0. (local frame.)
+ // revolute: vector from parent's COM to the pivot point, in PARENT's frame.
+ btVector3 e_vector;
+
+ bool is_revolute; // true = revolute, false = prismatic
+
+ btQuaternion cached_rot_parent_to_this; // rotates vectors in parent frame to vectors in local frame
+ btVector3 cached_r_vector; // vector from COM of parent to COM of this link, in local frame.
+
+ btVector3 applied_force; // In WORLD frame
+ btVector3 applied_torque; // In WORLD frame
+ btScalar joint_torque;
+
+ class btMultiBodyLinkCollider* m_collider;
+ int m_flags;
+
+ // ctor: set some sensible defaults
+ btMultibodyLink()
+ : joint_pos(0),
+ mass(1),
+ parent(-1),
+ zero_rot_parent_to_this(1, 0, 0, 0),
+ is_revolute(false),
+ cached_rot_parent_to_this(1, 0, 0, 0),
+ joint_torque(0),
+ m_collider(0),
+ m_flags(0)
+ {
+ inertia.setValue(1, 1, 1);
+ axis_top.setValue(0, 0, 0);
+ axis_bottom.setValue(1, 0, 0);
+ d_vector.setValue(0, 0, 0);
+ e_vector.setValue(0, 0, 0);
+ cached_r_vector.setValue(0, 0, 0);
+ applied_force.setValue( 0, 0, 0);
+ applied_torque.setValue(0, 0, 0);
+ }
+
+ // routine to update cached_rot_parent_to_this and cached_r_vector
+ void updateCache()
+ {
+ if (is_revolute)
+ {
+ cached_rot_parent_to_this = btQuaternion(axis_top,-joint_pos) * zero_rot_parent_to_this;
+ cached_r_vector = d_vector + quatRotate(cached_rot_parent_to_this,e_vector);
+ } else
+ {
+ // cached_rot_parent_to_this never changes, so no need to update
+ cached_r_vector = e_vector + joint_pos * axis_bottom;
+ }
+ }
+};
+
+
+#endif //BT_MULTIBODY_LINK_H
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h
new file mode 100644
index 00000000000..27f12514a6d
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h
@@ -0,0 +1,92 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_FEATHERSTONE_LINK_COLLIDER_H
+#define BT_FEATHERSTONE_LINK_COLLIDER_H
+
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+#include "btMultiBody.h"
+
+class btMultiBodyLinkCollider : public btCollisionObject
+{
+//protected:
+public:
+
+ btMultiBody* m_multiBody;
+ int m_link;
+
+
+ btMultiBodyLinkCollider (btMultiBody* multiBody,int link)
+ :m_multiBody(multiBody),
+ m_link(link)
+ {
+ m_checkCollideWith = true;
+ //we need to remove the 'CF_STATIC_OBJECT' flag, otherwise links/base doesn't merge islands
+ //this means that some constraints might point to bodies that are not in the islands, causing crashes
+ //if (link>=0 || (multiBody && !multiBody->hasFixedBase()))
+ {
+ m_collisionFlags &= (~btCollisionObject::CF_STATIC_OBJECT);
+ }
+ // else
+ //{
+ // m_collisionFlags |= (btCollisionObject::CF_STATIC_OBJECT);
+ //}
+
+ m_internalType = CO_FEATHERSTONE_LINK;
+ }
+ static btMultiBodyLinkCollider* upcast(btCollisionObject* colObj)
+ {
+ if (colObj->getInternalType()&btCollisionObject::CO_FEATHERSTONE_LINK)
+ return (btMultiBodyLinkCollider*)colObj;
+ return 0;
+ }
+ static const btMultiBodyLinkCollider* upcast(const btCollisionObject* colObj)
+ {
+ if (colObj->getInternalType()&btCollisionObject::CO_FEATHERSTONE_LINK)
+ return (btMultiBodyLinkCollider*)colObj;
+ return 0;
+ }
+
+ virtual bool checkCollideWithOverride(const btCollisionObject* co) const
+ {
+ const btMultiBodyLinkCollider* other = btMultiBodyLinkCollider::upcast(co);
+ if (!other)
+ return true;
+ if (other->m_multiBody != this->m_multiBody)
+ return true;
+ if (!m_multiBody->hasSelfCollision())
+ return false;
+
+ //check if 'link' has collision disabled
+ if (m_link>=0)
+ {
+ const btMultibodyLink& link = m_multiBody->getLink(this->m_link);
+ if ((link.m_flags&BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION) && link.parent == other->m_link)
+ return false;
+ }
+
+ if (other->m_link>=0)
+ {
+ const btMultibodyLink& otherLink = other->m_multiBody->getLink(other->m_link);
+ if ((otherLink.m_flags& BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION) && otherLink.parent == this->m_link)
+ return false;
+ }
+ return true;
+ }
+};
+
+#endif //BT_FEATHERSTONE_LINK_COLLIDER_H
+
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp
new file mode 100644
index 00000000000..f6690049156
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp
@@ -0,0 +1,143 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///This file was written by Erwin Coumans
+
+#include "btMultiBodyPoint2Point.h"
+#include "btMultiBodyLinkCollider.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+btMultiBodyPoint2Point::btMultiBodyPoint2Point(btMultiBody* body, int link, btRigidBody* bodyB, const btVector3& pivotInA, const btVector3& pivotInB)
+ :btMultiBodyConstraint(body,0,link,-1,3,false),
+ m_rigidBodyA(0),
+ m_rigidBodyB(bodyB),
+ m_pivotInA(pivotInA),
+ m_pivotInB(pivotInB)
+{
+}
+
+btMultiBodyPoint2Point::btMultiBodyPoint2Point(btMultiBody* bodyA, int linkA, btMultiBody* bodyB, int linkB, const btVector3& pivotInA, const btVector3& pivotInB)
+ :btMultiBodyConstraint(bodyA,bodyB,linkA,linkB,3,false),
+ m_rigidBodyA(0),
+ m_rigidBodyB(0),
+ m_pivotInA(pivotInA),
+ m_pivotInB(pivotInB)
+{
+}
+
+
+btMultiBodyPoint2Point::~btMultiBodyPoint2Point()
+{
+}
+
+
+int btMultiBodyPoint2Point::getIslandIdA() const
+{
+ if (m_rigidBodyA)
+ return m_rigidBodyA->getIslandTag();
+
+ if (m_bodyA)
+ {
+ btMultiBodyLinkCollider* col = m_bodyA->getBaseCollider();
+ if (col)
+ return col->getIslandTag();
+ for (int i=0;i<m_bodyA->getNumLinks();i++)
+ {
+ if (m_bodyA->getLink(i).m_collider)
+ return m_bodyA->getLink(i).m_collider->getIslandTag();
+ }
+ }
+ return -1;
+}
+
+int btMultiBodyPoint2Point::getIslandIdB() const
+{
+ if (m_rigidBodyB)
+ return m_rigidBodyB->getIslandTag();
+ if (m_bodyB)
+ {
+ btMultiBodyLinkCollider* col = m_bodyB->getBaseCollider();
+ if (col)
+ return col->getIslandTag();
+
+ for (int i=0;i<m_bodyB->getNumLinks();i++)
+ {
+ col = m_bodyB->getLink(i).m_collider;
+ if (col)
+ return col->getIslandTag();
+ }
+ }
+ return -1;
+}
+
+
+
+void btMultiBodyPoint2Point::createConstraintRows(btMultiBodyConstraintArray& constraintRows,
+ btMultiBodyJacobianData& data,
+ const btContactSolverInfo& infoGlobal)
+{
+
+// int i=1;
+ for (int i=0;i<3;i++)
+ {
+
+ btMultiBodySolverConstraint& constraintRow = constraintRows.expandNonInitializing();
+
+ constraintRow.m_solverBodyIdA = data.m_fixedBodyId;
+ constraintRow.m_solverBodyIdB = data.m_fixedBodyId;
+
+
+ btVector3 contactNormalOnB(0,0,0);
+ contactNormalOnB[i] = -1;
+
+ btScalar penetration = 0;
+
+ // Convert local points back to world
+ btVector3 pivotAworld = m_pivotInA;
+ if (m_rigidBodyA)
+ {
+
+ constraintRow.m_solverBodyIdA = m_rigidBodyA->getCompanionId();
+ pivotAworld = m_rigidBodyA->getCenterOfMassTransform()*m_pivotInA;
+ } else
+ {
+ if (m_bodyA)
+ pivotAworld = m_bodyA->localPosToWorld(m_linkA, m_pivotInA);
+ }
+ btVector3 pivotBworld = m_pivotInB;
+ if (m_rigidBodyB)
+ {
+ constraintRow.m_solverBodyIdB = m_rigidBodyB->getCompanionId();
+ pivotBworld = m_rigidBodyB->getCenterOfMassTransform()*m_pivotInB;
+ } else
+ {
+ if (m_bodyB)
+ pivotBworld = m_bodyB->localPosToWorld(m_linkB, m_pivotInB);
+
+ }
+ btScalar position = (pivotAworld-pivotBworld).dot(contactNormalOnB);
+ btScalar relaxation = 1.f;
+ fillMultiBodyConstraintMixed(constraintRow, data,
+ contactNormalOnB,
+ pivotAworld, pivotBworld,
+ position,
+ infoGlobal,
+ relaxation,
+ false);
+ constraintRow.m_lowerLimit = -m_maxAppliedImpulse;
+ constraintRow.m_upperLimit = m_maxAppliedImpulse;
+
+ }
+}
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h
new file mode 100644
index 00000000000..26ca12b406d
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h
@@ -0,0 +1,60 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///This file was written by Erwin Coumans
+
+#ifndef BT_MULTIBODY_POINT2POINT_H
+#define BT_MULTIBODY_POINT2POINT_H
+
+#include "btMultiBodyConstraint.h"
+
+class btMultiBodyPoint2Point : public btMultiBodyConstraint
+{
+protected:
+
+ btRigidBody* m_rigidBodyA;
+ btRigidBody* m_rigidBodyB;
+ btVector3 m_pivotInA;
+ btVector3 m_pivotInB;
+
+
+public:
+
+ btMultiBodyPoint2Point(btMultiBody* body, int link, btRigidBody* bodyB, const btVector3& pivotInA, const btVector3& pivotInB);
+ btMultiBodyPoint2Point(btMultiBody* bodyA, int linkA, btMultiBody* bodyB, int linkB, const btVector3& pivotInA, const btVector3& pivotInB);
+
+ virtual ~btMultiBodyPoint2Point();
+
+ virtual int getIslandIdA() const;
+ virtual int getIslandIdB() const;
+
+ virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
+ btMultiBodyJacobianData& data,
+ const btContactSolverInfo& infoGlobal);
+
+ const btVector3& getPivotInB() const
+ {
+ return m_pivotInB;
+ }
+
+ void setPivotInB(const btVector3& pivotInB)
+ {
+ m_pivotInB = pivotInB;
+ }
+
+
+};
+
+#endif //BT_MULTIBODY_POINT2POINT_H
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h
new file mode 100644
index 00000000000..cf06dfb9ebf
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h
@@ -0,0 +1,82 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_MULTIBODY_SOLVER_CONSTRAINT_H
+#define BT_MULTIBODY_SOLVER_CONSTRAINT_H
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+class btMultiBody;
+#include "BulletDynamics/ConstraintSolver/btSolverBody.h"
+#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
+
+///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints.
+ATTRIBUTE_ALIGNED16 (struct) btMultiBodySolverConstraint
+{
+ BT_DECLARE_ALIGNED_ALLOCATOR();
+
+
+ int m_deltaVelAindex;//more generic version of m_relpos1CrossNormal/m_contactNormal1
+ btVector3 m_relpos1CrossNormal;
+ btVector3 m_contactNormal1;
+ int m_jacAindex;
+
+ int m_deltaVelBindex;
+ btVector3 m_relpos2CrossNormal;
+ btVector3 m_contactNormal2; //usually m_contactNormal2 == -m_contactNormal1, but not always
+ int m_jacBindex;
+
+ btVector3 m_angularComponentA;
+ btVector3 m_angularComponentB;
+
+ mutable btSimdScalar m_appliedPushImpulse;
+ mutable btSimdScalar m_appliedImpulse;
+
+ btScalar m_friction;
+ btScalar m_jacDiagABInv;
+ btScalar m_rhs;
+ btScalar m_cfm;
+
+ btScalar m_lowerLimit;
+ btScalar m_upperLimit;
+ btScalar m_rhsPenetration;
+ union
+ {
+ void* m_originalContactPoint;
+ btScalar m_unusedPadding4;
+ };
+
+ int m_overrideNumSolverIterations;
+ int m_frictionIndex;
+
+ int m_solverBodyIdA;
+ btMultiBody* m_multiBodyA;
+ int m_linkA;
+
+ int m_solverBodyIdB;
+ btMultiBody* m_multiBodyB;
+ int m_linkB;
+
+ enum btSolverConstraintType
+ {
+ BT_SOLVER_CONTACT_1D = 0,
+ BT_SOLVER_FRICTION_1D
+ };
+};
+
+typedef btAlignedObjectArray<btMultiBodySolverConstraint> btMultiBodyConstraintArray;
+
+#endif //BT_MULTIBODY_SOLVER_CONSTRAINT_H
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp
new file mode 100644
index 00000000000..3bf7b5c1311
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp
@@ -0,0 +1,2079 @@
+/*************************************************************************
+* *
+* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
+* All rights reserved. Email: russ@q12.org Web: www.q12.org *
+* *
+* This library is free software; you can redistribute it and/or *
+* modify it under the terms of EITHER: *
+* (1) The GNU Lesser General Public License as published by the Free *
+* Software Foundation; either version 2.1 of the License, or (at *
+* your option) any later version. The text of the GNU Lesser *
+* General Public License is included with this library in the *
+* file LICENSE.TXT. *
+* (2) The BSD-style license that is included with this library in *
+* the file LICENSE-BSD.TXT. *
+* *
+* This library 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 files *
+* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
+* *
+*************************************************************************/
+
+/*
+
+
+THE ALGORITHM
+-------------
+
+solve A*x = b+w, with x and w subject to certain LCP conditions.
+each x(i),w(i) must lie on one of the three line segments in the following
+diagram. each line segment corresponds to one index set :
+
+ w(i)
+ /|\ | :
+ | | :
+ | |i in N :
+ w>0 | |state[i]=0 :
+ | | :
+ | | : i in C
+ w=0 + +-----------------------+
+ | : |
+ | : |
+ w<0 | : |i in N
+ | : |state[i]=1
+ | : |
+ | : |
+ +-------|-----------|-----------|----------> x(i)
+ lo 0 hi
+
+the Dantzig algorithm proceeds as follows:
+ for i=1:n
+ * if (x(i),w(i)) is not on the line, push x(i) and w(i) positive or
+ negative towards the line. as this is done, the other (x(j),w(j))
+ for j<i are constrained to be on the line. if any (x,w) reaches the
+ end of a line segment then it is switched between index sets.
+ * i is added to the appropriate index set depending on what line segment
+ it hits.
+
+we restrict lo(i) <= 0 and hi(i) >= 0. this makes the algorithm a bit
+simpler, because the starting point for x(i),w(i) is always on the dotted
+line x=0 and x will only ever increase in one direction, so it can only hit
+two out of the three line segments.
+
+
+NOTES
+-----
+
+this is an implementation of "lcp_dantzig2_ldlt.m" and "lcp_dantzig_lohi.m".
+the implementation is split into an LCP problem object (btLCP) and an LCP
+driver function. most optimization occurs in the btLCP object.
+
+a naive implementation of the algorithm requires either a lot of data motion
+or a lot of permutation-array lookup, because we are constantly re-ordering
+rows and columns. to avoid this and make a more optimized algorithm, a
+non-trivial data structure is used to represent the matrix A (this is
+implemented in the fast version of the btLCP object).
+
+during execution of this algorithm, some indexes in A are clamped (set C),
+some are non-clamped (set N), and some are "don't care" (where x=0).
+A,x,b,w (and other problem vectors) are permuted such that the clamped
+indexes are first, the unclamped indexes are next, and the don't-care
+indexes are last. this permutation is recorded in the array `p'.
+initially p = 0..n-1, and as the rows and columns of A,x,b,w are swapped,
+the corresponding elements of p are swapped.
+
+because the C and N elements are grouped together in the rows of A, we can do
+lots of work with a fast dot product function. if A,x,etc were not permuted
+and we only had a permutation array, then those dot products would be much
+slower as we would have a permutation array lookup in some inner loops.
+
+A is accessed through an array of row pointers, so that element (i,j) of the
+permuted matrix is A[i][j]. this makes row swapping fast. for column swapping
+we still have to actually move the data.
+
+during execution of this algorithm we maintain an L*D*L' factorization of
+the clamped submatrix of A (call it `AC') which is the top left nC*nC
+submatrix of A. there are two ways we could arrange the rows/columns in AC.
+
+(1) AC is always permuted such that L*D*L' = AC. this causes a problem
+when a row/column is removed from C, because then all the rows/columns of A
+between the deleted index and the end of C need to be rotated downward.
+this results in a lot of data motion and slows things down.
+(2) L*D*L' is actually a factorization of a *permutation* of AC (which is
+itself a permutation of the underlying A). this is what we do - the
+permutation is recorded in the vector C. call this permutation A[C,C].
+when a row/column is removed from C, all we have to do is swap two
+rows/columns and manipulate C.
+
+*/
+
+
+#include "btDantzigLCP.h"
+
+#include <string.h>//memcpy
+
+bool s_error = false;
+
+//***************************************************************************
+// code generation parameters
+
+
+#define btLCP_FAST // use fast btLCP object
+
+// option 1 : matrix row pointers (less data copying)
+#define BTROWPTRS
+#define BTATYPE btScalar **
+#define BTAROW(i) (m_A[i])
+
+// option 2 : no matrix row pointers (slightly faster inner loops)
+//#define NOROWPTRS
+//#define BTATYPE btScalar *
+//#define BTAROW(i) (m_A+(i)*m_nskip)
+
+#define BTNUB_OPTIMIZATIONS
+
+
+
+/* solve L*X=B, with B containing 1 right hand sides.
+ * L is an n*n lower triangular matrix with ones on the diagonal.
+ * L is stored by rows and its leading dimension is lskip.
+ * B is an n*1 matrix that contains the right hand sides.
+ * B is stored by columns and its leading dimension is also lskip.
+ * B is overwritten with X.
+ * this processes blocks of 2*2.
+ * if this is in the factorizer source file, n must be a multiple of 2.
+ */
+
+static void btSolveL1_1 (const btScalar *L, btScalar *B, int n, int lskip1)
+{
+ /* declare variables - Z matrix, p and q vectors, etc */
+ btScalar Z11,m11,Z21,m21,p1,q1,p2,*ex;
+ const btScalar *ell;
+ int i,j;
+ /* compute all 2 x 1 blocks of X */
+ for (i=0; i < n; i+=2) {
+ /* compute all 2 x 1 block of X, from rows i..i+2-1 */
+ /* set the Z matrix to 0 */
+ Z11=0;
+ Z21=0;
+ ell = L + i*lskip1;
+ ex = B;
+ /* the inner loop that computes outer products and adds them to Z */
+ for (j=i-2; j >= 0; j -= 2) {
+ /* compute outer product and add it to the Z matrix */
+ p1=ell[0];
+ q1=ex[0];
+ m11 = p1 * q1;
+ p2=ell[lskip1];
+ m21 = p2 * q1;
+ Z11 += m11;
+ Z21 += m21;
+ /* compute outer product and add it to the Z matrix */
+ p1=ell[1];
+ q1=ex[1];
+ m11 = p1 * q1;
+ p2=ell[1+lskip1];
+ m21 = p2 * q1;
+ /* advance pointers */
+ ell += 2;
+ ex += 2;
+ Z11 += m11;
+ Z21 += m21;
+ /* end of inner loop */
+ }
+ /* compute left-over iterations */
+ j += 2;
+ for (; j > 0; j--) {
+ /* compute outer product and add it to the Z matrix */
+ p1=ell[0];
+ q1=ex[0];
+ m11 = p1 * q1;
+ p2=ell[lskip1];
+ m21 = p2 * q1;
+ /* advance pointers */
+ ell += 1;
+ ex += 1;
+ Z11 += m11;
+ Z21 += m21;
+ }
+ /* finish computing the X(i) block */
+ Z11 = ex[0] - Z11;
+ ex[0] = Z11;
+ p1 = ell[lskip1];
+ Z21 = ex[1] - Z21 - p1*Z11;
+ ex[1] = Z21;
+ /* end of outer loop */
+ }
+}
+
+/* solve L*X=B, with B containing 2 right hand sides.
+ * L is an n*n lower triangular matrix with ones on the diagonal.
+ * L is stored by rows and its leading dimension is lskip.
+ * B is an n*2 matrix that contains the right hand sides.
+ * B is stored by columns and its leading dimension is also lskip.
+ * B is overwritten with X.
+ * this processes blocks of 2*2.
+ * if this is in the factorizer source file, n must be a multiple of 2.
+ */
+
+static void btSolveL1_2 (const btScalar *L, btScalar *B, int n, int lskip1)
+{
+ /* declare variables - Z matrix, p and q vectors, etc */
+ btScalar Z11,m11,Z12,m12,Z21,m21,Z22,m22,p1,q1,p2,q2,*ex;
+ const btScalar *ell;
+ int i,j;
+ /* compute all 2 x 2 blocks of X */
+ for (i=0; i < n; i+=2) {
+ /* compute all 2 x 2 block of X, from rows i..i+2-1 */
+ /* set the Z matrix to 0 */
+ Z11=0;
+ Z12=0;
+ Z21=0;
+ Z22=0;
+ ell = L + i*lskip1;
+ ex = B;
+ /* the inner loop that computes outer products and adds them to Z */
+ for (j=i-2; j >= 0; j -= 2) {
+ /* compute outer product and add it to the Z matrix */
+ p1=ell[0];
+ q1=ex[0];
+ m11 = p1 * q1;
+ q2=ex[lskip1];
+ m12 = p1 * q2;
+ p2=ell[lskip1];
+ m21 = p2 * q1;
+ m22 = p2 * q2;
+ Z11 += m11;
+ Z12 += m12;
+ Z21 += m21;
+ Z22 += m22;
+ /* compute outer product and add it to the Z matrix */
+ p1=ell[1];
+ q1=ex[1];
+ m11 = p1 * q1;
+ q2=ex[1+lskip1];
+ m12 = p1 * q2;
+ p2=ell[1+lskip1];
+ m21 = p2 * q1;
+ m22 = p2 * q2;
+ /* advance pointers */
+ ell += 2;
+ ex += 2;
+ Z11 += m11;
+ Z12 += m12;
+ Z21 += m21;
+ Z22 += m22;
+ /* end of inner loop */
+ }
+ /* compute left-over iterations */
+ j += 2;
+ for (; j > 0; j--) {
+ /* compute outer product and add it to the Z matrix */
+ p1=ell[0];
+ q1=ex[0];
+ m11 = p1 * q1;
+ q2=ex[lskip1];
+ m12 = p1 * q2;
+ p2=ell[lskip1];
+ m21 = p2 * q1;
+ m22 = p2 * q2;
+ /* advance pointers */
+ ell += 1;
+ ex += 1;
+ Z11 += m11;
+ Z12 += m12;
+ Z21 += m21;
+ Z22 += m22;
+ }
+ /* finish computing the X(i) block */
+ Z11 = ex[0] - Z11;
+ ex[0] = Z11;
+ Z12 = ex[lskip1] - Z12;
+ ex[lskip1] = Z12;
+ p1 = ell[lskip1];
+ Z21 = ex[1] - Z21 - p1*Z11;
+ ex[1] = Z21;
+ Z22 = ex[1+lskip1] - Z22 - p1*Z12;
+ ex[1+lskip1] = Z22;
+ /* end of outer loop */
+ }
+}
+
+
+void btFactorLDLT (btScalar *A, btScalar *d, int n, int nskip1)
+{
+ int i,j;
+ btScalar sum,*ell,*dee,dd,p1,p2,q1,q2,Z11,m11,Z21,m21,Z22,m22;
+ if (n < 1) return;
+
+ for (i=0; i<=n-2; i += 2) {
+ /* solve L*(D*l)=a, l is scaled elements in 2 x i block at A(i,0) */
+ btSolveL1_2 (A,A+i*nskip1,i,nskip1);
+ /* scale the elements in a 2 x i block at A(i,0), and also */
+ /* compute Z = the outer product matrix that we'll need. */
+ Z11 = 0;
+ Z21 = 0;
+ Z22 = 0;
+ ell = A+i*nskip1;
+ dee = d;
+ for (j=i-6; j >= 0; j -= 6) {
+ p1 = ell[0];
+ p2 = ell[nskip1];
+ dd = dee[0];
+ q1 = p1*dd;
+ q2 = p2*dd;
+ ell[0] = q1;
+ ell[nskip1] = q2;
+ m11 = p1*q1;
+ m21 = p2*q1;
+ m22 = p2*q2;
+ Z11 += m11;
+ Z21 += m21;
+ Z22 += m22;
+ p1 = ell[1];
+ p2 = ell[1+nskip1];
+ dd = dee[1];
+ q1 = p1*dd;
+ q2 = p2*dd;
+ ell[1] = q1;
+ ell[1+nskip1] = q2;
+ m11 = p1*q1;
+ m21 = p2*q1;
+ m22 = p2*q2;
+ Z11 += m11;
+ Z21 += m21;
+ Z22 += m22;
+ p1 = ell[2];
+ p2 = ell[2+nskip1];
+ dd = dee[2];
+ q1 = p1*dd;
+ q2 = p2*dd;
+ ell[2] = q1;
+ ell[2+nskip1] = q2;
+ m11 = p1*q1;
+ m21 = p2*q1;
+ m22 = p2*q2;
+ Z11 += m11;
+ Z21 += m21;
+ Z22 += m22;
+ p1 = ell[3];
+ p2 = ell[3+nskip1];
+ dd = dee[3];
+ q1 = p1*dd;
+ q2 = p2*dd;
+ ell[3] = q1;
+ ell[3+nskip1] = q2;
+ m11 = p1*q1;
+ m21 = p2*q1;
+ m22 = p2*q2;
+ Z11 += m11;
+ Z21 += m21;
+ Z22 += m22;
+ p1 = ell[4];
+ p2 = ell[4+nskip1];
+ dd = dee[4];
+ q1 = p1*dd;
+ q2 = p2*dd;
+ ell[4] = q1;
+ ell[4+nskip1] = q2;
+ m11 = p1*q1;
+ m21 = p2*q1;
+ m22 = p2*q2;
+ Z11 += m11;
+ Z21 += m21;
+ Z22 += m22;
+ p1 = ell[5];
+ p2 = ell[5+nskip1];
+ dd = dee[5];
+ q1 = p1*dd;
+ q2 = p2*dd;
+ ell[5] = q1;
+ ell[5+nskip1] = q2;
+ m11 = p1*q1;
+ m21 = p2*q1;
+ m22 = p2*q2;
+ Z11 += m11;
+ Z21 += m21;
+ Z22 += m22;
+ ell += 6;
+ dee += 6;
+ }
+ /* compute left-over iterations */
+ j += 6;
+ for (; j > 0; j--) {
+ p1 = ell[0];
+ p2 = ell[nskip1];
+ dd = dee[0];
+ q1 = p1*dd;
+ q2 = p2*dd;
+ ell[0] = q1;
+ ell[nskip1] = q2;
+ m11 = p1*q1;
+ m21 = p2*q1;
+ m22 = p2*q2;
+ Z11 += m11;
+ Z21 += m21;
+ Z22 += m22;
+ ell++;
+ dee++;
+ }
+ /* solve for diagonal 2 x 2 block at A(i,i) */
+ Z11 = ell[0] - Z11;
+ Z21 = ell[nskip1] - Z21;
+ Z22 = ell[1+nskip1] - Z22;
+ dee = d + i;
+ /* factorize 2 x 2 block Z,dee */
+ /* factorize row 1 */
+ dee[0] = btRecip(Z11);
+ /* factorize row 2 */
+ sum = 0;
+ q1 = Z21;
+ q2 = q1 * dee[0];
+ Z21 = q2;
+ sum += q1*q2;
+ dee[1] = btRecip(Z22 - sum);
+ /* done factorizing 2 x 2 block */
+ ell[nskip1] = Z21;
+ }
+ /* compute the (less than 2) rows at the bottom */
+ switch (n-i) {
+ case 0:
+ break;
+
+ case 1:
+ btSolveL1_1 (A,A+i*nskip1,i,nskip1);
+ /* scale the elements in a 1 x i block at A(i,0), and also */
+ /* compute Z = the outer product matrix that we'll need. */
+ Z11 = 0;
+ ell = A+i*nskip1;
+ dee = d;
+ for (j=i-6; j >= 0; j -= 6) {
+ p1 = ell[0];
+ dd = dee[0];
+ q1 = p1*dd;
+ ell[0] = q1;
+ m11 = p1*q1;
+ Z11 += m11;
+ p1 = ell[1];
+ dd = dee[1];
+ q1 = p1*dd;
+ ell[1] = q1;
+ m11 = p1*q1;
+ Z11 += m11;
+ p1 = ell[2];
+ dd = dee[2];
+ q1 = p1*dd;
+ ell[2] = q1;
+ m11 = p1*q1;
+ Z11 += m11;
+ p1 = ell[3];
+ dd = dee[3];
+ q1 = p1*dd;
+ ell[3] = q1;
+ m11 = p1*q1;
+ Z11 += m11;
+ p1 = ell[4];
+ dd = dee[4];
+ q1 = p1*dd;
+ ell[4] = q1;
+ m11 = p1*q1;
+ Z11 += m11;
+ p1 = ell[5];
+ dd = dee[5];
+ q1 = p1*dd;
+ ell[5] = q1;
+ m11 = p1*q1;
+ Z11 += m11;
+ ell += 6;
+ dee += 6;
+ }
+ /* compute left-over iterations */
+ j += 6;
+ for (; j > 0; j--) {
+ p1 = ell[0];
+ dd = dee[0];
+ q1 = p1*dd;
+ ell[0] = q1;
+ m11 = p1*q1;
+ Z11 += m11;
+ ell++;
+ dee++;
+ }
+ /* solve for diagonal 1 x 1 block at A(i,i) */
+ Z11 = ell[0] - Z11;
+ dee = d + i;
+ /* factorize 1 x 1 block Z,dee */
+ /* factorize row 1 */
+ dee[0] = btRecip(Z11);
+ /* done factorizing 1 x 1 block */
+ break;
+
+ //default: *((char*)0)=0; /* this should never happen! */
+ }
+}
+
+/* solve L*X=B, with B containing 1 right hand sides.
+ * L is an n*n lower triangular matrix with ones on the diagonal.
+ * L is stored by rows and its leading dimension is lskip.
+ * B is an n*1 matrix that contains the right hand sides.
+ * B is stored by columns and its leading dimension is also lskip.
+ * B is overwritten with X.
+ * this processes blocks of 4*4.
+ * if this is in the factorizer source file, n must be a multiple of 4.
+ */
+
+void btSolveL1 (const btScalar *L, btScalar *B, int n, int lskip1)
+{
+ /* declare variables - Z matrix, p and q vectors, etc */
+ btScalar Z11,Z21,Z31,Z41,p1,q1,p2,p3,p4,*ex;
+ const btScalar *ell;
+ int lskip2,lskip3,i,j;
+ /* compute lskip values */
+ lskip2 = 2*lskip1;
+ lskip3 = 3*lskip1;
+ /* compute all 4 x 1 blocks of X */
+ for (i=0; i <= n-4; i+=4) {
+ /* compute all 4 x 1 block of X, from rows i..i+4-1 */
+ /* set the Z matrix to 0 */
+ Z11=0;
+ Z21=0;
+ Z31=0;
+ Z41=0;
+ ell = L + i*lskip1;
+ ex = B;
+ /* the inner loop that computes outer products and adds them to Z */
+ for (j=i-12; j >= 0; j -= 12) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ p2=ell[lskip1];
+ p3=ell[lskip2];
+ p4=ell[lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[1];
+ q1=ex[1];
+ p2=ell[1+lskip1];
+ p3=ell[1+lskip2];
+ p4=ell[1+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[2];
+ q1=ex[2];
+ p2=ell[2+lskip1];
+ p3=ell[2+lskip2];
+ p4=ell[2+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[3];
+ q1=ex[3];
+ p2=ell[3+lskip1];
+ p3=ell[3+lskip2];
+ p4=ell[3+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[4];
+ q1=ex[4];
+ p2=ell[4+lskip1];
+ p3=ell[4+lskip2];
+ p4=ell[4+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[5];
+ q1=ex[5];
+ p2=ell[5+lskip1];
+ p3=ell[5+lskip2];
+ p4=ell[5+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[6];
+ q1=ex[6];
+ p2=ell[6+lskip1];
+ p3=ell[6+lskip2];
+ p4=ell[6+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[7];
+ q1=ex[7];
+ p2=ell[7+lskip1];
+ p3=ell[7+lskip2];
+ p4=ell[7+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[8];
+ q1=ex[8];
+ p2=ell[8+lskip1];
+ p3=ell[8+lskip2];
+ p4=ell[8+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[9];
+ q1=ex[9];
+ p2=ell[9+lskip1];
+ p3=ell[9+lskip2];
+ p4=ell[9+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[10];
+ q1=ex[10];
+ p2=ell[10+lskip1];
+ p3=ell[10+lskip2];
+ p4=ell[10+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* load p and q values */
+ p1=ell[11];
+ q1=ex[11];
+ p2=ell[11+lskip1];
+ p3=ell[11+lskip2];
+ p4=ell[11+lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* advance pointers */
+ ell += 12;
+ ex += 12;
+ /* end of inner loop */
+ }
+ /* compute left-over iterations */
+ j += 12;
+ for (; j > 0; j--) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ p2=ell[lskip1];
+ p3=ell[lskip2];
+ p4=ell[lskip3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ Z21 += p2 * q1;
+ Z31 += p3 * q1;
+ Z41 += p4 * q1;
+ /* advance pointers */
+ ell += 1;
+ ex += 1;
+ }
+ /* finish computing the X(i) block */
+ Z11 = ex[0] - Z11;
+ ex[0] = Z11;
+ p1 = ell[lskip1];
+ Z21 = ex[1] - Z21 - p1*Z11;
+ ex[1] = Z21;
+ p1 = ell[lskip2];
+ p2 = ell[1+lskip2];
+ Z31 = ex[2] - Z31 - p1*Z11 - p2*Z21;
+ ex[2] = Z31;
+ p1 = ell[lskip3];
+ p2 = ell[1+lskip3];
+ p3 = ell[2+lskip3];
+ Z41 = ex[3] - Z41 - p1*Z11 - p2*Z21 - p3*Z31;
+ ex[3] = Z41;
+ /* end of outer loop */
+ }
+ /* compute rows at end that are not a multiple of block size */
+ for (; i < n; i++) {
+ /* compute all 1 x 1 block of X, from rows i..i+1-1 */
+ /* set the Z matrix to 0 */
+ Z11=0;
+ ell = L + i*lskip1;
+ ex = B;
+ /* the inner loop that computes outer products and adds them to Z */
+ for (j=i-12; j >= 0; j -= 12) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[1];
+ q1=ex[1];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[2];
+ q1=ex[2];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[3];
+ q1=ex[3];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[4];
+ q1=ex[4];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[5];
+ q1=ex[5];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[6];
+ q1=ex[6];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[7];
+ q1=ex[7];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[8];
+ q1=ex[8];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[9];
+ q1=ex[9];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[10];
+ q1=ex[10];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* load p and q values */
+ p1=ell[11];
+ q1=ex[11];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* advance pointers */
+ ell += 12;
+ ex += 12;
+ /* end of inner loop */
+ }
+ /* compute left-over iterations */
+ j += 12;
+ for (; j > 0; j--) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ /* compute outer product and add it to the Z matrix */
+ Z11 += p1 * q1;
+ /* advance pointers */
+ ell += 1;
+ ex += 1;
+ }
+ /* finish computing the X(i) block */
+ Z11 = ex[0] - Z11;
+ ex[0] = Z11;
+ }
+}
+
+/* solve L^T * x=b, with b containing 1 right hand side.
+ * L is an n*n lower triangular matrix with ones on the diagonal.
+ * L is stored by rows and its leading dimension is lskip.
+ * b is an n*1 matrix that contains the right hand side.
+ * b is overwritten with x.
+ * this processes blocks of 4.
+ */
+
+void btSolveL1T (const btScalar *L, btScalar *B, int n, int lskip1)
+{
+ /* declare variables - Z matrix, p and q vectors, etc */
+ btScalar Z11,m11,Z21,m21,Z31,m31,Z41,m41,p1,q1,p2,p3,p4,*ex;
+ const btScalar *ell;
+ int lskip2,lskip3,i,j;
+ /* special handling for L and B because we're solving L1 *transpose* */
+ L = L + (n-1)*(lskip1+1);
+ B = B + n-1;
+ lskip1 = -lskip1;
+ /* compute lskip values */
+ lskip2 = 2*lskip1;
+ lskip3 = 3*lskip1;
+ /* compute all 4 x 1 blocks of X */
+ for (i=0; i <= n-4; i+=4) {
+ /* compute all 4 x 1 block of X, from rows i..i+4-1 */
+ /* set the Z matrix to 0 */
+ Z11=0;
+ Z21=0;
+ Z31=0;
+ Z41=0;
+ ell = L - i;
+ ex = B;
+ /* the inner loop that computes outer products and adds them to Z */
+ for (j=i-4; j >= 0; j -= 4) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ p2=ell[-1];
+ p3=ell[-2];
+ p4=ell[-3];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ m21 = p2 * q1;
+ m31 = p3 * q1;
+ m41 = p4 * q1;
+ ell += lskip1;
+ Z11 += m11;
+ Z21 += m21;
+ Z31 += m31;
+ Z41 += m41;
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[-1];
+ p2=ell[-1];
+ p3=ell[-2];
+ p4=ell[-3];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ m21 = p2 * q1;
+ m31 = p3 * q1;
+ m41 = p4 * q1;
+ ell += lskip1;
+ Z11 += m11;
+ Z21 += m21;
+ Z31 += m31;
+ Z41 += m41;
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[-2];
+ p2=ell[-1];
+ p3=ell[-2];
+ p4=ell[-3];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ m21 = p2 * q1;
+ m31 = p3 * q1;
+ m41 = p4 * q1;
+ ell += lskip1;
+ Z11 += m11;
+ Z21 += m21;
+ Z31 += m31;
+ Z41 += m41;
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[-3];
+ p2=ell[-1];
+ p3=ell[-2];
+ p4=ell[-3];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ m21 = p2 * q1;
+ m31 = p3 * q1;
+ m41 = p4 * q1;
+ ell += lskip1;
+ ex -= 4;
+ Z11 += m11;
+ Z21 += m21;
+ Z31 += m31;
+ Z41 += m41;
+ /* end of inner loop */
+ }
+ /* compute left-over iterations */
+ j += 4;
+ for (; j > 0; j--) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ p2=ell[-1];
+ p3=ell[-2];
+ p4=ell[-3];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ m21 = p2 * q1;
+ m31 = p3 * q1;
+ m41 = p4 * q1;
+ ell += lskip1;
+ ex -= 1;
+ Z11 += m11;
+ Z21 += m21;
+ Z31 += m31;
+ Z41 += m41;
+ }
+ /* finish computing the X(i) block */
+ Z11 = ex[0] - Z11;
+ ex[0] = Z11;
+ p1 = ell[-1];
+ Z21 = ex[-1] - Z21 - p1*Z11;
+ ex[-1] = Z21;
+ p1 = ell[-2];
+ p2 = ell[-2+lskip1];
+ Z31 = ex[-2] - Z31 - p1*Z11 - p2*Z21;
+ ex[-2] = Z31;
+ p1 = ell[-3];
+ p2 = ell[-3+lskip1];
+ p3 = ell[-3+lskip2];
+ Z41 = ex[-3] - Z41 - p1*Z11 - p2*Z21 - p3*Z31;
+ ex[-3] = Z41;
+ /* end of outer loop */
+ }
+ /* compute rows at end that are not a multiple of block size */
+ for (; i < n; i++) {
+ /* compute all 1 x 1 block of X, from rows i..i+1-1 */
+ /* set the Z matrix to 0 */
+ Z11=0;
+ ell = L - i;
+ ex = B;
+ /* the inner loop that computes outer products and adds them to Z */
+ for (j=i-4; j >= 0; j -= 4) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ ell += lskip1;
+ Z11 += m11;
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[-1];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ ell += lskip1;
+ Z11 += m11;
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[-2];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ ell += lskip1;
+ Z11 += m11;
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[-3];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ ell += lskip1;
+ ex -= 4;
+ Z11 += m11;
+ /* end of inner loop */
+ }
+ /* compute left-over iterations */
+ j += 4;
+ for (; j > 0; j--) {
+ /* load p and q values */
+ p1=ell[0];
+ q1=ex[0];
+ /* compute outer product and add it to the Z matrix */
+ m11 = p1 * q1;
+ ell += lskip1;
+ ex -= 1;
+ Z11 += m11;
+ }
+ /* finish computing the X(i) block */
+ Z11 = ex[0] - Z11;
+ ex[0] = Z11;
+ }
+}
+
+
+
+void btVectorScale (btScalar *a, const btScalar *d, int n)
+{
+ btAssert (a && d && n >= 0);
+ for (int i=0; i<n; i++) {
+ a[i] *= d[i];
+ }
+}
+
+void btSolveLDLT (const btScalar *L, const btScalar *d, btScalar *b, int n, int nskip)
+{
+ btAssert (L && d && b && n > 0 && nskip >= n);
+ btSolveL1 (L,b,n,nskip);
+ btVectorScale (b,d,n);
+ btSolveL1T (L,b,n,nskip);
+}
+
+
+
+//***************************************************************************
+
+// swap row/column i1 with i2 in the n*n matrix A. the leading dimension of
+// A is nskip. this only references and swaps the lower triangle.
+// if `do_fast_row_swaps' is nonzero and row pointers are being used, then
+// rows will be swapped by exchanging row pointers. otherwise the data will
+// be copied.
+
+static void btSwapRowsAndCols (BTATYPE A, int n, int i1, int i2, int nskip,
+ int do_fast_row_swaps)
+{
+ btAssert (A && n > 0 && i1 >= 0 && i2 >= 0 && i1 < n && i2 < n &&
+ nskip >= n && i1 < i2);
+
+# ifdef BTROWPTRS
+ btScalar *A_i1 = A[i1];
+ btScalar *A_i2 = A[i2];
+ for (int i=i1+1; i<i2; ++i) {
+ btScalar *A_i_i1 = A[i] + i1;
+ A_i1[i] = *A_i_i1;
+ *A_i_i1 = A_i2[i];
+ }
+ A_i1[i2] = A_i1[i1];
+ A_i1[i1] = A_i2[i1];
+ A_i2[i1] = A_i2[i2];
+ // swap rows, by swapping row pointers
+ if (do_fast_row_swaps) {
+ A[i1] = A_i2;
+ A[i2] = A_i1;
+ }
+ else {
+ // Only swap till i2 column to match A plain storage variant.
+ for (int k = 0; k <= i2; ++k) {
+ btScalar tmp = A_i1[k];
+ A_i1[k] = A_i2[k];
+ A_i2[k] = tmp;
+ }
+ }
+ // swap columns the hard way
+ for (int j=i2+1; j<n; ++j) {
+ btScalar *A_j = A[j];
+ btScalar tmp = A_j[i1];
+ A_j[i1] = A_j[i2];
+ A_j[i2] = tmp;
+ }
+# else
+ btScalar *A_i1 = A+i1*nskip;
+ btScalar *A_i2 = A+i2*nskip;
+ for (int k = 0; k < i1; ++k) {
+ btScalar tmp = A_i1[k];
+ A_i1[k] = A_i2[k];
+ A_i2[k] = tmp;
+ }
+ btScalar *A_i = A_i1 + nskip;
+ for (int i=i1+1; i<i2; A_i+=nskip, ++i) {
+ btScalar tmp = A_i2[i];
+ A_i2[i] = A_i[i1];
+ A_i[i1] = tmp;
+ }
+ {
+ btScalar tmp = A_i1[i1];
+ A_i1[i1] = A_i2[i2];
+ A_i2[i2] = tmp;
+ }
+ btScalar *A_j = A_i2 + nskip;
+ for (int j=i2+1; j<n; A_j+=nskip, ++j) {
+ btScalar tmp = A_j[i1];
+ A_j[i1] = A_j[i2];
+ A_j[i2] = tmp;
+ }
+# endif
+}
+
+
+// swap two indexes in the n*n LCP problem. i1 must be <= i2.
+
+static void btSwapProblem (BTATYPE A, btScalar *x, btScalar *b, btScalar *w, btScalar *lo,
+ btScalar *hi, int *p, bool *state, int *findex,
+ int n, int i1, int i2, int nskip,
+ int do_fast_row_swaps)
+{
+ btScalar tmpr;
+ int tmpi;
+ bool tmpb;
+ btAssert (n>0 && i1 >=0 && i2 >= 0 && i1 < n && i2 < n && nskip >= n && i1 <= i2);
+ if (i1==i2) return;
+
+ btSwapRowsAndCols (A,n,i1,i2,nskip,do_fast_row_swaps);
+
+ tmpr = x[i1];
+ x[i1] = x[i2];
+ x[i2] = tmpr;
+
+ tmpr = b[i1];
+ b[i1] = b[i2];
+ b[i2] = tmpr;
+
+ tmpr = w[i1];
+ w[i1] = w[i2];
+ w[i2] = tmpr;
+
+ tmpr = lo[i1];
+ lo[i1] = lo[i2];
+ lo[i2] = tmpr;
+
+ tmpr = hi[i1];
+ hi[i1] = hi[i2];
+ hi[i2] = tmpr;
+
+ tmpi = p[i1];
+ p[i1] = p[i2];
+ p[i2] = tmpi;
+
+ tmpb = state[i1];
+ state[i1] = state[i2];
+ state[i2] = tmpb;
+
+ if (findex) {
+ tmpi = findex[i1];
+ findex[i1] = findex[i2];
+ findex[i2] = tmpi;
+ }
+}
+
+
+
+
+//***************************************************************************
+// btLCP manipulator object. this represents an n*n LCP problem.
+//
+// two index sets C and N are kept. each set holds a subset of
+// the variable indexes 0..n-1. an index can only be in one set.
+// initially both sets are empty.
+//
+// the index set C is special: solutions to A(C,C)\A(C,i) can be generated.
+
+//***************************************************************************
+// fast implementation of btLCP. see the above definition of btLCP for
+// interface comments.
+//
+// `p' records the permutation of A,x,b,w,etc. p is initially 1:n and is
+// permuted as the other vectors/matrices are permuted.
+//
+// A,x,b,w,lo,hi,state,findex,p,c are permuted such that sets C,N have
+// contiguous indexes. the don't-care indexes follow N.
+//
+// an L*D*L' factorization is maintained of A(C,C), and whenever indexes are
+// added or removed from the set C the factorization is updated.
+// thus L*D*L'=A[C,C], i.e. a permuted top left nC*nC submatrix of A.
+// the leading dimension of the matrix L is always `nskip'.
+//
+// at the start there may be other indexes that are unbounded but are not
+// included in `nub'. btLCP will permute the matrix so that absolutely all
+// unbounded vectors are at the start. thus there may be some initial
+// permutation.
+//
+// the algorithms here assume certain patterns, particularly with respect to
+// index transfer.
+
+#ifdef btLCP_FAST
+
+struct btLCP
+{
+ const int m_n;
+ const int m_nskip;
+ int m_nub;
+ int m_nC, m_nN; // size of each index set
+ BTATYPE const m_A; // A rows
+ btScalar *const m_x, * const m_b, *const m_w, *const m_lo,* const m_hi; // permuted LCP problem data
+ btScalar *const m_L, *const m_d; // L*D*L' factorization of set C
+ btScalar *const m_Dell, *const m_ell, *const m_tmp;
+ bool *const m_state;
+ int *const m_findex, *const m_p, *const m_C;
+
+ btLCP (int _n, int _nskip, int _nub, btScalar *_Adata, btScalar *_x, btScalar *_b, btScalar *_w,
+ btScalar *_lo, btScalar *_hi, btScalar *_L, btScalar *_d,
+ btScalar *_Dell, btScalar *_ell, btScalar *_tmp,
+ bool *_state, int *_findex, int *_p, int *_C, btScalar **Arows);
+ int getNub() const { return m_nub; }
+ void transfer_i_to_C (int i);
+ void transfer_i_to_N (int i) { m_nN++; } // because we can assume C and N span 1:i-1
+ void transfer_i_from_N_to_C (int i);
+ void transfer_i_from_C_to_N (int i, btAlignedObjectArray<btScalar>& scratch);
+ int numC() const { return m_nC; }
+ int numN() const { return m_nN; }
+ int indexC (int i) const { return i; }
+ int indexN (int i) const { return i+m_nC; }
+ btScalar Aii (int i) const { return BTAROW(i)[i]; }
+ btScalar AiC_times_qC (int i, btScalar *q) const { return btLargeDot (BTAROW(i), q, m_nC); }
+ btScalar AiN_times_qN (int i, btScalar *q) const { return btLargeDot (BTAROW(i)+m_nC, q+m_nC, m_nN); }
+ void pN_equals_ANC_times_qC (btScalar *p, btScalar *q);
+ void pN_plusequals_ANi (btScalar *p, int i, int sign=1);
+ void pC_plusequals_s_times_qC (btScalar *p, btScalar s, btScalar *q);
+ void pN_plusequals_s_times_qN (btScalar *p, btScalar s, btScalar *q);
+ void solve1 (btScalar *a, int i, int dir=1, int only_transfer=0);
+ void unpermute();
+};
+
+
+btLCP::btLCP (int _n, int _nskip, int _nub, btScalar *_Adata, btScalar *_x, btScalar *_b, btScalar *_w,
+ btScalar *_lo, btScalar *_hi, btScalar *_L, btScalar *_d,
+ btScalar *_Dell, btScalar *_ell, btScalar *_tmp,
+ bool *_state, int *_findex, int *_p, int *_C, btScalar **Arows):
+ m_n(_n), m_nskip(_nskip), m_nub(_nub), m_nC(0), m_nN(0),
+# ifdef BTROWPTRS
+ m_A(Arows),
+#else
+ m_A(_Adata),
+#endif
+ m_x(_x), m_b(_b), m_w(_w), m_lo(_lo), m_hi(_hi),
+ m_L(_L), m_d(_d), m_Dell(_Dell), m_ell(_ell), m_tmp(_tmp),
+ m_state(_state), m_findex(_findex), m_p(_p), m_C(_C)
+{
+ {
+ btSetZero (m_x,m_n);
+ }
+
+ {
+# ifdef BTROWPTRS
+ // make matrix row pointers
+ btScalar *aptr = _Adata;
+ BTATYPE A = m_A;
+ const int n = m_n, nskip = m_nskip;
+ for (int k=0; k<n; aptr+=nskip, ++k) A[k] = aptr;
+# endif
+ }
+
+ {
+ int *p = m_p;
+ const int n = m_n;
+ for (int k=0; k<n; ++k) p[k]=k; // initially unpermuted
+ }
+
+ /*
+ // for testing, we can do some random swaps in the area i > nub
+ {
+ const int n = m_n;
+ const int nub = m_nub;
+ if (nub < n) {
+ for (int k=0; k<100; k++) {
+ int i1,i2;
+ do {
+ i1 = dRandInt(n-nub)+nub;
+ i2 = dRandInt(n-nub)+nub;
+ }
+ while (i1 > i2);
+ //printf ("--> %d %d\n",i1,i2);
+ btSwapProblem (m_A,m_x,m_b,m_w,m_lo,m_hi,m_p,m_state,m_findex,n,i1,i2,m_nskip,0);
+ }
+ }
+ */
+
+ // permute the problem so that *all* the unbounded variables are at the
+ // start, i.e. look for unbounded variables not included in `nub'. we can
+ // potentially push up `nub' this way and get a bigger initial factorization.
+ // note that when we swap rows/cols here we must not just swap row pointers,
+ // as the initial factorization relies on the data being all in one chunk.
+ // variables that have findex >= 0 are *not* considered to be unbounded even
+ // if lo=-inf and hi=inf - this is because these limits may change during the
+ // solution process.
+
+ {
+ int *findex = m_findex;
+ btScalar *lo = m_lo, *hi = m_hi;
+ const int n = m_n;
+ for (int k = m_nub; k<n; ++k) {
+ if (findex && findex[k] >= 0) continue;
+ if (lo[k]==-BT_INFINITY && hi[k]==BT_INFINITY) {
+ btSwapProblem (m_A,m_x,m_b,m_w,lo,hi,m_p,m_state,findex,n,m_nub,k,m_nskip,0);
+ m_nub++;
+ }
+ }
+ }
+
+ // if there are unbounded variables at the start, factorize A up to that
+ // point and solve for x. this puts all indexes 0..nub-1 into C.
+ if (m_nub > 0) {
+ const int nub = m_nub;
+ {
+ btScalar *Lrow = m_L;
+ const int nskip = m_nskip;
+ for (int j=0; j<nub; Lrow+=nskip, ++j) memcpy(Lrow,BTAROW(j),(j+1)*sizeof(btScalar));
+ }
+ btFactorLDLT (m_L,m_d,nub,m_nskip);
+ memcpy (m_x,m_b,nub*sizeof(btScalar));
+ btSolveLDLT (m_L,m_d,m_x,nub,m_nskip);
+ btSetZero (m_w,nub);
+ {
+ int *C = m_C;
+ for (int k=0; k<nub; ++k) C[k] = k;
+ }
+ m_nC = nub;
+ }
+
+ // permute the indexes > nub such that all findex variables are at the end
+ if (m_findex) {
+ const int nub = m_nub;
+ int *findex = m_findex;
+ int num_at_end = 0;
+ for (int k=m_n-1; k >= nub; k--) {
+ if (findex[k] >= 0) {
+ btSwapProblem (m_A,m_x,m_b,m_w,m_lo,m_hi,m_p,m_state,findex,m_n,k,m_n-1-num_at_end,m_nskip,1);
+ num_at_end++;
+ }
+ }
+ }
+
+ // print info about indexes
+ /*
+ {
+ const int n = m_n;
+ const int nub = m_nub;
+ for (int k=0; k<n; k++) {
+ if (k<nub) printf ("C");
+ else if (m_lo[k]==-BT_INFINITY && m_hi[k]==BT_INFINITY) printf ("c");
+ else printf (".");
+ }
+ printf ("\n");
+ }
+ */
+}
+
+
+void btLCP::transfer_i_to_C (int i)
+{
+ {
+ if (m_nC > 0) {
+ // ell,Dell were computed by solve1(). note, ell = D \ L1solve (L,A(i,C))
+ {
+ const int nC = m_nC;
+ btScalar *const Ltgt = m_L + nC*m_nskip, *ell = m_ell;
+ for (int j=0; j<nC; ++j) Ltgt[j] = ell[j];
+ }
+ const int nC = m_nC;
+ m_d[nC] = btRecip (BTAROW(i)[i] - btLargeDot(m_ell,m_Dell,nC));
+ }
+ else {
+ m_d[0] = btRecip (BTAROW(i)[i]);
+ }
+
+ btSwapProblem (m_A,m_x,m_b,m_w,m_lo,m_hi,m_p,m_state,m_findex,m_n,m_nC,i,m_nskip,1);
+
+ const int nC = m_nC;
+ m_C[nC] = nC;
+ m_nC = nC + 1; // nC value is outdated after this line
+ }
+
+}
+
+
+void btLCP::transfer_i_from_N_to_C (int i)
+{
+ {
+ if (m_nC > 0) {
+ {
+ btScalar *const aptr = BTAROW(i);
+ btScalar *Dell = m_Dell;
+ const int *C = m_C;
+# ifdef BTNUB_OPTIMIZATIONS
+ // if nub>0, initial part of aptr unpermuted
+ const int nub = m_nub;
+ int j=0;
+ for ( ; j<nub; ++j) Dell[j] = aptr[j];
+ const int nC = m_nC;
+ for ( ; j<nC; ++j) Dell[j] = aptr[C[j]];
+# else
+ const int nC = m_nC;
+ for (int j=0; j<nC; ++j) Dell[j] = aptr[C[j]];
+# endif
+ }
+ btSolveL1 (m_L,m_Dell,m_nC,m_nskip);
+ {
+ const int nC = m_nC;
+ btScalar *const Ltgt = m_L + nC*m_nskip;
+ btScalar *ell = m_ell, *Dell = m_Dell, *d = m_d;
+ for (int j=0; j<nC; ++j) Ltgt[j] = ell[j] = Dell[j] * d[j];
+ }
+ const int nC = m_nC;
+ m_d[nC] = btRecip (BTAROW(i)[i] - btLargeDot(m_ell,m_Dell,nC));
+ }
+ else {
+ m_d[0] = btRecip (BTAROW(i)[i]);
+ }
+
+ btSwapProblem (m_A,m_x,m_b,m_w,m_lo,m_hi,m_p,m_state,m_findex,m_n,m_nC,i,m_nskip,1);
+
+ const int nC = m_nC;
+ m_C[nC] = nC;
+ m_nN--;
+ m_nC = nC + 1; // nC value is outdated after this line
+ }
+
+ // @@@ TO DO LATER
+ // if we just finish here then we'll go back and re-solve for
+ // delta_x. but actually we can be more efficient and incrementally
+ // update delta_x here. but if we do this, we wont have ell and Dell
+ // to use in updating the factorization later.
+
+}
+
+void btRemoveRowCol (btScalar *A, int n, int nskip, int r)
+{
+ btAssert(A && n > 0 && nskip >= n && r >= 0 && r < n);
+ if (r >= n-1) return;
+ if (r > 0) {
+ {
+ const size_t move_size = (n-r-1)*sizeof(btScalar);
+ btScalar *Adst = A + r;
+ for (int i=0; i<r; Adst+=nskip,++i) {
+ btScalar *Asrc = Adst + 1;
+ memmove (Adst,Asrc,move_size);
+ }
+ }
+ {
+ const size_t cpy_size = r*sizeof(btScalar);
+ btScalar *Adst = A + r * nskip;
+ for (int i=r; i<(n-1); ++i) {
+ btScalar *Asrc = Adst + nskip;
+ memcpy (Adst,Asrc,cpy_size);
+ Adst = Asrc;
+ }
+ }
+ }
+ {
+ const size_t cpy_size = (n-r-1)*sizeof(btScalar);
+ btScalar *Adst = A + r * (nskip + 1);
+ for (int i=r; i<(n-1); ++i) {
+ btScalar *Asrc = Adst + (nskip + 1);
+ memcpy (Adst,Asrc,cpy_size);
+ Adst = Asrc - 1;
+ }
+ }
+}
+
+
+
+
+void btLDLTAddTL (btScalar *L, btScalar *d, const btScalar *a, int n, int nskip, btAlignedObjectArray<btScalar>& scratch)
+{
+ btAssert (L && d && a && n > 0 && nskip >= n);
+
+ if (n < 2) return;
+ scratch.resize(2*nskip);
+ btScalar *W1 = &scratch[0];
+
+ btScalar *W2 = W1 + nskip;
+
+ W1[0] = btScalar(0.0);
+ W2[0] = btScalar(0.0);
+ for (int j=1; j<n; ++j) {
+ W1[j] = W2[j] = (btScalar) (a[j] * SIMDSQRT12);
+ }
+ btScalar W11 = (btScalar) ((btScalar(0.5)*a[0]+1)*SIMDSQRT12);
+ btScalar W21 = (btScalar) ((btScalar(0.5)*a[0]-1)*SIMDSQRT12);
+
+ btScalar alpha1 = btScalar(1.0);
+ btScalar alpha2 = btScalar(1.0);
+
+ {
+ btScalar dee = d[0];
+ btScalar alphanew = alpha1 + (W11*W11)*dee;
+ btAssert(alphanew != btScalar(0.0));
+ dee /= alphanew;
+ btScalar gamma1 = W11 * dee;
+ dee *= alpha1;
+ alpha1 = alphanew;
+ alphanew = alpha2 - (W21*W21)*dee;
+ dee /= alphanew;
+ //btScalar gamma2 = W21 * dee;
+ alpha2 = alphanew;
+ btScalar k1 = btScalar(1.0) - W21*gamma1;
+ btScalar k2 = W21*gamma1*W11 - W21;
+ btScalar *ll = L + nskip;
+ for (int p=1; p<n; ll+=nskip, ++p) {
+ btScalar Wp = W1[p];
+ btScalar ell = *ll;
+ W1[p] = Wp - W11*ell;
+ W2[p] = k1*Wp + k2*ell;
+ }
+ }
+
+ btScalar *ll = L + (nskip + 1);
+ for (int j=1; j<n; ll+=nskip+1, ++j) {
+ btScalar k1 = W1[j];
+ btScalar k2 = W2[j];
+
+ btScalar dee = d[j];
+ btScalar alphanew = alpha1 + (k1*k1)*dee;
+ btAssert(alphanew != btScalar(0.0));
+ dee /= alphanew;
+ btScalar gamma1 = k1 * dee;
+ dee *= alpha1;
+ alpha1 = alphanew;
+ alphanew = alpha2 - (k2*k2)*dee;
+ dee /= alphanew;
+ btScalar gamma2 = k2 * dee;
+ dee *= alpha2;
+ d[j] = dee;
+ alpha2 = alphanew;
+
+ btScalar *l = ll + nskip;
+ for (int p=j+1; p<n; l+=nskip, ++p) {
+ btScalar ell = *l;
+ btScalar Wp = W1[p] - k1 * ell;
+ ell += gamma1 * Wp;
+ W1[p] = Wp;
+ Wp = W2[p] - k2 * ell;
+ ell -= gamma2 * Wp;
+ W2[p] = Wp;
+ *l = ell;
+ }
+ }
+}
+
+
+#define _BTGETA(i,j) (A[i][j])
+//#define _GETA(i,j) (A[(i)*nskip+(j)])
+#define BTGETA(i,j) ((i > j) ? _BTGETA(i,j) : _BTGETA(j,i))
+
+inline size_t btEstimateLDLTAddTLTmpbufSize(int nskip)
+{
+ return nskip * 2 * sizeof(btScalar);
+}
+
+
+void btLDLTRemove (btScalar **A, const int *p, btScalar *L, btScalar *d,
+ int n1, int n2, int r, int nskip, btAlignedObjectArray<btScalar>& scratch)
+{
+ btAssert(A && p && L && d && n1 > 0 && n2 > 0 && r >= 0 && r < n2 &&
+ n1 >= n2 && nskip >= n1);
+ #ifdef BT_DEBUG
+ for (int i=0; i<n2; ++i)
+ btAssert(p[i] >= 0 && p[i] < n1);
+ #endif
+
+ if (r==n2-1) {
+ return; // deleting last row/col is easy
+ }
+ else {
+ size_t LDLTAddTL_size = btEstimateLDLTAddTLTmpbufSize(nskip);
+ btAssert(LDLTAddTL_size % sizeof(btScalar) == 0);
+ scratch.resize(nskip * 2+n2);
+ btScalar *tmp = &scratch[0];
+ if (r==0) {
+ btScalar *a = (btScalar *)((char *)tmp + LDLTAddTL_size);
+ const int p_0 = p[0];
+ for (int i=0; i<n2; ++i) {
+ a[i] = -BTGETA(p[i],p_0);
+ }
+ a[0] += btScalar(1.0);
+ btLDLTAddTL (L,d,a,n2,nskip,scratch);
+ }
+ else {
+ btScalar *t = (btScalar *)((char *)tmp + LDLTAddTL_size);
+ {
+ btScalar *Lcurr = L + r*nskip;
+ for (int i=0; i<r; ++Lcurr, ++i) {
+ btAssert(d[i] != btScalar(0.0));
+ t[i] = *Lcurr / d[i];
+ }
+ }
+ btScalar *a = t + r;
+ {
+ btScalar *Lcurr = L + r*nskip;
+ const int *pp_r = p + r, p_r = *pp_r;
+ const int n2_minus_r = n2-r;
+ for (int i=0; i<n2_minus_r; Lcurr+=nskip,++i) {
+ a[i] = btLargeDot(Lcurr,t,r) - BTGETA(pp_r[i],p_r);
+ }
+ }
+ a[0] += btScalar(1.0);
+ btLDLTAddTL (L + r*nskip+r, d+r, a, n2-r, nskip, scratch);
+ }
+ }
+
+ // snip out row/column r from L and d
+ btRemoveRowCol (L,n2,nskip,r);
+ if (r < (n2-1)) memmove (d+r,d+r+1,(n2-r-1)*sizeof(btScalar));
+}
+
+
+void btLCP::transfer_i_from_C_to_N (int i, btAlignedObjectArray<btScalar>& scratch)
+{
+ {
+ int *C = m_C;
+ // remove a row/column from the factorization, and adjust the
+ // indexes (black magic!)
+ int last_idx = -1;
+ const int nC = m_nC;
+ int j = 0;
+ for ( ; j<nC; ++j) {
+ if (C[j]==nC-1) {
+ last_idx = j;
+ }
+ if (C[j]==i) {
+ btLDLTRemove (m_A,C,m_L,m_d,m_n,nC,j,m_nskip,scratch);
+ int k;
+ if (last_idx == -1) {
+ for (k=j+1 ; k<nC; ++k) {
+ if (C[k]==nC-1) {
+ break;
+ }
+ }
+ btAssert (k < nC);
+ }
+ else {
+ k = last_idx;
+ }
+ C[k] = C[j];
+ if (j < (nC-1)) memmove (C+j,C+j+1,(nC-j-1)*sizeof(int));
+ break;
+ }
+ }
+ btAssert (j < nC);
+
+ btSwapProblem (m_A,m_x,m_b,m_w,m_lo,m_hi,m_p,m_state,m_findex,m_n,i,nC-1,m_nskip,1);
+
+ m_nN++;
+ m_nC = nC - 1; // nC value is outdated after this line
+ }
+
+}
+
+
+void btLCP::pN_equals_ANC_times_qC (btScalar *p, btScalar *q)
+{
+ // we could try to make this matrix-vector multiplication faster using
+ // outer product matrix tricks, e.g. with the dMultidotX() functions.
+ // but i tried it and it actually made things slower on random 100x100
+ // problems because of the overhead involved. so we'll stick with the
+ // simple method for now.
+ const int nC = m_nC;
+ btScalar *ptgt = p + nC;
+ const int nN = m_nN;
+ for (int i=0; i<nN; ++i) {
+ ptgt[i] = btLargeDot (BTAROW(i+nC),q,nC);
+ }
+}
+
+
+void btLCP::pN_plusequals_ANi (btScalar *p, int i, int sign)
+{
+ const int nC = m_nC;
+ btScalar *aptr = BTAROW(i) + nC;
+ btScalar *ptgt = p + nC;
+ if (sign > 0) {
+ const int nN = m_nN;
+ for (int j=0; j<nN; ++j) ptgt[j] += aptr[j];
+ }
+ else {
+ const int nN = m_nN;
+ for (int j=0; j<nN; ++j) ptgt[j] -= aptr[j];
+ }
+}
+
+void btLCP::pC_plusequals_s_times_qC (btScalar *p, btScalar s, btScalar *q)
+{
+ const int nC = m_nC;
+ for (int i=0; i<nC; ++i) {
+ p[i] += s*q[i];
+ }
+}
+
+void btLCP::pN_plusequals_s_times_qN (btScalar *p, btScalar s, btScalar *q)
+{
+ const int nC = m_nC;
+ btScalar *ptgt = p + nC, *qsrc = q + nC;
+ const int nN = m_nN;
+ for (int i=0; i<nN; ++i) {
+ ptgt[i] += s*qsrc[i];
+ }
+}
+
+void btLCP::solve1 (btScalar *a, int i, int dir, int only_transfer)
+{
+ // the `Dell' and `ell' that are computed here are saved. if index i is
+ // later added to the factorization then they can be reused.
+ //
+ // @@@ question: do we need to solve for entire delta_x??? yes, but
+ // only if an x goes below 0 during the step.
+
+ if (m_nC > 0) {
+ {
+ btScalar *Dell = m_Dell;
+ int *C = m_C;
+ btScalar *aptr = BTAROW(i);
+# ifdef BTNUB_OPTIMIZATIONS
+ // if nub>0, initial part of aptr[] is guaranteed unpermuted
+ const int nub = m_nub;
+ int j=0;
+ for ( ; j<nub; ++j) Dell[j] = aptr[j];
+ const int nC = m_nC;
+ for ( ; j<nC; ++j) Dell[j] = aptr[C[j]];
+# else
+ const int nC = m_nC;
+ for (int j=0; j<nC; ++j) Dell[j] = aptr[C[j]];
+# endif
+ }
+ btSolveL1 (m_L,m_Dell,m_nC,m_nskip);
+ {
+ btScalar *ell = m_ell, *Dell = m_Dell, *d = m_d;
+ const int nC = m_nC;
+ for (int j=0; j<nC; ++j) ell[j] = Dell[j] * d[j];
+ }
+
+ if (!only_transfer) {
+ btScalar *tmp = m_tmp, *ell = m_ell;
+ {
+ const int nC = m_nC;
+ for (int j=0; j<nC; ++j) tmp[j] = ell[j];
+ }
+ btSolveL1T (m_L,tmp,m_nC,m_nskip);
+ if (dir > 0) {
+ int *C = m_C;
+ btScalar *tmp = m_tmp;
+ const int nC = m_nC;
+ for (int j=0; j<nC; ++j) a[C[j]] = -tmp[j];
+ } else {
+ int *C = m_C;
+ btScalar *tmp = m_tmp;
+ const int nC = m_nC;
+ for (int j=0; j<nC; ++j) a[C[j]] = tmp[j];
+ }
+ }
+ }
+}
+
+
+void btLCP::unpermute()
+{
+ // now we have to un-permute x and w
+ {
+ memcpy (m_tmp,m_x,m_n*sizeof(btScalar));
+ btScalar *x = m_x, *tmp = m_tmp;
+ const int *p = m_p;
+ const int n = m_n;
+ for (int j=0; j<n; ++j) x[p[j]] = tmp[j];
+ }
+ {
+ memcpy (m_tmp,m_w,m_n*sizeof(btScalar));
+ btScalar *w = m_w, *tmp = m_tmp;
+ const int *p = m_p;
+ const int n = m_n;
+ for (int j=0; j<n; ++j) w[p[j]] = tmp[j];
+ }
+}
+
+#endif // btLCP_FAST
+
+
+//***************************************************************************
+// an optimized Dantzig LCP driver routine for the lo-hi LCP problem.
+
+bool btSolveDantzigLCP (int n, btScalar *A, btScalar *x, btScalar *b,
+ btScalar* outer_w, int nub, btScalar *lo, btScalar *hi, int *findex, btDantzigScratchMemory& scratchMem)
+{
+ s_error = false;
+
+// printf("btSolveDantzigLCP n=%d\n",n);
+ btAssert (n>0 && A && x && b && lo && hi && nub >= 0 && nub <= n);
+ btAssert(outer_w);
+
+#ifdef BT_DEBUG
+ {
+ // check restrictions on lo and hi
+ for (int k=0; k<n; ++k)
+ btAssert (lo[k] <= 0 && hi[k] >= 0);
+ }
+# endif
+
+
+ // if all the variables are unbounded then we can just factor, solve,
+ // and return
+ if (nub >= n)
+ {
+
+
+ int nskip = (n);
+ btFactorLDLT (A, outer_w, n, nskip);
+ btSolveLDLT (A, outer_w, b, n, nskip);
+ memcpy (x, b, n*sizeof(btScalar));
+
+ return !s_error;
+ }
+
+ const int nskip = (n);
+ scratchMem.L.resize(n*nskip);
+
+ scratchMem.d.resize(n);
+
+ btScalar *w = outer_w;
+ scratchMem.delta_w.resize(n);
+ scratchMem.delta_x.resize(n);
+ scratchMem.Dell.resize(n);
+ scratchMem.ell.resize(n);
+ scratchMem.Arows.resize(n);
+ scratchMem.p.resize(n);
+ scratchMem.C.resize(n);
+
+ // for i in N, state[i] is 0 if x(i)==lo(i) or 1 if x(i)==hi(i)
+ scratchMem.state.resize(n);
+
+
+ // create LCP object. note that tmp is set to delta_w to save space, this
+ // optimization relies on knowledge of how tmp is used, so be careful!
+ btLCP lcp(n,nskip,nub,A,x,b,w,lo,hi,&scratchMem.L[0],&scratchMem.d[0],&scratchMem.Dell[0],&scratchMem.ell[0],&scratchMem.delta_w[0],&scratchMem.state[0],findex,&scratchMem.p[0],&scratchMem.C[0],&scratchMem.Arows[0]);
+ int adj_nub = lcp.getNub();
+
+ // loop over all indexes adj_nub..n-1. for index i, if x(i),w(i) satisfy the
+ // LCP conditions then i is added to the appropriate index set. otherwise
+ // x(i),w(i) is driven either +ve or -ve to force it to the valid region.
+ // as we drive x(i), x(C) is also adjusted to keep w(C) at zero.
+ // while driving x(i) we maintain the LCP conditions on the other variables
+ // 0..i-1. we do this by watching out for other x(i),w(i) values going
+ // outside the valid region, and then switching them between index sets
+ // when that happens.
+
+ bool hit_first_friction_index = false;
+ for (int i=adj_nub; i<n; ++i)
+ {
+ s_error = false;
+ // the index i is the driving index and indexes i+1..n-1 are "dont care",
+ // i.e. when we make changes to the system those x's will be zero and we
+ // don't care what happens to those w's. in other words, we only consider
+ // an (i+1)*(i+1) sub-problem of A*x=b+w.
+
+ // if we've hit the first friction index, we have to compute the lo and
+ // hi values based on the values of x already computed. we have been
+ // permuting the indexes, so the values stored in the findex vector are
+ // no longer valid. thus we have to temporarily unpermute the x vector.
+ // for the purposes of this computation, 0*infinity = 0 ... so if the
+ // contact constraint's normal force is 0, there should be no tangential
+ // force applied.
+
+ if (!hit_first_friction_index && findex && findex[i] >= 0) {
+ // un-permute x into delta_w, which is not being used at the moment
+ for (int j=0; j<n; ++j) scratchMem.delta_w[scratchMem.p[j]] = x[j];
+
+ // set lo and hi values
+ for (int k=i; k<n; ++k) {
+ btScalar wfk = scratchMem.delta_w[findex[k]];
+ if (wfk == 0) {
+ hi[k] = 0;
+ lo[k] = 0;
+ }
+ else {
+ hi[k] = btFabs (hi[k] * wfk);
+ lo[k] = -hi[k];
+ }
+ }
+ hit_first_friction_index = true;
+ }
+
+ // thus far we have not even been computing the w values for indexes
+ // greater than i, so compute w[i] now.
+ w[i] = lcp.AiC_times_qC (i,x) + lcp.AiN_times_qN (i,x) - b[i];
+
+ // if lo=hi=0 (which can happen for tangential friction when normals are
+ // 0) then the index will be assigned to set N with some state. however,
+ // set C's line has zero size, so the index will always remain in set N.
+ // with the "normal" switching logic, if w changed sign then the index
+ // would have to switch to set C and then back to set N with an inverted
+ // state. this is pointless, and also computationally expensive. to
+ // prevent this from happening, we use the rule that indexes with lo=hi=0
+ // will never be checked for set changes. this means that the state for
+ // these indexes may be incorrect, but that doesn't matter.
+
+ // see if x(i),w(i) is in a valid region
+ if (lo[i]==0 && w[i] >= 0) {
+ lcp.transfer_i_to_N (i);
+ scratchMem.state[i] = false;
+ }
+ else if (hi[i]==0 && w[i] <= 0) {
+ lcp.transfer_i_to_N (i);
+ scratchMem.state[i] = true;
+ }
+ else if (w[i]==0) {
+ // this is a degenerate case. by the time we get to this test we know
+ // that lo != 0, which means that lo < 0 as lo is not allowed to be +ve,
+ // and similarly that hi > 0. this means that the line segment
+ // corresponding to set C is at least finite in extent, and we are on it.
+ // NOTE: we must call lcp.solve1() before lcp.transfer_i_to_C()
+ lcp.solve1 (&scratchMem.delta_x[0],i,0,1);
+
+ lcp.transfer_i_to_C (i);
+ }
+ else {
+ // we must push x(i) and w(i)
+ for (;;) {
+ int dir;
+ btScalar dirf;
+ // find direction to push on x(i)
+ if (w[i] <= 0) {
+ dir = 1;
+ dirf = btScalar(1.0);
+ }
+ else {
+ dir = -1;
+ dirf = btScalar(-1.0);
+ }
+
+ // compute: delta_x(C) = -dir*A(C,C)\A(C,i)
+ lcp.solve1 (&scratchMem.delta_x[0],i,dir);
+
+ // note that delta_x[i] = dirf, but we wont bother to set it
+
+ // compute: delta_w = A*delta_x ... note we only care about
+ // delta_w(N) and delta_w(i), the rest is ignored
+ lcp.pN_equals_ANC_times_qC (&scratchMem.delta_w[0],&scratchMem.delta_x[0]);
+ lcp.pN_plusequals_ANi (&scratchMem.delta_w[0],i,dir);
+ scratchMem.delta_w[i] = lcp.AiC_times_qC (i,&scratchMem.delta_x[0]) + lcp.Aii(i)*dirf;
+
+ // find largest step we can take (size=s), either to drive x(i),w(i)
+ // to the valid LCP region or to drive an already-valid variable
+ // outside the valid region.
+
+ int cmd = 1; // index switching command
+ int si = 0; // si = index to switch if cmd>3
+ btScalar s = -w[i]/scratchMem.delta_w[i];
+ if (dir > 0) {
+ if (hi[i] < BT_INFINITY) {
+ btScalar s2 = (hi[i]-x[i])*dirf; // was (hi[i]-x[i])/dirf // step to x(i)=hi(i)
+ if (s2 < s) {
+ s = s2;
+ cmd = 3;
+ }
+ }
+ }
+ else {
+ if (lo[i] > -BT_INFINITY) {
+ btScalar s2 = (lo[i]-x[i])*dirf; // was (lo[i]-x[i])/dirf // step to x(i)=lo(i)
+ if (s2 < s) {
+ s = s2;
+ cmd = 2;
+ }
+ }
+ }
+
+ {
+ const int numN = lcp.numN();
+ for (int k=0; k < numN; ++k) {
+ const int indexN_k = lcp.indexN(k);
+ if (!scratchMem.state[indexN_k] ? scratchMem.delta_w[indexN_k] < 0 : scratchMem.delta_w[indexN_k] > 0) {
+ // don't bother checking if lo=hi=0
+ if (lo[indexN_k] == 0 && hi[indexN_k] == 0) continue;
+ btScalar s2 = -w[indexN_k] / scratchMem.delta_w[indexN_k];
+ if (s2 < s) {
+ s = s2;
+ cmd = 4;
+ si = indexN_k;
+ }
+ }
+ }
+ }
+
+ {
+ const int numC = lcp.numC();
+ for (int k=adj_nub; k < numC; ++k) {
+ const int indexC_k = lcp.indexC(k);
+ if (scratchMem.delta_x[indexC_k] < 0 && lo[indexC_k] > -BT_INFINITY) {
+ btScalar s2 = (lo[indexC_k]-x[indexC_k]) / scratchMem.delta_x[indexC_k];
+ if (s2 < s) {
+ s = s2;
+ cmd = 5;
+ si = indexC_k;
+ }
+ }
+ if (scratchMem.delta_x[indexC_k] > 0 && hi[indexC_k] < BT_INFINITY) {
+ btScalar s2 = (hi[indexC_k]-x[indexC_k]) / scratchMem.delta_x[indexC_k];
+ if (s2 < s) {
+ s = s2;
+ cmd = 6;
+ si = indexC_k;
+ }
+ }
+ }
+ }
+
+ //static char* cmdstring[8] = {0,"->C","->NL","->NH","N->C",
+ // "C->NL","C->NH"};
+ //printf ("cmd=%d (%s), si=%d\n",cmd,cmdstring[cmd],(cmd>3) ? si : i);
+
+ // if s <= 0 then we've got a problem. if we just keep going then
+ // we're going to get stuck in an infinite loop. instead, just cross
+ // our fingers and exit with the current solution.
+ if (s <= btScalar(0.0))
+ {
+// printf("LCP internal error, s <= 0 (s=%.4e)",(double)s);
+ if (i < n) {
+ btSetZero (x+i,n-i);
+ btSetZero (w+i,n-i);
+ }
+ s_error = true;
+ break;
+ }
+
+ // apply x = x + s * delta_x
+ lcp.pC_plusequals_s_times_qC (x, s, &scratchMem.delta_x[0]);
+ x[i] += s * dirf;
+
+ // apply w = w + s * delta_w
+ lcp.pN_plusequals_s_times_qN (w, s, &scratchMem.delta_w[0]);
+ w[i] += s * scratchMem.delta_w[i];
+
+// void *tmpbuf;
+ // switch indexes between sets if necessary
+ switch (cmd) {
+ case 1: // done
+ w[i] = 0;
+ lcp.transfer_i_to_C (i);
+ break;
+ case 2: // done
+ x[i] = lo[i];
+ scratchMem.state[i] = false;
+ lcp.transfer_i_to_N (i);
+ break;
+ case 3: // done
+ x[i] = hi[i];
+ scratchMem.state[i] = true;
+ lcp.transfer_i_to_N (i);
+ break;
+ case 4: // keep going
+ w[si] = 0;
+ lcp.transfer_i_from_N_to_C (si);
+ break;
+ case 5: // keep going
+ x[si] = lo[si];
+ scratchMem.state[si] = false;
+ lcp.transfer_i_from_C_to_N (si, scratchMem.m_scratch);
+ break;
+ case 6: // keep going
+ x[si] = hi[si];
+ scratchMem.state[si] = true;
+ lcp.transfer_i_from_C_to_N (si, scratchMem.m_scratch);
+ break;
+ }
+
+ if (cmd <= 3) break;
+ } // for (;;)
+ } // else
+
+ if (s_error)
+ {
+ break;
+ }
+ } // for (int i=adj_nub; i<n; ++i)
+
+ lcp.unpermute();
+
+
+ return !s_error;
+}
+
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.h
new file mode 100644
index 00000000000..903832770ae
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.h
@@ -0,0 +1,77 @@
+/*************************************************************************
+ * *
+ * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
+ * All rights reserved. Email: russ@q12.org Web: www.q12.org *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of *
+ * The BSD-style license that is included with this library in *
+ * the file LICENSE-BSD.TXT. *
+ * *
+ * This library 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 files *
+ * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
+ * *
+ *************************************************************************/
+
+/*
+
+given (A,b,lo,hi), solve the LCP problem: A*x = b+w, where each x(i),w(i)
+satisfies one of
+ (1) x = lo, w >= 0
+ (2) x = hi, w <= 0
+ (3) lo < x < hi, w = 0
+A is a matrix of dimension n*n, everything else is a vector of size n*1.
+lo and hi can be +/- dInfinity as needed. the first `nub' variables are
+unbounded, i.e. hi and lo are assumed to be +/- dInfinity.
+
+we restrict lo(i) <= 0 and hi(i) >= 0.
+
+the original data (A,b) may be modified by this function.
+
+if the `findex' (friction index) parameter is nonzero, it points to an array
+of index values. in this case constraints that have findex[i] >= 0 are
+special. all non-special constraints are solved for, then the lo and hi values
+for the special constraints are set:
+ hi[i] = abs( hi[i] * x[findex[i]] )
+ lo[i] = -hi[i]
+and the solution continues. this mechanism allows a friction approximation
+to be implemented. the first `nub' variables are assumed to have findex < 0.
+
+*/
+
+
+#ifndef _BT_LCP_H_
+#define _BT_LCP_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+
+#include "LinearMath/btScalar.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+struct btDantzigScratchMemory
+{
+ btAlignedObjectArray<btScalar> m_scratch;
+ btAlignedObjectArray<btScalar> L;
+ btAlignedObjectArray<btScalar> d;
+ btAlignedObjectArray<btScalar> delta_w;
+ btAlignedObjectArray<btScalar> delta_x;
+ btAlignedObjectArray<btScalar> Dell;
+ btAlignedObjectArray<btScalar> ell;
+ btAlignedObjectArray<btScalar*> Arows;
+ btAlignedObjectArray<int> p;
+ btAlignedObjectArray<int> C;
+ btAlignedObjectArray<bool> state;
+};
+
+//return false if solving failed
+bool btSolveDantzigLCP (int n, btScalar *A, btScalar *x, btScalar *b, btScalar *w,
+ int nub, btScalar *lo, btScalar *hi, int *findex,btDantzigScratchMemory& scratch);
+
+
+
+#endif //_BT_LCP_H_
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h
new file mode 100644
index 00000000000..2a2f2d3d32d
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h
@@ -0,0 +1,112 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///original version written by Erwin Coumans, October 2013
+
+#ifndef BT_DANTZIG_SOLVER_H
+#define BT_DANTZIG_SOLVER_H
+
+#include "btMLCPSolverInterface.h"
+#include "btDantzigLCP.h"
+
+
+class btDantzigSolver : public btMLCPSolverInterface
+{
+protected:
+
+ btScalar m_acceptableUpperLimitSolution;
+
+ btAlignedObjectArray<char> m_tempBuffer;
+
+ btAlignedObjectArray<btScalar> m_A;
+ btAlignedObjectArray<btScalar> m_b;
+ btAlignedObjectArray<btScalar> m_x;
+ btAlignedObjectArray<btScalar> m_lo;
+ btAlignedObjectArray<btScalar> m_hi;
+ btAlignedObjectArray<int> m_dependencies;
+ btDantzigScratchMemory m_scratchMemory;
+public:
+
+ btDantzigSolver()
+ :m_acceptableUpperLimitSolution(btScalar(1000))
+ {
+ }
+
+ virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray<int>& limitDependency, int numIterations, bool useSparsity = true)
+ {
+ bool result = true;
+ int n = b.rows();
+ if (n)
+ {
+ int nub = 0;
+ btAlignedObjectArray<btScalar> ww;
+ ww.resize(n);
+
+
+ const btScalar* Aptr = A.getBufferPointer();
+ m_A.resize(n*n);
+ for (int i=0;i<n*n;i++)
+ {
+ m_A[i] = Aptr[i];
+
+ }
+
+ m_b.resize(n);
+ m_x.resize(n);
+ m_lo.resize(n);
+ m_hi.resize(n);
+ m_dependencies.resize(n);
+ for (int i=0;i<n;i++)
+ {
+ m_lo[i] = lo[i];
+ m_hi[i] = hi[i];
+ m_b[i] = b[i];
+ m_x[i] = x[i];
+ m_dependencies[i] = limitDependency[i];
+ }
+
+
+ result = btSolveDantzigLCP (n,&m_A[0],&m_x[0],&m_b[0],&ww[0],nub,&m_lo[0],&m_hi[0],&m_dependencies[0],m_scratchMemory);
+ if (!result)
+ return result;
+
+// printf("numAllocas = %d\n",numAllocas);
+ for (int i=0;i<n;i++)
+ {
+ volatile btScalar xx = m_x[i];
+ if (xx != m_x[i])
+ return false;
+ if (x[i] >= m_acceptableUpperLimitSolution)
+ {
+ return false;
+ }
+
+ if (x[i] <= -m_acceptableUpperLimitSolution)
+ {
+ return false;
+ }
+ }
+
+ for (int i=0;i<n;i++)
+ {
+ x[i] = m_x[i];
+ }
+
+ }
+
+ return result;
+ }
+};
+
+#endif //BT_DANTZIG_SOLVER_H
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
new file mode 100644
index 00000000000..8888d3961f5
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
@@ -0,0 +1,626 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///original version written by Erwin Coumans, October 2013
+
+#include "btMLCPSolver.h"
+#include "LinearMath/btMatrixX.h"
+#include "LinearMath/btQuickprof.h"
+#include "btSolveProjectedGaussSeidel.h"
+
+btMLCPSolver::btMLCPSolver( btMLCPSolverInterface* solver)
+:m_solver(solver),
+m_fallback(0)
+{
+}
+
+btMLCPSolver::~btMLCPSolver()
+{
+}
+
+bool gUseMatrixMultiply = false;
+bool interleaveContactAndFriction = false;
+
+btScalar btMLCPSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodiesUnUsed, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
+{
+ btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup( bodies, numBodiesUnUsed, manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer);
+
+ {
+ BT_PROFILE("gather constraint data");
+
+ int numFrictionPerContact = m_tmpSolverContactConstraintPool.size()==m_tmpSolverContactFrictionConstraintPool.size()? 1 : 2;
+
+
+ int numBodies = m_tmpSolverBodyPool.size();
+ m_allConstraintArray.resize(0);
+ m_limitDependencies.resize(m_tmpSolverNonContactConstraintPool.size()+m_tmpSolverContactConstraintPool.size()+m_tmpSolverContactFrictionConstraintPool.size());
+ btAssert(m_limitDependencies.size() == m_tmpSolverNonContactConstraintPool.size()+m_tmpSolverContactConstraintPool.size()+m_tmpSolverContactFrictionConstraintPool.size());
+ // printf("m_limitDependencies.size() = %d\n",m_limitDependencies.size());
+
+ int dindex = 0;
+ for (int i=0;i<m_tmpSolverNonContactConstraintPool.size();i++)
+ {
+ m_allConstraintArray.push_back(m_tmpSolverNonContactConstraintPool[i]);
+ m_limitDependencies[dindex++] = -1;
+ }
+
+ ///The btSequentialImpulseConstraintSolver moves all friction constraints at the very end, we can also interleave them instead
+
+ int firstContactConstraintOffset=dindex;
+
+ if (interleaveContactAndFriction)
+ {
+ for (int i=0;i<m_tmpSolverContactConstraintPool.size();i++)
+ {
+ m_allConstraintArray.push_back(m_tmpSolverContactConstraintPool[i]);
+ m_limitDependencies[dindex++] = -1;
+ m_allConstraintArray.push_back(m_tmpSolverContactFrictionConstraintPool[i*numFrictionPerContact]);
+ int findex = (m_tmpSolverContactFrictionConstraintPool[i*numFrictionPerContact].m_frictionIndex*(1+numFrictionPerContact));
+ m_limitDependencies[dindex++] = findex +firstContactConstraintOffset;
+ if (numFrictionPerContact==2)
+ {
+ m_allConstraintArray.push_back(m_tmpSolverContactFrictionConstraintPool[i*numFrictionPerContact+1]);
+ m_limitDependencies[dindex++] = findex+firstContactConstraintOffset;
+ }
+ }
+ } else
+ {
+ for (int i=0;i<m_tmpSolverContactConstraintPool.size();i++)
+ {
+ m_allConstraintArray.push_back(m_tmpSolverContactConstraintPool[i]);
+ m_limitDependencies[dindex++] = -1;
+ }
+ for (int i=0;i<m_tmpSolverContactFrictionConstraintPool.size();i++)
+ {
+ m_allConstraintArray.push_back(m_tmpSolverContactFrictionConstraintPool[i]);
+ m_limitDependencies[dindex++] = m_tmpSolverContactFrictionConstraintPool[i].m_frictionIndex+firstContactConstraintOffset;
+ }
+
+ }
+
+
+ if (!m_allConstraintArray.size())
+ {
+ m_A.resize(0,0);
+ m_b.resize(0);
+ m_x.resize(0);
+ m_lo.resize(0);
+ m_hi.resize(0);
+ return 0.f;
+ }
+ }
+
+
+ if (gUseMatrixMultiply)
+ {
+ BT_PROFILE("createMLCP");
+ createMLCP(infoGlobal);
+ }
+ else
+ {
+ BT_PROFILE("createMLCPFast");
+ createMLCPFast(infoGlobal);
+ }
+
+ return 0.f;
+}
+
+bool btMLCPSolver::solveMLCP(const btContactSolverInfo& infoGlobal)
+{
+ bool result = true;
+
+ if (m_A.rows()==0)
+ return true;
+
+ //if using split impulse, we solve 2 separate (M)LCPs
+ if (infoGlobal.m_splitImpulse)
+ {
+ btMatrixXu Acopy = m_A;
+ btAlignedObjectArray<int> limitDependenciesCopy = m_limitDependencies;
+// printf("solve first LCP\n");
+ result = m_solver->solveMLCP(m_A, m_b, m_x, m_lo,m_hi, m_limitDependencies,infoGlobal.m_numIterations );
+ if (result)
+ result = m_solver->solveMLCP(Acopy, m_bSplit, m_xSplit, m_lo,m_hi, limitDependenciesCopy,infoGlobal.m_numIterations );
+
+ } else
+ {
+ result = m_solver->solveMLCP(m_A, m_b, m_x, m_lo,m_hi, m_limitDependencies,infoGlobal.m_numIterations );
+ }
+ return result;
+}
+
+struct btJointNode
+{
+ int jointIndex; // pointer to enclosing dxJoint object
+ int otherBodyIndex; // *other* body this joint is connected to
+ int nextJointNodeIndex;//-1 for null
+ int constraintRowIndex;
+};
+
+
+
+void btMLCPSolver::createMLCPFast(const btContactSolverInfo& infoGlobal)
+{
+ int numContactRows = interleaveContactAndFriction ? 3 : 1;
+
+ int numConstraintRows = m_allConstraintArray.size();
+ int n = numConstraintRows;
+ {
+ BT_PROFILE("init b (rhs)");
+ m_b.resize(numConstraintRows);
+ m_bSplit.resize(numConstraintRows);
+ //m_b.setZero();
+ for (int i=0;i<numConstraintRows ;i++)
+ {
+ if (m_allConstraintArray[i].m_jacDiagABInv)
+ {
+ m_b[i]=m_allConstraintArray[i].m_rhs/m_allConstraintArray[i].m_jacDiagABInv;
+ m_bSplit[i] = m_allConstraintArray[i].m_rhsPenetration/m_allConstraintArray[i].m_jacDiagABInv;
+ }
+
+ }
+ }
+
+ btScalar* w = 0;
+ int nub = 0;
+
+ m_lo.resize(numConstraintRows);
+ m_hi.resize(numConstraintRows);
+
+ {
+ BT_PROFILE("init lo/ho");
+
+ for (int i=0;i<numConstraintRows;i++)
+ {
+ if (0)//m_limitDependencies[i]>=0)
+ {
+ m_lo[i] = -BT_INFINITY;
+ m_hi[i] = BT_INFINITY;
+ } else
+ {
+ m_lo[i] = m_allConstraintArray[i].m_lowerLimit;
+ m_hi[i] = m_allConstraintArray[i].m_upperLimit;
+ }
+ }
+ }
+
+ //
+ int m=m_allConstraintArray.size();
+
+ int numBodies = m_tmpSolverBodyPool.size();
+ btAlignedObjectArray<int> bodyJointNodeArray;
+ {
+ BT_PROFILE("bodyJointNodeArray.resize");
+ bodyJointNodeArray.resize(numBodies,-1);
+ }
+ btAlignedObjectArray<btJointNode> jointNodeArray;
+ {
+ BT_PROFILE("jointNodeArray.reserve");
+ jointNodeArray.reserve(2*m_allConstraintArray.size());
+ }
+
+ static btMatrixXu J3;
+ {
+ BT_PROFILE("J3.resize");
+ J3.resize(2*m,8);
+ }
+ static btMatrixXu JinvM3;
+ {
+ BT_PROFILE("JinvM3.resize/setZero");
+
+ JinvM3.resize(2*m,8);
+ JinvM3.setZero();
+ J3.setZero();
+ }
+ int cur=0;
+ int rowOffset = 0;
+ static btAlignedObjectArray<int> ofs;
+ {
+ BT_PROFILE("ofs resize");
+ ofs.resize(0);
+ ofs.resizeNoInitialize(m_allConstraintArray.size());
+ }
+ {
+ BT_PROFILE("Compute J and JinvM");
+ int c=0;
+
+ int numRows = 0;
+
+ for (int i=0;i<m_allConstraintArray.size();i+=numRows,c++)
+ {
+ ofs[c] = rowOffset;
+ int sbA = m_allConstraintArray[i].m_solverBodyIdA;
+ int sbB = m_allConstraintArray[i].m_solverBodyIdB;
+ btRigidBody* orgBodyA = m_tmpSolverBodyPool[sbA].m_originalBody;
+ btRigidBody* orgBodyB = m_tmpSolverBodyPool[sbB].m_originalBody;
+
+ numRows = i<m_tmpSolverNonContactConstraintPool.size() ? m_tmpConstraintSizesPool[c].m_numConstraintRows : numContactRows ;
+ if (orgBodyA)
+ {
+ {
+ int slotA=-1;
+ //find free jointNode slot for sbA
+ slotA =jointNodeArray.size();
+ jointNodeArray.expand();//NonInitializing();
+ int prevSlot = bodyJointNodeArray[sbA];
+ bodyJointNodeArray[sbA] = slotA;
+ jointNodeArray[slotA].nextJointNodeIndex = prevSlot;
+ jointNodeArray[slotA].jointIndex = c;
+ jointNodeArray[slotA].constraintRowIndex = i;
+ jointNodeArray[slotA].otherBodyIndex = orgBodyB ? sbB : -1;
+ }
+ for (int row=0;row<numRows;row++,cur++)
+ {
+ btVector3 normalInvMass = m_allConstraintArray[i+row].m_contactNormal1 * orgBodyA->getInvMass();
+ btVector3 relPosCrossNormalInvInertia = m_allConstraintArray[i+row].m_relpos1CrossNormal * orgBodyA->getInvInertiaTensorWorld();
+
+ for (int r=0;r<3;r++)
+ {
+ J3.setElem(cur,r,m_allConstraintArray[i+row].m_contactNormal1[r]);
+ J3.setElem(cur,r+4,m_allConstraintArray[i+row].m_relpos1CrossNormal[r]);
+ JinvM3.setElem(cur,r,normalInvMass[r]);
+ JinvM3.setElem(cur,r+4,relPosCrossNormalInvInertia[r]);
+ }
+ J3.setElem(cur,3,0);
+ JinvM3.setElem(cur,3,0);
+ J3.setElem(cur,7,0);
+ JinvM3.setElem(cur,7,0);
+ }
+ } else
+ {
+ cur += numRows;
+ }
+ if (orgBodyB)
+ {
+
+ {
+ int slotB=-1;
+ //find free jointNode slot for sbA
+ slotB =jointNodeArray.size();
+ jointNodeArray.expand();//NonInitializing();
+ int prevSlot = bodyJointNodeArray[sbB];
+ bodyJointNodeArray[sbB] = slotB;
+ jointNodeArray[slotB].nextJointNodeIndex = prevSlot;
+ jointNodeArray[slotB].jointIndex = c;
+ jointNodeArray[slotB].otherBodyIndex = orgBodyA ? sbA : -1;
+ jointNodeArray[slotB].constraintRowIndex = i;
+ }
+
+ for (int row=0;row<numRows;row++,cur++)
+ {
+ btVector3 normalInvMassB = m_allConstraintArray[i+row].m_contactNormal2*orgBodyB->getInvMass();
+ btVector3 relPosInvInertiaB = m_allConstraintArray[i+row].m_relpos2CrossNormal * orgBodyB->getInvInertiaTensorWorld();
+
+ for (int r=0;r<3;r++)
+ {
+ J3.setElem(cur,r,m_allConstraintArray[i+row].m_contactNormal2[r]);
+ J3.setElem(cur,r+4,m_allConstraintArray[i+row].m_relpos2CrossNormal[r]);
+ JinvM3.setElem(cur,r,normalInvMassB[r]);
+ JinvM3.setElem(cur,r+4,relPosInvInertiaB[r]);
+ }
+ J3.setElem(cur,3,0);
+ JinvM3.setElem(cur,3,0);
+ J3.setElem(cur,7,0);
+ JinvM3.setElem(cur,7,0);
+ }
+ }
+ else
+ {
+ cur += numRows;
+ }
+ rowOffset+=numRows;
+
+ }
+
+ }
+
+
+ //compute JinvM = J*invM.
+ const btScalar* JinvM = JinvM3.getBufferPointer();
+
+ const btScalar* Jptr = J3.getBufferPointer();
+ {
+ BT_PROFILE("m_A.resize");
+ m_A.resize(n,n);
+ }
+
+ {
+ BT_PROFILE("m_A.setZero");
+ m_A.setZero();
+ }
+ int c=0;
+ {
+ int numRows = 0;
+ BT_PROFILE("Compute A");
+ for (int i=0;i<m_allConstraintArray.size();i+= numRows,c++)
+ {
+ int row__ = ofs[c];
+ int sbA = m_allConstraintArray[i].m_solverBodyIdA;
+ int sbB = m_allConstraintArray[i].m_solverBodyIdB;
+ btRigidBody* orgBodyA = m_tmpSolverBodyPool[sbA].m_originalBody;
+ btRigidBody* orgBodyB = m_tmpSolverBodyPool[sbB].m_originalBody;
+
+ numRows = i<m_tmpSolverNonContactConstraintPool.size() ? m_tmpConstraintSizesPool[c].m_numConstraintRows : numContactRows ;
+
+ const btScalar *JinvMrow = JinvM + 2*8*(size_t)row__;
+
+ {
+ int startJointNodeA = bodyJointNodeArray[sbA];
+ while (startJointNodeA>=0)
+ {
+ int j0 = jointNodeArray[startJointNodeA].jointIndex;
+ int cr0 = jointNodeArray[startJointNodeA].constraintRowIndex;
+ if (j0<c)
+ {
+
+ int numRowsOther = cr0 < m_tmpSolverNonContactConstraintPool.size() ? m_tmpConstraintSizesPool[j0].m_numConstraintRows : numContactRows;
+ size_t ofsother = (m_allConstraintArray[cr0].m_solverBodyIdB == sbA) ? 8*numRowsOther : 0;
+ //printf("%d joint i %d and j0: %d: ",count++,i,j0);
+ m_A.multiplyAdd2_p8r ( JinvMrow,
+ Jptr + 2*8*(size_t)ofs[j0] + ofsother, numRows, numRowsOther, row__,ofs[j0]);
+ }
+ startJointNodeA = jointNodeArray[startJointNodeA].nextJointNodeIndex;
+ }
+ }
+
+ {
+ int startJointNodeB = bodyJointNodeArray[sbB];
+ while (startJointNodeB>=0)
+ {
+ int j1 = jointNodeArray[startJointNodeB].jointIndex;
+ int cj1 = jointNodeArray[startJointNodeB].constraintRowIndex;
+
+ if (j1<c)
+ {
+ int numRowsOther = cj1 < m_tmpSolverNonContactConstraintPool.size() ? m_tmpConstraintSizesPool[j1].m_numConstraintRows : numContactRows;
+ size_t ofsother = (m_allConstraintArray[cj1].m_solverBodyIdB == sbB) ? 8*numRowsOther : 0;
+ m_A.multiplyAdd2_p8r ( JinvMrow + 8*(size_t)numRows,
+ Jptr + 2*8*(size_t)ofs[j1] + ofsother, numRows, numRowsOther, row__,ofs[j1]);
+ }
+ startJointNodeB = jointNodeArray[startJointNodeB].nextJointNodeIndex;
+ }
+ }
+ }
+
+ {
+ BT_PROFILE("compute diagonal");
+ // compute diagonal blocks of m_A
+
+ int row__ = 0;
+ int numJointRows = m_allConstraintArray.size();
+
+ int jj=0;
+ for (;row__<numJointRows;)
+ {
+
+ int sbA = m_allConstraintArray[row__].m_solverBodyIdA;
+ int sbB = m_allConstraintArray[row__].m_solverBodyIdB;
+ btRigidBody* orgBodyA = m_tmpSolverBodyPool[sbA].m_originalBody;
+ btRigidBody* orgBodyB = m_tmpSolverBodyPool[sbB].m_originalBody;
+
+
+ const unsigned int infom = row__ < m_tmpSolverNonContactConstraintPool.size() ? m_tmpConstraintSizesPool[jj].m_numConstraintRows : numContactRows;
+
+ const btScalar *JinvMrow = JinvM + 2*8*(size_t)row__;
+ const btScalar *Jrow = Jptr + 2*8*(size_t)row__;
+ m_A.multiply2_p8r (JinvMrow, Jrow, infom, infom, row__,row__);
+ if (orgBodyB)
+ {
+ m_A.multiplyAdd2_p8r (JinvMrow + 8*(size_t)infom, Jrow + 8*(size_t)infom, infom, infom, row__,row__);
+ }
+ row__ += infom;
+ jj++;
+ }
+ }
+ }
+
+ ///todo: use proper cfm values from the constraints (getInfo2)
+ if (1)
+ {
+ // add cfm to the diagonal of m_A
+ for ( int i=0; i<m_A.rows(); ++i)
+ {
+ float cfm = 0.00001f;
+ m_A.setElem(i,i,m_A(i,i)+ cfm / infoGlobal.m_timeStep);
+ }
+ }
+
+ ///fill the upper triangle of the matrix, to make it symmetric
+ {
+ BT_PROFILE("fill the upper triangle ");
+ m_A.copyLowerToUpperTriangle();
+ }
+
+ {
+ BT_PROFILE("resize/init x");
+ m_x.resize(numConstraintRows);
+ m_xSplit.resize(numConstraintRows);
+
+ if (infoGlobal.m_solverMode&SOLVER_USE_WARMSTARTING)
+ {
+ for (int i=0;i<m_allConstraintArray.size();i++)
+ {
+ const btSolverConstraint& c = m_allConstraintArray[i];
+ m_x[i]=c.m_appliedImpulse;
+ m_xSplit[i] = c.m_appliedPushImpulse;
+ }
+ } else
+ {
+ m_x.setZero();
+ m_xSplit.setZero();
+ }
+ }
+
+}
+
+void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
+{
+ int numBodies = this->m_tmpSolverBodyPool.size();
+ int numConstraintRows = m_allConstraintArray.size();
+
+ m_b.resize(numConstraintRows);
+ if (infoGlobal.m_splitImpulse)
+ m_bSplit.resize(numConstraintRows);
+
+ for (int i=0;i<numConstraintRows ;i++)
+ {
+ if (m_allConstraintArray[i].m_jacDiagABInv)
+ {
+ m_b[i]=m_allConstraintArray[i].m_rhs/m_allConstraintArray[i].m_jacDiagABInv;
+ if (infoGlobal.m_splitImpulse)
+ m_bSplit[i] = m_allConstraintArray[i].m_rhsPenetration/m_allConstraintArray[i].m_jacDiagABInv;
+ }
+ }
+
+ static btMatrixXu Minv;
+ Minv.resize(6*numBodies,6*numBodies);
+ Minv.setZero();
+ for (int i=0;i<numBodies;i++)
+ {
+ const btSolverBody& rb = m_tmpSolverBodyPool[i];
+ const btVector3& invMass = rb.m_invMass;
+ setElem(Minv,i*6+0,i*6+0,invMass[0]);
+ setElem(Minv,i*6+1,i*6+1,invMass[1]);
+ setElem(Minv,i*6+2,i*6+2,invMass[2]);
+ btRigidBody* orgBody = m_tmpSolverBodyPool[i].m_originalBody;
+
+ for (int r=0;r<3;r++)
+ for (int c=0;c<3;c++)
+ setElem(Minv,i*6+3+r,i*6+3+c,orgBody? orgBody->getInvInertiaTensorWorld()[r][c] : 0);
+ }
+
+ static btMatrixXu J;
+ J.resize(numConstraintRows,6*numBodies);
+ J.setZero();
+
+ m_lo.resize(numConstraintRows);
+ m_hi.resize(numConstraintRows);
+
+ for (int i=0;i<numConstraintRows;i++)
+ {
+
+ m_lo[i] = m_allConstraintArray[i].m_lowerLimit;
+ m_hi[i] = m_allConstraintArray[i].m_upperLimit;
+
+ int bodyIndex0 = m_allConstraintArray[i].m_solverBodyIdA;
+ int bodyIndex1 = m_allConstraintArray[i].m_solverBodyIdB;
+ if (m_tmpSolverBodyPool[bodyIndex0].m_originalBody)
+ {
+ setElem(J,i,6*bodyIndex0+0,m_allConstraintArray[i].m_contactNormal1[0]);
+ setElem(J,i,6*bodyIndex0+1,m_allConstraintArray[i].m_contactNormal1[1]);
+ setElem(J,i,6*bodyIndex0+2,m_allConstraintArray[i].m_contactNormal1[2]);
+ setElem(J,i,6*bodyIndex0+3,m_allConstraintArray[i].m_relpos1CrossNormal[0]);
+ setElem(J,i,6*bodyIndex0+4,m_allConstraintArray[i].m_relpos1CrossNormal[1]);
+ setElem(J,i,6*bodyIndex0+5,m_allConstraintArray[i].m_relpos1CrossNormal[2]);
+ }
+ if (m_tmpSolverBodyPool[bodyIndex1].m_originalBody)
+ {
+ setElem(J,i,6*bodyIndex1+0,m_allConstraintArray[i].m_contactNormal2[0]);
+ setElem(J,i,6*bodyIndex1+1,m_allConstraintArray[i].m_contactNormal2[1]);
+ setElem(J,i,6*bodyIndex1+2,m_allConstraintArray[i].m_contactNormal2[2]);
+ setElem(J,i,6*bodyIndex1+3,m_allConstraintArray[i].m_relpos2CrossNormal[0]);
+ setElem(J,i,6*bodyIndex1+4,m_allConstraintArray[i].m_relpos2CrossNormal[1]);
+ setElem(J,i,6*bodyIndex1+5,m_allConstraintArray[i].m_relpos2CrossNormal[2]);
+ }
+ }
+
+ static btMatrixXu J_transpose;
+ J_transpose= J.transpose();
+
+ static btMatrixXu tmp;
+
+ {
+ {
+ BT_PROFILE("J*Minv");
+ tmp = J*Minv;
+
+ }
+ {
+ BT_PROFILE("J*tmp");
+ m_A = tmp*J_transpose;
+ }
+ }
+
+ if (1)
+ {
+ ///todo: use proper cfm values from the constraints (getInfo2)
+ // add cfm to the diagonal of m_A
+ for ( int i=0; i<m_A.rows(); ++i)
+ {
+ float cfm = 0.0001f;
+ m_A.setElem(i,i,m_A(i,i)+ cfm / infoGlobal.m_timeStep);
+ }
+ }
+
+ m_x.resize(numConstraintRows);
+ if (infoGlobal.m_splitImpulse)
+ m_xSplit.resize(numConstraintRows);
+// m_x.setZero();
+
+ for (int i=0;i<m_allConstraintArray.size();i++)
+ {
+ const btSolverConstraint& c = m_allConstraintArray[i];
+ m_x[i]=c.m_appliedImpulse;
+ if (infoGlobal.m_splitImpulse)
+ m_xSplit[i] = c.m_appliedPushImpulse;
+ }
+
+}
+
+
+btScalar btMLCPSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
+{
+ bool result = true;
+ {
+ BT_PROFILE("solveMLCP");
+// printf("m_A(%d,%d)\n", m_A.rows(),m_A.cols());
+ result = solveMLCP(infoGlobal);
+ }
+
+ //check if solution is valid, and otherwise fallback to btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations
+ if (result)
+ {
+ BT_PROFILE("process MLCP results");
+ for (int i=0;i<m_allConstraintArray.size();i++)
+ {
+ {
+ btSolverConstraint& c = m_allConstraintArray[i];
+ int sbA = c.m_solverBodyIdA;
+ int sbB = c.m_solverBodyIdB;
+ btRigidBody* orgBodyA = m_tmpSolverBodyPool[sbA].m_originalBody;
+ btRigidBody* orgBodyB = m_tmpSolverBodyPool[sbB].m_originalBody;
+
+ btSolverBody& solverBodyA = m_tmpSolverBodyPool[sbA];
+ btSolverBody& solverBodyB = m_tmpSolverBodyPool[sbB];
+
+ solverBodyA.internalApplyImpulse(c.m_contactNormal1*solverBodyA.internalGetInvMass(),c.m_angularComponentA,m_x[i]);
+ solverBodyB.internalApplyImpulse(c.m_contactNormal2*solverBodyB.internalGetInvMass(),c.m_angularComponentB,m_x[i]);
+ if (infoGlobal.m_splitImpulse)
+ {
+ solverBodyA.internalApplyPushImpulse(c.m_contactNormal1*solverBodyA.internalGetInvMass(),c.m_angularComponentA,m_xSplit[i]);
+ solverBodyB.internalApplyPushImpulse(c.m_contactNormal2*solverBodyB.internalGetInvMass(),c.m_angularComponentB,m_xSplit[i]);
+ c.m_appliedPushImpulse = m_xSplit[i];
+ }
+ c.m_appliedImpulse = m_x[i];
+ }
+ }
+ }
+ else
+ {
+ m_fallback++;
+ btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer);
+ }
+
+ return 0.f;
+} \ No newline at end of file
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h
new file mode 100644
index 00000000000..a5dae2d28f6
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h
@@ -0,0 +1,81 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///original version written by Erwin Coumans, October 2013
+
+#ifndef BT_MLCP_SOLVER_H
+#define BT_MLCP_SOLVER_H
+
+#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
+#include "LinearMath/btMatrixX.h"
+#include "BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h"
+
+class btMLCPSolver : public btSequentialImpulseConstraintSolver
+{
+
+protected:
+
+ btMatrixXu m_A;
+ btVectorXu m_b;
+ btVectorXu m_x;
+ btVectorXu m_lo;
+ btVectorXu m_hi;
+
+ ///when using 'split impulse' we solve two separate (M)LCPs
+ btVectorXu m_bSplit;
+ btVectorXu m_xSplit;
+ btVectorXu m_bSplit1;
+ btVectorXu m_xSplit2;
+
+ btAlignedObjectArray<int> m_limitDependencies;
+ btConstraintArray m_allConstraintArray;
+ btMLCPSolverInterface* m_solver;
+ int m_fallback;
+
+ virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
+ virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
+ virtual void createMLCP(const btContactSolverInfo& infoGlobal);
+ virtual void createMLCPFast(const btContactSolverInfo& infoGlobal);
+
+ //return true is it solves the problem successfully
+ virtual bool solveMLCP(const btContactSolverInfo& infoGlobal);
+
+public:
+
+ btMLCPSolver( btMLCPSolverInterface* solver);
+ virtual ~btMLCPSolver();
+
+ void setMLCPSolver(btMLCPSolverInterface* solver)
+ {
+ m_solver = solver;
+ }
+
+ int getNumFallbacks() const
+ {
+ return m_fallback;
+ }
+ void setNumFallbacks(int num)
+ {
+ m_fallback = num;
+ }
+
+ virtual btConstraintSolverType getSolverType() const
+ {
+ return BT_MLCP_SOLVER;
+ }
+
+};
+
+
+#endif //BT_MLCP_SOLVER_H
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h
new file mode 100644
index 00000000000..25bb3f6d327
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h
@@ -0,0 +1,33 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///original version written by Erwin Coumans, October 2013
+
+#ifndef BT_MLCP_SOLVER_INTERFACE_H
+#define BT_MLCP_SOLVER_INTERFACE_H
+
+#include "LinearMath/btMatrixX.h"
+
+class btMLCPSolverInterface
+{
+public:
+ virtual ~btMLCPSolverInterface()
+ {
+ }
+
+ //return true is it solves the problem successfully
+ virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray<int>& limitDependency, int numIterations, bool useSparsity = true)=0;
+};
+
+#endif //BT_MLCP_SOLVER_INTERFACE_H
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h
new file mode 100644
index 00000000000..9ec31a6d4e4
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h
@@ -0,0 +1,151 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///original version written by Erwin Coumans, October 2013
+
+
+#ifndef BT_PATH_SOLVER_H
+#define BT_PATH_SOLVER_H
+
+//#define BT_USE_PATH
+#ifdef BT_USE_PATH
+
+extern "C" {
+#include "PATH/SimpleLCP.h"
+#include "PATH/License.h"
+#include "PATH/Error_Interface.h"
+};
+ void __stdcall MyError(Void *data, Char *msg)
+{
+ printf("Path Error: %s\n",msg);
+}
+ void __stdcall MyWarning(Void *data, Char *msg)
+{
+ printf("Path Warning: %s\n",msg);
+}
+
+Error_Interface e;
+
+
+
+#include "btMLCPSolverInterface.h"
+#include "Dantzig/lcp.h"
+
+class btPathSolver : public btMLCPSolverInterface
+{
+public:
+
+ btPathSolver()
+ {
+ License_SetString("2069810742&Courtesy_License&&&USR&2013&14_12_2011&1000&PATH&GEN&31_12_2013&0_0_0&0&0_0");
+ e.error_data = 0;
+ e.warning = MyWarning;
+ e.error = MyError;
+ Error_SetInterface(&e);
+ }
+
+
+ virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray<int>& limitDependency, int numIterations, bool useSparsity = true)
+ {
+ MCP_Termination status;
+
+
+ int numVariables = b.rows();
+ if (0==numVariables)
+ return true;
+
+ /* - variables - the number of variables in the problem
+ - m_nnz - the number of nonzeros in the M matrix
+ - m_i - a vector of size m_nnz containing the row indices for M
+ - m_j - a vector of size m_nnz containing the column indices for M
+ - m_ij - a vector of size m_nnz containing the data for M
+ - q - a vector of size variables
+ - lb - a vector of size variables containing the lower bounds on x
+ - ub - a vector of size variables containing the upper bounds on x
+ */
+ btAlignedObjectArray<double> values;
+ btAlignedObjectArray<int> rowIndices;
+ btAlignedObjectArray<int> colIndices;
+
+ for (int i=0;i<A.rows();i++)
+ {
+ for (int j=0;j<A.cols();j++)
+ {
+ if (A(i,j)!=0.f)
+ {
+ //add 1, because Path starts at 1, instead of 0
+ rowIndices.push_back(i+1);
+ colIndices.push_back(j+1);
+ values.push_back(A(i,j));
+ }
+ }
+ }
+ int numNonZero = rowIndices.size();
+ btAlignedObjectArray<double> zResult;
+ zResult.resize(numVariables);
+ btAlignedObjectArray<double> rhs;
+ btAlignedObjectArray<double> upperBounds;
+ btAlignedObjectArray<double> lowerBounds;
+ for (int i=0;i<numVariables;i++)
+ {
+ upperBounds.push_back(hi[i]);
+ lowerBounds.push_back(lo[i]);
+ rhs.push_back(-b[i]);
+ }
+
+
+ SimpleLCP(numVariables,numNonZero,&rowIndices[0],&colIndices[0],&values[0],&rhs[0],&lowerBounds[0],&upperBounds[0], &status, &zResult[0]);
+
+ if (status != MCP_Solved)
+ {
+ static const char* gReturnMsgs[] = {
+ "Invalid return",
+ "MCP_Solved: The problem was solved",
+ "MCP_NoProgress: A stationary point was found",
+ "MCP_MajorIterationLimit: Major iteration limit met",
+ "MCP_MinorIterationLimit: Cumulative minor iteration limit met",
+ "MCP_TimeLimit: Ran out of time",
+ "MCP_UserInterrupt: Control-C, typically",
+ "MCP_BoundError: Problem has a bound error",
+ "MCP_DomainError: Could not find starting point",
+ "MCP_Infeasible: Problem has no solution",
+ "MCP_Error: An error occurred within the code",
+ "MCP_LicenseError: License could not be found",
+ "MCP_OK"
+ };
+
+ printf("ERROR: The PATH MCP solver failed: %s\n", gReturnMsgs[(unsigned int)status]);// << std::endl;
+ printf("using Projected Gauss Seidel fallback\n");
+
+ return false;
+ } else
+ {
+ for (int i=0;i<numVariables;i++)
+ {
+ x[i] = zResult[i];
+ //check for #NAN
+ if (x[i] != zResult[i])
+ return false;
+ }
+ return true;
+
+ }
+
+ }
+};
+
+#endif //BT_USE_PATH
+
+
+#endif //BT_PATH_SOLVER_H
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h
new file mode 100644
index 00000000000..44fbfeadddc
--- /dev/null
+++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h
@@ -0,0 +1,80 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///original version written by Erwin Coumans, October 2013
+
+#ifndef BT_SOLVE_PROJECTED_GAUSS_SEIDEL_H
+#define BT_SOLVE_PROJECTED_GAUSS_SEIDEL_H
+
+
+#include "btMLCPSolverInterface.h"
+
+class btSolveProjectedGaussSeidel : public btMLCPSolverInterface
+{
+public:
+ virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray<int>& limitDependency, int numIterations, bool useSparsity = true)
+ {
+ //A is a m-n matrix, m rows, n columns
+ btAssert(A.rows() == b.rows());
+
+ int i, j, numRows = A.rows();
+
+ float delta;
+
+ for (int k = 0; k <numIterations; k++)
+ {
+ for (i = 0; i <numRows; i++)
+ {
+ delta = 0.0f;
+ if (useSparsity)
+ {
+ for (int h=0;h<A.m_rowNonZeroElements1[i].size();h++)
+ {
+ int j = A.m_rowNonZeroElements1[i][h];
+ if (j != i)//skip main diagonal
+ {
+ delta += A(i,j) * x[j];
+ }
+ }
+ } else
+ {
+ for (j = 0; j <i; j++)
+ delta += A(i,j) * x[j];
+ for (j = i+1; j<numRows; j++)
+ delta += A(i,j) * x[j];
+ }
+
+ float aDiag = A(i,i);
+ x [i] = (b [i] - delta) / A(i,i);
+ float s = 1.f;
+
+ if (limitDependency[i]>=0)
+ {
+ s = x[limitDependency[i]];
+ if (s<0)
+ s=1;
+ }
+
+ if (x[i]<lo[i]*s)
+ x[i]=lo[i]*s;
+ if (x[i]>hi[i]*s)
+ x[i]=hi[i]*s;
+ }
+ }
+ return true;
+ }
+
+};
+
+#endif //BT_SOLVE_PROJECTED_GAUSS_SEIDEL_H
diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp b/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
index e8c8fdb6402..9429d56e05a 100644
--- a/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
+++ b/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
@@ -1767,7 +1767,23 @@ void btSoftBody::predictMotion(btScalar dt)
{
Node& n=m_nodes[i];
n.m_q = n.m_x;
- n.m_v += n.m_f*n.m_im*m_sst.sdt;
+ btVector3 deltaV = n.m_f*n.m_im*m_sst.sdt;
+ {
+ btScalar maxDisplacement = m_worldInfo->m_maxDisplacement;
+ btScalar clampDeltaV = maxDisplacement/m_sst.sdt;
+ for (int c=0;c<3;c++)
+ {
+ if (deltaV[c]>clampDeltaV)
+ {
+ deltaV[c] = clampDeltaV;
+ }
+ if (deltaV[c]<-clampDeltaV)
+ {
+ deltaV[c]=-clampDeltaV;
+ }
+ }
+ }
+ n.m_v += deltaV;
n.m_x += n.m_v*m_sst.sdt;
n.m_f = btVector3(0,0,0);
}
diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBody.h b/extern/bullet2/src/BulletSoftBody/btSoftBody.h
index 2116c34f06d..ee1a3d95228 100644
--- a/extern/bullet2/src/BulletSoftBody/btSoftBody.h
+++ b/extern/bullet2/src/BulletSoftBody/btSoftBody.h
@@ -45,6 +45,7 @@ struct btSoftBodyWorldInfo
btScalar air_density;
btScalar water_density;
btScalar water_offset;
+ btScalar m_maxDisplacement;
btVector3 water_normal;
btBroadphaseInterface* m_broadphase;
btDispatcher* m_dispatcher;
@@ -55,6 +56,7 @@ struct btSoftBodyWorldInfo
:air_density((btScalar)1.2),
water_density(0),
water_offset(0),
+ m_maxDisplacement(1000.f),//avoid soft body from 'exploding' so use some upper threshold of maximum motion that a node can travel per frame
water_normal(0,0,0),
m_broadphase(0),
m_dispatcher(0),
diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp b/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp
index 0fb3560e94c..36f675a6c0c 100644
--- a/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp
+++ b/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp
@@ -911,9 +911,9 @@ btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldI
&hres.m_OutputVertices[0],0);
for(int i=0;i<(int)hres.mNumFaces;++i)
{
- const int idx[]={ hres.m_Indices[i*3+0],
- hres.m_Indices[i*3+1],
- hres.m_Indices[i*3+2]};
+ const int idx[]={ static_cast<int>(hres.m_Indices[i*3+0]),
+ static_cast<int>(hres.m_Indices[i*3+1]),
+ static_cast<int>(hres.m_Indices[i*3+2])};
if(idx[0]<idx[1]) psb->appendLink( idx[0],idx[1]);
if(idx[1]<idx[2]) psb->appendLink( idx[1],idx[2]);
if(idx[2]<idx[0]) psb->appendLink( idx[2],idx[0]);
diff --git a/extern/bullet2/src/BulletSoftBody/btSparseSDF.h b/extern/bullet2/src/BulletSoftBody/btSparseSDF.h
index 180e3c218cc..bcf0c798253 100644
--- a/extern/bullet2/src/BulletSoftBody/btSparseSDF.h
+++ b/extern/bullet2/src/BulletSoftBody/btSparseSDF.h
@@ -69,6 +69,7 @@ struct btSparseSdf
btScalar voxelsz;
int puid;
int ncells;
+ int m_clampCells;
int nprobes;
int nqueries;
@@ -77,10 +78,13 @@ struct btSparseSdf
//
//
- void Initialize(int hashsize=2383)
+ void Initialize(int hashsize=2383, int clampCells = 256*1024)
{
+ //avoid a crash due to running out of memory, so clamp the maximum number of cells allocated
+ //if this limit is reached, the SDF is reset (at the cost of some performance during the reset)
+ m_clampCells = clampCells;
cells.resize(hashsize,0);
- Reset();
+ Reset();
}
//
void Reset()
@@ -181,6 +185,15 @@ struct btSparseSdf
{
++nprobes;
++ncells;
+ int sz = sizeof(Cell);
+ if (ncells>m_clampCells)
+ {
+ static int numResets=0;
+ numResets++;
+// printf("numResets=%d\n",numResets);
+ Reset();
+ }
+
c=new Cell();
c->next=root;root=c;
c->pclient=shape;
diff --git a/extern/bullet2/src/LinearMath/btIDebugDraw.h b/extern/bullet2/src/LinearMath/btIDebugDraw.h
index a00d7763a75..de97c3f87fd 100644
--- a/extern/bullet2/src/LinearMath/btIDebugDraw.h
+++ b/extern/bullet2/src/LinearMath/btIDebugDraw.h
@@ -62,29 +62,17 @@ class btIDebugDraw
virtual void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color)
{
- btVector3 start = transform.getOrigin();
-
- const btVector3 xoffs = transform.getBasis() * btVector3(radius,0,0);
- const btVector3 yoffs = transform.getBasis() * btVector3(0,radius,0);
- const btVector3 zoffs = transform.getBasis() * btVector3(0,0,radius);
-
- // XY
- drawLine(start-xoffs, start+yoffs, color);
- drawLine(start+yoffs, start+xoffs, color);
- drawLine(start+xoffs, start-yoffs, color);
- drawLine(start-yoffs, start-xoffs, color);
-
- // XZ
- drawLine(start-xoffs, start+zoffs, color);
- drawLine(start+zoffs, start+xoffs, color);
- drawLine(start+xoffs, start-zoffs, color);
- drawLine(start-zoffs, start-xoffs, color);
-
- // YZ
- drawLine(start-yoffs, start+zoffs, color);
- drawLine(start+zoffs, start+yoffs, color);
- drawLine(start+yoffs, start-zoffs, color);
- drawLine(start-zoffs, start-yoffs, color);
+
+ btVector3 center = transform.getOrigin();
+ btVector3 up = transform.getBasis().getColumn(1);
+ btVector3 axis = transform.getBasis().getColumn(0);
+ btScalar minTh = -SIMD_HALF_PI;
+ btScalar maxTh = SIMD_HALF_PI;
+ btScalar minPs = -SIMD_HALF_PI;
+ btScalar maxPs = SIMD_HALF_PI;
+ btScalar stepDegrees = 30.f;
+ drawSpherePatch(center, up, axis, radius,minTh, maxTh, minPs, maxPs, color, stepDegrees ,false);
+ drawSpherePatch(center, up, -axis, radius,minTh, maxTh, minPs, maxPs, color, stepDegrees,false );
}
virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color)
@@ -179,7 +167,7 @@ class btIDebugDraw
}
}
virtual void drawSpherePatch(const btVector3& center, const btVector3& up, const btVector3& axis, btScalar radius,
- btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3& color, btScalar stepDegrees = btScalar(10.f))
+ btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3& color, btScalar stepDegrees = btScalar(10.f),bool drawCenter = true)
{
btVector3 vA[74];
btVector3 vB[74];
@@ -261,18 +249,22 @@ class btIDebugDraw
{
drawLine(npole, pvB[j], color);
}
- if(isClosed)
+
+ if (drawCenter)
{
- if(j == (n_vert-1))
+ if(isClosed)
{
- drawLine(arcStart, pvB[j], color);
+ if(j == (n_vert-1))
+ {
+ drawLine(arcStart, pvB[j], color);
+ }
}
- }
- else
- {
- if(((!i) || (i == (n_hor-1))) && ((!j) || (j == (n_vert-1))))
+ else
{
- drawLine(center, pvB[j], color);
+ if(((!i) || (i == (n_hor-1))) && ((!j) || (j == (n_vert-1))))
+ {
+ drawLine(center, pvB[j], color);
+ }
}
}
}
@@ -314,6 +306,8 @@ class btIDebugDraw
virtual void drawCapsule(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color)
{
+ int stepDegrees = 30;
+
btVector3 capStart(0.f,0.f,0.f);
capStart[upAxis] = -halfHeight;
@@ -325,34 +319,47 @@ class btIDebugDraw
btTransform childTransform = transform;
childTransform.getOrigin() = transform * capStart;
- drawSphere(radius, childTransform, color);
+ {
+ btVector3 center = childTransform.getOrigin();
+ btVector3 up = childTransform.getBasis().getColumn((upAxis+1)%3);
+ btVector3 axis = -childTransform.getBasis().getColumn(upAxis);
+ btScalar minTh = -SIMD_HALF_PI;
+ btScalar maxTh = SIMD_HALF_PI;
+ btScalar minPs = -SIMD_HALF_PI;
+ btScalar maxPs = SIMD_HALF_PI;
+
+ drawSpherePatch(center, up, axis, radius,minTh, maxTh, minPs, maxPs, color, btScalar(stepDegrees) ,false);
+ }
+
+
+
}
{
btTransform childTransform = transform;
childTransform.getOrigin() = transform * capEnd;
- drawSphere(radius, childTransform, color);
+ {
+ btVector3 center = childTransform.getOrigin();
+ btVector3 up = childTransform.getBasis().getColumn((upAxis+1)%3);
+ btVector3 axis = childTransform.getBasis().getColumn(upAxis);
+ btScalar minTh = -SIMD_HALF_PI;
+ btScalar maxTh = SIMD_HALF_PI;
+ btScalar minPs = -SIMD_HALF_PI;
+ btScalar maxPs = SIMD_HALF_PI;
+ drawSpherePatch(center, up, axis, radius,minTh, maxTh, minPs, maxPs, color, btScalar(stepDegrees) ,false);
+ }
}
// Draw some additional lines
btVector3 start = transform.getOrigin();
- capStart[(upAxis+1)%3] = radius;
- capEnd[(upAxis+1)%3] = radius;
- drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color);
- capStart[(upAxis+1)%3] = -radius;
- capEnd[(upAxis+1)%3] = -radius;
- drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color);
-
- capStart[(upAxis+1)%3] = 0.f;
- capEnd[(upAxis+1)%3] = 0.f;
-
- capStart[(upAxis+2)%3] = radius;
- capEnd[(upAxis+2)%3] = radius;
- drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color);
- capStart[(upAxis+2)%3] = -radius;
- capEnd[(upAxis+2)%3] = -radius;
- drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color);
+ for (int i=0;i<360;i+=stepDegrees)
+ {
+ capEnd[(upAxis+1)%3] = capStart[(upAxis+1)%3] = btSin(btScalar(i)*SIMD_RADS_PER_DEG)*radius;
+ capEnd[(upAxis+2)%3] = capStart[(upAxis+2)%3] = btCos(btScalar(i)*SIMD_RADS_PER_DEG)*radius;
+ drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color);
+ }
+
}
virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color)
@@ -360,11 +367,18 @@ class btIDebugDraw
btVector3 start = transform.getOrigin();
btVector3 offsetHeight(0,0,0);
offsetHeight[upAxis] = halfHeight;
- btVector3 offsetRadius(0,0,0);
- offsetRadius[(upAxis+1)%3] = radius;
- drawLine(start+transform.getBasis() * (offsetHeight+offsetRadius),start+transform.getBasis() * (-offsetHeight+offsetRadius),color);
- drawLine(start+transform.getBasis() * (offsetHeight-offsetRadius),start+transform.getBasis() * (-offsetHeight-offsetRadius),color);
+ int stepDegrees=30;
+ btVector3 capStart(0.f,0.f,0.f);
+ capStart[upAxis] = -halfHeight;
+ btVector3 capEnd(0.f,0.f,0.f);
+ capEnd[upAxis] = halfHeight;
+ for (int i=0;i<360;i+=stepDegrees)
+ {
+ capEnd[(upAxis+1)%3] = capStart[(upAxis+1)%3] = btSin(btScalar(i)*SIMD_RADS_PER_DEG)*radius;
+ capEnd[(upAxis+2)%3] = capStart[(upAxis+2)%3] = btCos(btScalar(i)*SIMD_RADS_PER_DEG)*radius;
+ drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color);
+ }
// Drawing top and bottom caps of the cylinder
btVector3 yaxis(0,0,0);
yaxis[upAxis] = btScalar(1.0);
@@ -376,16 +390,28 @@ class btIDebugDraw
virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform& transform, const btVector3& color)
{
-
+ int stepDegrees = 30;
btVector3 start = transform.getOrigin();
btVector3 offsetHeight(0,0,0);
- offsetHeight[upAxis] = height * btScalar(0.5);
+ btScalar halfHeight = height * btScalar(0.5);
+ offsetHeight[upAxis] = halfHeight;
btVector3 offsetRadius(0,0,0);
offsetRadius[(upAxis+1)%3] = radius;
btVector3 offset2Radius(0,0,0);
offset2Radius[(upAxis+2)%3] = radius;
+
+ btVector3 capEnd(0.f,0.f,0.f);
+ capEnd[upAxis] = -halfHeight;
+
+ for (int i=0;i<360;i+=stepDegrees)
+ {
+ capEnd[(upAxis+1)%3] = btSin(btScalar(i)*SIMD_RADS_PER_DEG)*radius;
+ capEnd[(upAxis+2)%3] = btCos(btScalar(i)*SIMD_RADS_PER_DEG)*radius;
+ drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * capEnd, color);
+ }
+
drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * (-offsetHeight+offsetRadius),color);
drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * (-offsetHeight-offsetRadius),color);
drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * (-offsetHeight+offset2Radius),color);
diff --git a/extern/bullet2/src/LinearMath/btMatrix3x3.h b/extern/bullet2/src/LinearMath/btMatrix3x3.h
index d4f5c95aa64..14fe704f81a 100644
--- a/extern/bullet2/src/LinearMath/btMatrix3x3.h
+++ b/extern/bullet2/src/LinearMath/btMatrix3x3.h
@@ -22,10 +22,15 @@ subject to the following restrictions:
#ifdef BT_USE_SSE
//const __m128 ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f};
-const __m128 ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f};
+//const __m128 ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f};
+#define vMPPP (_mm_set_ps (+0.0f, +0.0f, +0.0f, -0.0f))
#endif
-#if defined(BT_USE_SSE) || defined(BT_USE_NEON)
+#if defined(BT_USE_SSE)
+#define v1000 (_mm_set_ps(0.0f,0.0f,0.0f,1.0f))
+#define v0100 (_mm_set_ps(0.0f,0.0f,1.0f,0.0f))
+#define v0010 (_mm_set_ps(0.0f,1.0f,0.0f,0.0f))
+#elif defined(BT_USE_NEON)
const btSimdFloat4 ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f};
const btSimdFloat4 ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f};
const btSimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f};
@@ -207,7 +212,7 @@ public:
btFullAssert(d != btScalar(0.0));
btScalar s = btScalar(2.0) / d;
- #if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
+ #if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
__m128 vs, Q = q.get128();
__m128i Qi = btCastfTo128i(Q);
__m128 Y, Z;
@@ -341,7 +346,7 @@ public:
* @param m The array to be filled */
void getOpenGLSubMatrix(btScalar *m) const
{
-#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
+#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
__m128 v0 = m_el[0].mVec128;
__m128 v1 = m_el[1].mVec128;
__m128 v2 = m_el[2].mVec128; // x2 y2 z2 w2
@@ -362,7 +367,7 @@ public:
vm[2] = v2;
#elif defined(BT_USE_NEON)
// note: zeros the w channel. We can preserve it at the cost of two more vtrn instructions.
- static const uint32x2_t zMask = (const uint32x2_t) {-1, 0 };
+ static const uint32x2_t zMask = (const uint32x2_t) {static_cast<uint32_t>(-1), 0 };
float32x4_t *vm = (float32x4_t *)m;
float32x4x2_t top = vtrnq_f32( m_el[0].mVec128, m_el[1].mVec128 ); // {x0 x1 z0 z1}, {y0 y1 w0 w1}
float32x2x2_t bl = vtrn_f32( vget_low_f32(m_el[2].mVec128), vdup_n_f32(0.0f) ); // {x2 0 }, {y2 0}
@@ -740,7 +745,7 @@ public:
SIMD_FORCE_INLINE btMatrix3x3&
btMatrix3x3::operator*=(const btMatrix3x3& m)
{
-#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
+#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
__m128 rv00, rv01, rv02;
__m128 rv10, rv11, rv12;
__m128 rv20, rv21, rv22;
@@ -953,7 +958,7 @@ btMatrix3x3::determinant() const
SIMD_FORCE_INLINE btMatrix3x3
btMatrix3x3::absolute() const
{
-#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
+#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
return btMatrix3x3(
_mm_and_ps(m_el[0].mVec128, btvAbsfMask),
_mm_and_ps(m_el[1].mVec128, btvAbsfMask),
@@ -974,7 +979,7 @@ btMatrix3x3::absolute() const
SIMD_FORCE_INLINE btMatrix3x3
btMatrix3x3::transpose() const
{
-#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
+#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
__m128 v0 = m_el[0].mVec128;
__m128 v1 = m_el[1].mVec128;
__m128 v2 = m_el[2].mVec128; // x2 y2 z2 w2
@@ -993,7 +998,7 @@ btMatrix3x3::transpose() const
return btMatrix3x3( v0, v1, v2 );
#elif defined(BT_USE_NEON)
// note: zeros the w channel. We can preserve it at the cost of two more vtrn instructions.
- static const uint32x2_t zMask = (const uint32x2_t) {-1, 0 };
+ static const uint32x2_t zMask = (const uint32x2_t) {static_cast<uint32_t>(-1), 0 };
float32x4x2_t top = vtrnq_f32( m_el[0].mVec128, m_el[1].mVec128 ); // {x0 x1 z0 z1}, {y0 y1 w0 w1}
float32x2x2_t bl = vtrn_f32( vget_low_f32(m_el[2].mVec128), vdup_n_f32(0.0f) ); // {x2 0 }, {y2 0}
float32x4_t v0 = vcombine_f32( vget_low_f32(top.val[0]), bl.val[0] );
@@ -1031,7 +1036,7 @@ btMatrix3x3::inverse() const
SIMD_FORCE_INLINE btMatrix3x3
btMatrix3x3::transposeTimes(const btMatrix3x3& m) const
{
-#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
+#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
// zeros w
// static const __m128i xyzMask = (const __m128i){ -1ULL, 0xffffffffULL };
__m128 row = m_el[0].mVec128;
@@ -1053,7 +1058,7 @@ btMatrix3x3::transposeTimes(const btMatrix3x3& m) const
#elif defined BT_USE_NEON
// zeros w
- static const uint32x4_t xyzMask = (const uint32x4_t){ -1, -1, -1, 0 };
+ static const uint32x4_t xyzMask = (const uint32x4_t){ static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), 0 };
float32x4_t m0 = (float32x4_t) vandq_u32( (uint32x4_t) m.getRow(0).mVec128, xyzMask );
float32x4_t m1 = (float32x4_t) vandq_u32( (uint32x4_t) m.getRow(1).mVec128, xyzMask );
float32x4_t m2 = (float32x4_t) vandq_u32( (uint32x4_t) m.getRow(2).mVec128, xyzMask );
@@ -1151,7 +1156,7 @@ operator*(const btMatrix3x3& m, const btVector3& v)
SIMD_FORCE_INLINE btVector3
operator*(const btVector3& v, const btMatrix3x3& m)
{
-#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
+#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
const __m128 vv = v.mVec128;
@@ -1191,7 +1196,7 @@ operator*(const btVector3& v, const btMatrix3x3& m)
SIMD_FORCE_INLINE btMatrix3x3
operator*(const btMatrix3x3& m1, const btMatrix3x3& m2)
{
-#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
+#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
__m128 m10 = m1[0].mVec128;
__m128 m11 = m1[1].mVec128;
diff --git a/extern/bullet2/src/LinearMath/btMatrixX.h b/extern/bullet2/src/LinearMath/btMatrixX.h
new file mode 100644
index 00000000000..1c29632c536
--- /dev/null
+++ b/extern/bullet2/src/LinearMath/btMatrixX.h
@@ -0,0 +1,504 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///original version written by Erwin Coumans, October 2013
+
+#ifndef BT_MATRIX_X_H
+#define BT_MATRIX_X_H
+
+#include "LinearMath/btQuickprof.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+class btIntSortPredicate
+{
+ public:
+ bool operator() ( const int& a, const int& b ) const
+ {
+ return a < b;
+ }
+};
+
+
+template <typename T>
+struct btMatrixX
+{
+ int m_rows;
+ int m_cols;
+ int m_operations;
+ int m_resizeOperations;
+ int m_setElemOperations;
+
+ btAlignedObjectArray<T> m_storage;
+ btAlignedObjectArray< btAlignedObjectArray<int> > m_rowNonZeroElements1;
+ btAlignedObjectArray< btAlignedObjectArray<int> > m_colNonZeroElements;
+
+ T* getBufferPointerWritable()
+ {
+ return m_storage.size() ? &m_storage[0] : 0;
+ }
+
+ const T* getBufferPointer() const
+ {
+ return m_storage.size() ? &m_storage[0] : 0;
+ }
+ btMatrixX()
+ :m_rows(0),
+ m_cols(0),
+ m_operations(0),
+ m_resizeOperations(0),
+ m_setElemOperations(0)
+ {
+ }
+ btMatrixX(int rows,int cols)
+ :m_rows(rows),
+ m_cols(cols),
+ m_operations(0),
+ m_resizeOperations(0),
+ m_setElemOperations(0)
+ {
+ resize(rows,cols);
+ }
+ void resize(int rows, int cols)
+ {
+ m_resizeOperations++;
+ m_rows = rows;
+ m_cols = cols;
+ {
+ BT_PROFILE("m_storage.resize");
+ m_storage.resize(rows*cols);
+ }
+ clearSparseInfo();
+ }
+ int cols() const
+ {
+ return m_cols;
+ }
+ int rows() const
+ {
+ return m_rows;
+ }
+ ///we don't want this read/write operator(), because we cannot keep track of non-zero elements, use setElem instead
+ /*T& operator() (int row,int col)
+ {
+ return m_storage[col*m_rows+row];
+ }
+ */
+
+ void addElem(int row,int col, T val)
+ {
+ if (val)
+ {
+ if (m_storage[col+row*m_cols]==0.f)
+ {
+ setElem(row,col,val);
+ } else
+ {
+ m_storage[row*m_cols+col] += val;
+ }
+ }
+ }
+
+ void copyLowerToUpperTriangle()
+ {
+ int count=0;
+ for (int row=0;row<m_rowNonZeroElements1.size();row++)
+ {
+ for (int j=0;j<m_rowNonZeroElements1[row].size();j++)
+ {
+ int col = m_rowNonZeroElements1[row][j];
+ setElem(col,row, (*this)(row,col));
+ count++;
+
+ }
+ }
+ //printf("copyLowerToUpperTriangle copied %d elements out of %dx%d=%d\n", count,rows(),cols(),cols()*rows());
+ }
+ void setElem(int row,int col, T val)
+ {
+ m_setElemOperations++;
+ if (val)
+ {
+ if (m_storage[col+row*m_cols]==0.f)
+ {
+ m_rowNonZeroElements1[row].push_back(col);
+ m_colNonZeroElements[col].push_back(row);
+ }
+ m_storage[row*m_cols+col] = val;
+ }
+ }
+ const T& operator() (int row,int col) const
+ {
+ return m_storage[col+row*m_cols];
+ }
+
+ void clearSparseInfo()
+ {
+ BT_PROFILE("clearSparseInfo=0");
+ m_rowNonZeroElements1.resize(m_rows);
+ m_colNonZeroElements.resize(m_cols);
+ for (int i=0;i<m_rows;i++)
+ m_rowNonZeroElements1[i].resize(0);
+ for (int j=0;j<m_cols;j++)
+ m_colNonZeroElements[j].resize(0);
+ }
+
+ void setZero()
+ {
+ {
+ BT_PROFILE("storage=0");
+ btSetZero(&m_storage[0],m_storage.size());
+ //memset(&m_storage[0],0,sizeof(T)*m_storage.size());
+ //for (int i=0;i<m_storage.size();i++)
+ // m_storage[i]=0;
+ }
+ {
+ BT_PROFILE("clearSparseInfo=0");
+ clearSparseInfo();
+ }
+ }
+
+ void printMatrix(const char* msg)
+ {
+ printf("%s ---------------------\n",msg);
+ for (int i=0;i<rows();i++)
+ {
+ printf("\n");
+ for (int j=0;j<cols();j++)
+ {
+ printf("%2.1f\t",(*this)(i,j));
+ }
+ }
+ printf("\n---------------------\n");
+
+ }
+ void printNumZeros(const char* msg)
+ {
+ printf("%s: ",msg);
+ int numZeros = 0;
+ for (int i=0;i<m_storage.size();i++)
+ if (m_storage[i]==0)
+ numZeros++;
+ int total = m_cols*m_rows;
+ int computedNonZero = total-numZeros;
+ int nonZero = 0;
+ for (int i=0;i<m_colNonZeroElements.size();i++)
+ nonZero += m_colNonZeroElements[i].size();
+ btAssert(computedNonZero==nonZero);
+ if(computedNonZero!=nonZero)
+ {
+ printf("Error: computedNonZero=%d, but nonZero=%d\n",computedNonZero,nonZero);
+ }
+ //printf("%d numZeros out of %d (%f)\n",numZeros,m_cols*m_rows,numZeros/(m_cols*m_rows));
+ printf("total %d, %d rows, %d cols, %d non-zeros (%f %)\n", total, rows(),cols(), nonZero,100.f*(T)nonZero/T(total));
+ }
+ /*
+ void rowComputeNonZeroElements()
+ {
+ m_rowNonZeroElements1.resize(rows());
+ for (int i=0;i<rows();i++)
+ {
+ m_rowNonZeroElements1[i].resize(0);
+ for (int j=0;j<cols();j++)
+ {
+ if ((*this)(i,j)!=0.f)
+ {
+ m_rowNonZeroElements1[i].push_back(j);
+ }
+ }
+ }
+ }
+ */
+ btMatrixX transpose() const
+ {
+ //transpose is optimized for sparse matrices
+ btMatrixX tr(m_cols,m_rows);
+ tr.setZero();
+#if 0
+ for (int i=0;i<m_cols;i++)
+ for (int j=0;j<m_rows;j++)
+ {
+ T v = (*this)(j,i);
+ if (v)
+ {
+ tr.setElem(i,j,v);
+ }
+ }
+#else
+ for (int i=0;i<m_colNonZeroElements.size();i++)
+ for (int h=0;h<m_colNonZeroElements[i].size();h++)
+ {
+ int j = m_colNonZeroElements[i][h];
+ T v = (*this)(j,i);
+ tr.setElem(i,j,v);
+ }
+#endif
+ return tr;
+ }
+
+ void sortRowIndexArrays()
+ {
+ for (int i=0;i<m_rowNonZeroElements1[i].size();i++)
+ {
+ m_rowNonZeroElements1[i].quickSort(btIntSortPredicate());
+ }
+ }
+
+ void sortColIndexArrays()
+ {
+ for (int i=0;i<m_colNonZeroElements[i].size();i++)
+ {
+ m_colNonZeroElements[i].quickSort(btIntSortPredicate());
+ }
+ }
+
+ btMatrixX operator*(const btMatrixX& other)
+ {
+ //btMatrixX*btMatrixX implementation, optimized for sparse matrices
+ btAssert(cols() == other.rows());
+
+ btMatrixX res(rows(),other.cols());
+ res.setZero();
+// BT_PROFILE("btMatrixX mul");
+ for (int j=0; j < res.cols(); ++j)
+ {
+ //int numZero=other.m_colNonZeroElements[j].size();
+ //if (numZero)
+ {
+ for (int i=0; i < res.rows(); ++i)
+ //for (int g = 0;g<m_colNonZeroElements[j].size();g++)
+ {
+ T dotProd=0;
+ T dotProd2=0;
+ int waste=0,waste2=0;
+
+ bool doubleWalk = false;
+ if (doubleWalk)
+ {
+ int numRows = m_rowNonZeroElements1[i].size();
+ int numOtherCols = other.m_colNonZeroElements[j].size();
+ for (int ii=0;ii<numRows;ii++)
+ {
+ int vThis=m_rowNonZeroElements1[i][ii];
+ }
+
+ for (int ii=0;ii<numOtherCols;ii++)
+ {
+ int vOther = other.m_colNonZeroElements[j][ii];
+ }
+
+
+ int indexRow = 0;
+ int indexOtherCol = 0;
+ while (indexRow < numRows && indexOtherCol < numOtherCols)
+ {
+ int vThis=m_rowNonZeroElements1[i][indexRow];
+ int vOther = other.m_colNonZeroElements[j][indexOtherCol];
+ if (vOther==vThis)
+ {
+ dotProd += (*this)(i,vThis) * other(vThis,j);
+ }
+ if (vThis<vOther)
+ {
+ indexRow++;
+ } else
+ {
+ indexOtherCol++;
+ }
+ }
+
+ } else
+ {
+ bool useOtherCol = true;
+ if (other.m_colNonZeroElements[j].size() <m_rowNonZeroElements1[i].size())
+ {
+ useOtherCol=true;
+ }
+ if (!useOtherCol )
+ {
+ for (int q=0;q<other.m_colNonZeroElements[j].size();q++)
+ {
+ int v = other.m_colNonZeroElements[j][q];
+ T w = (*this)(i,v);
+ if (w!=0.f)
+ {
+ dotProd+=w*other(v,j);
+ }
+
+ }
+ }
+ else
+ {
+ for (int q=0;q<m_rowNonZeroElements1[i].size();q++)
+ {
+ int v=m_rowNonZeroElements1[i][q];
+ T w = (*this)(i,v);
+ if (other(v,j)!=0.f)
+ {
+ dotProd+=w*other(v,j);
+ }
+
+ }
+ }
+ }
+ if (dotProd)
+ res.setElem(i,j,dotProd);
+ }
+ }
+ }
+ return res;
+ }
+
+ // this assumes the 4th and 8th rows of B and C are zero.
+ void multiplyAdd2_p8r (const btScalar *B, const btScalar *C, int numRows, int numRowsOther ,int row, int col)
+ {
+ const btScalar *bb = B;
+ for ( int i = 0;i<numRows;i++)
+ {
+ const btScalar *cc = C;
+ for ( int j = 0;j<numRowsOther;j++)
+ {
+ btScalar sum;
+ sum = bb[0]*cc[0];
+ sum += bb[1]*cc[1];
+ sum += bb[2]*cc[2];
+ sum += bb[4]*cc[4];
+ sum += bb[5]*cc[5];
+ sum += bb[6]*cc[6];
+ addElem(row+i,col+j,sum);
+ cc += 8;
+ }
+ bb += 8;
+ }
+ }
+
+ void multiply2_p8r (const btScalar *B, const btScalar *C, int numRows, int numRowsOther, int row, int col)
+ {
+ btAssert (numRows>0 && numRowsOther>0 && B && C);
+ const btScalar *bb = B;
+ for ( int i = 0;i<numRows;i++)
+ {
+ const btScalar *cc = C;
+ for ( int j = 0;j<numRowsOther;j++)
+ {
+ btScalar sum;
+ sum = bb[0]*cc[0];
+ sum += bb[1]*cc[1];
+ sum += bb[2]*cc[2];
+ sum += bb[4]*cc[4];
+ sum += bb[5]*cc[5];
+ sum += bb[6]*cc[6];
+ setElem(row+i,col+j,sum);
+ cc += 8;
+ }
+ bb += 8;
+ }
+ }
+
+};
+
+template <typename T>
+struct btVectorX
+{
+ btAlignedObjectArray<T> m_storage;
+
+ btVectorX()
+ {
+ }
+ btVectorX(int numRows)
+ {
+ m_storage.resize(numRows);
+ }
+
+ void resize(int rows)
+ {
+ m_storage.resize(rows);
+ }
+ int cols() const
+ {
+ return 1;
+ }
+ int rows() const
+ {
+ return m_storage.size();
+ }
+ int size() const
+ {
+ return rows();
+ }
+ void setZero()
+ {
+ // for (int i=0;i<m_storage.size();i++)
+ // m_storage[i]=0;
+ //memset(&m_storage[0],0,sizeof(T)*m_storage.size());
+ btSetZero(&m_storage[0],m_storage.size());
+ }
+ const T& operator[] (int index) const
+ {
+ return m_storage[index];
+ }
+
+ T& operator[] (int index)
+ {
+ return m_storage[index];
+ }
+
+ T* getBufferPointerWritable()
+ {
+ return m_storage.size() ? &m_storage[0] : 0;
+ }
+
+ const T* getBufferPointer() const
+ {
+ return m_storage.size() ? &m_storage[0] : 0;
+ }
+
+};
+/*
+template <typename T>
+void setElem(btMatrixX<T>& mat, int row, int col, T val)
+{
+ mat.setElem(row,col,val);
+}
+*/
+
+
+typedef btMatrixX<float> btMatrixXf;
+typedef btVectorX<float> btVectorXf;
+
+typedef btMatrixX<double> btMatrixXd;
+typedef btVectorX<double> btVectorXd;
+
+
+
+inline void setElem(btMatrixXd& mat, int row, int col, double val)
+{
+ mat.setElem(row,col,val);
+}
+
+inline void setElem(btMatrixXf& mat, int row, int col, float val)
+{
+ mat.setElem(row,col,val);
+}
+
+#ifdef BT_USE_DOUBLE_PRECISION
+ #define btVectorXu btVectorXd
+ #define btMatrixXu btMatrixXd
+#else
+ #define btVectorXu btVectorXf
+ #define btMatrixXu btMatrixXf
+#endif //BT_USE_DOUBLE_PRECISION
+
+
+
+#endif//BT_MATRIX_H_H
diff --git a/extern/bullet2/src/LinearMath/btQuaternion.h b/extern/bullet2/src/LinearMath/btQuaternion.h
index 7d7f25fb4d3..665421de1e4 100644
--- a/extern/bullet2/src/LinearMath/btQuaternion.h
+++ b/extern/bullet2/src/LinearMath/btQuaternion.h
@@ -27,11 +27,17 @@ subject to the following restrictions:
#ifdef BT_USE_SSE
-const __m128 ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f};
+//const __m128 ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f};
+#define vOnes (_mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f))
#endif
-#if defined(BT_USE_SSE) || defined(BT_USE_NEON)
+#if defined(BT_USE_SSE)
+
+#define vQInv (_mm_set_ps(+0.0f, -0.0f, -0.0f, -0.0f))
+#define vPPPM (_mm_set_ps(-0.0f, +0.0f, +0.0f, +0.0f))
+
+#elif defined(BT_USE_NEON)
const btSimdFloat4 ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f};
const btSimdFloat4 ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f};
@@ -285,7 +291,7 @@ public:
* @param q The other quaternion */
btScalar dot(const btQuaternion& q) const
{
-#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
+#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
__m128 vd;
vd = _mm_mul_ps(mVec128, q.mVec128);
@@ -384,7 +390,7 @@ public:
{
return *this / length();
}
- /**@brief Return the angle between this quaternion and the other
+ /**@brief Return the ***half*** angle between this quaternion and the other
* @param q The other quaternion */
btScalar angle(const btQuaternion& q) const
{
@@ -392,6 +398,19 @@ public:
btAssert(s != btScalar(0.0));
return btAcos(dot(q) / s);
}
+
+ /**@brief Return the angle between this quaternion and the other along the shortest path
+ * @param q The other quaternion */
+ btScalar angleShortestPath(const btQuaternion& q) const
+ {
+ btScalar s = btSqrt(length2() * q.length2());
+ btAssert(s != btScalar(0.0));
+ if (dot(q) < 0) // Take care of long angle case see http://en.wikipedia.org/wiki/Slerp
+ return btAcos(dot(-q) / s) * btScalar(2.0);
+ else
+ return btAcos(dot(q) / s) * btScalar(2.0);
+ }
+
/**@brief Return the angle of rotation represented by this quaternion */
btScalar getAngle() const
{
@@ -399,6 +418,19 @@ public:
return s;
}
+ /**@brief Return the angle of rotation represented by this quaternion along the shortest path*/
+ btScalar getAngleShortestPath() const
+ {
+ btScalar s;
+ if (dot(*this) < 0)
+ s = btScalar(2.) * btAcos(m_floats[3]);
+ else
+ s = btScalar(2.) * btAcos(-m_floats[3]);
+
+ return s;
+ }
+
+
/**@brief Return the axis of the rotation represented by this quaternion */
btVector3 getAxis() const
{
@@ -835,7 +867,7 @@ quatRotate(const btQuaternion& rotation, const btVector3& v)
{
btQuaternion q = rotation * v;
q *= rotation.inverse();
-#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
+#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
return btVector3(_mm_and_ps(q.get128(), btvFFF0fMask));
#elif defined(BT_USE_NEON)
return btVector3((float32x4_t)vandq_s32((int32x4_t)q.get128(), btvFFF0Mask));
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
index aaa1d6de6b4..37c6dec191d 100644
--- a/extern/bullet2/src/LinearMath/btScalar.h
+++ b/extern/bullet2/src/LinearMath/btScalar.h
@@ -28,7 +28,7 @@ subject to the following restrictions:
#include <float.h>
/* SVN $Revision$ on $Date$ from http://bullet.googlecode.com*/
-#define BT_BULLET_VERSION 281
+#define BT_BULLET_VERSION 282
inline int btGetVersion()
{
@@ -180,7 +180,7 @@ inline int btGetVersion()
#include <emmintrin.h>
#endif
#endif //BT_USE_SSE
- #elif defined( __armv7__ )
+ #elif defined( __ARM_NEON__ )
#ifdef __clang__
#define BT_USE_NEON 1
#define BT_USE_SIMD_VECTOR3
@@ -257,10 +257,12 @@ inline int btGetVersion()
///The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision.
#if defined(BT_USE_DOUBLE_PRECISION)
+
typedef double btScalar;
//this number could be bigger in double precision
#define BT_LARGE_FLOAT 1e30
#else
+
typedef float btScalar;
//keep BT_LARGE_FLOAT*BT_LARGE_FLOAT < FLT_MAX
#define BT_LARGE_FLOAT 1e18f
@@ -284,6 +286,8 @@ static int btInfinityMask = 0x7F800000;
#define BT_INFINITY (*(float*)&btInfinityMask)
#endif
+//use this, in case there are clashes (such as xnamath.h)
+#ifndef BT_NO_SIMD_OPERATOR_OVERLOADS
inline __m128 operator + (const __m128 A, const __m128 B)
{
return _mm_add_ps(A, B);
@@ -298,6 +302,7 @@ inline __m128 operator * (const __m128 A, const __m128 B)
{
return _mm_mul_ps(A, B);
}
+#endif //BT_NO_SIMD_OPERATOR_OVERLOADS
#define btCastfTo128i(a) (_mm_castps_si128(a))
#define btCastfTo128d(a) (_mm_castps_pd(a))
@@ -317,7 +322,24 @@ inline __m128 operator * (const __m128 A, const __m128 B)
#define BT_INFINITY INFINITY
#define BT_NAN NAN
#endif//_WIN32
-#endif //BT_USE_SSE_IN_API
+#else
+
+#ifdef BT_USE_NEON
+ #include <arm_neon.h>
+
+ typedef float32x4_t btSimdFloat4;
+ #define BT_INFINITY INFINITY
+ #define BT_NAN NAN
+ #define btAssign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3}
+#else//BT_USE_NEON
+
+ #ifndef BT_INFINITY
+ static int btInfinityMask = 0x7F800000;
+ #define BT_INFINITY (*(float*)&btInfinityMask)
+ #endif
+#endif//BT_USE_NEON
+
+#endif //BT_USE_SSE
#ifdef BT_USE_NEON
#include <arm_neon.h>
@@ -409,15 +431,15 @@ SIMD_FORCE_INLINE btScalar btFmod(btScalar x,btScalar y) { return fmodf(x,y); }
#endif
-#define SIMD_2_PI btScalar(6.283185307179586232)
-#define SIMD_PI (SIMD_2_PI * btScalar(0.5))
-#define SIMD_HALF_PI (SIMD_2_PI * btScalar(0.25))
+#define SIMD_PI btScalar(3.1415926535897932384626433832795029)
+#define SIMD_2_PI btScalar(2.0) * SIMD_PI
+#define SIMD_HALF_PI (SIMD_PI * btScalar(0.5))
#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))
#define SIMD_DEGS_PER_RAD (btScalar(360.0) / SIMD_2_PI)
#define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490)
#define btRecipSqrt(x) ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x)))) /* reciprocal square root */
-
+#define btRecip(x) (btScalar(1.0)/btScalar(x))
#ifdef BT_USE_DOUBLE_PRECISION
#define SIMD_EPSILON DBL_EPSILON
@@ -608,6 +630,46 @@ SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src)
return d;
}
+template<typename T>
+SIMD_FORCE_INLINE void btSetZero(T* a, int n)
+{
+ T* acurr = a;
+ size_t ncurr = n;
+ while (ncurr > 0)
+ {
+ *(acurr++) = 0;
+ --ncurr;
+ }
+}
+
+
+SIMD_FORCE_INLINE btScalar btLargeDot(const btScalar *a, const btScalar *b, int n)
+{
+ btScalar p0,q0,m0,p1,q1,m1,sum;
+ sum = 0;
+ n -= 2;
+ while (n >= 0) {
+ p0 = a[0]; q0 = b[0];
+ m0 = p0 * q0;
+ p1 = a[1]; q1 = b[1];
+ m1 = p1 * q1;
+ sum += m0;
+ sum += m1;
+ a += 2;
+ b += 2;
+ n -= 2;
+ }
+ n += 2;
+ while (n > 0) {
+ sum += (*a) * (*b);
+ a++;
+ b++;
+ n--;
+ }
+ return sum;
+}
+
+
// returns normalized value in range [-SIMD_PI, SIMD_PI]
SIMD_FORCE_INLINE btScalar btNormalizeAngle(btScalar angleInRadians)
{
@@ -626,6 +688,8 @@ SIMD_FORCE_INLINE btScalar btNormalizeAngle(btScalar angleInRadians)
}
}
+
+
///rudimentary class to provide type info
struct btTypedObject
{
diff --git a/extern/bullet2/src/LinearMath/btSerializer.cpp b/extern/bullet2/src/LinearMath/btSerializer.cpp
index d6b2b3a5a5c..ba344939530 100644
--- a/extern/bullet2/src/LinearMath/btSerializer.cpp
+++ b/extern/bullet2/src/LinearMath/btSerializer.cpp
@@ -1,5 +1,5 @@
char sBulletDNAstr[]= {
-char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109),
+char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(69),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109),
char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95),
char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111),
char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),
@@ -58,238 +58,242 @@ char(102),char(111),char(114),char(109),char(0),char(42),char(109),char(95),char
char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104),char(97),char(112),char(101),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104),
char(105),char(108),char(100),char(77),char(97),char(114),char(103),char(105),char(110),char(0),char(42),char(109),char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104),
char(97),char(112),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(104),char(105),char(108),char(100),char(83),char(104),char(97),
-char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115),
-char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86),char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),
-char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),
-char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),
-char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101),char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118),
-char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65),
-char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105),
-char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110),char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),
-char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114),char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111),
-char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68),char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114),
-char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122),char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114),
-char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95),
-char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86),
-char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105),
-char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),
-char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42),
-char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98),
-char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),
-char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0),
-char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104),char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0),
-char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109),
-char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),
-char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),
-char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97),
+char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(117),char(112),char(73),char(110),char(100),
+char(101),char(120),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86),
+char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103),
+char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42),
+char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101),
+char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118),char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80),
+char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95),
+char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110),
+char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114),
+char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68),
+char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122),
+char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),
+char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83),
+char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86),char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117),
+char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105),char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121),
+char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),
+char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),
+char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),
+char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97),
+char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0),char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104),
+char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0),char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),
+char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109),char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105),
+char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97),
char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),
-char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105),
-char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86),
-char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),
-char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80),
-char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95),
-char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),
-char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),
-char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100),
-char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114),char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95),
-char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),
-char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115),
-char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84),char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112),
-char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),
-char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112),
-char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67),char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104),
-char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73),char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118),
-char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),
-char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101),
-char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101),
-char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),
-char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),
-char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114),
-char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101),char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109),
-char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116),
-char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114),
-char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101),char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95),
-char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117),
-char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),
-char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97),
-char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),
-char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),
-char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),
-char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),
-char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),
-char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112),
-char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),
-char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),
-char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),
-char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0),
-char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65),char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95),
-char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),
-char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),
-char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100),char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101),
-char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97),char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117),
-char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68),char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95),
-char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116),
-char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100),char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111),
-char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114),
-char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98),char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112),
-char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110),
-char(97),char(98),char(108),char(101),char(100),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),
-char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109),char(95),
-char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101),char(0),
-char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102),char(101),
-char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),
-char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108),char(97),
-char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101),char(116),
-char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114),char(73),
-char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),
-char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105),char(116),
-char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116),char(111),
-char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111),char(114),
-char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110),
-char(103),char(83),char(112),char(97),char(110),char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109),
-char(95),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112),
-char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101),
-char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101),
-char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101),
-char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101),
-char(102),char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79),
-char(102),char(102),char(115),char(101),char(116),char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114),
-char(97),char(109),char(101),char(0),char(109),char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114),
-char(105),char(110),char(103),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105),
-char(108),char(105),char(98),char(114),char(105),char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),
-char(114),char(105),char(110),char(103),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115),
-char(112),char(114),char(105),char(110),char(103),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(116),char(97),
-char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97),char(120),char(69),char(114),
-char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111),char(114),char(0),char(109),
-char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111),char(98),char(97),char(108),
-char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(80),char(101),
-char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110),char(69),char(114),char(112),
-char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119),char(97),char(114),char(109),
-char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(97),char(120),
-char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(115),char(105),
-char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116),
-char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117),char(109),char(73),char(116),
-char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(77),char(111),char(100),
-char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(82),char(101),
-char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116),char(99),char(104),char(83),
-char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),
-char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),
-char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(118),char(111),
-char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(116),
-char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),
-char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(118),char(101),
-char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97),char(116),char(101),char(100),
-char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95),char(97),char(114),char(101),
-char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),
-char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110),char(103),char(116),char(104),
-char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),
-char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114),char(101),char(97),char(0),
-char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),
-char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),
-char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111),char(99),char(97),char(108),
-char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(0),char(109),
-char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111),char(77),char(111),char(100),
-char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95),char(100),char(114),char(97),
-char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117),char(114),char(101),char(0),
-char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105),char(99),char(70),char(114),
-char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99),char(104),char(0),char(109),
-char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),
-char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),
-char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116),char(97),char(99),char(116),
-char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(72),char(97),char(114),
-char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67),char(108),char(117),
-char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75),
-char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),
-char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),
-char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67),
-char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),
-char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),
-char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),
-char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),
-char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116),char(105),char(109),char(101),
-char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73),char(116),char(101),char(114),
-char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(73),char(116),char(101),
-char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116),char(101),char(114),char(97),
-char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116),char(101),char(114),char(97),
-char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97),char(108),char(101),char(0),
-char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111),char(115),char(105),char(116),
-char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109),char(95),char(110),char(117),
-char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87),char(101),char(105),char(103),
-char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102),char(114),char(97),char(109),
-char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(108),char(111),char(99),
-char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112),char(117),char(108),char(115),
-char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93),
-char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(114),
-char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(0),char(42),
-char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97),char(109),char(101),char(82),
-char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),
-char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(105),char(109),
-char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),
-char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112),char(105),char(110),char(103),
-char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97),char(109),char(112),char(105),
-char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(120),char(83),
-char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),
-char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),
-char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105),char(110),char(115),char(65),
-char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109),char(95),char(99),char(108),
-char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(0),
-char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50),char(93),char(0),char(109),
-char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101),char(108),char(101),char(116),
-char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50),char(93),char(0),char(109),
-char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(116),char(121),
-char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(112),char(111),
-char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(42),char(109),char(95),
-char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109),char(95),char(102),char(97),
-char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(42),char(109),
-char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(115),
-char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77),char(97),char(116),char(101),
-char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0),char(109),char(95),char(110),
-char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114),char(97),char(104),char(101),
-char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(109),char(95),char(110),
-char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74),char(111),char(105),char(110),
-char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(84),char(89),char(80),char(69),char(76),char(0),char(0),char(0),
-char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116),char(0),char(117),char(115),char(104),
-char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111),char(110),char(103),char(0),char(102),
-char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100),char(0),char(80),char(111),char(105),
-char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115),char(105),char(99),char(115),char(83),
-char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98),char(116),char(86),char(101),char(99),
-char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(86),char(101),char(99),char(116),
-char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116),char(114),
-char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116),
-char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),
-char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),
-char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97),
-char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(70),
-char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),
-char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),
-char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70),char(108),char(111),char(97),char(116),
-char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(68),
-char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),
-char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97),char(116),char(105),char(99),char(80),
-char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118),
-char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),
-char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100),char(105),char(117),char(115),char(0),
-char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),
-char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112),char(108),char(101),char(116),
-char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112),
-char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97),char(114),char(116),char(68),char(97),
-char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115),char(104),char(73),char(110),char(116),
-char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),
-char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),
-char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),
-char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),
-char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97),
-char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),
-char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121),char(108),char(105),char(110),char(100),
-char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108),
+char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),
+char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101),
+char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),
+char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),
+char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),
+char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80),char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84),
+char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116),
+char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),
+char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),
+char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99),
+char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100),char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114),
+char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95),char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84),
+char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116),
+char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108),
+char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84),
+char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112),char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95),
+char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105),
+char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67),
+char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73),
+char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108),
+char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110),
+char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101),char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0),
+char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),
+char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),
+char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70),
+char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101),
+char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),
+char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0),
+char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114),char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101),
+char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),
+char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),
+char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),
+char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76),
+char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),
+char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),
+char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),
+char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),
+char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),
+char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),
+char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),
+char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),
+char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116),
+char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0),char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65),
+char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95),char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101),
+char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112),
+char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100),
+char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101),char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97),
+char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68),
+char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108),
+char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116),char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100),
+char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111),char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109),
+char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98),
+char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104),
+char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(0),char(112),char(97),char(100),char(100),
+char(105),char(110),char(103),char(91),char(52),char(93),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),
+char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109),
+char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101),
+char(0),char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102),
+char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),
+char(97),char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108),
+char(97),char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101),
+char(116),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114),
+char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116),
+char(0),char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105),
+char(116),char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116),
+char(111),char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111),
+char(114),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(49),char(91),char(52),char(93),char(0),char(109),char(95),char(115),char(119),
+char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110),
+char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109),char(95),char(100),char(97),char(109),char(112),
+char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109),
+char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),
+char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),
+char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),
+char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101),char(102),char(101),char(114),char(101),char(110),
+char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79),char(102),char(102),char(115),char(101),char(116),
+char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114),char(97),char(109),char(101),char(0),char(109),
+char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(69),char(110),
+char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105),char(108),char(105),char(98),char(114),char(105),
+char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(83),
+char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),
+char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(65),
+char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(97),char(116),char(105),char(111),char(0),char(109),
+char(95),char(116),char(97),char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97),
+char(120),char(69),char(114),char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111),
+char(114),char(0),char(109),char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111),
+char(98),char(97),char(108),char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),
+char(101),char(80),char(101),char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),
+char(100),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110),
+char(69),char(114),char(112),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119),
+char(97),char(114),char(109),char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),
+char(109),char(97),char(120),char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109),
+char(95),char(115),char(105),char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),
+char(105),char(99),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117),
+char(109),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),
+char(77),char(111),char(100),char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99),
+char(116),char(82),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),
+char(100),char(0),char(109),char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116),
+char(99),char(104),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),
+char(101),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),
+char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),
+char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95),
+char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),
+char(109),char(95),char(112),char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),
+char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97),
+char(116),char(101),char(100),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95),
+char(97),char(114),char(101),char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101),
+char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110),
+char(103),char(116),char(104),char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100),
+char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114),
+char(101),char(97),char(0),char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),
+char(105),char(99),char(101),char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101),
+char(0),char(109),char(95),char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111),
+char(99),char(97),char(108),char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100),
+char(121),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111),
+char(77),char(111),char(100),char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95),
+char(100),char(114),char(97),char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117),
+char(114),char(101),char(0),char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105),
+char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99),
+char(104),char(0),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100),
+char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99),
+char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116),
+char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),
+char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),
+char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),
+char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),
+char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),
+char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),
+char(105),char(100),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),
+char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),
+char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102),
+char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),
+char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116),
+char(105),char(109),char(101),char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73),
+char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),
+char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116),
+char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116),
+char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97),
+char(108),char(101),char(0),char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111),
+char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109),
+char(95),char(110),char(117),char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87),
+char(101),char(105),char(103),char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102),
+char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95),
+char(108),char(111),char(99),char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112),
+char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),
+char(91),char(50),char(93),char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97),
+char(109),char(101),char(114),char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),
+char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97),
+char(109),char(101),char(82),char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95),
+char(110),char(117),char(109),char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109),
+char(95),char(105),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),
+char(109),char(95),char(110),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112),
+char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97),
+char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109),
+char(97),char(120),char(83),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),
+char(115),char(101),char(0),char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),
+char(112),char(117),char(108),char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105),
+char(110),char(115),char(65),char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109),
+char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100),
+char(121),char(65),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50),
+char(93),char(0),char(109),char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101),
+char(108),char(101),char(116),char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50),
+char(93),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121),
+char(66),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109),
+char(95),char(112),char(111),char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),
+char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109),
+char(95),char(102),char(97),char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97),
+char(0),char(42),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116),
+char(101),char(114),char(115),char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77),
+char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0),
+char(109),char(95),char(110),char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114),
+char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0),
+char(109),char(95),char(110),char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74),
+char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(0),char(84),char(89),char(80),char(69),
+char(87),char(0),char(0),char(0),char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116),
+char(0),char(117),char(115),char(104),char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111),
+char(110),char(103),char(0),char(102),char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100),
+char(0),char(80),char(111),char(105),char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115),
+char(105),char(99),char(115),char(83),char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98),
+char(116),char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),
+char(116),char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),
+char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68),
+char(97),char(116),char(97),char(0),char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111),
+char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),
+char(111),char(100),char(101),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),
+char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),
+char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70),
+char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),
+char(66),char(118),char(104),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108),
+char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97),
+char(116),char(105),char(99),char(80),char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(67),char(111),char(110),char(118),char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68),
+char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100),
+char(105),char(117),char(115),char(0),char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97),
+char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),
+char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120),
+char(84),char(114),char(105),char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97),
+char(114),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115),
+char(104),char(73),char(110),char(116),char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),
+char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),
+char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97),
+char(0),char(98),char(116),char(83),char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),
+char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110),
+char(100),char(83),char(104),char(97),char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),
+char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121),
+char(108),char(105),char(110),char(100),char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),
+char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108),
char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),
char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(73),char(109),char(112),char(97),char(99),char(116),char(77),
char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118),char(101),
@@ -305,155 +309,193 @@ char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(110),ch
char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),
char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),
char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(110),char(102),char(111),char(49),
-char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),
-char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(97),char(116),char(97),char(0),char(98),
-char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),
-char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),
-char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),
-char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),
-char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),
-char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),
-char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),
-char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),
+char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),
+char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),
+char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),
+char(121),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),
+char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),
+char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111),
+char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),
+char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),
+char(50),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),
+char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),
+char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),
+char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),
+char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),
+char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0),
+char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),
+char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),
+char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),
+char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67),
+char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),
+char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103),
char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),
char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103),char(67),char(111),char(110),char(115),char(116),char(114),
-char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110),
-char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),
-char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),
-char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105),
-char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68),
-char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116),
-char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116),
-char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97),
-char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111),char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),
-char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(0),
-char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0),
-char(8),char(0),char(0),char(0),char(12),char(0),char(36),char(0),char(8),char(0),char(16),char(0),char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0),
-char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(84),char(0),char(-124),char(0),char(12),char(0),char(52),char(0),char(52),char(0),
-char(20),char(0),char(64),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0),char(32),char(0),char(28),char(0),char(60),char(0),char(56),char(0),
-char(76),char(0),char(76),char(0),char(24),char(0),char(60),char(0),char(60),char(0),char(16),char(0),char(64),char(0),char(68),char(0),char(-48),char(1),char(0),char(1),
-char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-24),char(1),char(-96),char(3),char(8),char(0),char(52),char(0),char(0),char(0),char(84),char(0),
-char(116),char(0),char(92),char(1),char(-36),char(0),char(-44),char(0),char(-4),char(0),char(92),char(1),char(-52),char(0),char(16),char(0),char(100),char(0),char(20),char(0),
-char(36),char(0),char(100),char(0),char(92),char(0),char(104),char(0),char(-64),char(0),char(92),char(1),char(104),char(0),char(-84),char(1),char(83),char(84),char(82),char(67),
-char(65),char(0),char(0),char(0),char(10),char(0),char(3),char(0),char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0),
-char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0),char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0),
-char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0),char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0),
-char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0),char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0),
-char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0),char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0),
-char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0),char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0),
-char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0),char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0),
-char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0),
-char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),
-char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0),
-char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0),char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),
-char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0),
-char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0),
-char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),
-char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0),
-char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0),
-char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0),
-char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0),
-char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0),char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0),
-char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0),char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0),
-char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0),char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0),
-char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0),char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0),
-char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0),char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0),
-char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0),char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0),
-char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0),char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0),
-char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0),
-char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0),char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0),
-char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0),char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0),
-char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0),char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0),
-char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0),
-char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(43),char(0),char(4),char(0),char(4),char(0),char(78),char(0),
-char(7),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(37),char(0),char(14),char(0),char(4),char(0),char(82),char(0),
-char(4),char(0),char(83),char(0),char(43),char(0),char(84),char(0),char(4),char(0),char(85),char(0),char(7),char(0),char(86),char(0),char(7),char(0),char(87),char(0),
-char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(4),char(0),char(91),char(0),char(4),char(0),char(92),char(0),
-char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(0),char(0),char(37),char(0),char(44),char(0),char(5),char(0),char(25),char(0),char(38),char(0),
-char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(95),char(0),char(45),char(0),char(5),char(0),
-char(27),char(0),char(47),char(0),char(13),char(0),char(96),char(0),char(14),char(0),char(97),char(0),char(4),char(0),char(98),char(0),char(0),char(0),char(99),char(0),
-char(46),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0),char(0),char(0),char(35),char(0),
-char(18),char(0),char(103),char(0),char(18),char(0),char(104),char(0),char(14),char(0),char(105),char(0),char(14),char(0),char(106),char(0),char(14),char(0),char(107),char(0),
-char(8),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0),char(8),char(0),char(112),char(0),
-char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(4),char(0),char(116),char(0),char(4),char(0),char(117),char(0),
-char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0),
-char(0),char(0),char(37),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0),
-char(0),char(0),char(35),char(0),char(17),char(0),char(103),char(0),char(17),char(0),char(104),char(0),char(13),char(0),char(105),char(0),char(13),char(0),char(106),char(0),
-char(13),char(0),char(107),char(0),char(7),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0),char(7),char(0),char(111),char(0),
-char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0),char(4),char(0),char(116),char(0),
+char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0),char(98),char(116),char(83),char(108),
+char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),
+char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),
+char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114),char(67),char(111),char(110),char(115),char(116),char(114),
+char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114),
+char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),
+char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116),
+char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83),
+char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105),char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),
+char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),
+char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),
+char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),
+char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111),
+char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116),
+char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105),
+char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111),
+char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0),
+char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(0),char(0),char(12),char(0),char(36),char(0),char(8),char(0),char(16),char(0),
+char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0),char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(84),char(0),
+char(-124),char(0),char(12),char(0),char(52),char(0),char(52),char(0),char(20),char(0),char(64),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0),
+char(32),char(0),char(28),char(0),char(60),char(0),char(56),char(0),char(76),char(0),char(76),char(0),char(24),char(0),char(60),char(0),char(60),char(0),char(60),char(0),
+char(16),char(0),char(64),char(0),char(68),char(0),char(-48),char(1),char(0),char(1),char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-24),char(1),
+char(-96),char(3),char(8),char(0),char(52),char(0),char(52),char(0),char(0),char(0),char(68),char(0),char(84),char(0),char(-124),char(0),char(116),char(0),char(92),char(1),
+char(-36),char(0),char(-116),char(1),char(124),char(1),char(-44),char(0),char(-4),char(0),char(-52),char(1),char(92),char(1),char(116),char(2),char(-52),char(0),char(108),char(1),
+char(92),char(0),char(-116),char(0),char(16),char(0),char(100),char(0),char(20),char(0),char(36),char(0),char(100),char(0),char(92),char(0),char(104),char(0),char(-64),char(0),
+char(92),char(1),char(104),char(0),char(-84),char(1),char(0),char(0),char(83),char(84),char(82),char(67),char(76),char(0),char(0),char(0),char(10),char(0),char(3),char(0),
+char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0),char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0),
+char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0),char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0),
+char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0),char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0),
+char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0),char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0),
+char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0),char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0),
+char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0),
+char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),
+char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0),char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0),
+char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0),
+char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0),char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0),
+char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),
+char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),
+char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0),char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0),
+char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0),
+char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0),char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0),
+char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),
+char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0),char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0),
+char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0),
+char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0),char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0),
+char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0),char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0),
+char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0),char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0),
+char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0),char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0),
+char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0),char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0),
+char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0),char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0),
+char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),
+char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0),char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0),
+char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0),char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0),
+char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0),char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0),
+char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0),char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0),
+char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(78),char(0),
+char(0),char(0),char(37),char(0),char(43),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),
+char(44),char(0),char(4),char(0),char(4),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(7),char(0),char(82),char(0),
+char(37),char(0),char(14),char(0),char(4),char(0),char(83),char(0),char(4),char(0),char(84),char(0),char(44),char(0),char(85),char(0),char(4),char(0),char(86),char(0),
+char(7),char(0),char(87),char(0),char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(7),char(0),char(91),char(0),
+char(4),char(0),char(92),char(0),char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(4),char(0),char(95),char(0),char(0),char(0),char(37),char(0),
+char(45),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0),
+char(4),char(0),char(96),char(0),char(46),char(0),char(5),char(0),char(27),char(0),char(47),char(0),char(13),char(0),char(97),char(0),char(14),char(0),char(98),char(0),
+char(4),char(0),char(99),char(0),char(0),char(0),char(100),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(101),char(0),char(9),char(0),char(102),char(0),
+char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(18),char(0),char(104),char(0),char(18),char(0),char(105),char(0),char(14),char(0),char(106),char(0),
+char(14),char(0),char(107),char(0),char(14),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0),
+char(8),char(0),char(112),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(8),char(0),char(116),char(0),
char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0),
-char(4),char(0),char(122),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(2),char(0),char(49),char(0),char(123),char(0),char(14),char(0),char(124),char(0),
-char(50),char(0),char(2),char(0),char(51),char(0),char(123),char(0),char(13),char(0),char(124),char(0),char(52),char(0),char(21),char(0),char(47),char(0),char(125),char(0),
-char(15),char(0),char(126),char(0),char(13),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0),char(13),char(0),char(-126),char(0),
-char(13),char(0),char(124),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0),char(13),char(0),char(-122),char(0),
-char(7),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0),char(7),char(0),char(-117),char(0),
-char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0),
-char(53),char(0),char(22),char(0),char(46),char(0),char(125),char(0),char(16),char(0),char(126),char(0),char(14),char(0),char(127),char(0),char(14),char(0),char(-128),char(0),
-char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(124),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(-124),char(0),
-char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(8),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0),char(8),char(0),char(-119),char(0),
-char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0),char(8),char(0),char(-114),char(0),
-char(8),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0),char(0),char(0),char(37),char(0),char(54),char(0),char(2),char(0),char(4),char(0),char(-111),char(0),
-char(4),char(0),char(-110),char(0),char(55),char(0),char(13),char(0),char(56),char(0),char(-109),char(0),char(56),char(0),char(-108),char(0),char(0),char(0),char(35),char(0),
-char(4),char(0),char(-107),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(7),char(0),char(-103),char(0),
-char(7),char(0),char(-102),char(0),char(4),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(7),char(0),char(-99),char(0),char(4),char(0),char(-98),char(0),
-char(57),char(0),char(3),char(0),char(55),char(0),char(-97),char(0),char(13),char(0),char(-96),char(0),char(13),char(0),char(-95),char(0),char(58),char(0),char(3),char(0),
-char(55),char(0),char(-97),char(0),char(14),char(0),char(-96),char(0),char(14),char(0),char(-95),char(0),char(59),char(0),char(13),char(0),char(55),char(0),char(-97),char(0),
-char(18),char(0),char(-94),char(0),char(18),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),
-char(7),char(0),char(-89),char(0),char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),
-char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(60),char(0),char(13),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),
-char(17),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(7),char(0),char(-89),char(0),
-char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),
-char(7),char(0),char(-83),char(0),char(61),char(0),char(11),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),
-char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-80),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),
-char(7),char(0),char(-83),char(0),char(7),char(0),char(-79),char(0),char(0),char(0),char(21),char(0),char(62),char(0),char(9),char(0),char(55),char(0),char(-97),char(0),
-char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(13),char(0),char(-78),char(0),char(13),char(0),char(-77),char(0),char(13),char(0),char(-76),char(0),
-char(13),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(63),char(0),char(5),char(0),char(62),char(0),char(-72),char(0),
-char(4),char(0),char(-71),char(0),char(7),char(0),char(-70),char(0),char(7),char(0),char(-69),char(0),char(7),char(0),char(-68),char(0),char(64),char(0),char(9),char(0),
-char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0),
-char(7),char(0),char(-76),char(0),char(7),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(49),char(0),char(22),char(0),
-char(8),char(0),char(-67),char(0),char(8),char(0),char(-79),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(-66),char(0),char(8),char(0),char(112),char(0),
-char(8),char(0),char(-65),char(0),char(8),char(0),char(-64),char(0),char(8),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(8),char(0),char(-61),char(0),
-char(8),char(0),char(-60),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0),char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0),
-char(8),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0),char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0),
-char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0),char(51),char(0),char(22),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-79),char(0),
-char(7),char(0),char(110),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(-65),char(0),char(7),char(0),char(-64),char(0),
-char(7),char(0),char(-63),char(0),char(7),char(0),char(-62),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-60),char(0),char(7),char(0),char(-59),char(0),
-char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0),char(7),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0),
-char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0),char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0),
-char(65),char(0),char(4),char(0),char(7),char(0),char(-49),char(0),char(7),char(0),char(-48),char(0),char(7),char(0),char(-47),char(0),char(4),char(0),char(78),char(0),
-char(66),char(0),char(10),char(0),char(65),char(0),char(-46),char(0),char(13),char(0),char(-45),char(0),char(13),char(0),char(-44),char(0),char(13),char(0),char(-43),char(0),
-char(13),char(0),char(-42),char(0),char(13),char(0),char(-41),char(0),char(7),char(0),char(-121),char(0),char(7),char(0),char(-40),char(0),char(4),char(0),char(-39),char(0),
-char(4),char(0),char(53),char(0),char(67),char(0),char(4),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-38),char(0),char(7),char(0),char(-37),char(0),
-char(4),char(0),char(-36),char(0),char(68),char(0),char(4),char(0),char(13),char(0),char(-41),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-35),char(0),
-char(7),char(0),char(-34),char(0),char(69),char(0),char(7),char(0),char(13),char(0),char(-33),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-32),char(0),
-char(7),char(0),char(-31),char(0),char(7),char(0),char(-30),char(0),char(7),char(0),char(-29),char(0),char(4),char(0),char(53),char(0),char(70),char(0),char(6),char(0),
-char(15),char(0),char(-28),char(0),char(13),char(0),char(-30),char(0),char(13),char(0),char(-27),char(0),char(56),char(0),char(-26),char(0),char(4),char(0),char(-25),char(0),
-char(7),char(0),char(-29),char(0),char(71),char(0),char(26),char(0),char(4),char(0),char(-24),char(0),char(7),char(0),char(-23),char(0),char(7),char(0),char(-79),char(0),
-char(7),char(0),char(-22),char(0),char(7),char(0),char(-21),char(0),char(7),char(0),char(-20),char(0),char(7),char(0),char(-19),char(0),char(7),char(0),char(-18),char(0),
-char(7),char(0),char(-17),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0),char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0),
-char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0),char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0),
-char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0),char(4),char(0),char(-4),char(0),char(4),char(0),char(-3),char(0),
-char(4),char(0),char(-2),char(0),char(4),char(0),char(-1),char(0),char(4),char(0),char(117),char(0),char(72),char(0),char(12),char(0),char(15),char(0),char(0),char(1),
-char(15),char(0),char(1),char(1),char(15),char(0),char(2),char(1),char(13),char(0),char(3),char(1),char(13),char(0),char(4),char(1),char(7),char(0),char(5),char(1),
-char(4),char(0),char(6),char(1),char(4),char(0),char(7),char(1),char(4),char(0),char(8),char(1),char(4),char(0),char(9),char(1),char(7),char(0),char(-31),char(0),
-char(4),char(0),char(53),char(0),char(73),char(0),char(27),char(0),char(17),char(0),char(10),char(1),char(15),char(0),char(11),char(1),char(15),char(0),char(12),char(1),
-char(13),char(0),char(3),char(1),char(13),char(0),char(13),char(1),char(13),char(0),char(14),char(1),char(13),char(0),char(15),char(1),char(13),char(0),char(16),char(1),
-char(13),char(0),char(17),char(1),char(4),char(0),char(18),char(1),char(7),char(0),char(19),char(1),char(4),char(0),char(20),char(1),char(4),char(0),char(21),char(1),
-char(4),char(0),char(22),char(1),char(7),char(0),char(23),char(1),char(7),char(0),char(24),char(1),char(4),char(0),char(25),char(1),char(4),char(0),char(26),char(1),
-char(7),char(0),char(27),char(1),char(7),char(0),char(28),char(1),char(7),char(0),char(29),char(1),char(7),char(0),char(30),char(1),char(7),char(0),char(31),char(1),
-char(7),char(0),char(32),char(1),char(4),char(0),char(33),char(1),char(4),char(0),char(34),char(1),char(4),char(0),char(35),char(1),char(74),char(0),char(12),char(0),
-char(9),char(0),char(36),char(1),char(9),char(0),char(37),char(1),char(13),char(0),char(38),char(1),char(7),char(0),char(39),char(1),char(7),char(0),char(-63),char(0),
-char(7),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(13),char(0),char(42),char(1),char(4),char(0),char(43),char(1),char(4),char(0),char(44),char(1),
-char(4),char(0),char(45),char(1),char(4),char(0),char(53),char(0),char(75),char(0),char(19),char(0),char(47),char(0),char(125),char(0),char(72),char(0),char(46),char(1),
-char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),char(0),char(49),char(1),char(68),char(0),char(50),char(1),char(69),char(0),char(51),char(1),
-char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1),
-char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1),
-char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),};
+char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(25),char(0),char(9),char(0),char(101),char(0),
+char(9),char(0),char(102),char(0),char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(17),char(0),char(104),char(0),char(17),char(0),char(105),char(0),
+char(13),char(0),char(106),char(0),char(13),char(0),char(107),char(0),char(13),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0),
+char(7),char(0),char(111),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0),
+char(7),char(0),char(116),char(0),char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),
+char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(49),char(0),char(2),char(0),
+char(50),char(0),char(124),char(0),char(14),char(0),char(125),char(0),char(51),char(0),char(2),char(0),char(52),char(0),char(124),char(0),char(13),char(0),char(125),char(0),
+char(53),char(0),char(21),char(0),char(48),char(0),char(126),char(0),char(15),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0),
+char(13),char(0),char(-126),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0),
+char(13),char(0),char(-122),char(0),char(13),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0),
+char(7),char(0),char(-117),char(0),char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0),
+char(7),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(54),char(0),char(22),char(0),char(47),char(0),char(126),char(0),char(16),char(0),char(127),char(0),
+char(14),char(0),char(-128),char(0),char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(125),char(0),
+char(14),char(0),char(-124),char(0),char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(14),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0),
+char(8),char(0),char(-119),char(0),char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0),
+char(8),char(0),char(-114),char(0),char(8),char(0),char(-113),char(0),char(8),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(0),char(0),char(37),char(0),
+char(55),char(0),char(2),char(0),char(4),char(0),char(-110),char(0),char(4),char(0),char(-109),char(0),char(56),char(0),char(13),char(0),char(53),char(0),char(-108),char(0),
+char(53),char(0),char(-107),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),
+char(4),char(0),char(-103),char(0),char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),
+char(7),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0),char(57),char(0),char(13),char(0),char(58),char(0),char(-108),char(0),char(58),char(0),char(-107),char(0),
+char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0),
+char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(7),char(0),char(-98),char(0),
+char(4),char(0),char(-97),char(0),char(59),char(0),char(14),char(0),char(54),char(0),char(-108),char(0),char(54),char(0),char(-107),char(0),char(0),char(0),char(35),char(0),
+char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0),char(8),char(0),char(-102),char(0),
+char(8),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(8),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0),
+char(0),char(0),char(-96),char(0),char(60),char(0),char(3),char(0),char(57),char(0),char(-95),char(0),char(13),char(0),char(-94),char(0),char(13),char(0),char(-93),char(0),
+char(61),char(0),char(3),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(62),char(0),char(3),char(0),
+char(57),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(63),char(0),char(13),char(0),char(57),char(0),char(-95),char(0),
+char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),
+char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),
+char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(64),char(0),char(13),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),
+char(17),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),
+char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(7),char(0),char(-82),char(0),
+char(7),char(0),char(-81),char(0),char(65),char(0),char(14),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),
+char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(8),char(0),char(-87),char(0),char(8),char(0),char(-86),char(0),
+char(8),char(0),char(-85),char(0),char(8),char(0),char(-84),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0),char(8),char(0),char(-81),char(0),
+char(0),char(0),char(-80),char(0),char(66),char(0),char(10),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),
+char(8),char(0),char(-79),char(0),char(8),char(0),char(-78),char(0),char(8),char(0),char(-77),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0),
+char(8),char(0),char(-81),char(0),char(8),char(0),char(-76),char(0),char(67),char(0),char(11),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),
+char(17),char(0),char(-91),char(0),char(7),char(0),char(-79),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0),char(7),char(0),char(-83),char(0),
+char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-76),char(0),char(0),char(0),char(21),char(0),char(68),char(0),char(9),char(0),
+char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0),char(13),char(0),char(-75),char(0),char(13),char(0),char(-74),char(0),
+char(13),char(0),char(-73),char(0),char(13),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(69),char(0),char(9),char(0),
+char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(14),char(0),char(-75),char(0),char(14),char(0),char(-74),char(0),
+char(14),char(0),char(-73),char(0),char(14),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(70),char(0),char(5),char(0),
+char(68),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(-65),char(0),
+char(71),char(0),char(5),char(0),char(69),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(8),char(0),char(-67),char(0),char(8),char(0),char(-66),char(0),
+char(8),char(0),char(-65),char(0),char(72),char(0),char(9),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0),
+char(7),char(0),char(-75),char(0),char(7),char(0),char(-74),char(0),char(7),char(0),char(-73),char(0),char(7),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),
+char(4),char(0),char(-70),char(0),char(73),char(0),char(9),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),
+char(8),char(0),char(-75),char(0),char(8),char(0),char(-74),char(0),char(8),char(0),char(-73),char(0),char(8),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),
+char(4),char(0),char(-70),char(0),char(74),char(0),char(5),char(0),char(56),char(0),char(-95),char(0),char(13),char(0),char(-64),char(0),char(13),char(0),char(-63),char(0),
+char(7),char(0),char(-62),char(0),char(0),char(0),char(37),char(0),char(75),char(0),char(4),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-64),char(0),
+char(14),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(50),char(0),char(22),char(0),char(8),char(0),char(-61),char(0),char(8),char(0),char(-76),char(0),
+char(8),char(0),char(111),char(0),char(8),char(0),char(-60),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0),
+char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0),char(8),char(0),char(-55),char(0),char(8),char(0),char(-54),char(0),char(8),char(0),char(-53),char(0),
+char(8),char(0),char(-52),char(0),char(8),char(0),char(-51),char(0),char(8),char(0),char(-50),char(0),char(8),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0),
+char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0),char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0),
+char(52),char(0),char(22),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(111),char(0),char(7),char(0),char(-60),char(0),
+char(7),char(0),char(113),char(0),char(7),char(0),char(-59),char(0),char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0),
+char(7),char(0),char(-55),char(0),char(7),char(0),char(-54),char(0),char(7),char(0),char(-53),char(0),char(7),char(0),char(-52),char(0),char(7),char(0),char(-51),char(0),
+char(7),char(0),char(-50),char(0),char(7),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0),char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0),
+char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0),char(76),char(0),char(4),char(0),char(7),char(0),char(-43),char(0),
+char(7),char(0),char(-42),char(0),char(7),char(0),char(-41),char(0),char(4),char(0),char(79),char(0),char(77),char(0),char(10),char(0),char(76),char(0),char(-40),char(0),
+char(13),char(0),char(-39),char(0),char(13),char(0),char(-38),char(0),char(13),char(0),char(-37),char(0),char(13),char(0),char(-36),char(0),char(13),char(0),char(-35),char(0),
+char(7),char(0),char(-120),char(0),char(7),char(0),char(-34),char(0),char(4),char(0),char(-33),char(0),char(4),char(0),char(53),char(0),char(78),char(0),char(4),char(0),
+char(76),char(0),char(-40),char(0),char(4),char(0),char(-32),char(0),char(7),char(0),char(-31),char(0),char(4),char(0),char(-30),char(0),char(79),char(0),char(4),char(0),
+char(13),char(0),char(-35),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-29),char(0),char(7),char(0),char(-28),char(0),char(80),char(0),char(7),char(0),
+char(13),char(0),char(-27),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-26),char(0),char(7),char(0),char(-25),char(0),char(7),char(0),char(-24),char(0),
+char(7),char(0),char(-23),char(0),char(4),char(0),char(53),char(0),char(81),char(0),char(6),char(0),char(15),char(0),char(-22),char(0),char(13),char(0),char(-24),char(0),
+char(13),char(0),char(-21),char(0),char(58),char(0),char(-20),char(0),char(4),char(0),char(-19),char(0),char(7),char(0),char(-23),char(0),char(82),char(0),char(26),char(0),
+char(4),char(0),char(-18),char(0),char(7),char(0),char(-17),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0),
+char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0),char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0),
+char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0),char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0),
+char(7),char(0),char(-4),char(0),char(7),char(0),char(-3),char(0),char(7),char(0),char(-2),char(0),char(7),char(0),char(-1),char(0),char(7),char(0),char(0),char(1),
+char(7),char(0),char(1),char(1),char(4),char(0),char(2),char(1),char(4),char(0),char(3),char(1),char(4),char(0),char(4),char(1),char(4),char(0),char(5),char(1),
+char(4),char(0),char(118),char(0),char(83),char(0),char(12),char(0),char(15),char(0),char(6),char(1),char(15),char(0),char(7),char(1),char(15),char(0),char(8),char(1),
+char(13),char(0),char(9),char(1),char(13),char(0),char(10),char(1),char(7),char(0),char(11),char(1),char(4),char(0),char(12),char(1),char(4),char(0),char(13),char(1),
+char(4),char(0),char(14),char(1),char(4),char(0),char(15),char(1),char(7),char(0),char(-25),char(0),char(4),char(0),char(53),char(0),char(84),char(0),char(27),char(0),
+char(17),char(0),char(16),char(1),char(15),char(0),char(17),char(1),char(15),char(0),char(18),char(1),char(13),char(0),char(9),char(1),char(13),char(0),char(19),char(1),
+char(13),char(0),char(20),char(1),char(13),char(0),char(21),char(1),char(13),char(0),char(22),char(1),char(13),char(0),char(23),char(1),char(4),char(0),char(24),char(1),
+char(7),char(0),char(25),char(1),char(4),char(0),char(26),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(28),char(1),char(7),char(0),char(29),char(1),
+char(7),char(0),char(30),char(1),char(4),char(0),char(31),char(1),char(4),char(0),char(32),char(1),char(7),char(0),char(33),char(1),char(7),char(0),char(34),char(1),
+char(7),char(0),char(35),char(1),char(7),char(0),char(36),char(1),char(7),char(0),char(37),char(1),char(7),char(0),char(38),char(1),char(4),char(0),char(39),char(1),
+char(4),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(85),char(0),char(12),char(0),char(9),char(0),char(42),char(1),char(9),char(0),char(43),char(1),
+char(13),char(0),char(44),char(1),char(7),char(0),char(45),char(1),char(7),char(0),char(-57),char(0),char(7),char(0),char(46),char(1),char(4),char(0),char(47),char(1),
+char(13),char(0),char(48),char(1),char(4),char(0),char(49),char(1),char(4),char(0),char(50),char(1),char(4),char(0),char(51),char(1),char(4),char(0),char(53),char(0),
+char(86),char(0),char(19),char(0),char(48),char(0),char(126),char(0),char(83),char(0),char(52),char(1),char(76),char(0),char(53),char(1),char(77),char(0),char(54),char(1),
+char(78),char(0),char(55),char(1),char(79),char(0),char(56),char(1),char(80),char(0),char(57),char(1),char(81),char(0),char(58),char(1),char(84),char(0),char(59),char(1),
+char(85),char(0),char(60),char(1),char(4),char(0),char(61),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(62),char(1),char(4),char(0),char(63),char(1),
+char(4),char(0),char(64),char(1),char(4),char(0),char(65),char(1),char(4),char(0),char(66),char(1),char(4),char(0),char(67),char(1),char(82),char(0),char(68),char(1),
+};
int sBulletDNAlen= sizeof(sBulletDNAstr);
+
char sBulletDNAstr64[]= {
-char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109),
+char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(69),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109),
char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95),
char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111),
char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),
@@ -512,238 +554,242 @@ char(102),char(111),char(114),char(109),char(0),char(42),char(109),char(95),char
char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104),char(97),char(112),char(101),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104),
char(105),char(108),char(100),char(77),char(97),char(114),char(103),char(105),char(110),char(0),char(42),char(109),char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104),
char(97),char(112),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(104),char(105),char(108),char(100),char(83),char(104),char(97),
-char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115),
-char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86),char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),
-char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),
-char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),
-char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101),char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118),
-char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65),
-char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105),
-char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110),char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),
-char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114),char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111),
-char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68),char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114),
-char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122),char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114),
-char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95),
-char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86),
-char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105),
-char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),
-char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42),
-char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98),
-char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),
-char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0),
-char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104),char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0),
-char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109),
-char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),
-char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),
-char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97),
+char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(117),char(112),char(73),char(110),char(100),
+char(101),char(120),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86),
+char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103),
+char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42),
+char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101),
+char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118),char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80),
+char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95),
+char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110),
+char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114),
+char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68),
+char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122),
+char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),
+char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83),
+char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86),char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117),
+char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105),char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121),
+char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),
+char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),
+char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),
+char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97),
+char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0),char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104),
+char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0),char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),
+char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109),char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105),
+char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97),
char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),
-char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105),
-char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86),
-char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),
-char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80),
-char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95),
-char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),
-char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),
-char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100),
-char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114),char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95),
-char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),
-char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115),
-char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84),char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112),
-char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),
-char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112),
-char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67),char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104),
-char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73),char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118),
-char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),
-char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101),
-char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101),
-char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),
-char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),
-char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114),
-char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101),char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109),
-char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116),
-char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114),
-char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101),char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95),
-char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117),
-char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),
-char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97),
-char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),
-char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),
-char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),
-char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),
-char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),
-char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112),
-char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),
-char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),
-char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),
-char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0),
-char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65),char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95),
-char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),
-char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),
-char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100),char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101),
-char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97),char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117),
-char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68),char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95),
-char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116),
-char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100),char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111),
-char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114),
-char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98),char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112),
-char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110),
-char(97),char(98),char(108),char(101),char(100),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),
-char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109),char(95),
-char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101),char(0),
-char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102),char(101),
-char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),
-char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108),char(97),
-char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101),char(116),
-char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114),char(73),
-char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),
-char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105),char(116),
-char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116),char(111),
-char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111),char(114),
-char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110),
-char(103),char(83),char(112),char(97),char(110),char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109),
-char(95),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112),
-char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101),
-char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101),
-char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101),
-char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101),
-char(102),char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79),
-char(102),char(102),char(115),char(101),char(116),char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114),
-char(97),char(109),char(101),char(0),char(109),char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114),
-char(105),char(110),char(103),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105),
-char(108),char(105),char(98),char(114),char(105),char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),
-char(114),char(105),char(110),char(103),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115),
-char(112),char(114),char(105),char(110),char(103),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(116),char(97),
-char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97),char(120),char(69),char(114),
-char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111),char(114),char(0),char(109),
-char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111),char(98),char(97),char(108),
-char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(80),char(101),
-char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110),char(69),char(114),char(112),
-char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119),char(97),char(114),char(109),
-char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(97),char(120),
-char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(115),char(105),
-char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116),
-char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117),char(109),char(73),char(116),
-char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(77),char(111),char(100),
-char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(82),char(101),
-char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),
-char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116),char(99),char(104),char(83),
-char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),
-char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),
-char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(118),char(111),
-char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(116),
-char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),
-char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(118),char(101),
-char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97),char(116),char(101),char(100),
-char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95),char(97),char(114),char(101),
-char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),
-char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110),char(103),char(116),char(104),
-char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),
-char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114),char(101),char(97),char(0),
-char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),
-char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),
-char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111),char(99),char(97),char(108),
-char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(0),char(109),
-char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111),char(77),char(111),char(100),
-char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95),char(100),char(114),char(97),
-char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117),char(114),char(101),char(0),
-char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105),char(99),char(70),char(114),
-char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99),char(104),char(0),char(109),
-char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),
-char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),
-char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116),char(97),char(99),char(116),
-char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(72),char(97),char(114),
-char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67),char(108),char(117),
-char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75),
-char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),
-char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),
-char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67),
-char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),
-char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),
-char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),
-char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),
-char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116),char(105),char(109),char(101),
-char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73),char(116),char(101),char(114),
-char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(73),char(116),char(101),
-char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116),char(101),char(114),char(97),
-char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116),char(101),char(114),char(97),
-char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97),char(108),char(101),char(0),
-char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111),char(115),char(105),char(116),
-char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109),char(95),char(110),char(117),
-char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87),char(101),char(105),char(103),
-char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102),char(114),char(97),char(109),
-char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(108),char(111),char(99),
-char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112),char(117),char(108),char(115),
-char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93),
-char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(114),
-char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(0),char(42),
-char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97),char(109),char(101),char(82),
-char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),
-char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(105),char(109),
-char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),
-char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112),char(105),char(110),char(103),
-char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97),char(109),char(112),char(105),
-char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(120),char(83),
-char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),
-char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),
-char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105),char(110),char(115),char(65),
-char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109),char(95),char(99),char(108),
-char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(0),
-char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50),char(93),char(0),char(109),
-char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101),char(108),char(101),char(116),
-char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50),char(93),char(0),char(109),
-char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(116),char(121),
-char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(112),char(111),
-char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(42),char(109),char(95),
-char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109),char(95),char(102),char(97),
-char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(42),char(109),
-char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(115),
-char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77),char(97),char(116),char(101),
-char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0),char(109),char(95),char(110),
-char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114),char(97),char(104),char(101),
-char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(109),char(95),char(110),
-char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74),char(111),char(105),char(110),
-char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(84),char(89),char(80),char(69),char(76),char(0),char(0),char(0),
-char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116),char(0),char(117),char(115),char(104),
-char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111),char(110),char(103),char(0),char(102),
-char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100),char(0),char(80),char(111),char(105),
-char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115),char(105),char(99),char(115),char(83),
-char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98),char(116),char(86),char(101),char(99),
-char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(86),char(101),char(99),char(116),
-char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116),char(114),
-char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116),
-char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),
-char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),
-char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97),
-char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(70),
-char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),
-char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),
-char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70),char(108),char(111),char(97),char(116),
-char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(68),
-char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),
-char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97),char(116),char(105),char(99),char(80),
-char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118),
-char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),
-char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100),char(105),char(117),char(115),char(0),
-char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),
-char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112),char(108),char(101),char(116),
-char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112),
-char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97),char(114),char(116),char(68),char(97),
-char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115),char(104),char(73),char(110),char(116),
-char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),
-char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),
-char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),
-char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),
-char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97),
-char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),
-char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121),char(108),char(105),char(110),char(100),
-char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108),
+char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),
+char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101),
+char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),
+char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),
+char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),
+char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80),char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84),
+char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116),
+char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),
+char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),
+char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99),
+char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100),char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114),
+char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95),char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84),
+char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116),
+char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108),
+char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84),
+char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112),char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95),
+char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105),
+char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67),
+char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73),
+char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108),
+char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110),
+char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101),char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0),
+char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),
+char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),
+char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70),
+char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101),
+char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),
+char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0),
+char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114),char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101),
+char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),
+char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),
+char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),
+char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76),
+char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),
+char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),
+char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),
+char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),
+char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),
+char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),
+char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),
+char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),
+char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116),
+char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0),char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65),
+char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95),char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101),
+char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112),
+char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100),
+char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101),char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97),
+char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68),
+char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108),
+char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116),char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100),
+char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111),char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109),
+char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98),
+char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104),
+char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(0),char(112),char(97),char(100),char(100),
+char(105),char(110),char(103),char(91),char(52),char(93),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),
+char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109),
+char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101),
+char(0),char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102),
+char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),
+char(97),char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108),
+char(97),char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101),
+char(116),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114),
+char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116),
+char(0),char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105),
+char(116),char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116),
+char(111),char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111),
+char(114),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(49),char(91),char(52),char(93),char(0),char(109),char(95),char(115),char(119),
+char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110),
+char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109),char(95),char(100),char(97),char(109),char(112),
+char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109),
+char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),
+char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),
+char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),
+char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101),char(102),char(101),char(114),char(101),char(110),
+char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79),char(102),char(102),char(115),char(101),char(116),
+char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114),char(97),char(109),char(101),char(0),char(109),
+char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(69),char(110),
+char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105),char(108),char(105),char(98),char(114),char(105),
+char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(83),
+char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),
+char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(65),
+char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(97),char(116),char(105),char(111),char(0),char(109),
+char(95),char(116),char(97),char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97),
+char(120),char(69),char(114),char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111),
+char(114),char(0),char(109),char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111),
+char(98),char(97),char(108),char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),
+char(101),char(80),char(101),char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),
+char(100),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110),
+char(69),char(114),char(112),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119),
+char(97),char(114),char(109),char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),
+char(109),char(97),char(120),char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109),
+char(95),char(115),char(105),char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),
+char(105),char(99),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117),
+char(109),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),
+char(77),char(111),char(100),char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99),
+char(116),char(82),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),
+char(100),char(0),char(109),char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116),
+char(99),char(104),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),
+char(101),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),
+char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),
+char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95),
+char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),
+char(109),char(95),char(112),char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),
+char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97),
+char(116),char(101),char(100),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95),
+char(97),char(114),char(101),char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101),
+char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110),
+char(103),char(116),char(104),char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100),
+char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114),
+char(101),char(97),char(0),char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),
+char(105),char(99),char(101),char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101),
+char(0),char(109),char(95),char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111),
+char(99),char(97),char(108),char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100),
+char(121),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111),
+char(77),char(111),char(100),char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95),
+char(100),char(114),char(97),char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117),
+char(114),char(101),char(0),char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105),
+char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99),
+char(104),char(0),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100),
+char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99),
+char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116),
+char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),
+char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),
+char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),
+char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),
+char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),
+char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),
+char(105),char(100),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),
+char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),
+char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102),
+char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),
+char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116),
+char(105),char(109),char(101),char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73),
+char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),
+char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116),
+char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116),
+char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97),
+char(108),char(101),char(0),char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111),
+char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109),
+char(95),char(110),char(117),char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87),
+char(101),char(105),char(103),char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102),
+char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95),
+char(108),char(111),char(99),char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112),
+char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),
+char(91),char(50),char(93),char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97),
+char(109),char(101),char(114),char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),
+char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97),
+char(109),char(101),char(82),char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95),
+char(110),char(117),char(109),char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109),
+char(95),char(105),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),
+char(109),char(95),char(110),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112),
+char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97),
+char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109),
+char(97),char(120),char(83),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),
+char(115),char(101),char(0),char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),
+char(112),char(117),char(108),char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105),
+char(110),char(115),char(65),char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109),
+char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100),
+char(121),char(65),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50),
+char(93),char(0),char(109),char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101),
+char(108),char(101),char(116),char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50),
+char(93),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121),
+char(66),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109),
+char(95),char(112),char(111),char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),
+char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109),
+char(95),char(102),char(97),char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97),
+char(0),char(42),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116),
+char(101),char(114),char(115),char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77),
+char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0),
+char(109),char(95),char(110),char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114),
+char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0),
+char(109),char(95),char(110),char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74),
+char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(0),char(84),char(89),char(80),char(69),
+char(87),char(0),char(0),char(0),char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116),
+char(0),char(117),char(115),char(104),char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111),
+char(110),char(103),char(0),char(102),char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100),
+char(0),char(80),char(111),char(105),char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115),
+char(105),char(99),char(115),char(83),char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98),
+char(116),char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),
+char(116),char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),
+char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68),
+char(97),char(116),char(97),char(0),char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111),
+char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),
+char(111),char(100),char(101),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),
+char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),
+char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70),
+char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),
+char(66),char(118),char(104),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108),
+char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97),
+char(116),char(105),char(99),char(80),char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(67),char(111),char(110),char(118),char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68),
+char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100),
+char(105),char(117),char(115),char(0),char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97),
+char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),
+char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),
+char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120),
+char(84),char(114),char(105),char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97),
+char(114),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115),
+char(104),char(73),char(110),char(116),char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),
+char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),
+char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97),
+char(0),char(98),char(116),char(83),char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),
+char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110),
+char(100),char(83),char(104),char(97),char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),
+char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121),
+char(108),char(105),char(110),char(100),char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),
+char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108),
char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),
char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(73),char(109),char(112),char(97),char(99),char(116),char(77),
char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118),char(101),
@@ -759,150 +805,187 @@ char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(110),ch
char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),
char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),
char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(110),char(102),char(111),char(49),
-char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),
-char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(97),char(116),char(97),char(0),char(98),
-char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),
-char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),
-char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),
-char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),
-char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),
-char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),
-char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),
-char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),
+char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),
+char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),
+char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),
+char(121),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),
+char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),
+char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111),
+char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),
+char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),
+char(50),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),
+char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),
+char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),
+char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),
+char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),
+char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0),
+char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),
+char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),
+char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
+char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),
+char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67),
+char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),
+char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103),
char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),
char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103),char(67),char(111),char(110),char(115),char(116),char(114),
-char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110),
-char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),
-char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),
-char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105),
-char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68),
-char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116),
-char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116),
-char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97),
-char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111),char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),
-char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),
-char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(0),
-char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0),
-char(8),char(0),char(0),char(0),char(16),char(0),char(48),char(0),char(16),char(0),char(16),char(0),char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0),
-char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(96),char(0),char(-112),char(0),char(16),char(0),char(56),char(0),char(56),char(0),
-char(20),char(0),char(72),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0),char(56),char(0),char(32),char(0),char(80),char(0),char(72),char(0),
-char(96),char(0),char(80),char(0),char(32),char(0),char(64),char(0),char(64),char(0),char(16),char(0),char(72),char(0),char(80),char(0),char(-32),char(1),char(16),char(1),
-char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-8),char(1),char(-80),char(3),char(8),char(0),char(64),char(0),char(0),char(0),char(96),char(0),
-char(-128),char(0),char(104),char(1),char(-24),char(0),char(-32),char(0),char(8),char(1),char(104),char(1),char(-40),char(0),char(16),char(0),char(104),char(0),char(24),char(0),
-char(40),char(0),char(104),char(0),char(96),char(0),char(104),char(0),char(-56),char(0),char(104),char(1),char(112),char(0),char(-32),char(1),char(83),char(84),char(82),char(67),
-char(65),char(0),char(0),char(0),char(10),char(0),char(3),char(0),char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0),
-char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0),char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0),
-char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0),char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0),
-char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0),char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0),
-char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0),char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0),
-char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0),char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0),
-char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0),char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0),
-char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0),
-char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),
-char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0),
-char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0),char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),
-char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0),
-char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0),
-char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),
-char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0),
-char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0),
-char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0),
-char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0),
-char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0),char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0),
-char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0),char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0),
-char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0),char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0),
-char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0),char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0),
-char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0),char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0),
-char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0),char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0),
-char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0),char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0),
-char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0),
-char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0),char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0),
-char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0),char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0),
-char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0),char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0),
-char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0),
-char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(43),char(0),char(4),char(0),char(4),char(0),char(78),char(0),
-char(7),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(37),char(0),char(14),char(0),char(4),char(0),char(82),char(0),
-char(4),char(0),char(83),char(0),char(43),char(0),char(84),char(0),char(4),char(0),char(85),char(0),char(7),char(0),char(86),char(0),char(7),char(0),char(87),char(0),
-char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(4),char(0),char(91),char(0),char(4),char(0),char(92),char(0),
-char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(0),char(0),char(37),char(0),char(44),char(0),char(5),char(0),char(25),char(0),char(38),char(0),
-char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(95),char(0),char(45),char(0),char(5),char(0),
-char(27),char(0),char(47),char(0),char(13),char(0),char(96),char(0),char(14),char(0),char(97),char(0),char(4),char(0),char(98),char(0),char(0),char(0),char(99),char(0),
-char(46),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0),char(0),char(0),char(35),char(0),
-char(18),char(0),char(103),char(0),char(18),char(0),char(104),char(0),char(14),char(0),char(105),char(0),char(14),char(0),char(106),char(0),char(14),char(0),char(107),char(0),
-char(8),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0),char(8),char(0),char(112),char(0),
-char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(4),char(0),char(116),char(0),char(4),char(0),char(117),char(0),
-char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0),
-char(0),char(0),char(37),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0),
-char(0),char(0),char(35),char(0),char(17),char(0),char(103),char(0),char(17),char(0),char(104),char(0),char(13),char(0),char(105),char(0),char(13),char(0),char(106),char(0),
-char(13),char(0),char(107),char(0),char(7),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0),char(7),char(0),char(111),char(0),
-char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0),char(4),char(0),char(116),char(0),
+char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0),char(98),char(116),char(83),char(108),
+char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),
+char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),
+char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114),char(67),char(111),char(110),char(115),char(116),char(114),
+char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114),
+char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),
+char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116),
+char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83),
+char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105),char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),
+char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),
+char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),
+char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),
+char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111),
+char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116),
+char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105),
+char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111),
+char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0),
+char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(0),char(0),char(16),char(0),char(48),char(0),char(16),char(0),char(16),char(0),
+char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0),char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(96),char(0),
+char(-112),char(0),char(16),char(0),char(56),char(0),char(56),char(0),char(20),char(0),char(72),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0),
+char(56),char(0),char(32),char(0),char(80),char(0),char(72),char(0),char(96),char(0),char(80),char(0),char(32),char(0),char(64),char(0),char(64),char(0),char(64),char(0),
+char(16),char(0),char(72),char(0),char(80),char(0),char(-32),char(1),char(16),char(1),char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-8),char(1),
+char(-80),char(3),char(8),char(0),char(64),char(0),char(64),char(0),char(0),char(0),char(80),char(0),char(96),char(0),char(-112),char(0),char(-128),char(0),char(104),char(1),
+char(-24),char(0),char(-104),char(1),char(-120),char(1),char(-32),char(0),char(8),char(1),char(-40),char(1),char(104),char(1),char(-128),char(2),char(-40),char(0),char(120),char(1),
+char(104),char(0),char(-104),char(0),char(16),char(0),char(104),char(0),char(24),char(0),char(40),char(0),char(104),char(0),char(96),char(0),char(104),char(0),char(-56),char(0),
+char(104),char(1),char(112),char(0),char(-32),char(1),char(0),char(0),char(83),char(84),char(82),char(67),char(76),char(0),char(0),char(0),char(10),char(0),char(3),char(0),
+char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0),char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0),
+char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0),char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0),
+char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0),char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0),
+char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0),char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0),
+char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0),char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0),
+char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0),
+char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),
+char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0),char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0),
+char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0),
+char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0),char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0),
+char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),
+char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),
+char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0),char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0),
+char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0),
+char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0),char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0),
+char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),
+char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0),char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0),
+char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0),
+char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0),char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0),
+char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0),char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0),
+char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0),char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0),
+char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0),char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0),
+char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0),char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0),
+char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0),char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0),
+char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),
+char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0),char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0),
+char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0),char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0),
+char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0),char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0),
+char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0),char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0),
+char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(78),char(0),
+char(0),char(0),char(37),char(0),char(43),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),
+char(44),char(0),char(4),char(0),char(4),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(7),char(0),char(82),char(0),
+char(37),char(0),char(14),char(0),char(4),char(0),char(83),char(0),char(4),char(0),char(84),char(0),char(44),char(0),char(85),char(0),char(4),char(0),char(86),char(0),
+char(7),char(0),char(87),char(0),char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(7),char(0),char(91),char(0),
+char(4),char(0),char(92),char(0),char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(4),char(0),char(95),char(0),char(0),char(0),char(37),char(0),
+char(45),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0),
+char(4),char(0),char(96),char(0),char(46),char(0),char(5),char(0),char(27),char(0),char(47),char(0),char(13),char(0),char(97),char(0),char(14),char(0),char(98),char(0),
+char(4),char(0),char(99),char(0),char(0),char(0),char(100),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(101),char(0),char(9),char(0),char(102),char(0),
+char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(18),char(0),char(104),char(0),char(18),char(0),char(105),char(0),char(14),char(0),char(106),char(0),
+char(14),char(0),char(107),char(0),char(14),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0),
+char(8),char(0),char(112),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(8),char(0),char(116),char(0),
char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0),
-char(4),char(0),char(122),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(2),char(0),char(49),char(0),char(123),char(0),char(14),char(0),char(124),char(0),
-char(50),char(0),char(2),char(0),char(51),char(0),char(123),char(0),char(13),char(0),char(124),char(0),char(52),char(0),char(21),char(0),char(47),char(0),char(125),char(0),
-char(15),char(0),char(126),char(0),char(13),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0),char(13),char(0),char(-126),char(0),
-char(13),char(0),char(124),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0),char(13),char(0),char(-122),char(0),
-char(7),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0),char(7),char(0),char(-117),char(0),
-char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0),
-char(53),char(0),char(22),char(0),char(46),char(0),char(125),char(0),char(16),char(0),char(126),char(0),char(14),char(0),char(127),char(0),char(14),char(0),char(-128),char(0),
-char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(124),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(-124),char(0),
-char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(8),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0),char(8),char(0),char(-119),char(0),
-char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0),char(8),char(0),char(-114),char(0),
-char(8),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0),char(0),char(0),char(37),char(0),char(54),char(0),char(2),char(0),char(4),char(0),char(-111),char(0),
-char(4),char(0),char(-110),char(0),char(55),char(0),char(13),char(0),char(56),char(0),char(-109),char(0),char(56),char(0),char(-108),char(0),char(0),char(0),char(35),char(0),
-char(4),char(0),char(-107),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(7),char(0),char(-103),char(0),
-char(7),char(0),char(-102),char(0),char(4),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(7),char(0),char(-99),char(0),char(4),char(0),char(-98),char(0),
-char(57),char(0),char(3),char(0),char(55),char(0),char(-97),char(0),char(13),char(0),char(-96),char(0),char(13),char(0),char(-95),char(0),char(58),char(0),char(3),char(0),
-char(55),char(0),char(-97),char(0),char(14),char(0),char(-96),char(0),char(14),char(0),char(-95),char(0),char(59),char(0),char(13),char(0),char(55),char(0),char(-97),char(0),
-char(18),char(0),char(-94),char(0),char(18),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),
-char(7),char(0),char(-89),char(0),char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),
-char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(60),char(0),char(13),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),
-char(17),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(7),char(0),char(-89),char(0),
-char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),
-char(7),char(0),char(-83),char(0),char(61),char(0),char(11),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),
-char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-80),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),
-char(7),char(0),char(-83),char(0),char(7),char(0),char(-79),char(0),char(0),char(0),char(21),char(0),char(62),char(0),char(9),char(0),char(55),char(0),char(-97),char(0),
-char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(13),char(0),char(-78),char(0),char(13),char(0),char(-77),char(0),char(13),char(0),char(-76),char(0),
-char(13),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(63),char(0),char(5),char(0),char(62),char(0),char(-72),char(0),
-char(4),char(0),char(-71),char(0),char(7),char(0),char(-70),char(0),char(7),char(0),char(-69),char(0),char(7),char(0),char(-68),char(0),char(64),char(0),char(9),char(0),
-char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0),
-char(7),char(0),char(-76),char(0),char(7),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(49),char(0),char(22),char(0),
-char(8),char(0),char(-67),char(0),char(8),char(0),char(-79),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(-66),char(0),char(8),char(0),char(112),char(0),
-char(8),char(0),char(-65),char(0),char(8),char(0),char(-64),char(0),char(8),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(8),char(0),char(-61),char(0),
-char(8),char(0),char(-60),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0),char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0),
-char(8),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0),char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0),
-char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0),char(51),char(0),char(22),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-79),char(0),
-char(7),char(0),char(110),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(-65),char(0),char(7),char(0),char(-64),char(0),
-char(7),char(0),char(-63),char(0),char(7),char(0),char(-62),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-60),char(0),char(7),char(0),char(-59),char(0),
-char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0),char(7),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0),
-char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0),char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0),
-char(65),char(0),char(4),char(0),char(7),char(0),char(-49),char(0),char(7),char(0),char(-48),char(0),char(7),char(0),char(-47),char(0),char(4),char(0),char(78),char(0),
-char(66),char(0),char(10),char(0),char(65),char(0),char(-46),char(0),char(13),char(0),char(-45),char(0),char(13),char(0),char(-44),char(0),char(13),char(0),char(-43),char(0),
-char(13),char(0),char(-42),char(0),char(13),char(0),char(-41),char(0),char(7),char(0),char(-121),char(0),char(7),char(0),char(-40),char(0),char(4),char(0),char(-39),char(0),
-char(4),char(0),char(53),char(0),char(67),char(0),char(4),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-38),char(0),char(7),char(0),char(-37),char(0),
-char(4),char(0),char(-36),char(0),char(68),char(0),char(4),char(0),char(13),char(0),char(-41),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-35),char(0),
-char(7),char(0),char(-34),char(0),char(69),char(0),char(7),char(0),char(13),char(0),char(-33),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-32),char(0),
-char(7),char(0),char(-31),char(0),char(7),char(0),char(-30),char(0),char(7),char(0),char(-29),char(0),char(4),char(0),char(53),char(0),char(70),char(0),char(6),char(0),
-char(15),char(0),char(-28),char(0),char(13),char(0),char(-30),char(0),char(13),char(0),char(-27),char(0),char(56),char(0),char(-26),char(0),char(4),char(0),char(-25),char(0),
-char(7),char(0),char(-29),char(0),char(71),char(0),char(26),char(0),char(4),char(0),char(-24),char(0),char(7),char(0),char(-23),char(0),char(7),char(0),char(-79),char(0),
-char(7),char(0),char(-22),char(0),char(7),char(0),char(-21),char(0),char(7),char(0),char(-20),char(0),char(7),char(0),char(-19),char(0),char(7),char(0),char(-18),char(0),
-char(7),char(0),char(-17),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0),char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0),
-char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0),char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0),
-char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0),char(4),char(0),char(-4),char(0),char(4),char(0),char(-3),char(0),
-char(4),char(0),char(-2),char(0),char(4),char(0),char(-1),char(0),char(4),char(0),char(117),char(0),char(72),char(0),char(12),char(0),char(15),char(0),char(0),char(1),
-char(15),char(0),char(1),char(1),char(15),char(0),char(2),char(1),char(13),char(0),char(3),char(1),char(13),char(0),char(4),char(1),char(7),char(0),char(5),char(1),
-char(4),char(0),char(6),char(1),char(4),char(0),char(7),char(1),char(4),char(0),char(8),char(1),char(4),char(0),char(9),char(1),char(7),char(0),char(-31),char(0),
-char(4),char(0),char(53),char(0),char(73),char(0),char(27),char(0),char(17),char(0),char(10),char(1),char(15),char(0),char(11),char(1),char(15),char(0),char(12),char(1),
-char(13),char(0),char(3),char(1),char(13),char(0),char(13),char(1),char(13),char(0),char(14),char(1),char(13),char(0),char(15),char(1),char(13),char(0),char(16),char(1),
-char(13),char(0),char(17),char(1),char(4),char(0),char(18),char(1),char(7),char(0),char(19),char(1),char(4),char(0),char(20),char(1),char(4),char(0),char(21),char(1),
-char(4),char(0),char(22),char(1),char(7),char(0),char(23),char(1),char(7),char(0),char(24),char(1),char(4),char(0),char(25),char(1),char(4),char(0),char(26),char(1),
-char(7),char(0),char(27),char(1),char(7),char(0),char(28),char(1),char(7),char(0),char(29),char(1),char(7),char(0),char(30),char(1),char(7),char(0),char(31),char(1),
-char(7),char(0),char(32),char(1),char(4),char(0),char(33),char(1),char(4),char(0),char(34),char(1),char(4),char(0),char(35),char(1),char(74),char(0),char(12),char(0),
-char(9),char(0),char(36),char(1),char(9),char(0),char(37),char(1),char(13),char(0),char(38),char(1),char(7),char(0),char(39),char(1),char(7),char(0),char(-63),char(0),
-char(7),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(13),char(0),char(42),char(1),char(4),char(0),char(43),char(1),char(4),char(0),char(44),char(1),
-char(4),char(0),char(45),char(1),char(4),char(0),char(53),char(0),char(75),char(0),char(19),char(0),char(47),char(0),char(125),char(0),char(72),char(0),char(46),char(1),
-char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),char(0),char(49),char(1),char(68),char(0),char(50),char(1),char(69),char(0),char(51),char(1),
-char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1),
-char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1),
-char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),};
+char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(25),char(0),char(9),char(0),char(101),char(0),
+char(9),char(0),char(102),char(0),char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(17),char(0),char(104),char(0),char(17),char(0),char(105),char(0),
+char(13),char(0),char(106),char(0),char(13),char(0),char(107),char(0),char(13),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0),
+char(7),char(0),char(111),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0),
+char(7),char(0),char(116),char(0),char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),
+char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(49),char(0),char(2),char(0),
+char(50),char(0),char(124),char(0),char(14),char(0),char(125),char(0),char(51),char(0),char(2),char(0),char(52),char(0),char(124),char(0),char(13),char(0),char(125),char(0),
+char(53),char(0),char(21),char(0),char(48),char(0),char(126),char(0),char(15),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0),
+char(13),char(0),char(-126),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0),
+char(13),char(0),char(-122),char(0),char(13),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0),
+char(7),char(0),char(-117),char(0),char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0),
+char(7),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(54),char(0),char(22),char(0),char(47),char(0),char(126),char(0),char(16),char(0),char(127),char(0),
+char(14),char(0),char(-128),char(0),char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(125),char(0),
+char(14),char(0),char(-124),char(0),char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(14),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0),
+char(8),char(0),char(-119),char(0),char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0),
+char(8),char(0),char(-114),char(0),char(8),char(0),char(-113),char(0),char(8),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(0),char(0),char(37),char(0),
+char(55),char(0),char(2),char(0),char(4),char(0),char(-110),char(0),char(4),char(0),char(-109),char(0),char(56),char(0),char(13),char(0),char(53),char(0),char(-108),char(0),
+char(53),char(0),char(-107),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),
+char(4),char(0),char(-103),char(0),char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),
+char(7),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0),char(57),char(0),char(13),char(0),char(58),char(0),char(-108),char(0),char(58),char(0),char(-107),char(0),
+char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0),
+char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(7),char(0),char(-98),char(0),
+char(4),char(0),char(-97),char(0),char(59),char(0),char(14),char(0),char(54),char(0),char(-108),char(0),char(54),char(0),char(-107),char(0),char(0),char(0),char(35),char(0),
+char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0),char(8),char(0),char(-102),char(0),
+char(8),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(8),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0),
+char(0),char(0),char(-96),char(0),char(60),char(0),char(3),char(0),char(57),char(0),char(-95),char(0),char(13),char(0),char(-94),char(0),char(13),char(0),char(-93),char(0),
+char(61),char(0),char(3),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(62),char(0),char(3),char(0),
+char(57),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(63),char(0),char(13),char(0),char(57),char(0),char(-95),char(0),
+char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),
+char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),
+char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(64),char(0),char(13),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),
+char(17),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),
+char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(7),char(0),char(-82),char(0),
+char(7),char(0),char(-81),char(0),char(65),char(0),char(14),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),
+char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(8),char(0),char(-87),char(0),char(8),char(0),char(-86),char(0),
+char(8),char(0),char(-85),char(0),char(8),char(0),char(-84),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0),char(8),char(0),char(-81),char(0),
+char(0),char(0),char(-80),char(0),char(66),char(0),char(10),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),
+char(8),char(0),char(-79),char(0),char(8),char(0),char(-78),char(0),char(8),char(0),char(-77),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0),
+char(8),char(0),char(-81),char(0),char(8),char(0),char(-76),char(0),char(67),char(0),char(11),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),
+char(17),char(0),char(-91),char(0),char(7),char(0),char(-79),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0),char(7),char(0),char(-83),char(0),
+char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-76),char(0),char(0),char(0),char(21),char(0),char(68),char(0),char(9),char(0),
+char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0),char(13),char(0),char(-75),char(0),char(13),char(0),char(-74),char(0),
+char(13),char(0),char(-73),char(0),char(13),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(69),char(0),char(9),char(0),
+char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(14),char(0),char(-75),char(0),char(14),char(0),char(-74),char(0),
+char(14),char(0),char(-73),char(0),char(14),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(70),char(0),char(5),char(0),
+char(68),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(-65),char(0),
+char(71),char(0),char(5),char(0),char(69),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(8),char(0),char(-67),char(0),char(8),char(0),char(-66),char(0),
+char(8),char(0),char(-65),char(0),char(72),char(0),char(9),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0),
+char(7),char(0),char(-75),char(0),char(7),char(0),char(-74),char(0),char(7),char(0),char(-73),char(0),char(7),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),
+char(4),char(0),char(-70),char(0),char(73),char(0),char(9),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),
+char(8),char(0),char(-75),char(0),char(8),char(0),char(-74),char(0),char(8),char(0),char(-73),char(0),char(8),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),
+char(4),char(0),char(-70),char(0),char(74),char(0),char(5),char(0),char(56),char(0),char(-95),char(0),char(13),char(0),char(-64),char(0),char(13),char(0),char(-63),char(0),
+char(7),char(0),char(-62),char(0),char(0),char(0),char(37),char(0),char(75),char(0),char(4),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-64),char(0),
+char(14),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(50),char(0),char(22),char(0),char(8),char(0),char(-61),char(0),char(8),char(0),char(-76),char(0),
+char(8),char(0),char(111),char(0),char(8),char(0),char(-60),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0),
+char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0),char(8),char(0),char(-55),char(0),char(8),char(0),char(-54),char(0),char(8),char(0),char(-53),char(0),
+char(8),char(0),char(-52),char(0),char(8),char(0),char(-51),char(0),char(8),char(0),char(-50),char(0),char(8),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0),
+char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0),char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0),
+char(52),char(0),char(22),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(111),char(0),char(7),char(0),char(-60),char(0),
+char(7),char(0),char(113),char(0),char(7),char(0),char(-59),char(0),char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0),
+char(7),char(0),char(-55),char(0),char(7),char(0),char(-54),char(0),char(7),char(0),char(-53),char(0),char(7),char(0),char(-52),char(0),char(7),char(0),char(-51),char(0),
+char(7),char(0),char(-50),char(0),char(7),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0),char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0),
+char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0),char(76),char(0),char(4),char(0),char(7),char(0),char(-43),char(0),
+char(7),char(0),char(-42),char(0),char(7),char(0),char(-41),char(0),char(4),char(0),char(79),char(0),char(77),char(0),char(10),char(0),char(76),char(0),char(-40),char(0),
+char(13),char(0),char(-39),char(0),char(13),char(0),char(-38),char(0),char(13),char(0),char(-37),char(0),char(13),char(0),char(-36),char(0),char(13),char(0),char(-35),char(0),
+char(7),char(0),char(-120),char(0),char(7),char(0),char(-34),char(0),char(4),char(0),char(-33),char(0),char(4),char(0),char(53),char(0),char(78),char(0),char(4),char(0),
+char(76),char(0),char(-40),char(0),char(4),char(0),char(-32),char(0),char(7),char(0),char(-31),char(0),char(4),char(0),char(-30),char(0),char(79),char(0),char(4),char(0),
+char(13),char(0),char(-35),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-29),char(0),char(7),char(0),char(-28),char(0),char(80),char(0),char(7),char(0),
+char(13),char(0),char(-27),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-26),char(0),char(7),char(0),char(-25),char(0),char(7),char(0),char(-24),char(0),
+char(7),char(0),char(-23),char(0),char(4),char(0),char(53),char(0),char(81),char(0),char(6),char(0),char(15),char(0),char(-22),char(0),char(13),char(0),char(-24),char(0),
+char(13),char(0),char(-21),char(0),char(58),char(0),char(-20),char(0),char(4),char(0),char(-19),char(0),char(7),char(0),char(-23),char(0),char(82),char(0),char(26),char(0),
+char(4),char(0),char(-18),char(0),char(7),char(0),char(-17),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0),
+char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0),char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0),
+char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0),char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0),
+char(7),char(0),char(-4),char(0),char(7),char(0),char(-3),char(0),char(7),char(0),char(-2),char(0),char(7),char(0),char(-1),char(0),char(7),char(0),char(0),char(1),
+char(7),char(0),char(1),char(1),char(4),char(0),char(2),char(1),char(4),char(0),char(3),char(1),char(4),char(0),char(4),char(1),char(4),char(0),char(5),char(1),
+char(4),char(0),char(118),char(0),char(83),char(0),char(12),char(0),char(15),char(0),char(6),char(1),char(15),char(0),char(7),char(1),char(15),char(0),char(8),char(1),
+char(13),char(0),char(9),char(1),char(13),char(0),char(10),char(1),char(7),char(0),char(11),char(1),char(4),char(0),char(12),char(1),char(4),char(0),char(13),char(1),
+char(4),char(0),char(14),char(1),char(4),char(0),char(15),char(1),char(7),char(0),char(-25),char(0),char(4),char(0),char(53),char(0),char(84),char(0),char(27),char(0),
+char(17),char(0),char(16),char(1),char(15),char(0),char(17),char(1),char(15),char(0),char(18),char(1),char(13),char(0),char(9),char(1),char(13),char(0),char(19),char(1),
+char(13),char(0),char(20),char(1),char(13),char(0),char(21),char(1),char(13),char(0),char(22),char(1),char(13),char(0),char(23),char(1),char(4),char(0),char(24),char(1),
+char(7),char(0),char(25),char(1),char(4),char(0),char(26),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(28),char(1),char(7),char(0),char(29),char(1),
+char(7),char(0),char(30),char(1),char(4),char(0),char(31),char(1),char(4),char(0),char(32),char(1),char(7),char(0),char(33),char(1),char(7),char(0),char(34),char(1),
+char(7),char(0),char(35),char(1),char(7),char(0),char(36),char(1),char(7),char(0),char(37),char(1),char(7),char(0),char(38),char(1),char(4),char(0),char(39),char(1),
+char(4),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(85),char(0),char(12),char(0),char(9),char(0),char(42),char(1),char(9),char(0),char(43),char(1),
+char(13),char(0),char(44),char(1),char(7),char(0),char(45),char(1),char(7),char(0),char(-57),char(0),char(7),char(0),char(46),char(1),char(4),char(0),char(47),char(1),
+char(13),char(0),char(48),char(1),char(4),char(0),char(49),char(1),char(4),char(0),char(50),char(1),char(4),char(0),char(51),char(1),char(4),char(0),char(53),char(0),
+char(86),char(0),char(19),char(0),char(48),char(0),char(126),char(0),char(83),char(0),char(52),char(1),char(76),char(0),char(53),char(1),char(77),char(0),char(54),char(1),
+char(78),char(0),char(55),char(1),char(79),char(0),char(56),char(1),char(80),char(0),char(57),char(1),char(81),char(0),char(58),char(1),char(84),char(0),char(59),char(1),
+char(85),char(0),char(60),char(1),char(4),char(0),char(61),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(62),char(1),char(4),char(0),char(63),char(1),
+char(4),char(0),char(64),char(1),char(4),char(0),char(65),char(1),char(4),char(0),char(66),char(1),char(4),char(0),char(67),char(1),char(82),char(0),char(68),char(1),
+};
int sBulletDNAlen64= sizeof(sBulletDNAstr64);
diff --git a/extern/bullet2/src/LinearMath/btSerializer.h b/extern/bullet2/src/LinearMath/btSerializer.h
index c5bc96b7839..ff1dc574c5d 100644
--- a/extern/bullet2/src/LinearMath/btSerializer.h
+++ b/extern/bullet2/src/LinearMath/btSerializer.h
@@ -17,7 +17,6 @@ subject to the following restrictions:
#define BT_SERIALIZER_H
#include "btScalar.h" // has definitions like SIMD_FORCE_INLINE
-#include "btStackAlloc.h"
#include "btHashMap.h"
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
@@ -439,7 +438,7 @@ public:
buffer[9] = '2';
buffer[10] = '8';
- buffer[11] = '1';
+ buffer[11] = '2';
}
diff --git a/extern/bullet2/src/LinearMath/btVector3.cpp b/extern/bullet2/src/LinearMath/btVector3.cpp
index bcb18704b93..a84f7baee2e 100644
--- a/extern/bullet2/src/LinearMath/btVector3.cpp
+++ b/extern/bullet2/src/LinearMath/btVector3.cpp
@@ -51,7 +51,7 @@ long _maxdot_large( const float *vv, const float *vec, unsigned long count, floa
long _maxdot_large( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
const float4 *vertices = (const float4*) vv;
- static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
+ static const unsigned char indexTable[16] = {(unsigned char)-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
float4 dotMax = btAssign128( -BT_INFINITY, -BT_INFINITY, -BT_INFINITY, -BT_INFINITY );
float4 vvec = _mm_loadu_ps( vec );
float4 vHi = btCastiTo128f(_mm_shuffle_epi32( btCastfTo128i( vvec), 0xaa )); /// zzzz
@@ -436,7 +436,7 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa
long _mindot_large( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
const float4 *vertices = (const float4*) vv;
- static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
+ static const unsigned char indexTable[16] = {(unsigned char)-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
float4 dotmin = btAssign128( BT_INFINITY, BT_INFINITY, BT_INFINITY, BT_INFINITY );
float4 vvec = _mm_loadu_ps( vec );
float4 vHi = btCastiTo128f(_mm_shuffle_epi32( btCastfTo128i( vvec), 0xaa )); /// zzzz
@@ -823,7 +823,8 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa
#elif defined BT_USE_NEON
#define ARM_NEON_GCC_COMPATIBILITY 1
#include <arm_neon.h>
-
+#include <sys/types.h>
+#include <sys/sysctl.h> //for sysctlbyname
static long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult );
@@ -835,11 +836,34 @@ static long _mindot_large_sel( const float *vv, const float *vec, unsigned long
long (*_maxdot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = _maxdot_large_sel;
long (*_mindot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = _mindot_large_sel;
-extern "C" {int _get_cpu_capabilities( void );}
+
+static inline uint32_t btGetCpuCapabilities( void )
+{
+ static uint32_t capabilities = 0;
+ static bool testedCapabilities = false;
+
+ if( 0 == testedCapabilities)
+ {
+ uint32_t hasFeature = 0;
+ size_t featureSize = sizeof( hasFeature );
+ int err = sysctlbyname( "hw.optional.neon_hpfp", &hasFeature, &featureSize, NULL, 0 );
+
+ if( 0 == err && hasFeature)
+ capabilities |= 0x2000;
+
+ testedCapabilities = true;
+ }
+
+ return capabilities;
+}
+
+
+
static long _maxdot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
- if( _get_cpu_capabilities() & 0x2000 )
+
+ if( btGetCpuCapabilities() & 0x2000 )
_maxdot_large = _maxdot_large_v1;
else
_maxdot_large = _maxdot_large_v0;
@@ -849,7 +873,8 @@ static long _maxdot_large_sel( const float *vv, const float *vec, unsigned long
static long _mindot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
- if( _get_cpu_capabilities() & 0x2000 )
+
+ if( btGetCpuCapabilities() & 0x2000 )
_mindot_large = _mindot_large_v1;
else
_mindot_large = _mindot_large_v0;
@@ -872,8 +897,8 @@ long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, f
float32x2_t dotMaxHi = (float32x2_t) { -BT_INFINITY, -BT_INFINITY };
uint32x2_t indexLo = (uint32x2_t) {0, 1};
uint32x2_t indexHi = (uint32x2_t) {2, 3};
- uint32x2_t iLo = (uint32x2_t) {-1, -1};
- uint32x2_t iHi = (uint32x2_t) {-1, -1};
+ uint32x2_t iLo = (uint32x2_t) {static_cast<uint32_t>(-1), static_cast<uint32_t>(-1)};
+ uint32x2_t iHi = (uint32x2_t) {static_cast<uint32_t>(-1), static_cast<uint32_t>(-1)};
const uint32x2_t four = (uint32x2_t) {4,4};
for( ; i+8 <= count; i+= 8 )
@@ -1059,7 +1084,7 @@ long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, f
float32x4_t vHi = vdupq_lane_f32(vget_high_f32(vvec), 0);
const uint32x4_t four = (uint32x4_t){ 4, 4, 4, 4 };
uint32x4_t local_index = (uint32x4_t) {0, 1, 2, 3};
- uint32x4_t index = (uint32x4_t) { -1, -1, -1, -1 };
+ uint32x4_t index = (uint32x4_t) { static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), static_cast<uint32_t>(-1) };
float32x4_t maxDot = (float32x4_t) { -BT_INFINITY, -BT_INFINITY, -BT_INFINITY, -BT_INFINITY };
unsigned long i = 0;
@@ -1257,8 +1282,8 @@ long _mindot_large_v0( const float *vv, const float *vec, unsigned long count, f
float32x2_t dotMinHi = (float32x2_t) { BT_INFINITY, BT_INFINITY };
uint32x2_t indexLo = (uint32x2_t) {0, 1};
uint32x2_t indexHi = (uint32x2_t) {2, 3};
- uint32x2_t iLo = (uint32x2_t) {-1, -1};
- uint32x2_t iHi = (uint32x2_t) {-1, -1};
+ uint32x2_t iLo = (uint32x2_t) {static_cast<uint32_t>(-1), static_cast<uint32_t>(-1)};
+ uint32x2_t iHi = (uint32x2_t) {static_cast<uint32_t>(-1), static_cast<uint32_t>(-1)};
const uint32x2_t four = (uint32x2_t) {4,4};
for( ; i+8 <= count; i+= 8 )
@@ -1442,7 +1467,7 @@ long _mindot_large_v1( const float *vv, const float *vec, unsigned long count, f
float32x4_t vHi = vdupq_lane_f32(vget_high_f32(vvec), 0);
const uint32x4_t four = (uint32x4_t){ 4, 4, 4, 4 };
uint32x4_t local_index = (uint32x4_t) {0, 1, 2, 3};
- uint32x4_t index = (uint32x4_t) { -1, -1, -1, -1 };
+ uint32x4_t index = (uint32x4_t) { static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), static_cast<uint32_t>(-1) };
float32x4_t minDot = (float32x4_t) { BT_INFINITY, BT_INFINITY, BT_INFINITY, BT_INFINITY };
unsigned long i = 0;
diff --git a/extern/bullet2/src/LinearMath/btVector3.h b/extern/bullet2/src/LinearMath/btVector3.h
index 1cf65358803..89685929288 100644
--- a/extern/bullet2/src/LinearMath/btVector3.h
+++ b/extern/bullet2/src/LinearMath/btVector3.h
@@ -53,19 +53,24 @@ subject to the following restrictions:
#define btvxyzMaskf btvFFF0fMask
#define btvAbsfMask btCastiTo128f(btvAbsMask)
+//there is an issue with XCode 3.2 (LCx errors)
+#define btvMzeroMask (_mm_set_ps(-0.0f, -0.0f, -0.0f, -0.0f))
+#define v1110 (_mm_set_ps(0.0f, 1.0f, 1.0f, 1.0f))
+#define vHalf (_mm_set_ps(0.5f, 0.5f, 0.5f, 0.5f))
+#define v1_5 (_mm_set_ps(1.5f, 1.5f, 1.5f, 1.5f))
-
-const __m128 ATTRIBUTE_ALIGNED16(btvMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f};
-const __m128 ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f};
-const __m128 ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f};
-const __m128 ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f};
+//const __m128 ATTRIBUTE_ALIGNED16(btvMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f};
+//const __m128 ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f};
+//const __m128 ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f};
+//const __m128 ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f};
#endif
#ifdef BT_USE_NEON
const float32x4_t ATTRIBUTE_ALIGNED16(btvMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f};
-const int32x4_t ATTRIBUTE_ALIGNED16(btvFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0};
+const int32x4_t ATTRIBUTE_ALIGNED16(btvFFF0Mask) = (int32x4_t){static_cast<int32_t>(0xFFFFFFFF),
+ static_cast<int32_t>(0xFFFFFFFF), static_cast<int32_t>(0xFFFFFFFF), 0x0};
const int32x4_t ATTRIBUTE_ALIGNED16(btvAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
const int32x4_t ATTRIBUTE_ALIGNED16(btv3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0};
@@ -260,6 +265,12 @@ public:
return btSqrt(length2());
}
+ /**@brief Return the norm (length) of the vector */
+ SIMD_FORCE_INLINE btScalar norm() const
+ {
+ return length();
+ }
+
/**@brief Return the distance squared between the ends of this and another vector
* This is symantically treating the vector like a point */
SIMD_FORCE_INLINE btScalar distance2(const btVector3& v) const;
@@ -285,6 +296,9 @@ public:
* x^2 + y^2 + z^2 = 1 */
SIMD_FORCE_INLINE btVector3& normalize()
{
+
+ btAssert(length() != btScalar(0));
+
#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
// dot product first
__m128 vd = _mm_mul_ps(mVec128, mVec128);
@@ -718,7 +732,7 @@ public:
return btVector3(r);
#elif defined(BT_USE_NEON)
- static const uint32x4_t xyzMask = (const uint32x4_t){ -1, -1, -1, 0 };
+ static const uint32x4_t xyzMask = (const uint32x4_t){ static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), static_cast<uint32_t>(-1), 0 };
float32x4_t a0 = vmulq_f32( v0.mVec128, this->mVec128);
float32x4_t a1 = vmulq_f32( v1.mVec128, this->mVec128);
float32x4_t a2 = vmulq_f32( v2.mVec128, this->mVec128);
@@ -936,13 +950,9 @@ SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const
SIMD_FORCE_INLINE btVector3 btVector3::normalized() const
{
-#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
btVector3 norm = *this;
return norm.normalize();
-#else
- return *this / length();
-#endif
}
SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btScalar _angle ) const
diff --git a/extern/bullet2/src/SConscript b/extern/bullet2/src/SConscript
index 3ffff9c80fc..ff2e86affb4 100644
--- a/extern/bullet2/src/SConscript
+++ b/extern/bullet2/src/SConscript
@@ -31,6 +31,8 @@ bullet2_src += env.Glob("BulletDynamics/Vehicle/*.cpp")
bullet2_src += env.Glob("BulletDynamics/ConstraintSolver/*.cpp")
bullet2_src += env.Glob("BulletDynamics/Dynamics/*.cpp")
bullet2_src += env.Glob("BulletDynamics/Character/*.cpp")
+bullet2_src += env.Glob("BulletDynamics/Featherstone/*.cpp")
+bullet2_src += env.Glob("BulletDynamics/MLCPSolvers/*.cpp")
bullet2_src += env.Glob("BulletSoftBody/*.cpp")
incs = '. BulletCollision BulletDynamics LinearMath BulletSoftBody'
diff --git a/extern/bullet2/src/btBulletDynamicsCommon.h b/extern/bullet2/src/btBulletDynamicsCommon.h
index dbd175c3fe6..50282bf2105 100644
--- a/extern/bullet2/src/btBulletDynamicsCommon.h
+++ b/extern/bullet2/src/btBulletDynamicsCommon.h
@@ -33,6 +33,8 @@ subject to the following restrictions:
#include "BulletDynamics/ConstraintSolver/btUniversalConstraint.h"
#include "BulletDynamics/ConstraintSolver/btHinge2Constraint.h"
#include "BulletDynamics/ConstraintSolver/btGearConstraint.h"
+#include "BulletDynamics/ConstraintSolver/btFixedConstraint.h"
+
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc
index 11608318a40..95ac2ff703a 100644
--- a/extern/libmv/libmv-capi.cc
+++ b/extern/libmv/libmv-capi.cc
@@ -306,6 +306,9 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options,
track_region_options.num_extra_points = 1;
track_region_options.image1_mask = NULL;
track_region_options.use_brute_initialization = options->use_brute;
+ /* TODO(keir): This will make some cases better, but may be a regression until
+ * the motion model is in. Since this is on trunk, enable it for now. */
+ track_region_options.attempt_refine_before_brute = true;
track_region_options.use_normalized_intensities = options->use_normalization;
if (options->image1_mask) {
@@ -393,9 +396,9 @@ void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks)
LIBMV_OBJECT_DELETE(libmv_tracks, Tracks);
}
-void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y)
+void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y, double weight)
{
- ((libmv::Tracks*) libmv_tracks)->Insert(image, track, x, y);
+ ((libmv::Tracks*) libmv_tracks)->Insert(image, track, x, y, weight);
}
/* ************ Reconstruction ************ */
@@ -498,7 +501,6 @@ static bool selectTwoKeyframesBasedOnGRICAndVariance(
libmv::Tracks &tracks,
libmv::Tracks &normalized_tracks,
libmv::CameraIntrinsics &camera_intrinsics,
- libmv::ReconstructionOptions &reconstruction_options,
int &keyframe1,
int &keyframe2)
{
@@ -542,8 +544,7 @@ static bool selectTwoKeyframesBasedOnGRICAndVariance(
/* get a solution from two keyframes only */
libmv::EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
libmv::EuclideanBundle(keyframe_tracks, &reconstruction);
- libmv::EuclideanCompleteReconstruction(reconstruction_options,
- keyframe_tracks,
+ libmv::EuclideanCompleteReconstruction(keyframe_tracks,
&reconstruction, NULL);
double current_error =
@@ -585,10 +586,6 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks
/* Retrieve reconstruction options from C-API to libmv API */
cameraIntrinsicsFromOptions(libmv_camera_intrinsics_options, &camera_intrinsics);
- libmv::ReconstructionOptions reconstruction_options;
- reconstruction_options.success_threshold = libmv_reconstruction_options->success_threshold;
- reconstruction_options.use_fallback_reconstruction = libmv_reconstruction_options->use_fallback_reconstruction;
-
/* Invert the camera intrinsics */
libmv::Tracks normalized_tracks = getNormalizedTracks(tracks, camera_intrinsics);
@@ -604,7 +601,6 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks
selectTwoKeyframesBasedOnGRICAndVariance(tracks,
normalized_tracks,
camera_intrinsics,
- reconstruction_options,
keyframe1,
keyframe2);
@@ -625,7 +621,7 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks
libmv::EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
libmv::EuclideanBundle(normalized_tracks, &reconstruction);
- libmv::EuclideanCompleteReconstruction(reconstruction_options, normalized_tracks,
+ libmv::EuclideanCompleteReconstruction(normalized_tracks,
&reconstruction, &update_callback);
/* refinement */
@@ -1093,8 +1089,8 @@ void libmv_homography2DFromCorrespondencesEuc(double (*x1)[2], double (*x2)[2],
LG << "x1: " << x1_mat;
LG << "x2: " << x2_mat;
- libmv::HomographyEstimationOptions options;
- libmv::Homography2DFromCorrespondencesEuc(x1_mat, x2_mat, options, &H_mat);
+ libmv::EstimateHomographyOptions options;
+ libmv::EstimateHomography2DFromCorrespondences(x1_mat, x2_mat, options, &H_mat);
LG << "H: " << H_mat;
diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h
index a872eeb60a1..13cc3ae8499 100644
--- a/extern/libmv/libmv-capi.h
+++ b/extern/libmv/libmv-capi.h
@@ -73,7 +73,7 @@ void libmv_samplePlanarPatch(const float *image, int width, int height,
/* Tracks */
struct libmv_Tracks *libmv_tracksNew(void);
void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
-void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y);
+void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y, double weight);
/* Reconstruction */
#define LIBMV_REFINE_FOCAL_LENGTH (1 << 0)
@@ -94,9 +94,6 @@ typedef struct libmv_ReconstructionOptions {
int keyframe1, keyframe2;
int refine_intrinsics;
-
- double success_threshold;
- int use_fallback_reconstruction;
} libmv_ReconstructionOptions;
typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message);
diff --git a/extern/libmv/libmv-capi_stub.cc b/extern/libmv/libmv-capi_stub.cc
index e6d3753961b..bda9605b422 100644
--- a/extern/libmv/libmv-capi_stub.cc
+++ b/extern/libmv/libmv-capi_stub.cc
@@ -85,7 +85,7 @@ struct libmv_Tracks *libmv_tracksNew(void)
}
void libmv_tracksInsert(struct libmv_Tracks * /*libmv_tracks*/, int /*image*/,
- int /*track*/, double /*x*/, double /*y*/)
+ int /*track*/, double /*x*/, double /*y*/, double /*weight*/)
{
}
diff --git a/extern/libmv/libmv/multiview/euclidean_resection.cc b/extern/libmv/libmv/multiview/euclidean_resection.cc
index d5421b9691e..245b027fb7c 100644
--- a/extern/libmv/libmv/multiview/euclidean_resection.cc
+++ b/extern/libmv/libmv/multiview/euclidean_resection.cc
@@ -34,26 +34,20 @@ namespace libmv {
namespace euclidean_resection {
typedef unsigned int uint;
-
-bool EuclideanResectionPPnP(const Mat2X &x_camera,
- const Mat3X &X_world,
- Mat3 *R, Vec3 *t,
- double tolerance);
bool EuclideanResection(const Mat2X &x_camera,
const Mat3X &X_world,
Mat3 *R, Vec3 *t,
- ResectionMethod method,
- double success_threshold) {
+ ResectionMethod method) {
switch (method) {
case RESECTION_ANSAR_DANIILIDIS:
EuclideanResectionAnsarDaniilidis(x_camera, X_world, R, t);
break;
case RESECTION_EPNP:
- return EuclideanResectionEPnP(x_camera, X_world, R, t, success_threshold);
+ return EuclideanResectionEPnP(x_camera, X_world, R, t);
break;
case RESECTION_PPNP:
- return EuclideanResectionPPnP(x_camera, X_world, R, t, success_threshold);
+ return EuclideanResectionPPnP(x_camera, X_world, R, t);
break;
default:
LOG(FATAL) << "Unknown resection method.";
@@ -444,8 +438,7 @@ static void ComputePointsCoordinatesInCameraFrame(
bool EuclideanResectionEPnP(const Mat2X &x_camera,
const Mat3X &X_world,
- Mat3 *R, Vec3 *t,
- double success_threshold) {
+ Mat3 *R, Vec3 *t) {
CHECK(x_camera.cols() == X_world.cols());
CHECK(x_camera.cols() > 3);
size_t num_points = X_world.cols();
@@ -553,13 +546,7 @@ bool EuclideanResectionEPnP(const Mat2X &x_camera,
//
// TODO(keir): Decide if setting this to infinity, effectively disabling the
// check, is the right approach. So far this seems the case.
- //
- // TODO(sergey): Made it an option for now, in some cases it makes sense to
- // still fallback to reprojection solution
- // For details see bug [#32765] from Blender bug tracker
-
- // double kSuccessThreshold = std::numeric_limits<double>::max();
- double kSuccessThreshold = success_threshold;
+ double kSuccessThreshold = std::numeric_limits<double>::max();
// Find the first possible solution for R, t corresponding to:
// Betas = [b00 b01 b11 b02 b12 b22 b03 b13 b23 b33]
@@ -728,8 +715,7 @@ bool EuclideanResectionEPnP(const Mat2X &x_camera,
// other hand, it did work on the first try.
bool EuclideanResectionPPnP(const Mat2X &x_camera,
const Mat3X &X_world,
- Mat3 *R, Vec3 *t,
- double tolerance) {
+ Mat3 *R, Vec3 *t) {
int n = x_camera.cols();
Mat Z = Mat::Zero(n, n);
Vec e = Vec::Ones(n);
@@ -750,7 +736,7 @@ bool EuclideanResectionPPnP(const Mat2X &x_camera,
Mat E(n, 3);
int iteration = 0;
- tolerance = 1e-5;
+ double tolerance = 1e-5;
// TODO(keir): The limit of 100 can probably be reduced, but this will require
// some investigation.
while (error > tolerance && iteration < 100) {
diff --git a/extern/libmv/libmv/multiview/euclidean_resection.h b/extern/libmv/libmv/multiview/euclidean_resection.h
index ff9bccdd5c9..28eae92611c 100644
--- a/extern/libmv/libmv/multiview/euclidean_resection.h
+++ b/extern/libmv/libmv/multiview/euclidean_resection.h
@@ -49,14 +49,11 @@ enum ResectionMethod {
* \param R Solution for the camera rotation matrix
* \param t Solution for the camera translation vector
* \param method The resection method to use.
- * \param success_threshold Threshold of an error which is still considered a success
- * (currently used by EPnP algorithm only)
*/
bool EuclideanResection(const Mat2X &x_camera,
const Mat3X &X_world,
Mat3 *R, Vec3 *t,
- ResectionMethod method = RESECTION_EPNP,
- double success_threshold = 1e-3);
+ ResectionMethod method = RESECTION_EPNP);
/**
* Computes the extrinsic parameters, R and t for a calibrated camera
@@ -117,7 +114,6 @@ void EuclideanResectionAnsarDaniilidis(const Mat2X &x_camera,
* \param X_world 3D points in the world coordinate system
* \param R Solution for the camera rotation matrix
* \param t Solution for the camera translation vector
- * \param success_threshold Threshold of an error which is still considered a success
*
* This is the algorithm described in:
* "{EP$n$P: An Accurate $O(n)$ Solution to the P$n$P Problem", by V. Lepetit
@@ -126,8 +122,24 @@ void EuclideanResectionAnsarDaniilidis(const Mat2X &x_camera,
*/
bool EuclideanResectionEPnP(const Mat2X &x_camera,
const Mat3X &X_world,
- Mat3 *R, Vec3 *t,
- double success_threshold = 1e-3);
+ Mat3 *R, Vec3 *t);
+
+/**
+ * Computes the extrinsic parameters, R and t for a calibrated camera from 4 or
+ * more 3D points and their images.
+ *
+ * \param x_camera Image points in normalized camera coordinates,
+ * e.g. x_camera = inv(K) * x_image
+ * \param X_world 3D points in the world coordinate system
+ * \param R Solution for the camera rotation matrix
+ * \param t Solution for the camera translation vector
+ *
+ * Straight from the paper:
+ * http://www.diegm.uniud.it/fusiello/papers/3dimpvt12-b.pdf
+ */
+bool EuclideanResectionPPnP(const Mat2X &x_camera,
+ const Mat3X &X_world,
+ Mat3 *R, Vec3 *t);
} // namespace euclidean_resection
} // namespace libmv
diff --git a/extern/libmv/libmv/multiview/fundamental.cc b/extern/libmv/libmv/multiview/fundamental.cc
index ec6c70d81cf..7a1433c3419 100644
--- a/extern/libmv/libmv/multiview/fundamental.cc
+++ b/extern/libmv/libmv/multiview/fundamental.cc
@@ -408,13 +408,16 @@ void FundamentalToEssential(const Mat3 &F, Mat3 *E) {
*E = svd.matrixU() * diag.asDiagonal() * svd.matrixV().transpose();
}
-FundamentalEstimationOptions::FundamentalEstimationOptions(void) :
- use_refine_if_algebraic_fails(true),
+// Default settings for fundamental estimation which should be suitable
+// for a wide range of use cases.
+EstimateFundamentalOptions::EstimateFundamentalOptions(void) :
max_num_iterations(50),
- parameter_tolerance(1e-16),
- function_tolerance(1e-16) {
+ expected_average_symmetric_distance(1e-16) {
}
+namespace {
+// Cost functor which computes symmetric epipolar distance
+// used for fundamental matrix refinement.
class FundamentalSymmetricEpipolarCostFunctor {
public:
FundamentalSymmetricEpipolarCostFunctor(const Vec2 &x,
@@ -445,21 +448,60 @@ class FundamentalSymmetricEpipolarCostFunctor {
const Mat y_;
};
+// Termination checking callback used for fundamental estimation.
+// It finished the minimization as soon as actual average of
+// symmetric epipolar distance is less or equal to the expected
+// average value.
+class TerminationCheckingCallback : public ceres::IterationCallback {
+ public:
+ TerminationCheckingCallback(const Mat &x1, const Mat &x2,
+ const EstimateFundamentalOptions &options,
+ Mat3 *F)
+ : options_(options), x1_(x1), x2_(x2), F_(F) {}
+
+ virtual ceres::CallbackReturnType operator()(
+ const ceres::IterationSummary& summary) {
+ // If the step wasn't successful, there's nothing to do.
+ if (!summary.step_is_successful) {
+ return ceres::SOLVER_CONTINUE;
+ }
+
+ // Calculate average of symmetric epipolar distance.
+ double average_distance = 0.0;
+ for (int i = 0; i < x1_.cols(); i++) {
+ average_distance = SymmetricEpipolarDistance(*F_,
+ x1_.col(i),
+ x2_.col(i));
+ }
+ average_distance /= x1_.cols();
+
+ if (average_distance <= options_.expected_average_symmetric_distance) {
+ return ceres::SOLVER_TERMINATE_SUCCESSFULLY;
+ }
+
+ return ceres::SOLVER_CONTINUE;
+ }
+
+ private:
+ const EstimateFundamentalOptions &options_;
+ const Mat &x1_;
+ const Mat &x2_;
+ Mat3 *F_;
+};
+} // namespace
+
/* Fundamental transformation estimation. */
-bool FundamentalFromCorrespondencesEuc(
+bool EstimateFundamentalFromCorrespondences(
const Mat &x1,
const Mat &x2,
- const FundamentalEstimationOptions &options,
+ const EstimateFundamentalOptions &options,
Mat3 *F) {
// Step 1: Algebraic fundamental estimation.
- bool algebraic_success = NormalizedEightPointSolver(x1, x2, F);
- LG << "Algebraic result " << algebraic_success
- << ", estimated matrix:\n" << *F;
+ // Assume algebraic estiation always succeeds,
+ NormalizedEightPointSolver(x1, x2, F);
- if (!algebraic_success && !options.use_refine_if_algebraic_fails) {
- return false;
- }
+ LG << "Estimated matrix after algebraic estimation:\n" << *F;
// Step 2: Refine matrix using Ceres minimizer.
ceres::Problem problem;
@@ -483,8 +525,10 @@ bool FundamentalFromCorrespondencesEuc(
solver_options.linear_solver_type = ceres::DENSE_QR;
solver_options.max_num_iterations = options.max_num_iterations;
solver_options.update_state_every_iteration = true;
- solver_options.parameter_tolerance = options.parameter_tolerance;
- solver_options.function_tolerance = options.function_tolerance;
+
+ // Terminate if the average symmetric distance is good enough.
+ TerminationCheckingCallback callback(x1, x2, options, F);
+ solver_options.callbacks.push_back(&callback);
// Run the solve.
ceres::Solver::Summary summary;
@@ -495,7 +539,8 @@ bool FundamentalFromCorrespondencesEuc(
LG << "Final refined matrix:\n" << *F;
return !(summary.termination_type == ceres::DID_NOT_RUN ||
- summary.termination_type == ceres::NUMERICAL_FAILURE);
+ summary.termination_type == ceres::NUMERICAL_FAILURE ||
+ summary.termination_type == ceres::USER_ABORT);
}
} // namespace libmv
diff --git a/extern/libmv/libmv/multiview/fundamental.h b/extern/libmv/libmv/multiview/fundamental.h
index 2961a46cdc4..51067aefc2b 100644
--- a/extern/libmv/libmv/multiview/fundamental.h
+++ b/extern/libmv/libmv/multiview/fundamental.h
@@ -151,21 +151,22 @@ void FundamentalToEssential(const Mat3 &F, Mat3 *E);
* Defaults should be suitable for a wide range of use cases, but
* better performance and accuracy might require tweaking/
*/
-struct FundamentalEstimationOptions {
+struct EstimateFundamentalOptions {
// Default constructor which sets up a options for generic usage.
- FundamentalEstimationOptions(void);
-
- // Refine fundamental matrix even if algebraic estimation reported failure.
- bool use_refine_if_algebraic_fails;
+ EstimateFundamentalOptions(void);
// Maximal number of iterations for refinement step.
int max_num_iterations;
- // Paramaneter tolerance used by minimizer termination criteria.
- float parameter_tolerance;
-
- // Function tolerance used by minimizer termination criteria.
- float function_tolerance;
+ // Expected average of symmetric epipolar distance between
+ // actual destination points and original ones transformed by
+ // estimated fundamental matrix.
+ //
+ // Refinement will finish as soon as average of symmetric
+ // epipolar distance is less or equal to this value.
+ //
+ // This distance is measured in the same units as input points are.
+ double expected_average_symmetric_distance;
};
/**
@@ -175,10 +176,10 @@ struct FundamentalEstimationOptions {
* correspondences by doing algebraic estimation first followed with result
* refinement.
*/
-bool FundamentalFromCorrespondencesEuc(
+bool EstimateFundamentalFromCorrespondences(
const Mat &x1,
const Mat &x2,
- const FundamentalEstimationOptions &options,
+ const EstimateFundamentalOptions &options,
Mat3 *F);
} // namespace libmv
diff --git a/extern/libmv/libmv/multiview/homography.cc b/extern/libmv/libmv/multiview/homography.cc
index 6041849d9fe..cbd3ec78a57 100644
--- a/extern/libmv/libmv/multiview/homography.cc
+++ b/extern/libmv/libmv/multiview/homography.cc
@@ -22,6 +22,7 @@
#include "ceres/ceres.h"
#include "libmv/logging/logging.h"
+#include "libmv/multiview/conditioning.h"
#include "libmv/multiview/homography_parameterization.h"
namespace libmv {
@@ -155,14 +156,26 @@ bool Homography2DFromCorrespondencesLinear(const Mat &x1,
}
}
-HomographyEstimationOptions::HomographyEstimationOptions(void) :
- expected_algebraic_precision(EigenDouble::dummy_precision()),
- use_refine_if_algebraic_fails(true),
+// Default settings for homography estimation which should be suitable
+// for a wide range of use cases.
+EstimateHomographyOptions::EstimateHomographyOptions(void) :
+ use_normalization(true),
max_num_iterations(50),
- parameter_tolerance(1e-16),
- function_tolerance(1e-16) {
+ expected_average_symmetric_distance(1e-16) {
}
+namespace {
+void GetNormalizedPoints(const Mat &original_points,
+ Mat *normalized_points,
+ Mat3 *normalization_matrix) {
+ IsotropicPreconditionerFromPoints(original_points, normalization_matrix);
+ ApplyTransformationToPoints(original_points,
+ *normalization_matrix,
+ normalized_points);
+}
+
+// Cost functor which computes symmetric geometric distance
+// used for homography matrix refinement.
class HomographySymmetricGeometricCostFunctor {
public:
HomographySymmetricGeometricCostFunctor(const Vec2 &x,
@@ -200,13 +213,55 @@ class HomographySymmetricGeometricCostFunctor {
const Vec2 y_;
};
+// Termination checking callback used for homography estimation.
+// It finished the minimization as soon as actual average of
+// symmetric geometric distance is less or equal to the expected
+// average value.
+class TerminationCheckingCallback : public ceres::IterationCallback {
+ public:
+ TerminationCheckingCallback(const Mat &x1, const Mat &x2,
+ const EstimateHomographyOptions &options,
+ Mat3 *H)
+ : options_(options), x1_(x1), x2_(x2), H_(H) {}
+
+ virtual ceres::CallbackReturnType operator()(
+ const ceres::IterationSummary& summary) {
+ // If the step wasn't successful, there's nothing to do.
+ if (!summary.step_is_successful) {
+ return ceres::SOLVER_CONTINUE;
+ }
+
+ // Calculate average of symmetric geometric distance.
+ double average_distance = 0.0;
+ for (int i = 0; i < x1_.cols(); i++) {
+ average_distance = SymmetricGeometricDistance(*H_,
+ x1_.col(i),
+ x2_.col(i));
+ }
+ average_distance /= x1_.cols();
+
+ if (average_distance <= options_.expected_average_symmetric_distance) {
+ return ceres::SOLVER_TERMINATE_SUCCESSFULLY;
+ }
+
+ return ceres::SOLVER_CONTINUE;
+ }
+
+ private:
+ const EstimateHomographyOptions &options_;
+ const Mat &x1_;
+ const Mat &x2_;
+ Mat3 *H_;
+};
+} // namespace
+
/** 2D Homography transformation estimation in the case that points are in
* euclidean coordinates.
*/
-bool Homography2DFromCorrespondencesEuc(
+bool EstimateHomography2DFromCorrespondences(
const Mat &x1,
const Mat &x2,
- const HomographyEstimationOptions &options,
+ const EstimateHomographyOptions &options,
Mat3 *H) {
// TODO(sergey): Support homogenous coordinates, not just euclidean.
@@ -215,18 +270,31 @@ bool Homography2DFromCorrespondencesEuc(
assert(x1.rows() == x2.rows());
assert(x1.cols() == x2.cols());
+ Mat3 T1 = Mat3::Identity(),
+ T2 = Mat3::Identity();
+
// Step 1: Algebraic homography estimation.
- bool algebraic_success =
- Homography2DFromCorrespondencesLinear(x1, x2, H,
- options.expected_algebraic_precision);
+ Mat x1_normalized, x2_normalized;
- LG << "Algebraic result " << algebraic_success
- << ", estimated matrix:\n" << *H;
+ if (options.use_normalization) {
+ LG << "Estimating homography using normalization.";
+ GetNormalizedPoints(x1, &x1_normalized, &T1);
+ GetNormalizedPoints(x2, &x2_normalized, &T2);
+ } else {
+ x1_normalized = x1;
+ x2_normalized = x2;
+ }
- if (!algebraic_success && !options.use_refine_if_algebraic_fails) {
- return false;
+ // Assume algebraic estiation always suceeds,
+ Homography2DFromCorrespondencesLinear(x1_normalized, x2_normalized, H);
+
+ // Denormalize the homography matrix.
+ if (options.use_normalization) {
+ *H = T2.inverse() * (*H) * T1;
}
+ LG << "Estimated matrix after algebraic estimation:\n" << *H;
+
// Step 2: Refine matrix using Ceres minimizer.
ceres::Problem problem;
for (int i = 0; i < x1.cols(); i++) {
@@ -249,8 +317,10 @@ bool Homography2DFromCorrespondencesEuc(
solver_options.linear_solver_type = ceres::DENSE_QR;
solver_options.max_num_iterations = options.max_num_iterations;
solver_options.update_state_every_iteration = true;
- solver_options.parameter_tolerance = options.parameter_tolerance;
- solver_options.function_tolerance = options.function_tolerance;
+
+ // Terminate if the average symmetric distance is good enough.
+ TerminationCheckingCallback callback(x1, x2, options, H);
+ solver_options.callbacks.push_back(&callback);
// Run the solve.
ceres::Solver::Summary summary;
@@ -261,7 +331,8 @@ bool Homography2DFromCorrespondencesEuc(
LG << "Final refined matrix:\n" << *H;
return !(summary.termination_type == ceres::DID_NOT_RUN ||
- summary.termination_type == ceres::NUMERICAL_FAILURE);
+ summary.termination_type == ceres::NUMERICAL_FAILURE ||
+ summary.termination_type == ceres::USER_ABORT);
}
/**
@@ -377,7 +448,9 @@ bool Homography3DFromCorrespondencesLinear(const Mat &x1,
}
}
-double SymmetricGeometricDistance(Mat3 &H, Vec2 &x1, Vec2 &x2) {
+double SymmetricGeometricDistance(const Mat3 &H,
+ const Vec2 &x1,
+ const Vec2 &x2) {
Vec3 x(x1(0), x1(1), 1.0);
Vec3 y(x2(0), x2(1), 1.0);
diff --git a/extern/libmv/libmv/multiview/homography.h b/extern/libmv/libmv/multiview/homography.h
index 1928e39dffb..6d810c845ed 100644
--- a/extern/libmv/libmv/multiview/homography.h
+++ b/extern/libmv/libmv/multiview/homography.h
@@ -60,24 +60,35 @@ bool Homography2DFromCorrespondencesLinear(const Mat &x1,
* Defaults should be suitable for a wide range of use cases, but
* better performance and accuracy might require tweaking/
*/
-struct HomographyEstimationOptions {
+struct EstimateHomographyOptions {
// Default constructor which sets up a options for generic usage.
- HomographyEstimationOptions(void);
+ EstimateHomographyOptions(void);
- // Expected precision of algebraic estimation.
- double expected_algebraic_precision;
+ // Normalize correspondencies before estimating the homography
+ // in order to increase estimation stability.
+ //
+ // Normaliztion will make it so centroid od correspondences
+ // is the coordinate origin and their average distance from
+ // the origin is sqrt(2).
+ //
+ // See:
+ // - R. Hartley and A. Zisserman. Multiple View Geometry in Computer
+ // Vision. Cambridge University Press, second edition, 2003.
+ // - https://www.cs.ubc.ca/grads/resources/thesis/May09/Dubrofsky_Elan.pdf
+ bool use_normalization;
- // Refine homography even if algebraic estimation reported failure.
- bool use_refine_if_algebraic_fails;
-
- // Maximal number of iterations for refinement step.
+ // Maximal number of iterations for the refinement step.
int max_num_iterations;
- // Paramaneter tolerance used by minimizer termination criteria.
- float parameter_tolerance;
-
- // Function tolerance used by minimizer termination criteria.
- float function_tolerance;
+ // Expected average of symmetric geometric distance between
+ // actual destination points and original ones transformed by
+ // estimated homography matrix.
+ //
+ // Refinement will finish as soon as average of symmetric
+ // geometric distance is less or equal to this value.
+ //
+ // This distance is measured in the same units as input points are.
+ double expected_average_symmetric_distance;
};
/**
@@ -87,10 +98,11 @@ struct HomographyEstimationOptions {
* correspondences by doing algebraic estimation first followed with result
* refinement.
*/
-bool Homography2DFromCorrespondencesEuc(const Mat &x1,
- const Mat &x2,
- const HomographyEstimationOptions &options,
- Mat3 *H);
+bool EstimateHomography2DFromCorrespondences(
+ const Mat &x1,
+ const Mat &x2,
+ const EstimateHomographyOptions &options,
+ Mat3 *H);
/**
* 3D Homography transformation estimation.
@@ -124,7 +136,9 @@ bool Homography3DFromCorrespondencesLinear(const Mat &x1,
*
* D(H * x1, x2)^2 + D(H^-1 * x2, x1)
*/
-double SymmetricGeometricDistance(Mat3 &H, Vec2 &x1, Vec2 &x2);
+double SymmetricGeometricDistance(const Mat3 &H,
+ const Vec2 &x1,
+ const Vec2 &x2);
} // namespace libmv
diff --git a/extern/libmv/libmv/simple_pipeline/bundle.cc b/extern/libmv/libmv/simple_pipeline/bundle.cc
index c778c11b3f6..e7887256892 100644
--- a/extern/libmv/libmv/simple_pipeline/bundle.cc
+++ b/extern/libmv/libmv/simple_pipeline/bundle.cc
@@ -60,8 +60,11 @@ namespace {
//
// This functor uses a radial distortion model.
struct OpenCVReprojectionError {
- OpenCVReprojectionError(const double observed_x, const double observed_y)
- : observed_x(observed_x), observed_y(observed_y) {}
+ OpenCVReprojectionError(const double observed_x,
+ const double observed_y,
+ const double weight)
+ : observed_x_(observed_x), observed_y_(observed_y),
+ weight_(weight) {}
template <typename T>
bool operator()(const T* const intrinsics,
@@ -112,13 +115,14 @@ struct OpenCVReprojectionError {
&predicted_y);
// The error is the difference between the predicted and observed position.
- residuals[0] = predicted_x - T(observed_x);
- residuals[1] = predicted_y - T(observed_y);
+ residuals[0] = (predicted_x - T(observed_x_)) * weight_;
+ residuals[1] = (predicted_y - T(observed_y_)) * weight_;
return true;
}
- const double observed_x;
- const double observed_y;
+ const double observed_x_;
+ const double observed_y_;
+ const double weight_;
};
// Print a message to the log which camera intrinsics are gonna to be optimixed.
@@ -378,25 +382,31 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
// camera translaiton.
double *current_camera_R_t = &all_cameras_R_t[camera->image](0);
- problem.AddResidualBlock(new ceres::AutoDiffCostFunction<
- OpenCVReprojectionError, 2, 8, 6, 3>(
- new OpenCVReprojectionError(
- marker.x,
- marker.y)),
- NULL,
- ceres_intrinsics,
- current_camera_R_t,
- &point->X(0));
-
- // We lock the first camera to better deal with scene orientation ambiguity.
- if (!have_locked_camera) {
- problem.SetParameterBlockConstant(current_camera_R_t);
- have_locked_camera = true;
- }
+ // Skip residual block for markers which does have absolutely
+ // no affect on the final solution.
+ // This way ceres is not gonna to go crazy.
+ if (marker.weight != 0.0) {
+ problem.AddResidualBlock(new ceres::AutoDiffCostFunction<
+ OpenCVReprojectionError, 2, 8, 6, 3>(
+ new OpenCVReprojectionError(
+ marker.x,
+ marker.y,
+ marker.weight)),
+ NULL,
+ ceres_intrinsics,
+ current_camera_R_t,
+ &point->X(0));
+
+ // We lock the first camera to better deal with scene orientation ambiguity.
+ if (!have_locked_camera) {
+ problem.SetParameterBlockConstant(current_camera_R_t);
+ have_locked_camera = true;
+ }
- if (bundle_constraints & BUNDLE_NO_TRANSLATION) {
- problem.SetParameterization(current_camera_R_t,
+ if (bundle_constraints & BUNDLE_NO_TRANSLATION) {
+ problem.SetParameterization(current_camera_R_t,
constant_translation_parameterization);
+ }
}
num_residuals++;
diff --git a/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc b/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
index d4ddee56fda..6ab9e7eefb6 100644
--- a/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
+++ b/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
@@ -207,19 +207,19 @@ void SelectKeyframesBasedOnGRICAndVariance(const Tracks &tracks,
Mat3 H, F;
// Estimate homography using default options.
- HomographyEstimationOptions homography_estimation_options;
- Homography2DFromCorrespondencesEuc(x1,
- x2,
- homography_estimation_options,
- &H);
+ EstimateHomographyOptions estimate_homography_options;
+ EstimateHomography2DFromCorrespondences(x1,
+ x2,
+ estimate_homography_options,
+ &H);
// Convert homography to original pixel space.
H = N_inverse * H * N;
- FundamentalEstimationOptions fundamental_estimation_options;
- FundamentalFromCorrespondencesEuc(x1,
+ EstimateFundamentalOptions estimate_fundamental_options;
+ EstimateFundamentalFromCorrespondences(x1,
x2,
- fundamental_estimation_options,
+ estimate_fundamental_options,
&F);
// Convert fundamental to original pixel space.
diff --git a/extern/libmv/libmv/simple_pipeline/modal_solver.cc b/extern/libmv/libmv/simple_pipeline/modal_solver.cc
index 90dfde15660..caccce68cbe 100644
--- a/extern/libmv/libmv/simple_pipeline/modal_solver.cc
+++ b/extern/libmv/libmv/simple_pipeline/modal_solver.cc
@@ -57,8 +57,10 @@ void ModalSolverLogProress(ProgressUpdateCallback *update_callback,
struct ModalReprojectionError {
ModalReprojectionError(double observed_x,
double observed_y,
+ const double weight,
const Vec3 &bundle)
- : observed_x(observed_x), observed_y(observed_y), bundle(bundle) { }
+ : observed_x_(observed_x), observed_y_(observed_y),
+ weight_(weight), bundle_(bundle) { }
template <typename T>
bool operator()(const T* quaternion, // Rotation quaternion
@@ -68,9 +70,9 @@ struct ModalReprojectionError {
// Convert bundle position from double to T.
T X[3];
- X[0] = T(bundle(0));
- X[1] = T(bundle(1));
- X[2] = T(bundle(2));
+ X[0] = T(bundle_(0));
+ X[1] = T(bundle_(1));
+ X[2] = T(bundle_(2));
// Compute projective coordinates: x = RX.
T x[3];
@@ -84,15 +86,16 @@ struct ModalReprojectionError {
// The error is the difference between reprojected
// and observed marker position.
- residuals[0] = xn - T(observed_x);
- residuals[1] = yn - T(observed_y);
+ residuals[0] = xn - T(observed_x_);
+ residuals[1] = yn - T(observed_y_);
return true;
}
- double observed_x;
- double observed_y;
- Vec3 bundle;
+ double observed_x_;
+ double observed_y_;
+ double weight_;
+ Vec3 bundle_;
};
} // namespace
@@ -180,11 +183,13 @@ void ModalSolver(const Tracks &tracks,
Marker &marker = all_markers[i];
EuclideanPoint *point = reconstruction->PointForTrack(marker.track);
- if (point) {
+ if (point && marker.weight != 0.0) {
problem.AddResidualBlock(new ceres::AutoDiffCostFunction<
ModalReprojectionError,
2, /* num_residuals */
- 4>(new ModalReprojectionError(marker.x, marker.y,
+ 4>(new ModalReprojectionError(marker.x,
+ marker.y,
+ marker.weight,
point->X)),
NULL,
&quaternion(0));
diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc
index 20f82e43262..41dd3251f10 100644
--- a/extern/libmv/libmv/simple_pipeline/pipeline.cc
+++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc
@@ -51,10 +51,9 @@ struct EuclideanPipelineRoutines {
EuclideanBundle(tracks, reconstruction);
}
- static bool Resect(const ReconstructionOptions &options,
- const vector<Marker> &markers,
+ static bool Resect(const vector<Marker> &markers,
EuclideanReconstruction *reconstruction, bool final_pass) {
- return EuclideanResect(options, markers, reconstruction, final_pass);
+ return EuclideanResect(markers, reconstruction, final_pass);
}
static bool Intersect(const vector<Marker> &markers,
@@ -90,10 +89,8 @@ struct ProjectivePipelineRoutines {
ProjectiveBundle(tracks, reconstruction);
}
- static bool Resect(const ReconstructionOptions &options,
- const vector<Marker> &markers,
+ static bool Resect(const vector<Marker> &markers,
ProjectiveReconstruction *reconstruction, bool final_pass) {
- (void) options; // Ignored.
(void) final_pass; // Ignored.
return ProjectiveResect(markers, reconstruction);
@@ -144,7 +141,6 @@ static void CompleteReconstructionLogProgress(
template<typename PipelineRoutines>
void InternalCompleteReconstruction(
- const ReconstructionOptions &options,
const Tracks &tracks,
typename PipelineRoutines::Reconstruction *reconstruction,
ProgressUpdateCallback *update_callback = NULL) {
@@ -217,7 +213,7 @@ void InternalCompleteReconstruction(
if (reconstructed_markers.size() >= 5) {
CompleteReconstructionLogProgress(update_callback,
(double)tot_resects/(max_image));
- if (PipelineRoutines::Resect(options, reconstructed_markers,
+ if (PipelineRoutines::Resect(reconstructed_markers,
reconstruction, false)) {
num_resects++;
tot_resects++;
@@ -254,7 +250,7 @@ void InternalCompleteReconstruction(
if (reconstructed_markers.size() >= 5) {
CompleteReconstructionLogProgress(update_callback,
(double)tot_resects/(max_image));
- if (PipelineRoutines::Resect(options, reconstructed_markers,
+ if (PipelineRoutines::Resect(reconstructed_markers,
reconstruction, true)) {
num_resects++;
LG << "Ran final Resect() for image " << image;
@@ -341,21 +337,17 @@ double ProjectiveReprojectionError(
intrinsics);
}
-void EuclideanCompleteReconstruction(const ReconstructionOptions &options,
- const Tracks &tracks,
+void EuclideanCompleteReconstruction(const Tracks &tracks,
EuclideanReconstruction *reconstruction,
ProgressUpdateCallback *update_callback) {
- InternalCompleteReconstruction<EuclideanPipelineRoutines>(options,
- tracks,
+ InternalCompleteReconstruction<EuclideanPipelineRoutines>(tracks,
reconstruction,
update_callback);
}
-void ProjectiveCompleteReconstruction(const ReconstructionOptions &options,
- const Tracks &tracks,
+void ProjectiveCompleteReconstruction(const Tracks &tracks,
ProjectiveReconstruction *reconstruction) {
- InternalCompleteReconstruction<ProjectivePipelineRoutines>(options,
- tracks,
+ InternalCompleteReconstruction<ProjectivePipelineRoutines>(tracks,
reconstruction);
}
diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.h b/extern/libmv/libmv/simple_pipeline/pipeline.h
index d8489012b95..4d1bd00c51f 100644
--- a/extern/libmv/libmv/simple_pipeline/pipeline.h
+++ b/extern/libmv/libmv/simple_pipeline/pipeline.h
@@ -39,9 +39,6 @@ namespace libmv {
repeated until all points and cameras are estimated. Periodically, bundle
adjustment is run to ensure a quality reconstruction.
- \a options are used to define some specific befaviours based on settings
- see documentation for ReconstructionOptions
-
\a tracks should contain markers used in the reconstruction.
\a reconstruction should contain at least some 3D points or some estimated
cameras. The minimum number of cameras is two (with no 3D points) and the
@@ -50,7 +47,6 @@ namespace libmv {
\sa EuclideanResect, EuclideanIntersect, EuclideanBundle
*/
void EuclideanCompleteReconstruction(
- const ReconstructionOptions &options,
const Tracks &tracks,
EuclideanReconstruction *reconstruction,
ProgressUpdateCallback *update_callback = NULL);
@@ -68,9 +64,6 @@ void EuclideanCompleteReconstruction(
repeated until all points and cameras are estimated. Periodically, bundle
adjustment is run to ensure a quality reconstruction.
- \a options are used to define some specific befaviours based on settings
- see documentation for ReconstructionOptions
-
\a tracks should contain markers used in the reconstruction.
\a reconstruction should contain at least some 3D points or some estimated
cameras. The minimum number of cameras is two (with no 3D points) and the
@@ -78,8 +71,7 @@ void EuclideanCompleteReconstruction(
\sa ProjectiveResect, ProjectiveIntersect, ProjectiveBundle
*/
-void ProjectiveCompleteReconstruction(const ReconstructionOptions &options,
- const Tracks &tracks,
+void ProjectiveCompleteReconstruction(const Tracks &tracks,
ProjectiveReconstruction *reconstruction);
diff --git a/extern/libmv/libmv/simple_pipeline/reconstruction.h b/extern/libmv/libmv/simple_pipeline/reconstruction.h
index 1610029b9d2..947a0636476 100644
--- a/extern/libmv/libmv/simple_pipeline/reconstruction.h
+++ b/extern/libmv/libmv/simple_pipeline/reconstruction.h
@@ -26,17 +26,6 @@
namespace libmv {
-struct ReconstructionOptions {
- // threshold value of reconstruction error which is still considered successful
- // if reconstruction error bigger than this value, fallback reconstruction
- // algorithm would be used (if enabled)
- double success_threshold;
-
- // use fallback reconstruction algorithm in cases main reconstruction algorithm
- // failed to reconstruct
- bool use_fallback_reconstruction;
-};
-
/*!
A EuclideanCamera is the location and rotation of the camera viewing \a image.
diff --git a/extern/libmv/libmv/simple_pipeline/resect.cc b/extern/libmv/libmv/simple_pipeline/resect.cc
index 941c95cf237..e73fc44df2a 100644
--- a/extern/libmv/libmv/simple_pipeline/resect.cc
+++ b/extern/libmv/libmv/simple_pipeline/resect.cc
@@ -91,8 +91,7 @@ struct EuclideanResectCostFunction {
} // namespace
-bool EuclideanResect(const ReconstructionOptions &options,
- const vector<Marker> &markers,
+bool EuclideanResect(const vector<Marker> &markers,
EuclideanReconstruction *reconstruction, bool final_pass) {
if (markers.size() < 5) {
return false;
@@ -107,23 +106,15 @@ bool EuclideanResect(const ReconstructionOptions &options,
Mat3 R;
Vec3 t;
- double success_threshold = std::numeric_limits<double>::max();
-
- if (options.use_fallback_reconstruction)
- success_threshold = options.success_threshold;
-
if (0 || !euclidean_resection::EuclideanResection(
points_2d, points_3d, &R, &t,
- euclidean_resection::RESECTION_EPNP,
- success_threshold)) {
+ euclidean_resection::RESECTION_EPNP)) {
// printf("Resection for image %d failed\n", markers[0].image);
LG << "Resection for image " << markers[0].image << " failed;"
<< " trying fallback projective resection.";
- if (!options.use_fallback_reconstruction) {
- LG << "No fallback; failing resection for " << markers[0].image;
- return false;
- }
+ LG << "No fallback; failing resection for " << markers[0].image;
+ return false;
if (!final_pass) return false;
// Euclidean resection failed. Fall back to projective resection, which is
diff --git a/extern/libmv/libmv/simple_pipeline/resect.h b/extern/libmv/libmv/simple_pipeline/resect.h
index 47a6c6b60ea..7ca3237437e 100644
--- a/extern/libmv/libmv/simple_pipeline/resect.h
+++ b/extern/libmv/libmv/simple_pipeline/resect.h
@@ -35,9 +35,6 @@ namespace libmv {
reconstruction object, and solves for the pose and orientation of the
camera for that frame.
- \a options are used to define some specific befaviours based on settings
- see documentation for ReconstructionOptions
-
\a markers should contain \l Marker markers \endlink belonging to tracks
visible in the one frame to be resectioned. Each of the tracks associated
with the markers must have a corresponding reconstructed 3D position in the
@@ -54,8 +51,7 @@ namespace libmv {
\sa EuclideanIntersect, EuclideanReconstructTwoFrames
*/
-bool EuclideanResect(const ReconstructionOptions &options,
- const vector<Marker> &markers,
+bool EuclideanResect(const vector<Marker> &markers,
EuclideanReconstruction *reconstruction, bool final_pass);
/*!
diff --git a/extern/libmv/libmv/simple_pipeline/tracks.cc b/extern/libmv/libmv/simple_pipeline/tracks.cc
index f9e50d20af9..d5d009708ba 100644
--- a/extern/libmv/libmv/simple_pipeline/tracks.cc
+++ b/extern/libmv/libmv/simple_pipeline/tracks.cc
@@ -34,7 +34,7 @@ Tracks::Tracks(const Tracks &other) {
Tracks::Tracks(const vector<Marker> &markers) : markers_(markers) {}
-void Tracks::Insert(int image, int track, double x, double y) {
+void Tracks::Insert(int image, int track, double x, double y, double weight) {
// TODO(keir): Wow, this is quadratic for repeated insertions. Fix this by
// adding a smarter data structure like a set<>.
for (int i = 0; i < markers_.size(); ++i) {
@@ -45,7 +45,7 @@ void Tracks::Insert(int image, int track, double x, double y) {
return;
}
}
- Marker marker = { image, track, x, y };
+ Marker marker = { image, track, x, y, weight };
markers_.push_back(marker);
}
@@ -122,7 +122,7 @@ Marker Tracks::MarkerInImageForTrack(int image, int track) const {
return markers_[i];
}
}
- Marker null = { -1, -1, -1, -1 };
+ Marker null = { -1, -1, -1, -1, 0.0 };
return null;
}
diff --git a/extern/libmv/libmv/simple_pipeline/tracks.h b/extern/libmv/libmv/simple_pipeline/tracks.h
index f9af3ada45b..e2f8cf6b459 100644
--- a/extern/libmv/libmv/simple_pipeline/tracks.h
+++ b/extern/libmv/libmv/simple_pipeline/tracks.h
@@ -33,14 +33,20 @@ namespace libmv {
in the image identified by \a image. All markers for to the same target
form a track identified by a common \a track number.
+ \a weight is used by bundle adjustment and weight means how much the
+ track affects on a final solution.
+
\note Markers are typically aggregated with the help of the \l Tracks class.
\sa Tracks
*/
+// TODO(sergey): Consider using comment for every member separately
+// instead of having one giantic comment block.
struct Marker {
int image;
int track;
double x, y;
+ double weight;
};
/*!
@@ -72,9 +78,14 @@ class Tracks {
\a image and \a track are the keys used to retrieve the markers with the
other methods in this class.
+ \a weight is used by bundle adjustment and weight means how much the
+ track affects on a final solution.
+
\note To get an identifier for a new track, use \l MaxTrack() + 1.
*/
- void Insert(int image, int track, double x, double y);
+ // TODO(sergey): Consider using InsetWeightedMarker istead of using
+ // stupid default value?
+ void Insert(int image, int track, double x, double y, double weight = 1.0);
/// Returns all the markers.
vector<Marker> AllMarkers() const;
diff --git a/extern/libmv/libmv/tracking/track_region.cc b/extern/libmv/libmv/tracking/track_region.cc
index 349d84b3817..9e0bf9a77da 100644
--- a/extern/libmv/libmv/tracking/track_region.cc
+++ b/extern/libmv/libmv/tracking/track_region.cc
@@ -1289,6 +1289,15 @@ bool BruteTranslationOnlyInitialize(const FloatImage &image1,
return true;
}
+void CopyQuad(double *src_x, double *src_y,
+ double *dst_x, double *dst_y,
+ int num_extra_points) {
+ for (int i = 0; i < 4 + num_extra_points; ++i) {
+ dst_x[i] = src_x[i];
+ dst_y[i] = src_y[i];
+ }
+}
+
} // namespace
template<typename Warp>
@@ -1298,11 +1307,46 @@ void TemplatedTrackRegion(const FloatImage &image1,
const TrackRegionOptions &options,
double *x2, double *y2,
TrackRegionResult *result) {
- for (int i = 0; i < 4; ++i) {
+ for (int i = 0; i < 4 + options.num_extra_points; ++i) {
LG << "P" << i << ": (" << x1[i] << ", " << y1[i] << "); guess ("
<< x2[i] << ", " << y2[i] << "); (dx, dy): (" << (x2[i] - x1[i]) << ", "
<< (y2[i] - y1[i]) << ").";
}
+
+ // Since (x2, y2) contains a prediction for where the tracked point should
+ // go, try a refinement immediately in the hope that the prediction is close
+ // enough.
+ if (options.attempt_refine_before_brute) {
+ TrackRegionOptions modified_options = options;
+ modified_options.use_brute_initialization = false;
+ modified_options.attempt_refine_before_brute = false;
+
+ double x2_first_try[5];
+ double y2_first_try[5];
+ CopyQuad(x2, y2, x2_first_try, y2_first_try, options.num_extra_points);
+
+ TemplatedTrackRegion<Warp>(image1, image2,
+ x1, y1, modified_options,
+ x2_first_try, y2_first_try, result);
+
+ // Of the things that can happen in the first pass, don't try the brute
+ // pass (and second attempt) if the error is one of the terminations below.
+ if (result->termination == TrackRegionResult::PARAMETER_TOLERANCE ||
+ result->termination == TrackRegionResult::FUNCTION_TOLERANCE ||
+ result->termination == TrackRegionResult::GRADIENT_TOLERANCE ||
+ result->termination == TrackRegionResult::SOURCE_OUT_OF_BOUNDS ||
+ result->termination == TrackRegionResult::DESTINATION_OUT_OF_BOUNDS ||
+ result->termination == TrackRegionResult::INSUFFICIENT_PATTERN_AREA) {
+ LG << "Terminated with first try at refinement; no brute needed.";
+ // TODO(keir): Also check correlation?
+ CopyQuad(x2_first_try, y2_first_try, x2, y2, options.num_extra_points);
+ LG << "Early termination correlation: " << result->correlation;
+ return;
+ } else {
+ LG << "Initial eager-refinement failed; retrying normally.";
+ }
+ }
+
if (options.use_normalized_intensities) {
LG << "Using normalized intensities.";
}
@@ -1368,7 +1412,6 @@ void TemplatedTrackRegion(const FloatImage &image1,
int num_samples_y;
PickSampling(x1, y1, x2, y2, &num_samples_x, &num_samples_y);
-
// Compute the warp from rectangular coordinates.
Mat3 canonical_homography = ComputeCanonicalHomography(x1, y1,
num_samples_x,
@@ -1450,16 +1493,6 @@ void TemplatedTrackRegion(const FloatImage &image1,
return;
}
- // This happens when the minimum corner shift tolerance is reached. Due to
- // how the tolerance is computed this can't be done by Ceres. So return the
- // same termination enum as Ceres, even though this is slightly different
- // than Ceres's parameter tolerance, which operates on the raw parameter
- // values rather than the pixel shifts of the patch corners.
- if (summary.termination_type == ceres::USER_SUCCESS) {
- result->termination = TrackRegionResult::PARAMETER_TOLERANCE;
- return;
- }
-
#define HANDLE_TERMINATION(termination_enum) \
if (summary.termination_type == ceres::termination_enum) { \
result->termination = TrackRegionResult::termination_enum; \
@@ -1481,6 +1514,16 @@ void TemplatedTrackRegion(const FloatImage &image1,
}
}
+ // This happens when the minimum corner shift tolerance is reached. Due to
+ // how the tolerance is computed this can't be done by Ceres. So return the
+ // same termination enum as Ceres, even though this is slightly different
+ // than Ceres's parameter tolerance, which operates on the raw parameter
+ // values rather than the pixel shifts of the patch corners.
+ if (summary.termination_type == ceres::USER_SUCCESS) {
+ result->termination = TrackRegionResult::PARAMETER_TOLERANCE;
+ return;
+ }
+
HANDLE_TERMINATION(PARAMETER_TOLERANCE);
HANDLE_TERMINATION(FUNCTION_TOLERANCE);
HANDLE_TERMINATION(GRADIENT_TOLERANCE);
diff --git a/extern/libmv/libmv/tracking/track_region.h b/extern/libmv/libmv/tracking/track_region.h
index 6c7218f11d1..58742cab36c 100644
--- a/extern/libmv/libmv/tracking/track_region.h
+++ b/extern/libmv/libmv/tracking/track_region.h
@@ -55,6 +55,13 @@ struct TrackRegionOptions {
// that the nearby minima is correct, or the search area is too small.
bool use_brute_initialization;
+ // If true and brute initialization is enabled, first try refining with the
+ // initial guess instead of starting with the brute initialization. If the
+ // initial refinement fails, then a normal brute search followed by
+ // refinement is attempted. If the initial refinement succeeds, then the
+ // result is returned as is (skipping a costly brute search).
+ bool attempt_refine_before_brute;
+
// If true, normalize the image patches by their mean before doing the sum of
// squared error calculation. This is reasonable since the effect of
// increasing light intensity is multiplicative on the pixel intensities.
@@ -67,8 +74,9 @@ struct TrackRegionOptions {
// take the image derivative.
double sigma;
- // Extra points that should get transformed by the warp. This is useful
- // because the actual warp parameters are not exposed.
+ // Extra points that should get transformed by the warp. These points are
+ // appended to the x and y arrays. This is useful because the actual warp
+ // parameters are not exposed.
int num_extra_points;
// For motion models other than translation, the optimizer sometimes has
diff --git a/extern/libmv/third_party/ceres/SConscript b/extern/libmv/third_party/ceres/SConscript
index a914135fddc..164aedfe415 100644
--- a/extern/libmv/third_party/ceres/SConscript
+++ b/extern/libmv/third_party/ceres/SConscript
@@ -28,7 +28,7 @@ defs.append('CERES_HAVE_RWLOCK')
if env['WITH_BF_OPENMP']:
defs.append('CERES_USE_OPENMP')
-if 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
+if 'Mac OS X 10.5' in env['MACOSX_SDK']:
defs.append('CERES_NO_TR1')
incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags'
diff --git a/extern/libmv/third_party/ceres/bundle.sh b/extern/libmv/third_party/ceres/bundle.sh
index 6ab348af118..a6f040b6d29 100755
--- a/extern/libmv/third_party/ceres/bundle.sh
+++ b/extern/libmv/third_party/ceres/bundle.sh
@@ -225,7 +225,7 @@ defs.append('CERES_HAVE_RWLOCK')
if env['WITH_BF_OPENMP']:
defs.append('CERES_USE_OPENMP')
-if 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
+if 'Mac OS X 10.5' in env['MACOSX_SDK']:
defs.append('CERES_NO_TR1')
incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags'
diff --git a/extern/rangetree/range_tree.hh b/extern/rangetree/range_tree.hh
index 2a47c5a1d93..a88c70281b6 100644
--- a/extern/rangetree/range_tree.hh
+++ b/extern/rangetree/range_tree.hh
@@ -35,6 +35,11 @@ struct RangeTree {
: min(t), max(t), single(true)
{}
+ Range& operator=(const Range& v) {
+ *this = v;
+ return *this;
+ }
+
bool operator<(const Range& v) const {
return max < v.min;
}
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 364db3592c7..c45e66cd77b 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -61,7 +61,7 @@ if(WITH_IK_ITASC)
add_subdirectory(itasc)
endif()
-if(WITH_IK_SOLVER OR WITH_GAMEENGINE)
+if(WITH_IK_SOLVER OR WITH_GAMEENGINE OR WITH_MOD_BOOLEAN)
add_subdirectory(moto)
endif()
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
index 676a86e88fe..c3877c2c9f2 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
@@ -119,6 +119,14 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A
{
length = m_device->m_buffersize;
reader->read(length, eos, m_device->m_buffer.getBuffer());
+
+ if(length == 0)
+ {
+ // AUD_XXX: TODO: don't fill all buffers and enqueue them later
+ length = 1;
+ memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs));
+ }
+
alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(),
length * AUD_DEVICE_SAMPLE_SIZE(specs),
specs.rate);
@@ -132,8 +140,7 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A
try
{
- alSourceQueueBuffers(m_source, CYCLE_BUFFERS,
- m_buffers);
+ alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers);
if(alGetError() != AL_NO_ERROR)
AUD_THROW(AUD_ERROR_OPENAL, queue_error);
}
@@ -289,6 +296,14 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position)
{
length = m_device->m_buffersize;
m_reader->read(length, m_eos, m_device->m_buffer.getBuffer());
+
+ if(length == 0)
+ {
+ // AUD_XXX: TODO: don't fill all buffers and enqueue them later
+ length = 1;
+ memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs));
+ }
+
alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(),
length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate);
@@ -933,9 +948,8 @@ void AUD_OpenALDevice::updateStreams()
break;
}
- // unqueue buffer
- alSourceUnqueueBuffers(sound->m_source, 1,
- &sound->m_buffers[sound->m_current]);
+ // unqueue buffer (warning: this might fail for slow early returning sources (none exist so far) if the buffer was not queued due to recent changes - has to be tested)
+ alSourceUnqueueBuffers(sound->m_source, 1, &sound->m_buffers[sound->m_current]);
ALenum err;
if((err = alGetError()) != AL_NO_ERROR)
{
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
index 0b333e687ff..61adae4b34b 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
@@ -47,6 +47,15 @@ AUD_AnimateableProperty::AUD_AnimateableProperty(int count) :
pthread_mutexattr_destroy(&attr);
}
+void AUD_AnimateableProperty::updateUnknownCache(int start, int end)
+{
+ float* buf = getBuffer();
+
+ for(int i = start; i <= end; i++)
+ // TODO: maybe first instead of zero order interpolation?
+ memcpy(buf + i * m_count, buf + (start - 1) * m_count, m_count * sizeof(float));
+}
+
AUD_AnimateableProperty::~AUD_AnimateableProperty()
{
pthread_mutex_destroy(&m_mutex);
@@ -67,6 +76,7 @@ void AUD_AnimateableProperty::write(const float* data)
AUD_MutexLock lock(*this);
m_isAnimated = false;
+ m_unknown.clear();
memcpy(getBuffer(), data, m_count * sizeof(float));
}
@@ -74,18 +84,88 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count)
{
AUD_MutexLock lock(*this);
- m_isAnimated = true;
-
int pos = getSize() / (sizeof(float) * m_count);
+ if(!m_isAnimated)
+ pos = 0;
+
+ m_isAnimated = true;
+
assureSize((count + position) * m_count * sizeof(float), true);
float* buf = getBuffer();
memcpy(buf + position * m_count, data, count * m_count * sizeof(float));
- for(int i = pos; i < position; i++)
- memcpy(buf + i * m_count, buf + (pos - 1) * m_count, m_count * sizeof(float));
+ // have to fill up space between?
+ if(pos < position)
+ {
+ m_unknown.push_back(Unknown(pos, position - 1));
+
+ if(pos == 0)
+ {
+ memset(buf, 0, position * m_count * sizeof(float));
+ }
+ else
+ updateUnknownCache(pos, position - 1);
+ }
+ // otherwise it's not at the end, let's check if some unknown part got filled
+ else
+ {
+ bool erased = false;
+
+ for(std::list<Unknown>::iterator it = m_unknown.begin(); it != m_unknown.end(); erased ? it : it++)
+ {
+ erased = false;
+
+ // unknown area before position
+ if(it->end < position)
+ continue;
+
+ // we're after the new area, let's stop
+ if(it->start >= position + count)
+ break;
+
+ // we have an intersection, now 4 cases:
+ // the start is included
+ if(position <= it->start)
+ {
+ // the end is included
+ if(position + count > it->end)
+ {
+ // simply delete
+ it = m_unknown.erase(it);
+ erased = true;
+ }
+ // the end is excluded, a second part remains
+ else
+ {
+ // update second part
+ it->start = position + count;
+ updateUnknownCache(it->start, it->end);
+ break;
+ }
+ }
+ // start is excluded, a first part remains
+ else
+ {
+ // the end is included
+ if(position + count > it->end)
+ {
+ // update first part
+ it->end = position - 1;
+ }
+ // the end is excluded, a second part remains
+ else
+ {
+ // add another item and update both parts
+ m_unknown.insert(it, Unknown(it->start, position - 1));
+ it->start = position + count;
+ updateUnknownCache(it->start, it->end);
+ }
+ }
+ }
+ }
}
void AUD_AnimateableProperty::read(float position, float* out)
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.h b/intern/audaspace/intern/AUD_AnimateableProperty.h
index 322748ad571..37eb8f84550 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.h
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.h
@@ -34,6 +34,7 @@
#include "AUD_ILockable.h"
#include <pthread.h>
+#include <list>
/**
* This class saves animation data for float properties.
@@ -41,6 +42,14 @@
class AUD_AnimateableProperty : private AUD_Buffer, public AUD_ILockable
{
private:
+ struct Unknown {
+ int start;
+ int end;
+
+ Unknown(int start, int end) :
+ start(start), end(end) {}
+ };
+
/// The count of floats for a single property.
const int m_count;
@@ -50,10 +59,15 @@ private:
/// The mutex for locking.
pthread_mutex_t m_mutex;
+ /// The list of unknown buffer areas.
+ std::list<Unknown> m_unknown;
+
// hide copy constructor and operator=
AUD_AnimateableProperty(const AUD_AnimateableProperty&);
AUD_AnimateableProperty& operator=(const AUD_AnimateableProperty&);
+ void updateUnknownCache(int start, int end);
+
public:
/**
* Creates a new animateable property.
diff --git a/intern/bsp/intern/BOP_CarveInterface.cpp b/intern/bsp/intern/BOP_CarveInterface.cpp
index bb3a783548c..a96196ee8f5 100644
--- a/intern/bsp/intern/BOP_CarveInterface.cpp
+++ b/intern/bsp/intern/BOP_CarveInterface.cpp
@@ -711,6 +711,47 @@ static BSP_CSGMesh *Carve_exportMesh(MeshSet<3>* &poly, carve::interpolate::Face
return outputMesh;
}
+static void meshSetMinMax(const MeshSet<3> *mesh,
+ carve::geom3d::Vector *min,
+ carve::geom3d::Vector *max)
+{
+ for (uint i = 0; i < mesh->vertex_storage.size(); ++i) {
+ min->x = MIN(min->x, mesh->vertex_storage[i].v.x);
+ min->y = MIN(min->y, mesh->vertex_storage[i].v.y);
+ min->z = MIN(min->z, mesh->vertex_storage[i].v.z);
+ max->x = MAX(max->x, mesh->vertex_storage[i].v.x);
+ max->y = MAX(max->y, mesh->vertex_storage[i].v.y);
+ max->z = MAX(max->z, mesh->vertex_storage[i].v.z);
+ }
+}
+
+static void getRescaleMinMax(const MeshSet<3> *left,
+ const MeshSet<3> *right,
+ carve::geom3d::Vector *min,
+ carve::geom3d::Vector *max)
+{
+ min->x = max->x = left->vertex_storage[0].v.x;
+ min->y = max->y = left->vertex_storage[0].v.y;
+ min->z = max->z = left->vertex_storage[0].v.z;
+
+ meshSetMinMax(left, min, max);
+ meshSetMinMax(right, min, max);
+
+ // Make sure we don't scale object with zer oscale
+ if ((min->x - max->x) < DBL_EPSILON) {
+ min->x = -1.0;
+ max->x = 1.0;
+ }
+ if ((min->y - max->y) < DBL_EPSILON) {
+ min->y = -1.0;
+ max->y = 1.0;
+ }
+ if ((min->z - max->z) < DBL_EPSILON) {
+ min->z = -1.0;
+ max->z = 1.0;
+ }
+}
+
/**
* Performs a generic booleam operation, the entry point for external modules.
* @param opType Boolean operation type BOP_INTERSECTION, BOP_UNION, BOP_DIFFERENCE
@@ -753,29 +794,11 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType,
left = Carve_addMesh(obAFaces, obAVertices, oface_num, num_origfaces );
right = Carve_addMesh(obBFaces, obBVertices, oface_num, num_origfaces );
- min.x = max.x = left->vertex_storage[0].v.x;
- min.y = max.y = left->vertex_storage[0].v.y;
- min.z = max.z = left->vertex_storage[0].v.z;
- for (uint i = 1; i < left->vertex_storage.size(); ++i) {
- min.x = MIN(min.x,left->vertex_storage[i].v.x);
- min.y = MIN(min.y,left->vertex_storage[i].v.y);
- min.z = MIN(min.z,left->vertex_storage[i].v.z);
- max.x = MAX(max.x,left->vertex_storage[i].v.x);
- max.y = MAX(max.y,left->vertex_storage[i].v.y);
- max.z = MAX(max.z,left->vertex_storage[i].v.z);
- }
- for (uint i = 0; i < right->vertex_storage.size(); ++i) {
- min.x = MIN(min.x,right->vertex_storage[i].v.x);
- min.y = MIN(min.y,right->vertex_storage[i].v.y);
- min.z = MIN(min.z,right->vertex_storage[i].v.z);
- max.x = MAX(max.x,right->vertex_storage[i].v.x);
- max.y = MAX(max.y,right->vertex_storage[i].v.y);
- max.z = MAX(max.z,right->vertex_storage[i].v.z);
- }
+ getRescaleMinMax(left, right, &min, &max);
carve::rescale::rescale scaler(min.x, min.y, min.z, max.x, max.y, max.z);
carve::rescale::fwd fwd_r(scaler);
- carve::rescale::rev rev_r(scaler);
+ carve::rescale::rev rev_r(scaler);
left->transform(fwd_r);
right->transform(fwd_r);
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 6821e93ad87..9b84f882046 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -17,9 +17,11 @@ if(WIN32 AND MSVC)
if(CMAKE_CL_64)
set(CYCLES_SSE2_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
set(CYCLES_SSE3_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
+ set(CYCLES_SSE41_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
else()
set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
+ set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
@@ -29,10 +31,12 @@ if(WIN32 AND MSVC)
elseif(CMAKE_COMPILER_IS_GNUCC)
set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2 -mfpmath=sse")
set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse")
+ set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2")
set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3")
+ set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
endif()
diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript
index e61018bc3dd..eeb60f37f92 100644
--- a/intern/cycles/SConscript
+++ b/intern/cycles/SConscript
@@ -37,6 +37,7 @@ sources = cycles.Glob('bvh/*.cpp') + cycles.Glob('device/*.cpp') + cycles.Glob('
sources.remove(path.join('util', 'util_view.cpp'))
sources.remove(path.join('kernel', 'kernel_sse2.cpp'))
sources.remove(path.join('kernel', 'kernel_sse3.cpp'))
+sources.remove(path.join('kernel', 'kernel_sse41.cpp'))
incs = []
defs = []
@@ -77,21 +78,30 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', '
if env['WITH_BF_RAYOPTIMIZATION']:
sse2_cxxflags = Split(env['CXXFLAGS'])
sse3_cxxflags = Split(env['CXXFLAGS'])
+ sse41_cxxflags = Split(env['CXXFLAGS'])
if env['OURPLATFORM'] == 'win32-vc':
# there is no /arch:SSE3, but intrinsics are available anyway
sse2_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
sse3_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
+ sse41_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
elif env['OURPLATFORM'] == 'win64-vc':
sse2_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
sse3_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
+ sse41_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
else:
sse2_cxxflags.append('-ffast-math -msse -msse2 -mfpmath=sse'.split())
sse3_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse'.split())
+ sse41_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse'.split())
defs.append('WITH_OPTIMIZED_KERNEL')
optim_defs = defs[:]
+ # Disabled sse4+ patchs for now
+ #cycles_sse41 = cycles.Clone()
+ #sse41_sources = [path.join('kernel', 'kernel_sse41.cpp')]
+ #cycles_sse41.BlenderLib('bf_intern_cycles_sse41', sse41_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=sse41_cxxflags)
+
cycles_sse3 = cycles.Clone()
sse3_sources = [path.join('kernel', 'kernel_sse3.cpp')]
cycles_sse3.BlenderLib('bf_intern_cycles_sse3', sse3_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=sse3_cxxflags)
diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp
index 2a438397ae0..6b201017c46 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -190,7 +190,7 @@ static void keyboard(unsigned char key)
if(key == 'r')
options.session->reset(session_buffer_params(), options.session_params.samples);
else if(key == 27) // escape
- options.session->progress.set_cancel("Cancelled");
+ options.session->progress.set_cancel("Canceled");
}
#endif
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 367f021ee34..ac15acee0c5 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -253,26 +253,26 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
name="Max Bounces",
description="Total maximum number of bounces",
min=0, max=1024,
- default=8,
+ default=12,
)
cls.diffuse_bounces = IntProperty(
name="Diffuse Bounces",
description="Maximum number of diffuse reflection bounces, bounded by total maximum",
min=0, max=1024,
- default=128,
+ default=4,
)
cls.glossy_bounces = IntProperty(
name="Glossy Bounces",
description="Maximum number of glossy reflection bounces, bounded by total maximum",
min=0, max=1024,
- default=128,
+ default=4,
)
cls.transmission_bounces = IntProperty(
name="Transmission Bounces",
description="Maximum number of transmission bounces, bounded by total maximum",
min=0, max=1024,
- default=128,
+ default=12,
)
cls.transparent_min_bounces = IntProperty(
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 7a03df4f35a..cbf26fb8d0a 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -324,7 +324,7 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
rl = rd.layers.active
row = layout.row()
- row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2)
+ row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=1)
col = row.column(align=True)
col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
@@ -503,7 +503,7 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
if ob:
row = layout.row()
- row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=2)
+ row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1)
col = row.column(align=True)
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 1cddc25a22b..b780877a158 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -628,6 +628,47 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
}
}
+static void ExportCurveSegmentsMotion(Scene *scene, Mesh *mesh, ParticleCurveData *CData, int motion)
+{
+ /* export motion vectors for curve keys */
+ AttributeStandard std = (motion == -1)? ATTR_STD_MOTION_PRE: ATTR_STD_MOTION_POST;
+ Attribute *attr_motion = mesh->curve_attributes.add(std);
+ float3 *data_motion = attr_motion->data_float3();
+ float3 *current_motion = data_motion;
+ size_t size = mesh->curve_keys.size();
+ size_t i = 0;
+ bool have_motion = false;
+
+ for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+ if(CData->psys_curvenum[sys] == 0)
+ continue;
+
+ for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
+ if(CData->curve_keynum[curve] <= 1)
+ continue;
+
+ for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) {
+ if(i < mesh->curve_keys.size()) {
+ *current_motion = CData->curvekey_co[curvekey];
+
+ /* unlike mesh coordinates, these tend to be slightly different
+ * between frames due to particle transforms into/out of object
+ * space, so we use an epsilon to detect actual changes */
+ if(len_squared(*current_motion - mesh->curve_keys[i].co) > 1e-5f*1e-5f)
+ have_motion = true;
+
+ current_motion++;
+ }
+
+ i++;
+ }
+ }
+ }
+
+ if(i != size || !have_motion)
+ mesh->curve_attributes.remove(std);
+}
+
void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata)
{
if(uvdata == NULL)
@@ -778,18 +819,21 @@ void BlenderSync::sync_curve_settings()
}
-void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool object_updated)
+void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, int motion)
{
- /* Clear stored curve data */
- mesh->curve_keys.clear();
- mesh->curves.clear();
- mesh->curve_attributes.clear();
+ if(!motion) {
+ /* Clear stored curve data */
+ mesh->curve_keys.clear();
+ mesh->curves.clear();
+ mesh->curve_attributes.clear();
+ }
/* obtain general settings */
bool use_curves = scene->curve_system_manager->use_curves;
if(!(use_curves && b_ob.mode() == b_ob.mode_OBJECT)) {
- mesh->compute_bounds();
+ if(!motion)
+ mesh->compute_bounds();
return;
}
@@ -829,13 +873,15 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
}
}
else {
- ExportCurveSegments(scene, mesh, &CData);
+ if(motion)
+ ExportCurveSegmentsMotion(scene, mesh, &CData, motion);
+ else
+ ExportCurveSegments(scene, mesh, &CData);
}
-
/* generated coordinates from first key. we should ideally get this from
* blender to handle deforming objects */
- {
+ if(!motion) {
if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
float3 loc, size;
mesh_texture_space(b_mesh, loc, size);
@@ -861,7 +907,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
}
/* create vertex color attributes */
- {
+ if(!motion) {
BL::Mesh::tessface_vertex_colors_iterator l;
int vcol_num = 0;
@@ -895,7 +941,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
}
/* create UV attributes */
- {
+ if(!motion) {
BL::Mesh::tessface_uv_textures_iterator l;
int uv_num = 0;
@@ -943,6 +989,5 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
mesh->compute_bounds();
}
-
CCL_NAMESPACE_END
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 940a923e5af..e42af60c27b 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -488,7 +488,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
}
if(render_layer.use_hair)
- sync_curves(mesh, b_mesh, b_ob, object_updated);
+ sync_curves(mesh, b_mesh, b_ob, 0);
/* free derived mesh */
b_data.meshes.remove(b_mesh);
@@ -539,6 +539,12 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion)
if(!size || !ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview))
return;
+ /* ensure we only sync instanced meshes once */
+ if(mesh_motion_synced.find(mesh) != mesh_motion_synced.end())
+ return;
+
+ mesh_motion_synced.insert(mesh);
+
/* get derived mesh */
BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, false);
@@ -556,6 +562,10 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion)
if(i != size || memcmp(M, &mesh->verts[0], sizeof(float3)*size) == 0)
mesh->attributes.remove(std);
+ /* hair motion */
+ if(render_layer.use_hair)
+ sync_curves(mesh, b_mesh, b_ob, motion);
+
/* free derived mesh */
b_data.meshes.remove(b_mesh);
}
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 461e897efe1..ba584e172dc 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -405,6 +405,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
mesh_synced.clear();
particle_system_map.pre_sync();
}
+ else {
+ mesh_motion_synced.clear();
+ }
/* object loop */
BL::Scene::objects_iterator b_ob;
@@ -492,6 +495,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
scene->particle_system_manager->tag_update(scene);
mesh_synced.clear();
}
+
+ if(motion)
+ mesh_motion_synced.clear();
}
void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override)
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index b576181d890..a6d2b537bc7 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -673,59 +673,73 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
return node;
}
+static bool node_use_modified_socket_name(ShaderNode *node)
+{
+ if (node->special_type == SHADER_SPECIAL_TYPE_SCRIPT)
+ return false;
+
+ return true;
+}
+
static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
- BL::Node::inputs_iterator b_input;
string name = b_socket.name();
- bool found = false;
- int counter = 0, total = 0;
- for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
- if (b_input->name() == name) {
- if (!found)
- counter++;
- total++;
+ if (node_use_modified_socket_name(node)) {
+ BL::Node::inputs_iterator b_input;
+ bool found = false;
+ int counter = 0, total = 0;
+
+ for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
+ if (b_input->name() == name) {
+ if (!found)
+ counter++;
+ total++;
+ }
+
+ if(b_input->ptr.data == b_socket.ptr.data)
+ found = true;
}
-
- if(b_input->ptr.data == b_socket.ptr.data)
- found = true;
+
+ /* rename if needed */
+ if (name == "Shader")
+ name = "Closure";
+
+ if (total > 1)
+ name = string_printf("%s%d", name.c_str(), counter);
}
- /* rename if needed */
- if (name == "Shader")
- name = "Closure";
-
- if (total > 1)
- name = string_printf("%s%d", name.c_str(), counter);
-
return node->input(name.c_str());
}
static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
- BL::Node::outputs_iterator b_output;
string name = b_socket.name();
- bool found = false;
- int counter = 0, total = 0;
- for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
- if (b_output->name() == name) {
- if (!found)
- counter++;
- total++;
+ if (node_use_modified_socket_name(node)) {
+ BL::Node::outputs_iterator b_output;
+ bool found = false;
+ int counter = 0, total = 0;
+
+ for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
+ if (b_output->name() == name) {
+ if (!found)
+ counter++;
+ total++;
+ }
+
+ if(b_output->ptr.data == b_socket.ptr.data)
+ found = true;
}
-
- if(b_output->ptr.data == b_socket.ptr.data)
- found = true;
+
+ /* rename if needed */
+ if (name == "Shader")
+ name = "Closure";
+
+ if (total > 1)
+ name = string_printf("%s%d", name.c_str(), counter);
}
- /* rename if needed */
- if (name == "Shader")
- name = "Closure";
-
- if (total > 1)
- name = string_printf("%s%d", name.c_str(), counter);
-
return node->output(name.c_str());
}
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index f6e19229578..3d2a3ae5aac 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -81,7 +81,7 @@ private:
void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
Mesh *sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tris);
- void sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool object_updated);
+ void sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, int motion);
Object *sync_object(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::DupliObject b_dupli_object, Transform& tfm, uint layer_flag, int motion, bool hide_tris);
void sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::Object b_ob, Transform& tfm);
void sync_background_light();
@@ -108,6 +108,7 @@ private:
id_map<ObjectKey, Light> light_map;
id_map<ParticleSystemKey, ParticleSystem> particle_system_map;
set<Mesh*> mesh_synced;
+ set<Mesh*> mesh_motion_synced;
void *world_map;
bool world_recalc;
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 2c3c31b5429..b21b20a87e5 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -225,7 +225,7 @@ BVHNode* BVHBuild::run()
task_pool.wait_work();
}
- /* delete if we cancelled */
+ /* delete if we canceled */
if(rootnode) {
if(progress.get_cancel()) {
rootnode->deleteSubtree();
diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt
index fe2368b7ea8..920223dd8a4 100644
--- a/intern/cycles/device/CMakeLists.txt
+++ b/intern/cycles/device/CMakeLists.txt
@@ -13,6 +13,10 @@ set(INC_SYS
${GLEW_INCLUDE_PATH}
)
+if(WITH_CYCLES_OPTIMIZED_KERNEL_SSE41)
+ add_definitions(-DWITH_CYCLES_OPTIMIZED_KERNEL_SSE41=1)
+endif()
+
set(SRC
device.cpp
device_cpu.cpp
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index eb262a907a4..5c771aa1c8b 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -64,11 +64,16 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
glColor3f(1.0f, 1.0f, 1.0f);
if(rgba.data_type == TYPE_HALF) {
+ /* for multi devices, this assumes the ineffecient method that we allocate
+ * all pixels on the device even though we only render to a subset */
+ GLhalf *data_pointer = (GLhalf*)rgba.data_pointer;
+ data_pointer += 4*y*w;
+
/* draw half float texture, GLSL shader for display transform assumed to be bound */
GLuint texid;
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGBA, GL_HALF_FLOAT, (void*)rgba.data_pointer);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGBA, GL_HALF_FLOAT, data_pointer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index b1dbdec9d36..85a7b9c186d 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -58,6 +58,7 @@ public:
/* do now to avoid thread issues */
system_cpu_support_sse2();
system_cpu_support_sse3();
+ system_cpu_support_sse41();
}
~CPUDevice()
@@ -144,7 +145,7 @@ public:
void thread_path_trace(DeviceTask& task)
{
- if(task_pool.cancelled()) {
+ if(task_pool.canceled()) {
if(task.need_finish_queue == false)
return;
}
@@ -164,9 +165,31 @@ public:
int end_sample = tile.start_sample + tile.num_samples;
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int sample = start_sample; sample < end_sample; sample++) {
+ if (task.get_cancel() || task_pool.canceled()) {
+ if(task.need_finish_queue == false)
+ break;
+ }
+
+ for(int y = tile.y; y < tile.y + tile.h; y++) {
+ for(int x = tile.x; x < tile.x + tile.w; x++) {
+ kernel_cpu_sse41_path_trace(&kg, render_buffer, rng_state,
+ sample, x, y, tile.offset, tile.stride);
+ }
+ }
+
+ tile.sample = sample + 1;
+
+ task.update_progress(tile);
+ }
+ }
+ else
+#endif
if(system_cpu_support_sse3()) {
for(int sample = start_sample; sample < end_sample; sample++) {
- if (task.get_cancel() || task_pool.cancelled()) {
+ if (task.get_cancel() || task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -185,7 +208,7 @@ public:
}
else if(system_cpu_support_sse2()) {
for(int sample = start_sample; sample < end_sample; sample++) {
- if (task.get_cancel() || task_pool.cancelled()) {
+ if (task.get_cancel() || task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -206,7 +229,7 @@ public:
#endif
{
for(int sample = start_sample; sample < end_sample; sample++) {
- if (task.get_cancel() || task_pool.cancelled()) {
+ if (task.get_cancel() || task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -226,7 +249,7 @@ public:
task.release_tile(tile);
- if(task_pool.cancelled()) {
+ if(task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -243,6 +266,15 @@ public:
if(task.rgba_half) {
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int y = task.y; y < task.y + task.h; y++)
+ for(int x = task.x; x < task.x + task.w; x++)
+ kernel_cpu_sse41_convert_to_half_float(&kernel_globals, (uchar4*)task.rgba_half, (float*)task.buffer,
+ sample_scale, x, y, task.offset, task.stride);
+ }
+ else
+#endif
if(system_cpu_support_sse3()) {
for(int y = task.y; y < task.y + task.h; y++)
for(int x = task.x; x < task.x + task.w; x++)
@@ -266,6 +298,14 @@ public:
}
else {
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int y = task.y; y < task.y + task.h; y++)
+ for(int x = task.x; x < task.x + task.w; x++)
+ kernel_cpu_sse41_convert_to_byte(&kernel_globals, (uchar4*)task.rgba_byte, (float*)task.buffer,
+ sample_scale, x, y, task.offset, task.stride);
+ }
+#endif
if(system_cpu_support_sse3()) {
for(int y = task.y; y < task.y + task.h; y++)
for(int x = task.x; x < task.x + task.w; x++)
@@ -298,11 +338,21 @@ public:
#endif
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
+ kernel_cpu_sse41_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
+
+ if(task_pool.canceled())
+ break;
+ }
+ }
+#endif
if(system_cpu_support_sse3()) {
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.cancelled())
+ if(task_pool.canceled())
break;
}
}
@@ -310,7 +360,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.cancelled())
+ if(task_pool.canceled())
break;
}
}
@@ -320,7 +370,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.cancelled())
+ if(task_pool.canceled())
break;
}
}
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 56ba0e08743..39444b91131 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -190,13 +190,18 @@ endif()
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
-add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS})
-
if(WITH_CYCLES_OPTIMIZED_KERNEL)
set_source_files_properties(kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
set_source_files_properties(kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
endif()
+if(WITH_CYCLES_OPTIMIZED_KERNEL_SSE41)
+ set_source_files_properties(kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
+ list(APPEND SRC kernel_sse41.cpp)
+endif()
+
+add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS})
+
if(WITH_CYCLES_CUDA)
add_dependencies(cycles_kernel cycles_kernel_cuda)
endif()
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index 86fea48760f..b3141d1154f 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
+ccl_device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
{
int label;
@@ -132,7 +132,7 @@ __device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderCl
return label;
}
-__device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf)
{
float3 eval;
@@ -275,7 +275,7 @@ __device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderC
return eval;
}
-__device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness)
+ccl_device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness)
{
#ifdef __OSL__
if(kg->osl && sc->prim) {
diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
index 94bc6eb0dc5..3631f90bf8c 100644
--- a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
+++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc)
+ccl_device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc)
{
float sigma = fmaxf(sc->data0, 0.01f);
sc->data0 = 1.0f/(sigma * sigma); /* m_invsigma2 */
@@ -45,11 +45,11 @@ __device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_ashikhmin_velvet_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_ashikhmin_velvet_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_invsigma2 = sc->data0;
float3 N = sc->N;
@@ -87,12 +87,12 @@ __device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, cons
return make_float3(0, 0, 0);
}
-__device float3 bsdf_ashikhmin_velvet_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ashikhmin_velvet_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_invsigma2 = sc->data0;
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_diffuse.h b/intern/cycles/kernel/closure/bsdf_diffuse.h
index 46318ecd138..949fe869549 100644
--- a/intern/cycles/kernel/closure/bsdf_diffuse.h
+++ b/intern/cycles/kernel/closure/bsdf_diffuse.h
@@ -37,17 +37,17 @@ CCL_NAMESPACE_BEGIN
/* DIFFUSE */
-__device int bsdf_diffuse_setup(ShaderClosure *sc)
+ccl_device int bsdf_diffuse_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_DIFFUSE_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_diffuse_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_diffuse_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float3 N = sc->N;
@@ -56,12 +56,12 @@ __device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3
return make_float3(cos_pi, cos_pi, cos_pi);
}
-__device float3 bsdf_diffuse_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
@@ -84,22 +84,22 @@ __device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, f
/* TRANSLUCENT */
-__device int bsdf_translucent_setup(ShaderClosure *sc)
+ccl_device int bsdf_translucent_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_TRANSLUCENT_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_translucent_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_translucent_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_translucent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_translucent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float3 N = sc->N;
@@ -108,12 +108,12 @@ __device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const fl
return make_float3 (cos_pi, cos_pi, cos_pi);
}
-__device float bsdf_translucent_albedo(const ShaderClosure *sc, const float3 I)
+ccl_device float bsdf_translucent_albedo(const ShaderClosure *sc, const float3 I)
{
return 1.0f;
}
-__device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
index 2e43e16693f..b856774375f 100644
--- a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
+ccl_device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
{
int MAXCOLORS = 8;
@@ -49,17 +49,17 @@ __device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float
return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset;
}
-__device int bsdf_diffuse_ramp_setup(ShaderClosure *sc)
+ccl_device int bsdf_diffuse_ramp_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_DIFFUSE_RAMP_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
-__device void bsdf_diffuse_ramp_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_diffuse_ramp_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
float3 N = sc->N;
@@ -68,12 +68,12 @@ __device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const fl
return bsdf_diffuse_ramp_get_color(sc, colors, cos_pi) * M_1_PI_F;
}
-__device float3 bsdf_diffuse_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h
index 5825d2637ba..163e7cc5ee2 100644
--- a/intern/cycles/kernel/closure/bsdf_hair.h
+++ b/intern/cycles/kernel/closure/bsdf_hair.h
@@ -36,15 +36,15 @@
CCL_NAMESPACE_BEGIN
-__device void bsdf_hair_reflection_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_hair_reflection_blur(ShaderClosure *sc, float roughness)
{
}
-__device void bsdf_hair_transmission_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_hair_transmission_blur(ShaderClosure *sc, float roughness)
{
}
-__device int bsdf_hair_reflection_setup(ShaderClosure *sc)
+ccl_device int bsdf_hair_reflection_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_HAIR_REFLECTION_ID;
sc->data0 = clamp(sc->data0, 0.001f, 1.0f);
@@ -52,7 +52,7 @@ __device int bsdf_hair_reflection_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device int bsdf_hair_transmission_setup(ShaderClosure *sc)
+ccl_device int bsdf_hair_transmission_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_HAIR_TRANSMISSION_ID;
sc->data0 = clamp(sc->data0, 0.001f, 1.0f);
@@ -60,7 +60,7 @@ __device int bsdf_hair_transmission_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
@@ -106,18 +106,18 @@ __device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const
return make_float3(*pdf, *pdf, *pdf);
}
-__device float3 bsdf_hair_transmission_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_transmission_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_hair_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
@@ -163,7 +163,7 @@ __device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, co
return make_float3(*pdf, *pdf, *pdf);
}
-__device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
@@ -218,7 +218,7 @@ __device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, flo
return LABEL_REFLECT|LABEL_GLOSSY;
}
-__device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index b159f585831..737cffb0f18 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* GGX */
-__device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ag */
@@ -46,7 +46,7 @@ __device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ag */
@@ -55,12 +55,12 @@ __device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness)
{
sc->data0 = fmaxf(roughness, sc->data0); /* m_ag */
}
-__device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ag = max(sc->data0, 1e-4f);
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
@@ -97,7 +97,7 @@ __device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ag = max(sc->data0, 1e-4f);
float m_eta = sc->data1;
@@ -134,7 +134,7 @@ __device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const
return make_float3 (out, out, out);
}
-__device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_ag = sc->data0;
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
@@ -255,7 +255,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa
/* BECKMANN */
-__device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ab */
@@ -263,7 +263,7 @@ __device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ab */
@@ -271,12 +271,12 @@ __device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness)
{
sc->data0 = fmaxf(roughness, sc->data0); /* m_ab */
}
-__device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ab = max(sc->data0, 1e-4f);
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
@@ -315,7 +315,7 @@ __device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, c
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ab = max(sc->data0, 1e-4f);
float m_eta = sc->data1;
@@ -354,7 +354,7 @@ __device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc,
return make_float3 (out, out, out);
}
-__device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_ab = sc->data0;
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
diff --git a/intern/cycles/kernel/closure/bsdf_oren_nayar.h b/intern/cycles/kernel/closure/bsdf_oren_nayar.h
index c6c6811c007..6f685d5eeea 100644
--- a/intern/cycles/kernel/closure/bsdf_oren_nayar.h
+++ b/intern/cycles/kernel/closure/bsdf_oren_nayar.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n, float3 v, float3 l)
+ccl_device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n, float3 v, float3 l)
{
float nl = max(dot(n, l), 0.0f);
float nv = max(dot(n, v), 0.0f);
@@ -31,7 +31,7 @@ __device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n,
return make_float3(is, is, is);
}
-__device int bsdf_oren_nayar_setup(ShaderClosure *sc)
+ccl_device int bsdf_oren_nayar_setup(ShaderClosure *sc)
{
float sigma = sc->data0;
@@ -47,11 +47,11 @@ __device int bsdf_oren_nayar_setup(ShaderClosure *sc)
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
-__device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
if (dot(sc->N, omega_in) > 0.0f) {
*pdf = 0.5f * M_1_PI_F;
@@ -63,12 +63,12 @@ __device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const floa
}
}
-__device float3 bsdf_oren_nayar_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_oren_nayar_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
sample_uniform_hemisphere(sc->N, randu, randv, omega_in, pdf);
diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
index 1e332933287..219c5aea159 100644
--- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
+ccl_device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
{
int MAXCOLORS = 8;
@@ -49,7 +49,7 @@ __device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3
return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset;
}
-__device int bsdf_phong_ramp_setup(ShaderClosure *sc)
+ccl_device int bsdf_phong_ramp_setup(ShaderClosure *sc)
{
sc->data0 = max(sc->data0, 0.0f);
@@ -57,11 +57,11 @@ __device int bsdf_phong_ramp_setup(ShaderClosure *sc)
return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY;
}
-__device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
float m_exponent = sc->data0;
float cosNI = dot(sc->N, omega_in);
@@ -83,12 +83,12 @@ __device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const floa
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_phong_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_phong_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float cosNO = dot(sc->N, I);
float m_exponent = sc->data0;
diff --git a/intern/cycles/kernel/closure/bsdf_reflection.h b/intern/cycles/kernel/closure/bsdf_reflection.h
index 7715aac936f..0baccdf155c 100644
--- a/intern/cycles/kernel/closure/bsdf_reflection.h
+++ b/intern/cycles/kernel/closure/bsdf_reflection.h
@@ -37,27 +37,27 @@ CCL_NAMESPACE_BEGIN
/* REFLECTION */
-__device int bsdf_reflection_setup(ShaderClosure *sc)
+ccl_device int bsdf_reflection_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_REFLECTION_ID;
return SD_BSDF;
}
-__device void bsdf_reflection_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_reflection_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_refraction.h b/intern/cycles/kernel/closure/bsdf_refraction.h
index 8565c99d04e..c4698b42060 100644
--- a/intern/cycles/kernel/closure/bsdf_refraction.h
+++ b/intern/cycles/kernel/closure/bsdf_refraction.h
@@ -37,27 +37,27 @@ CCL_NAMESPACE_BEGIN
/* REFRACTION */
-__device int bsdf_refraction_setup(ShaderClosure *sc)
+ccl_device int bsdf_refraction_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_REFRACTION_ID;
return SD_BSDF;
}
-__device void bsdf_refraction_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_refraction_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_refraction_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_refraction_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_refraction_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_refraction_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_eta = sc->data0;
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_toon.h b/intern/cycles/kernel/closure/bsdf_toon.h
index e69981dba77..797fa4227ae 100644
--- a/intern/cycles/kernel/closure/bsdf_toon.h
+++ b/intern/cycles/kernel/closure/bsdf_toon.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* DIFFUSE TOON */
-__device int bsdf_diffuse_toon_setup(ShaderClosure *sc)
+ccl_device int bsdf_diffuse_toon_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_DIFFUSE_TOON_ID;
sc->data0 = clamp(sc->data0, 0.0f, 1.0f);
@@ -46,11 +46,11 @@ __device int bsdf_diffuse_toon_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_diffuse_toon_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_diffuse_toon_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float angle)
+ccl_device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float angle)
{
float is;
@@ -64,12 +64,12 @@ __device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float ang
return make_float3(is, is, is);
}
-__device float bsdf_toon_get_sample_angle(float max_angle, float smooth)
+ccl_device float bsdf_toon_get_sample_angle(float max_angle, float smooth)
{
return fminf(max_angle + smooth, M_PI_2_F);
}
-__device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
@@ -87,12 +87,12 @@ __device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const fl
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_diffuse_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
@@ -121,7 +121,7 @@ __device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3
/* GLOSSY TOON */
-__device int bsdf_glossy_toon_setup(ShaderClosure *sc)
+ccl_device int bsdf_glossy_toon_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_GLOSSY_TOON_ID;
sc->data0 = clamp(sc->data0, 0.0f, 1.0f);
@@ -130,11 +130,11 @@ __device int bsdf_glossy_toon_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_glossy_toon_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_glossy_toon_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
@@ -158,12 +158,12 @@ __device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const flo
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_glossy_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_glossy_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h
index 81bc7690b50..e62aecf3da6 100644
--- a/intern/cycles/kernel/closure/bsdf_transparent.h
+++ b/intern/cycles/kernel/closure/bsdf_transparent.h
@@ -35,27 +35,27 @@
CCL_NAMESPACE_BEGIN
-__device int bsdf_transparent_setup(ShaderClosure *sc)
+ccl_device int bsdf_transparent_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_TRANSPARENT_ID;
return SD_BSDF;
}
-__device void bsdf_transparent_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_transparent_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_transparent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_transparent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_transparent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_transparent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
// only one direction is possible
*omega_in = -I;
diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h
index 5ac26055e8d..f6dceb3ca82 100644
--- a/intern/cycles/kernel/closure/bsdf_util.h
+++ b/intern/cycles/kernel/closure/bsdf_util.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device float fresnel_dielectric(float eta, const float3 N,
+ccl_device float fresnel_dielectric(float eta, const float3 N,
const float3 I, float3 *R, float3 *T,
#ifdef __RAY_DIFFERENTIALS__
const float3 dIdx, const float3 dIdy,
@@ -95,7 +95,7 @@ __device float fresnel_dielectric(float eta, const float3 N,
}
}
-__device float fresnel_dielectric_cos(float cosi, float eta)
+ccl_device float fresnel_dielectric_cos(float cosi, float eta)
{
// compute fresnel reflectance without explicitly computing
// the refracted direction
@@ -110,7 +110,7 @@ __device float fresnel_dielectric_cos(float cosi, float eta)
return 1.0f; // TIR(no refracted component)
}
-__device float fresnel_conductor(float cosi, float eta, float k)
+ccl_device float fresnel_conductor(float cosi, float eta, float k)
{
float tmp_f = eta * eta + k * k;
float tmp = tmp_f * cosi * cosi;
@@ -121,7 +121,7 @@ __device float fresnel_conductor(float cosi, float eta, float k)
return(Rparl2 + Rperp2) * 0.5f;
}
-__device float smooth_step(float edge0, float edge1, float x)
+ccl_device float smooth_step(float edge0, float edge1, float x)
{
float result;
if(x < edge0) result = 0.0f;
diff --git a/intern/cycles/kernel/closure/bsdf_ward.h b/intern/cycles/kernel/closure/bsdf_ward.h
index 0e5b0c544c7..c9de615a011 100644
--- a/intern/cycles/kernel/closure/bsdf_ward.h
+++ b/intern/cycles/kernel/closure/bsdf_ward.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* WARD */
-__device int bsdf_ward_setup(ShaderClosure *sc)
+ccl_device int bsdf_ward_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 1e-4f, 1.0f); /* m_ax */
sc->data1 = clamp(sc->data1, 1e-4f, 1.0f); /* m_ay */
@@ -46,13 +46,13 @@ __device int bsdf_ward_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_ward_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_ward_blur(ShaderClosure *sc, float roughness)
{
sc->data0 = fmaxf(roughness, sc->data0); /* m_ax */
sc->data1 = fmaxf(roughness, sc->data1); /* m_ay */
}
-__device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ax = sc->data0;
float m_ay = sc->data1;
@@ -87,12 +87,12 @@ __device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I,
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_ward_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ward_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_ax = sc->data0;
float m_ay = sc->data1;
diff --git a/intern/cycles/kernel/closure/bsdf_westin.h b/intern/cycles/kernel/closure/bsdf_westin.h
index e1a6b031d5e..ca4c05e91fe 100644
--- a/intern/cycles/kernel/closure/bsdf_westin.h
+++ b/intern/cycles/kernel/closure/bsdf_westin.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* WESTIN BACKSCATTER */
-__device int bsdf_westin_backscatter_setup(ShaderClosure *sc)
+ccl_device int bsdf_westin_backscatter_setup(ShaderClosure *sc)
{
float roughness = sc->data0;
roughness = clamp(roughness, 1e-5f, 1.0f);
@@ -49,14 +49,14 @@ __device int bsdf_westin_backscatter_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_westin_backscatter_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_westin_backscatter_blur(ShaderClosure *sc, float roughness)
{
float m_invroughness = sc->data0;
m_invroughness = min(1.0f/roughness, m_invroughness);
sc->data0 = m_invroughness;
}
-__device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_invroughness = sc->data0;
float3 N = sc->N;
@@ -73,12 +73,12 @@ __device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, co
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_westin_backscatter_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_backscatter_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_invroughness = sc->data0;
float3 N = sc->N;
@@ -116,18 +116,18 @@ __device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng,
/* WESTIN SHEEN */
-__device int bsdf_westin_sheen_setup(ShaderClosure *sc)
+ccl_device int bsdf_westin_sheen_setup(ShaderClosure *sc)
{
/* float edginess = sc->data0; */
sc->type = CLOSURE_BSDF_WESTIN_SHEEN_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_westin_sheen_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_westin_sheen_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_edginess = sc->data0;
float3 N = sc->N;
@@ -144,12 +144,12 @@ __device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const fl
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_westin_sheen_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_sheen_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_westin_sheen_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_westin_sheen_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_edginess = sc->data0;
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h
index 4ceff655dd5..3849dedc3b6 100644
--- a/intern/cycles/kernel/closure/bssrdf.h
+++ b/intern/cycles/kernel/closure/bssrdf.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device int bssrdf_setup(ShaderClosure *sc, ClosureType type)
+ccl_device int bssrdf_setup(ShaderClosure *sc, ClosureType type)
{
if(sc->data0 < BSSRDF_MIN_RADIUS) {
/* revert to diffuse BSDF if radius too small */
@@ -47,7 +47,7 @@ __device int bssrdf_setup(ShaderClosure *sc, ClosureType type)
/* paper suggests 1/12.46 which is much too small, suspect it's *12.46 */
#define GAUSS_TRUNCATE 12.46f
-__device float bssrdf_gaussian_eval(ShaderClosure *sc, float r)
+ccl_device float bssrdf_gaussian_eval(ShaderClosure *sc, float r)
{
/* integrate (2*pi*r * exp(-r*r/(2*v)))/(2*pi*v)) from 0 to Rm
* = 1 - exp(-Rm*Rm/(2*v)) */
@@ -60,7 +60,7 @@ __device float bssrdf_gaussian_eval(ShaderClosure *sc, float r)
return expf(-r*r/(2.0f*v))/(2.0f*M_PI_F*v);
}
-__device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r)
{
/* 1.0 - expf(-Rm*Rm/(2*v)) simplified */
const float area_truncated = 1.0f - expf(-0.5f*GAUSS_TRUNCATE);
@@ -68,7 +68,7 @@ __device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r)
return bssrdf_gaussian_eval(sc, r) * (1.0f/(area_truncated));
}
-__device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
/* xi = integrate (2*pi*r * exp(-r*r/(2*v)))/(2*pi*v)) = -exp(-r^2/(2*v))
* r = sqrt(-2*v*logf(xi)) */
@@ -94,7 +94,7 @@ __device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, floa
* far as I can tell has no closed form solution. So we get an iterative solution
* instead with newton-raphson. */
-__device float bssrdf_cubic_eval(ShaderClosure *sc, float r)
+ccl_device float bssrdf_cubic_eval(ShaderClosure *sc, float r)
{
const float sharpness = sc->T.x;
@@ -141,13 +141,13 @@ __device float bssrdf_cubic_eval(ShaderClosure *sc, float r)
}
}
-__device float bssrdf_cubic_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_cubic_pdf(ShaderClosure *sc, float r)
{
return bssrdf_cubic_eval(sc, r);
}
/* solve 10x^2 - 20x^3 + 15x^4 - 4x^5 - xi == 0 */
-__device float bssrdf_cubic_quintic_root_find(float xi)
+ccl_device float bssrdf_cubic_quintic_root_find(float xi)
{
/* newton-raphson iteration, usually succeeds in 2-4 iterations, except
* outside 0.02 ... 0.98 where it can go up to 10, so overall performance
@@ -174,7 +174,7 @@ __device float bssrdf_cubic_quintic_root_find(float xi)
return x;
}
-__device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
float Rm = sc->data0;
float r_ = bssrdf_cubic_quintic_root_find(xi);
@@ -196,13 +196,13 @@ __device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *
*
* Samples distributed over disk with no falloff, for reference. */
-__device float bssrdf_none_eval(ShaderClosure *sc, float r)
+ccl_device float bssrdf_none_eval(ShaderClosure *sc, float r)
{
const float Rm = sc->data0;
return (r < Rm)? 1.0f: 0.0f;
}
-__device float bssrdf_none_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_none_pdf(ShaderClosure *sc, float r)
{
/* integrate (2*pi*r)/(pi*Rm*Rm) from 0 to Rm = 1 */
const float Rm = sc->data0;
@@ -211,7 +211,7 @@ __device float bssrdf_none_pdf(ShaderClosure *sc, float r)
return bssrdf_none_eval(sc, r) / area;
}
-__device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
/* xi = integrate (2*pi*r)/(pi*Rm*Rm) = r^2/Rm^2
* r = sqrt(xi)*Rm */
@@ -226,7 +226,7 @@ __device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h
/* Generic */
-__device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
if(sc->type == CLOSURE_BSSRDF_CUBIC_ID)
bssrdf_cubic_sample(sc, xi, r, h);
@@ -234,7 +234,7 @@ __device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h)
bssrdf_gaussian_sample(sc, xi, r, h);
}
-__device float bssrdf_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_pdf(ShaderClosure *sc, float r)
{
if(sc->type == CLOSURE_BSSRDF_CUBIC_ID)
return bssrdf_cubic_pdf(sc, r);
diff --git a/intern/cycles/kernel/closure/emissive.h b/intern/cycles/kernel/closure/emissive.h
index 33b1b695a9a..c534df373bd 100644
--- a/intern/cycles/kernel/closure/emissive.h
+++ b/intern/cycles/kernel/closure/emissive.h
@@ -37,19 +37,19 @@ CCL_NAMESPACE_BEGIN
/* return the probability distribution function in the direction I,
* given the parameters and the light's surface normal. This MUST match
* the PDF computed by sample(). */
-__device float emissive_pdf(const float3 Ng, const float3 I)
+ccl_device float emissive_pdf(const float3 Ng, const float3 I)
{
float cosNO = fabsf(dot(Ng, I));
return (cosNO > 0.0f)? 1.0f: 0.0f;
}
-__device void emissive_sample(const float3 Ng, float randu, float randv,
+ccl_device void emissive_sample(const float3 Ng, float randu, float randv,
float3 *omega_out, float *pdf)
{
/* todo: not implemented and used yet */
}
-__device float3 emissive_simple_eval(const float3 Ng, const float3 I)
+ccl_device float3 emissive_simple_eval(const float3 Ng, const float3 I)
{
float res = emissive_pdf(Ng, I);
diff --git a/intern/cycles/kernel/closure/volume.h b/intern/cycles/kernel/closure/volume.h
index ddaf939984e..f30b30c8c76 100644
--- a/intern/cycles/kernel/closure/volume.h
+++ b/intern/cycles/kernel/closure/volume.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
/* ISOTROPIC VOLUME CLOSURE */
-__device int volume_isotropic_setup(ShaderClosure *sc, float density)
+ccl_device int volume_isotropic_setup(ShaderClosure *sc, float density)
{
sc->type = CLOSURE_VOLUME_ISOTROPIC_ID;
sc->data0 = density;
@@ -29,14 +29,14 @@ __device int volume_isotropic_setup(ShaderClosure *sc, float density)
return SD_VOLUME;
}
-__device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
+ccl_device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
{
return make_float3(1.0f, 1.0f, 1.0f);
}
/* TRANSPARENT VOLUME CLOSURE */
-__device int volume_transparent_setup(ShaderClosure *sc, float density)
+ccl_device int volume_transparent_setup(ShaderClosure *sc, float density)
{
sc->type = CLOSURE_VOLUME_TRANSPARENT_ID;
sc->data0 = density;
@@ -44,14 +44,14 @@ __device int volume_transparent_setup(ShaderClosure *sc, float density)
return SD_VOLUME;
}
-__device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
+ccl_device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
{
return make_float3(1.0f, 1.0f, 1.0f);
}
/* VOLUME CLOSURE */
-__device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
+ccl_device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
{
#ifdef __OSL__
if(kg->osl && sc->prim)
diff --git a/intern/cycles/kernel/kernel.cl b/intern/cycles/kernel/kernel.cl
index 28e72d78731..6988ad6027f 100644
--- a/intern/cycles/kernel/kernel.cl
+++ b/intern/cycles/kernel/kernel.cl
@@ -26,12 +26,12 @@
#include "kernel_displace.h"
__kernel void kernel_ocl_path_trace(
- __constant KernelData *data,
- __global float *buffer,
- __global uint *rng_state,
+ ccl_constant KernelData *data,
+ ccl_global float *buffer,
+ ccl_global uint *rng_state,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
int sample,
@@ -53,12 +53,12 @@ __kernel void kernel_ocl_path_trace(
}
__kernel void kernel_ocl_convert_to_byte(
- __constant KernelData *data,
- __global uchar4 *rgba,
- __global float *buffer,
+ ccl_constant KernelData *data,
+ ccl_global uchar4 *rgba,
+ ccl_global float *buffer,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
float sample_scale,
@@ -80,12 +80,12 @@ __kernel void kernel_ocl_convert_to_byte(
}
__kernel void kernel_ocl_convert_to_half_float(
- __constant KernelData *data,
- __global uchar4 *rgba,
- __global float *buffer,
+ ccl_constant KernelData *data,
+ ccl_global uchar4 *rgba,
+ ccl_global float *buffer,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
float sample_scale,
@@ -107,12 +107,12 @@ __kernel void kernel_ocl_convert_to_half_float(
}
__kernel void kernel_ocl_shader(
- __constant KernelData *data,
- __global uint4 *input,
- __global float4 *output,
+ ccl_constant KernelData *data,
+ ccl_global uint4 *input,
+ ccl_global float4 *output,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
int type, int sx, int sw)
diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h
index 361f5b0856d..105a3887da0 100644
--- a/intern/cycles/kernel/kernel.h
+++ b/intern/cycles/kernel/kernel.h
@@ -61,6 +61,15 @@ void kernel_cpu_sse3_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, floa
float sample_scale, int x, int y, int offset, int stride);
void kernel_cpu_sse3_shader(KernelGlobals *kg, uint4 *input, float4 *output,
int type, int i);
+
+void kernel_cpu_sse41_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state,
+ int sample, int x, int y, int offset, int stride);
+void kernel_cpu_sse41_convert_to_byte(KernelGlobals *kg, uchar4 *rgba, float *buffer,
+ float sample_scale, int x, int y, int offset, int stride);
+void kernel_cpu_sse41_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, float *buffer,
+ float sample_scale, int x, int y, int offset, int stride);
+void kernel_cpu_sse41_shader(KernelGlobals *kg, uint4 *input, float4 *output,
+ int type, int i);
#endif
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h
index d7531be0d8a..f4febd7cf2c 100644
--- a/intern/cycles/kernel/kernel_accumulate.h
+++ b/intern/cycles/kernel/kernel_accumulate.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
* BSDF evaluation result, split per BSDF type. This is used to accumulate
* render passes separately. */
-__device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass)
+ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass)
{
#ifdef __PASSES__
eval->use_light_pass = use_light_pass;
@@ -51,7 +51,7 @@ __device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 val
#endif
}
-__device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value)
+ccl_device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value)
{
#ifdef __PASSES__
if(eval->use_light_pass) {
@@ -73,7 +73,7 @@ __device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 va
#endif
}
-__device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
+ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
{
#ifdef __PASSES__
if(eval->use_light_pass) {
@@ -90,7 +90,7 @@ __device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
#endif
}
-__device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
+ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
{
#ifdef __PASSES__
if(eval->use_light_pass) {
@@ -115,7 +115,7 @@ __device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
* visible as the first non-transparent hit, while indirectly visible are the
* bounces after that. */
-__device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
+ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
{
/* clear all */
#ifdef __PASSES__
@@ -159,7 +159,7 @@ __device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
#endif
}
-__device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput,
+ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput,
BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label)
{
float inverse_pdf = 1.0f/bsdf_pdf;
@@ -192,7 +192,7 @@ __device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughp
#endif
}
-__device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce)
+ccl_device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -210,7 +210,7 @@ __device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throug
#endif
}
-__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce)
+ccl_device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -231,7 +231,7 @@ __device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput,
#endif
}
-__device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, int bounce, bool is_lamp)
+ccl_device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, int bounce, bool is_lamp)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -261,7 +261,7 @@ __device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughpu
#endif
}
-__device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce)
+ccl_device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -279,7 +279,7 @@ __device_inline void path_radiance_accum_background(PathRadiance *L, float3 thro
#endif
}
-__device_inline void path_radiance_sum_indirect(PathRadiance *L)
+ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L)
{
#ifdef __PASSES__
/* this division is a bit ugly, but means we only have to keep track of
@@ -301,7 +301,7 @@ __device_inline void path_radiance_sum_indirect(PathRadiance *L)
#endif
}
-__device_inline void path_radiance_reset_indirect(PathRadiance *L)
+ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -316,7 +316,7 @@ __device_inline void path_radiance_reset_indirect(PathRadiance *L)
#endif
}
-__device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L)
+ccl_device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -338,7 +338,7 @@ __device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L)
#endif
}
-__device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp)
+ccl_device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp)
{
float sum = fabsf((*L_sum).x) + fabsf((*L_sum).y) + fabsf((*L_sum).z);
diff --git a/intern/cycles/kernel/kernel_bvh.h b/intern/cycles/kernel/kernel_bvh.h
index 44a9822c103..5aae4111fca 100644
--- a/intern/cycles/kernel/kernel_bvh.h
+++ b/intern/cycles/kernel/kernel_bvh.h
@@ -42,7 +42,7 @@ CCL_NAMESPACE_BEGIN
#define NO_EXTENDED_PRECISION volatile
#endif
-__device_inline float3 bvh_inverse_direction(float3 dir)
+ccl_device_inline float3 bvh_inverse_direction(float3 dir)
{
/* avoid divide by zero (ooeps = exp2f(-80.0f)) */
float ooeps = 0.00000000000000000000000082718061255302767487140869206996285356581211090087890625f;
@@ -55,7 +55,7 @@ __device_inline float3 bvh_inverse_direction(float3 dir)
return idir;
}
-__device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
+ccl_device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
{
Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
@@ -72,7 +72,7 @@ __device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray
*t *= len;
}
-__device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
+ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
{
if(*t != FLT_MAX) {
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
@@ -84,7 +84,7 @@ __device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *
}
#ifdef __OBJECT_MOTION__
-__device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
+ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
{
Transform itfm;
*tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm);
@@ -102,7 +102,7 @@ __device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, con
*t *= len;
}
-__device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
+ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
{
if(*t != FLT_MAX)
*t *= len(transform_direction(tfm, 1.0f/(*idir)));
@@ -113,7 +113,7 @@ __device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, cons
#endif
/* Sven Woop's algorithm */
-__device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *isect,
+ccl_device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *isect,
float3 P, float3 idir, uint visibility, int object, int triAddr)
{
/* compute and check intersection t-value */
@@ -161,7 +161,7 @@ __device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *ise
}
#ifdef __HAIR__
-__device_inline void curvebounds(float *lower, float *upper, float *extremta, float *extrema, float *extremtb, float *extremb, float p0, float p1, float p2, float p3)
+ccl_device_inline void curvebounds(float *lower, float *upper, float *extremta, float *extrema, float *extremtb, float *extremb, float p0, float p1, float p2, float p3)
{
float halfdiscroot = (p2 * p2 - 3 * p3 * p1);
float ta = -1.0f;
@@ -211,7 +211,7 @@ __device_inline void curvebounds(float *lower, float *upper, float *extremta, fl
}
}
-__device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect,
+ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect,
float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax)
{
float epsilon = 0.0f;
@@ -520,7 +520,7 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio
return hit;
}
-__device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
+ccl_device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax)
{
/* curve Intersection check */
@@ -689,7 +689,7 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
* only want to intersect with primitives in the same object, and if case of
* multiple hits we pick a single random primitive as the intersection point. */
-__device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Intersection *isect_array,
+ccl_device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Intersection *isect_array,
float3 P, float3 idir, int object, int triAddr, float tmax, uint *num_hits, uint *lcg_state, int max_hits)
{
/* compute and check intersection t-value */
@@ -811,9 +811,9 @@ __device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Inters
/* to work around titan bug when using arrays instead of textures */
#if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__)
-__device_inline
+ccl_device_inline
#else
-__device_noinline
+ccl_device_noinline
#endif
#ifdef __HAIR__
bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect, uint *lcg_state, float difl, float extmax)
@@ -859,9 +859,9 @@ bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, I
/* to work around titan bug when using arrays instead of textures */
#ifdef __SUBSURFACE__
#if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__)
-__device_inline
+ccl_device_inline
#else
-__device_noinline
+ccl_device_noinline
#endif
uint scene_intersect_subsurface(KernelGlobals *kg, const Ray *ray, Intersection *isect, int subsurface_object, uint *lcg_state, int max_hits)
{
@@ -903,7 +903,7 @@ uint scene_intersect_subsurface(KernelGlobals *kg, const Ray *ray, Intersection
/* Ray offset to avoid self intersection */
-__device_inline float3 ray_offset(float3 P, float3 Ng)
+ccl_device_inline float3 ray_offset(float3 P, float3 Ng)
{
#ifdef __INTERSECTION_REFINE__
const float epsilon_f = 1e-5f;
@@ -955,7 +955,7 @@ __device_inline float3 ray_offset(float3 P, float3 Ng)
* far the precision is often not so good, this reintersects the primitive from
* a closer distance. */
-__device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
+ccl_device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
{
float3 P = ray->P;
float3 D = ray->D;
@@ -1000,7 +1000,7 @@ __device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, co
}
/* same as above, except that isect->t is assumed to be in object space for instancing */
-__device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
+ccl_device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
{
float3 P = ray->P;
float3 D = ray->D;
@@ -1046,7 +1046,7 @@ __device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderD
#ifdef __HAIR__
-__device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
{
float fc = 0.71f;
float data[4];
@@ -1058,7 +1058,7 @@ __device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, fl
return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
}
-__device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
{
float data[4];
float fc = 0.71f;
@@ -1071,7 +1071,7 @@ __device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, floa
return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
}
-__device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, float t)
+ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, float t)
{
int flag = kernel_data.curve.curveflags;
float3 P = ray->P;
diff --git a/intern/cycles/kernel/kernel_bvh_subsurface.h b/intern/cycles/kernel/kernel_bvh_subsurface.h
index 4446c1821d5..fb41bdcfa37 100644
--- a/intern/cycles/kernel/kernel_bvh_subsurface.h
+++ b/intern/cycles/kernel/kernel_bvh_subsurface.h
@@ -28,7 +28,7 @@
#define FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0)
-__device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersection *isect_array,
+ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersection *isect_array,
int subsurface_object, uint *lcg_state, int max_hits)
{
/* todo:
diff --git a/intern/cycles/kernel/kernel_bvh_traversal.h b/intern/cycles/kernel/kernel_bvh_traversal.h
index a9264f318eb..8f69083575b 100644
--- a/intern/cycles/kernel/kernel_bvh_traversal.h
+++ b/intern/cycles/kernel/kernel_bvh_traversal.h
@@ -30,7 +30,7 @@
#define FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0)
-__device bool BVH_FUNCTION_NAME
+ccl_device bool BVH_FUNCTION_NAME
(KernelGlobals *kg, const Ray *ray, Intersection *isect, const uint visibility
#if FEATURE(BVH_HAIR_MINIMUM_WIDTH)
, uint *lcg_state, float difl, float extmax
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h
index 966f28df05f..887b1afddd4 100644
--- a/intern/cycles/kernel/kernel_camera.h
+++ b/intern/cycles/kernel/kernel_camera.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Perspective Camera */
-__device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v)
+ccl_device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v)
{
float blades = kernel_data.cam.blades;
@@ -33,7 +33,7 @@ __device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v)
}
}
-__device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
+ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
{
/* create ray form raster position */
Transform rastertocamera = kernel_data.cam.rastertocamera;
@@ -91,7 +91,7 @@ __device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float
/* Orthographic Camera */
-__device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
+ccl_device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
{
/* create ray form raster position */
Transform rastertocamera = kernel_data.cam.rastertocamera;
@@ -147,7 +147,7 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa
/* Panorama Camera */
-__device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
+ccl_device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
{
Transform rastertocamera = kernel_data.cam.rastertocamera;
float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
@@ -216,7 +216,7 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
/* Common */
-__device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v,
+ccl_device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v,
float lens_u, float lens_v, float time, Ray *ray)
{
/* pixel filter */
@@ -243,13 +243,13 @@ __device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, flo
/* Utilities */
-__device_inline float3 camera_position(KernelGlobals *kg)
+ccl_device_inline float3 camera_position(KernelGlobals *kg)
{
Transform cameratoworld = kernel_data.cam.cameratoworld;
return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
}
-__device_inline float camera_distance(KernelGlobals *kg, float3 P)
+ccl_device_inline float camera_distance(KernelGlobals *kg, float3 P)
{
Transform cameratoworld = kernel_data.cam.cameratoworld;
float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
@@ -262,7 +262,7 @@ __device_inline float camera_distance(KernelGlobals *kg, float3 P)
return len(P - camP);
}
-__device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P)
+ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P)
{
if(kernel_data.cam.type != CAMERA_PANORAMA) {
/* perspective / ortho */
diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h
index 44c2b9effe9..76f885aefe0 100644
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@ -27,13 +27,12 @@
/* Qualifier wrappers for different names on different devices */
-#define __device __device__ __inline__
-#define __device_inline __device__ __inline__
-#define __device_noinline __device__ __noinline__
-#define __global
-#define __shared __shared__
-#define __constant
-#define __may_alias
+#define ccl_device __device__ __inline__
+#define ccl_device_inline __device__ __inline__
+#define ccl_device_noinline __device__ __noinline__
+#define ccl_global
+#define ccl_constant
+#define ccl_may_alias
/* No assert supported for CUDA */
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index e0102a01146..1ff3615e448 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -33,16 +33,18 @@
#endif
#ifdef __CL_NOINLINE__
-#define __noinline __attribute__((noinline))
+#define ccl_noinline __attribute__((noinline))
#else
-#define __noinline
+#define ccl_noinline
#endif
/* in opencl all functions are device functions, so leave this empty */
-#define __device
-#define __device_inline __device
-#define __device_noinline __device __noinline
-#define __may_alias
+#define ccl_device
+#define ccl_device_inline ccl_device
+#define ccl_device_noinline ccl_device ccl_noinline
+#define ccl_may_alias
+#define ccl_constant __constant
+#define ccl_global __global
/* no assert in opencl */
#define kernel_assert(cond)
diff --git a/intern/cycles/kernel/kernel_curve.h b/intern/cycles/kernel/kernel_curve.h
index 9f7a1388a2b..821ac50eaa9 100644
--- a/intern/cycles/kernel/kernel_curve.h
+++ b/intern/cycles/kernel/kernel_curve.h
@@ -20,7 +20,7 @@ CCL_NAMESPACE_BEGIN
/* curve attributes */
-__device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
+ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
{
if(elem == ATTR_ELEMENT_CURVE) {
#ifdef __RAY_DIFFERENTIALS__
@@ -55,7 +55,7 @@ __device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, At
}
}
-__device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
+ccl_device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
{
if(elem == ATTR_ELEMENT_CURVE) {
/* idea: we can't derive any useful differentials here, but for tiled
@@ -96,7 +96,7 @@ __device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd,
/* hair info node functions */
-__device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
+ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
{
float r = 0.0f;
@@ -113,7 +113,7 @@ __device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
return r*2.0f;
}
-__device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
{
float3 tgN = make_float3(0.0f,0.0f,0.0f);
diff --git a/intern/cycles/kernel/kernel_differential.h b/intern/cycles/kernel/kernel_differential.h
index 71d6e87a4d9..daba2d927b7 100644
--- a/intern/cycles/kernel/kernel_differential.h
+++ b/intern/cycles/kernel/kernel_differential.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* See "Tracing Ray Differentials", Homan Igehy, 1999. */
-__device void differential_transfer(differential3 *dP_, const differential3 dP, float3 D, const differential3 dD, float3 Ng, float t)
+ccl_device void differential_transfer(differential3 *dP_, const differential3 dP, float3 D, const differential3 dD, float3 Ng, float t)
{
/* ray differential transfer through homogeneous medium, to
* compute dPdx/dy at a shading point from the incoming ray */
@@ -31,7 +31,7 @@ __device void differential_transfer(differential3 *dP_, const differential3 dP,
dP_->dy = tmpy - dot(tmpy, Ng)*tmp;
}
-__device void differential_incoming(differential3 *dI, const differential3 dD)
+ccl_device void differential_incoming(differential3 *dI, const differential3 dD)
{
/* compute dIdx/dy at a shading point, we just need to negate the
* differential of the ray direction */
@@ -40,7 +40,7 @@ __device void differential_incoming(differential3 *dI, const differential3 dD)
dI->dy = -dD.dy;
}
-__device void differential_dudv(differential *du, differential *dv, float3 dPdu, float3 dPdv, differential3 dP, float3 Ng)
+ccl_device void differential_dudv(differential *du, differential *dv, float3 dPdu, float3 dPdv, differential3 dP, float3 Ng)
{
/* now we have dPdx/dy from the ray differential transfer, and dPdu/dv
* from the primitive, we can compute dudx/dy and dvdx/dy. these are
@@ -84,7 +84,7 @@ __device void differential_dudv(differential *du, differential *dv, float3 dPdu,
dv->dy = (dP.dy.y*dPdu.x - dP.dy.x*dPdu.y)*det;
}
-__device differential differential_zero()
+ccl_device differential differential_zero()
{
differential d;
d.dx = 0.0f;
@@ -93,7 +93,7 @@ __device differential differential_zero()
return d;
}
-__device differential3 differential3_zero()
+ccl_device differential3 differential3_zero()
{
differential3 d;
d.dx = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h
index 38152b5571e..c50e2166660 100644
--- a/intern/cycles/kernel/kernel_displace.h
+++ b/intern/cycles/kernel/kernel_displace.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void kernel_shader_evaluate(KernelGlobals *kg, __global uint4 *input, __global float4 *output, ShaderEvalType type, int i)
+ccl_device void kernel_shader_evaluate(KernelGlobals *kg, ccl_global uint4 *input, ccl_global float4 *output, ShaderEvalType type, int i)
{
ShaderData sd;
uint4 in = input[i];
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index 0c8d69fb594..2ce0b758972 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Direction Emission */
-__device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
+ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
LightSample *ls, float u, float v, float3 I, differential3 dI, float t, float time, int bounce)
{
/* setup shading at emitter */
@@ -70,7 +70,7 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
return eval;
}
-__device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
+ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval,
bool *is_lamp, int bounce)
{
@@ -160,7 +160,7 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li
/* Indirect Primitive Emission */
-__device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf)
+ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf)
{
/* evaluate emissive closure */
float3 L = shader_emissive_eval(kg, sd);
@@ -183,7 +183,7 @@ __device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderDa
/* Indirect Lamp Emission */
-__device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce)
+ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce)
{
LightSample ls;
int lamp = lamp_light_eval_sample(kg, randt);
@@ -222,7 +222,7 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p
/* Indirect Background */
-__device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce)
+ccl_device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce)
{
#ifdef __BACKGROUND__
int shader = kernel_data.background.shader;
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index 721eceabc37..b4118666491 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
+ccl_device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
{
float exposure = kernel_data.film.exposure;
float4 result = irradiance*scale;
@@ -32,7 +32,7 @@ __device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
return result;
}
-__device uchar4 film_float_to_byte(float4 color)
+ccl_device uchar4 film_float_to_byte(float4 color)
{
uchar4 result;
@@ -45,8 +45,8 @@ __device uchar4 film_float_to_byte(float4 color)
return result;
}
-__device void kernel_film_convert_to_byte(KernelGlobals *kg,
- __global uchar4 *rgba, __global float *buffer,
+ccl_device void kernel_film_convert_to_byte(KernelGlobals *kg,
+ ccl_global uchar4 *rgba, ccl_global float *buffer,
float sample_scale, int x, int y, int offset, int stride)
{
/* buffer offset */
@@ -56,25 +56,36 @@ __device void kernel_film_convert_to_byte(KernelGlobals *kg,
buffer += index*kernel_data.film.pass_stride;
/* map colors */
- float4 irradiance = *((__global float4*)buffer);
+ float4 irradiance = *((ccl_global float4*)buffer);
float4 float_result = film_map(kg, irradiance, sample_scale);
uchar4 byte_result = film_float_to_byte(float_result);
*rgba = byte_result;
}
-__device void kernel_film_convert_to_half_float(KernelGlobals *kg,
- __global uchar4 *rgba, __global float *buffer,
+ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
+ ccl_global uchar4 *rgba, ccl_global float *buffer,
float sample_scale, int x, int y, int offset, int stride)
{
/* buffer offset */
int index = offset + x + y*stride;
- __global float4 *in = (__global float4*)(buffer + index*kernel_data.film.pass_stride);
- __global half *out = (__global half*)rgba + index*4;
- float scale = kernel_data.film.exposure*sample_scale;
+ ccl_global float4 *in = (ccl_global float4*)(buffer + index*kernel_data.film.pass_stride);
+ ccl_global half *out = (ccl_global half*)rgba + index*4;
- float4_store_half(out, in, scale);
+ float exposure = kernel_data.film.exposure;
+
+ if(exposure == 1.0f) {
+ float4_store_half(out, in, sample_scale);
+ }
+ else {
+ float4 rgba = *in;
+ rgba.x *= exposure;
+ rgba.y *= exposure;
+ rgba.z *= exposure;
+
+ float4_store_half(out, &rgba, sample_scale);
+ }
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h
index b5e691eb615..e60bd6c0067 100644
--- a/intern/cycles/kernel/kernel_globals.h
+++ b/intern/cycles/kernel/kernel_globals.h
@@ -81,10 +81,10 @@ typedef struct KernelGlobals {} KernelGlobals;
#ifdef __KERNEL_OPENCL__
typedef struct KernelGlobals {
- __constant KernelData *data;
+ ccl_constant KernelData *data;
#define KERNEL_TEX(type, ttype, name) \
- __global type *name;
+ ccl_global type *name;
#include "kernel_textures.h"
} KernelGlobals;
@@ -92,7 +92,7 @@ typedef struct KernelGlobals {
/* Interpolated lookup table access */
-__device float lookup_table_read(KernelGlobals *kg, float x, int offset, int size)
+ccl_device float lookup_table_read(KernelGlobals *kg, float x, int offset, int size)
{
x = clamp(x, 0.0f, 1.0f)*(size-1);
@@ -108,7 +108,7 @@ __device float lookup_table_read(KernelGlobals *kg, float x, int offset, int siz
return (1.0f - t)*data0 + t*data1;
}
-__device float lookup_table_read_2D(KernelGlobals *kg, float x, float y, int offset, int xsize, int ysize)
+ccl_device float lookup_table_read_2D(KernelGlobals *kg, float x, float y, int offset, int xsize, int ysize)
{
y = clamp(y, 0.0f, 1.0f)*(ysize-1);
diff --git a/intern/cycles/kernel/kernel_jitter.h b/intern/cycles/kernel/kernel_jitter.h
index 18666b51c0c..7a850844bf2 100644
--- a/intern/cycles/kernel/kernel_jitter.h
+++ b/intern/cycles/kernel/kernel_jitter.h
@@ -22,18 +22,18 @@ CCL_NAMESPACE_BEGIN
/* todo: find good value, suggested 64 gives pattern on cornell box ceiling */
#define CMJ_RANDOM_OFFSET_LIMIT 4096
-__device_inline bool cmj_is_pow2(int i)
+ccl_device_inline bool cmj_is_pow2(int i)
{
return (i & (i - 1)) == 0;
}
-__device_inline int cmj_fast_mod_pow2(int a, int b)
+ccl_device_inline int cmj_fast_mod_pow2(int a, int b)
{
return (a & (b - 1));
}
/* a must be > 0 and b must be > 1 */
-__device_inline int cmj_fast_div_pow2(int a, int b)
+ccl_device_inline int cmj_fast_div_pow2(int a, int b)
{
#if defined(__KERNEL_SSE2__) && !defined(_MSC_VER)
return a >> __builtin_ctz(b);
@@ -42,7 +42,7 @@ __device_inline int cmj_fast_div_pow2(int a, int b)
#endif
}
-__device_inline uint cmj_w_mask(uint w)
+ccl_device_inline uint cmj_w_mask(uint w)
{
#if defined(__KERNEL_SSE2__) && !defined(_MSC_VER)
return ((1 << (32 - __builtin_clz(w))) - 1);
@@ -57,7 +57,7 @@ __device_inline uint cmj_w_mask(uint w)
#endif
}
-__device_inline uint cmj_permute(uint i, uint l, uint p)
+ccl_device_inline uint cmj_permute(uint i, uint l, uint p)
{
uint w = l - 1;
@@ -113,7 +113,7 @@ __device_inline uint cmj_permute(uint i, uint l, uint p)
}
}
-__device_inline uint cmj_hash(uint i, uint p)
+ccl_device_inline uint cmj_hash(uint i, uint p)
{
i ^= p;
i ^= i >> 17;
@@ -129,13 +129,13 @@ __device_inline uint cmj_hash(uint i, uint p)
return i;
}
-__device_inline float cmj_randfloat(uint i, uint p)
+ccl_device_inline float cmj_randfloat(uint i, uint p)
{
return cmj_hash(i, p) * (1.0f / 4294967808.0f);
}
#ifdef __CMJ__
-__device float cmj_sample_1D(int s, int N, int p)
+ccl_device float cmj_sample_1D(int s, int N, int p)
{
kernel_assert(s < N);
@@ -146,7 +146,7 @@ __device float cmj_sample_1D(int s, int N, int p)
return (x + jx)*invN;
}
-__device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy)
+ccl_device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy)
{
kernel_assert(s < N);
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 6b00bd2ab01..9915cd2495f 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -36,7 +36,7 @@ typedef struct LightSample {
#ifdef __BACKGROUND_MIS__
-__device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf)
+ccl_device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf)
{
/* for the following, the CDF values are actually a pair of floats, with the
* function value as X and the actual CDF as Y. The last entry's function
@@ -112,7 +112,7 @@ __device float3 background_light_sample(KernelGlobals *kg, float randu, float ra
return -equirectangular_to_direction(u, v);
}
-__device float background_light_pdf(KernelGlobals *kg, float3 direction)
+ccl_device float background_light_pdf(KernelGlobals *kg, float3 direction)
{
float2 uv = direction_to_equirectangular(direction);
int res = kernel_data.integrator.pdf_background_res;
@@ -146,7 +146,7 @@ __device float background_light_pdf(KernelGlobals *kg, float3 direction)
/* Regular Light */
-__device float3 disk_light_sample(float3 v, float randu, float randv)
+ccl_device float3 disk_light_sample(float3 v, float randu, float randv)
{
float3 ru, rv;
@@ -156,17 +156,17 @@ __device float3 disk_light_sample(float3 v, float randu, float randv)
return ru*randu + rv*randv;
}
-__device float3 distant_light_sample(float3 D, float radius, float randu, float randv)
+ccl_device float3 distant_light_sample(float3 D, float radius, float randu, float randv)
{
return normalize(D + disk_light_sample(D, randu, randv)*radius);
}
-__device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv)
+ccl_device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv)
{
return disk_light_sample(normalize(P - center), randu, randv)*radius;
}
-__device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv)
+ccl_device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv)
{
randu = randu - 0.5f;
randv = randv - 0.5f;
@@ -174,7 +174,7 @@ __device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float
return axisu*randu + axisv*randv;
}
-__device float spot_light_attenuation(float4 data1, float4 data2, LightSample *ls)
+ccl_device float spot_light_attenuation(float4 data1, float4 data2, LightSample *ls)
{
float3 dir = make_float3(data2.y, data2.z, data2.w);
float3 I = ls->Ng;
@@ -197,7 +197,7 @@ __device float spot_light_attenuation(float4 data1, float4 data2, LightSample *l
return attenuation;
}
-__device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
+ccl_device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
{
float cos_pi = dot(Ng, I);
@@ -207,7 +207,7 @@ __device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I
return t*t/cos_pi;
}
-__device void lamp_light_sample(KernelGlobals *kg, int lamp,
+ccl_device void lamp_light_sample(KernelGlobals *kg, int lamp,
float randu, float randv, float3 P, LightSample *ls)
{
float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0);
@@ -298,7 +298,7 @@ __device void lamp_light_sample(KernelGlobals *kg, int lamp,
}
}
-__device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls)
+ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls)
{
float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0);
float4 data1 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 1);
@@ -422,7 +422,7 @@ __device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, f
/* Triangle Light */
-__device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time)
+ccl_device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time)
{
#ifdef __INSTANCING__
/* instance transform */
@@ -440,7 +440,7 @@ __device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls,
#endif
}
-__device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
+ccl_device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
float randu, float randv, float time, LightSample *ls)
{
/* triangle, so get position, normal, shader */
@@ -457,7 +457,7 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
object_transform_light_sample(kg, ls, object, time);
}
-__device float triangle_light_pdf(KernelGlobals *kg,
+ccl_device float triangle_light_pdf(KernelGlobals *kg,
const float3 Ng, const float3 I, float t)
{
float pdf = kernel_data.integrator.pdf_triangles;
@@ -473,7 +473,7 @@ __device float triangle_light_pdf(KernelGlobals *kg,
#ifdef __HAIR__
-__device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object,
+ccl_device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object,
int segment, float randu, float randv, float time, LightSample *ls)
{
/* this strand code needs completion */
@@ -515,7 +515,7 @@ __device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object
/* Light Distribution */
-__device int light_distribution_sample(KernelGlobals *kg, float randt)
+ccl_device int light_distribution_sample(KernelGlobals *kg, float randt)
{
/* this is basically std::upper_bound as used by pbrt, to find a point light or
* triangle to emit from, proportional to area. a good improvement would be to
@@ -544,7 +544,7 @@ __device int light_distribution_sample(KernelGlobals *kg, float randt)
/* Generic Light */
-__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls)
+ccl_device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls)
{
/* sample index */
int index = light_distribution_sample(kg, randt);
@@ -577,18 +577,18 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
}
}
-__device int light_select_num_samples(KernelGlobals *kg, int index)
+ccl_device int light_select_num_samples(KernelGlobals *kg, int index)
{
float4 data3 = kernel_tex_fetch(__light_data, index*LIGHT_SIZE + 3);
return __float_as_int(data3.x);
}
-__device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls)
+ccl_device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls)
{
lamp_light_sample(kg, index, randu, randv, P, ls);
}
-__device int lamp_light_eval_sample(KernelGlobals *kg, float randt)
+ccl_device int lamp_light_eval_sample(KernelGlobals *kg, float randt)
{
/* sample index */
int index = light_distribution_sample(kg, randt);
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h
index b3d53e00be7..92f3420a218 100644
--- a/intern/cycles/kernel/kernel_montecarlo.h
+++ b/intern/cycles/kernel/kernel_montecarlo.h
@@ -36,7 +36,7 @@
CCL_NAMESPACE_BEGIN
/* distribute uniform xy on [0,1] over unit disk [-1,1] */
-__device void to_unit_disk(float *x, float *y)
+ccl_device void to_unit_disk(float *x, float *y)
{
float phi = M_2PI_F * (*x);
float r = sqrtf(*y);
@@ -47,14 +47,14 @@ __device void to_unit_disk(float *x, float *y)
/* return an orthogonal tangent and bitangent given a normal and tangent that
* may not be exactly orthogonal */
-__device void make_orthonormals_tangent(const float3 N, const float3 T, float3 *a, float3 *b)
+ccl_device void make_orthonormals_tangent(const float3 N, const float3 T, float3 *a, float3 *b)
{
*b = normalize(cross(N, T));
*a = cross(*b, N);
}
/* sample direction with cosine weighted distributed in hemisphere */
-__device_inline void sample_cos_hemisphere(const float3 N,
+ccl_device_inline void sample_cos_hemisphere(const float3 N,
float randu, float randv, float3 *omega_in, float *pdf)
{
to_unit_disk(&randu, &randv);
@@ -66,7 +66,7 @@ __device_inline void sample_cos_hemisphere(const float3 N,
}
/* sample direction uniformly distributed in hemisphere */
-__device_inline void sample_uniform_hemisphere(const float3 N,
+ccl_device_inline void sample_uniform_hemisphere(const float3 N,
float randu, float randv,
float3 *omega_in, float *pdf)
{
@@ -83,7 +83,7 @@ __device_inline void sample_uniform_hemisphere(const float3 N,
}
/* sample direction uniformly distributed in cone */
-__device_inline void sample_uniform_cone(const float3 N, float angle,
+ccl_device_inline void sample_uniform_cone(const float3 N, float angle,
float randu, float randv,
float3 *omega_in, float *pdf)
{
@@ -100,7 +100,7 @@ __device_inline void sample_uniform_cone(const float3 N, float angle,
}
/* sample uniform point on the surface of a sphere */
-__device float3 sample_uniform_sphere(float u1, float u2)
+ccl_device float3 sample_uniform_sphere(float u1, float u2)
{
float z = 1.0f - 2.0f*u1;
float r = sqrtf(fmaxf(0.0f, 1.0f - z*z));
@@ -111,29 +111,29 @@ __device float3 sample_uniform_sphere(float u1, float u2)
return make_float3(x, y, z);
}
-__device float balance_heuristic(float a, float b)
+ccl_device float balance_heuristic(float a, float b)
{
return (a)/(a + b);
}
-__device float balance_heuristic_3(float a, float b, float c)
+ccl_device float balance_heuristic_3(float a, float b, float c)
{
return (a)/(a + b + c);
}
-__device float power_heuristic(float a, float b)
+ccl_device float power_heuristic(float a, float b)
{
return (a*a)/(a*a + b*b);
}
-__device float power_heuristic_3(float a, float b, float c)
+ccl_device float power_heuristic_3(float a, float b, float c)
{
return (a*a)/(a*a + b*b + c*c);
}
/* distribute uniform xy on [0,1] over unit disk [-1,1], with concentric mapping
* to better preserve stratification for some RNG sequences */
-__device float2 concentric_sample_disk(float u1, float u2)
+ccl_device float2 concentric_sample_disk(float u1, float u2)
{
float phi, r;
float a = 2.0f*u1 - 1.0f;
@@ -155,7 +155,7 @@ __device float2 concentric_sample_disk(float u1, float u2)
}
/* sample point in unit polygon with given number of corners and rotation */
-__device float2 regular_polygon_sample(float corners, float rotation, float u, float v)
+ccl_device float2 regular_polygon_sample(float corners, float rotation, float u, float v)
{
/* sample corner number and reuse u */
float corner = floorf(u*corners);
diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h
index d0aae119476..a66277e10cd 100644
--- a/intern/cycles/kernel/kernel_object.h
+++ b/intern/cycles/kernel/kernel_object.h
@@ -30,7 +30,7 @@ enum ObjectVectorTransform {
OBJECT_VECTOR_MOTION_POST = 3
};
-__device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type)
+ccl_device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type)
{
int offset = object*OBJECT_SIZE + (int)type;
@@ -43,7 +43,7 @@ __device_inline Transform object_fetch_transform(KernelGlobals *kg, int object,
return tfm;
}
-__device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int object, enum ObjectVectorTransform type)
+ccl_device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int object, enum ObjectVectorTransform type)
{
int offset = object*OBJECT_VECTOR_SIZE + (int)type;
@@ -57,7 +57,7 @@ __device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int o
}
#ifdef __OBJECT_MOTION__
-__device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int object, float time)
+ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int object, float time)
{
DecompMotionTransform motion;
@@ -79,7 +79,7 @@ __device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int o
return tfm;
}
-__device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg, int object, float time, Transform *itfm)
+ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg, int object, float time, Transform *itfm)
{
int object_flag = kernel_tex_fetch(__object_flag, object);
@@ -102,7 +102,7 @@ __device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg,
}
#endif
-__device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
+ccl_device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
{
#ifdef __OBJECT_MOTION__
*P = transform_point(&sd->ob_tfm, *P);
@@ -112,7 +112,7 @@ __device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd
#endif
}
-__device_inline void object_inverse_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
+ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
{
#ifdef __OBJECT_MOTION__
*P = transform_point(&sd->ob_itfm, *P);
@@ -122,7 +122,7 @@ __device_inline void object_inverse_position_transform(KernelGlobals *kg, Shader
#endif
}
-__device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
+ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
{
#ifdef __OBJECT_MOTION__
*N = normalize(transform_direction_transposed(&sd->ob_tfm, *N));
@@ -132,7 +132,7 @@ __device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderDa
#endif
}
-__device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
+ccl_device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
{
#ifdef __OBJECT_MOTION__
*N = normalize(transform_direction_transposed(&sd->ob_itfm, *N));
@@ -142,7 +142,7 @@ __device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd,
#endif
}
-__device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
+ccl_device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
{
#ifdef __OBJECT_MOTION__
*D = transform_direction(&sd->ob_tfm, *D);
@@ -152,7 +152,7 @@ __device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, flo
#endif
}
-__device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
+ccl_device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
{
#ifdef __OBJECT_MOTION__
*D = transform_direction(&sd->ob_itfm, *D);
@@ -162,7 +162,7 @@ __device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData
#endif
}
-__device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
+ccl_device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
{
if(sd->object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
@@ -175,14 +175,14 @@ __device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device_inline float object_surface_area(KernelGlobals *kg, int object)
+ccl_device_inline float object_surface_area(KernelGlobals *kg, int object)
{
int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
float4 f = kernel_tex_fetch(__objects, offset);
return f.x;
}
-__device_inline float object_pass_id(KernelGlobals *kg, int object)
+ccl_device_inline float object_pass_id(KernelGlobals *kg, int object)
{
if(object == ~0)
return 0.0f;
@@ -192,7 +192,7 @@ __device_inline float object_pass_id(KernelGlobals *kg, int object)
return f.y;
}
-__device_inline float object_random_number(KernelGlobals *kg, int object)
+ccl_device_inline float object_random_number(KernelGlobals *kg, int object)
{
if(object == ~0)
return 0.0f;
@@ -202,7 +202,7 @@ __device_inline float object_random_number(KernelGlobals *kg, int object)
return f.z;
}
-__device_inline uint object_particle_id(KernelGlobals *kg, int object)
+ccl_device_inline uint object_particle_id(KernelGlobals *kg, int object)
{
if(object == ~0)
return 0.0f;
@@ -212,7 +212,7 @@ __device_inline uint object_particle_id(KernelGlobals *kg, int object)
return __float_as_uint(f.w);
}
-__device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
+ccl_device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
{
if(object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
@@ -222,7 +222,7 @@ __device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
return make_float3(f.x, f.y, f.z);
}
-__device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
+ccl_device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
{
if(object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
@@ -233,54 +233,54 @@ __device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
}
-__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
+ccl_device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
{
return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1);
}
-__device_inline float particle_index(KernelGlobals *kg, int particle)
+ccl_device_inline float particle_index(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.x;
}
-__device float particle_age(KernelGlobals *kg, int particle)
+ccl_device float particle_age(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.y;
}
-__device float particle_lifetime(KernelGlobals *kg, int particle)
+ccl_device float particle_lifetime(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.z;
}
-__device float particle_size(KernelGlobals *kg, int particle)
+ccl_device float particle_size(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.w;
}
-__device float4 particle_rotation(KernelGlobals *kg, int particle)
+ccl_device float4 particle_rotation(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 1);
return f;
}
-__device float3 particle_location(KernelGlobals *kg, int particle)
+ccl_device float3 particle_location(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 2);
return make_float3(f.x, f.y, f.z);
}
-__device float3 particle_velocity(KernelGlobals *kg, int particle)
+ccl_device float3 particle_velocity(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f2 = kernel_tex_fetch(__particles, offset + 2);
@@ -288,7 +288,7 @@ __device float3 particle_velocity(KernelGlobals *kg, int particle)
return make_float3(f2.w, f3.x, f3.y);
}
-__device float3 particle_angular_velocity(KernelGlobals *kg, int particle)
+ccl_device float3 particle_angular_velocity(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f3 = kernel_tex_fetch(__particles, offset + 3);
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 5e91b13f90c..512db9ec392 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -16,25 +16,25 @@
CCL_NAMESPACE_BEGIN
-__device_inline void kernel_write_pass_float(__global float *buffer, int sample, float value)
+ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, int sample, float value)
{
- __global float *buf = buffer;
+ ccl_global float *buf = buffer;
*buf = (sample == 0)? value: *buf + value;
}
-__device_inline void kernel_write_pass_float3(__global float *buffer, int sample, float3 value)
+ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sample, float3 value)
{
- __global float3 *buf = (__global float3*)buffer;
+ ccl_global float3 *buf = (ccl_global float3*)buffer;
*buf = (sample == 0)? value: *buf + value;
}
-__device_inline void kernel_write_pass_float4(__global float *buffer, int sample, float4 value)
+ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sample, float4 value)
{
- __global float4 *buf = (__global float4*)buffer;
+ ccl_global float4 *buf = (ccl_global float4*)buffer;
*buf = (sample == 0)? value: *buf + value;
}
-__device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L,
+ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L,
ShaderData *sd, int sample, int path_flag, float3 throughput)
{
#ifdef __PASSES__
@@ -114,7 +114,7 @@ __device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float
#endif
}
-__device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample)
+ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L, int sample)
{
#ifdef __PASSES__
int flag = kernel_data.film.pass_flag;
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 5354738d378..4f3957b66ef 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -42,7 +42,7 @@
CCL_NAMESPACE_BEGIN
-__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow)
+ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow)
{
*shadow = make_float3(1.0f, 1.0f, 1.0f);
@@ -122,7 +122,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
#if defined(__BRANCHED_PATH__) || defined(__SUBSURFACE__)
-__device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer,
+ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer,
float3 throughput, int num_samples, int num_total_samples,
float min_ray_pdf, float ray_pdf, PathState state, int rng_offset, PathRadiance *L)
{
@@ -359,7 +359,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
#ifdef __SUBSURFACE__
-__device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
+ccl_device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
int sample, int num_samples,
ShaderData *sd, float3 *throughput,
float *min_ray_pdf, float *ray_pdf, PathState *state,
@@ -452,7 +452,7 @@ __device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
#endif
-__device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer)
+ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
{
/* initialize */
PathRadiance L;
@@ -790,11 +790,11 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
#ifdef __BRANCHED_PATH__
-__device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
+ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
int sample, int aa_samples,
ShaderData *sd, float3 throughput, float num_samples_adjust,
float min_ray_pdf, float ray_pdf, PathState state,
- int rng_offset, PathRadiance *L, __global float *buffer)
+ int rng_offset, PathRadiance *L, ccl_global float *buffer)
{
#ifdef __EMISSION__
/* sample illumination from lights to find path contribution */
@@ -941,7 +941,7 @@ __device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg
}
}
-__device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer)
+ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
{
/* initialize */
PathRadiance L;
@@ -1166,7 +1166,7 @@ __device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int
#endif
-__device_inline void kernel_path_trace_setup(KernelGlobals *kg, __global uint *rng_state, int sample, int x, int y, RNG *rng, Ray *ray)
+ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int x, int y, RNG *rng, Ray *ray)
{
float filter_u;
float filter_v;
@@ -1195,8 +1195,8 @@ __device_inline void kernel_path_trace_setup(KernelGlobals *kg, __global uint *r
camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray);
}
-__device void kernel_path_trace(KernelGlobals *kg,
- __global float *buffer, __global uint *rng_state,
+ccl_device void kernel_path_trace(KernelGlobals *kg,
+ ccl_global float *buffer, ccl_global uint *rng_state,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
@@ -1227,8 +1227,8 @@ __device void kernel_path_trace(KernelGlobals *kg,
}
#ifdef __BRANCHED_PATH__
-__device void kernel_branched_path_trace(KernelGlobals *kg,
- __global float *buffer, __global uint *rng_state,
+ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
+ ccl_global float *buffer, ccl_global uint *rng_state,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h
index e0e0f43fd26..0ded332b3b9 100644
--- a/intern/cycles/kernel/kernel_path_state.h
+++ b/intern/cycles/kernel/kernel_path_state.h
@@ -26,7 +26,7 @@ typedef struct PathState {
int transparent_bounce;
} PathState;
-__device_inline void path_state_init(PathState *state)
+ccl_device_inline void path_state_init(PathState *state)
{
state->flag = PATH_RAY_CAMERA|PATH_RAY_SINGULAR|PATH_RAY_MIS_SKIP;
state->bounce = 0;
@@ -36,7 +36,7 @@ __device_inline void path_state_init(PathState *state)
state->transparent_bounce = 0;
}
-__device_inline void path_state_next(KernelGlobals *kg, PathState *state, int label)
+ccl_device_inline void path_state_next(KernelGlobals *kg, PathState *state, int label)
{
/* ray through transparent keeps same flags from previous ray and is
* not counted as a regular bounce, transparent has separate max */
@@ -88,7 +88,7 @@ __device_inline void path_state_next(KernelGlobals *kg, PathState *state, int la
}
}
-__device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
+ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
{
uint flag = state->flag & PATH_RAY_ALL_VISIBILITY;
@@ -102,7 +102,7 @@ __device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *sta
return flag;
}
-__device_inline float path_state_terminate_probability(KernelGlobals *kg, PathState *state, const float3 throughput)
+ccl_device_inline float path_state_terminate_probability(KernelGlobals *kg, PathState *state, const float3 throughput)
{
if(state->flag & PATH_RAY_TRANSPARENT) {
/* transparent rays treated separately */
diff --git a/intern/cycles/kernel/kernel_primitive.h b/intern/cycles/kernel/kernel_primitive.h
index 636cfd06532..ababad28f35 100644
--- a/intern/cycles/kernel/kernel_primitive.h
+++ b/intern/cycles/kernel/kernel_primitive.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
/* attribute lookup */
-__device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, AttributeElement *elem)
+ccl_device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, AttributeElement *elem)
{
if(sd->object == ~0)
return (int)ATTR_STD_NOT_FOUND;
@@ -52,7 +52,7 @@ __device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, A
}
}
-__device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
+ccl_device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
{
#ifdef __HAIR__
if(sd->segment == ~0)
@@ -64,7 +64,7 @@ __device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd
#endif
}
-__device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
+ccl_device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
{
#ifdef __HAIR__
if(sd->segment == ~0)
@@ -76,7 +76,7 @@ __device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *
#endif
}
-__device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd)
{
AttributeElement elem_uv;
int offset_uv = find_attribute(kg, sd, ATTR_STD_UV, &elem_uv);
@@ -89,7 +89,7 @@ __device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd)
return uv;
}
-__device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __HAIR__
if(sd->segment != ~0)
@@ -122,7 +122,7 @@ __device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
/* motion */
-__device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
+ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
{
float3 motion_pre = sd->P, motion_post = sd->P;
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
index d9520de7956..e2108604bc8 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* Spherical coordinates <-> Cartesian direction */
-__device float2 direction_to_spherical(float3 dir)
+ccl_device float2 direction_to_spherical(float3 dir)
{
float theta = acosf(dir.z);
float phi = atan2f(dir.x, dir.y);
@@ -45,7 +45,7 @@ __device float2 direction_to_spherical(float3 dir)
return make_float2(theta, phi);
}
-__device float3 spherical_to_direction(float theta, float phi)
+ccl_device float3 spherical_to_direction(float theta, float phi)
{
return make_float3(
sinf(theta)*cosf(phi),
@@ -55,7 +55,7 @@ __device float3 spherical_to_direction(float theta, float phi)
/* Equirectangular coordinates <-> Cartesian direction */
-__device float2 direction_to_equirectangular(float3 dir)
+ccl_device float2 direction_to_equirectangular(float3 dir)
{
float u = -atan2f(dir.y, dir.x)/(M_2PI_F) + 0.5f;
float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f;
@@ -63,7 +63,7 @@ __device float2 direction_to_equirectangular(float3 dir)
return make_float2(u, v);
}
-__device float3 equirectangular_to_direction(float u, float v)
+ccl_device float3 equirectangular_to_direction(float u, float v)
{
float phi = M_PI_F*(1.0f - 2.0f*u);
float theta = M_PI_F*(1.0f - v);
@@ -76,7 +76,7 @@ __device float3 equirectangular_to_direction(float u, float v)
/* Fisheye <-> Cartesian direction */
-__device float2 direction_to_fisheye(float3 dir, float fov)
+ccl_device float2 direction_to_fisheye(float3 dir, float fov)
{
float r = atan2f(sqrtf(dir.y*dir.y + dir.z*dir.z), dir.x) / fov;
float phi = atan2f(dir.z, dir.y);
@@ -87,7 +87,7 @@ __device float2 direction_to_fisheye(float3 dir, float fov)
return make_float2(u, v);
}
-__device float3 fisheye_to_direction(float u, float v, float fov)
+ccl_device float3 fisheye_to_direction(float u, float v, float fov)
{
u = (u - 0.5f) * 2.0f;
v = (v - 0.5f) * 2.0f;
@@ -109,7 +109,7 @@ __device float3 fisheye_to_direction(float u, float v, float fov)
);
}
-__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height)
+ccl_device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height)
{
float theta = acosf(dir.x);
float r = 2.0f * lens * sinf(theta * 0.5f);
@@ -121,7 +121,7 @@ __device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float wid
return make_float2(u, v);
}
-__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height)
+ccl_device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height)
{
u = (u - 0.5f) * width;
v = (v - 0.5f) * height;
@@ -146,7 +146,7 @@ __device float3 fisheye_equisolid_to_direction(float u, float v, float lens, flo
/* Mirror Ball <-> Cartesion direction */
-__device float3 mirrorball_to_direction(float u, float v)
+ccl_device float3 mirrorball_to_direction(float u, float v)
{
/* point on sphere */
float3 dir;
@@ -161,7 +161,7 @@ __device float3 mirrorball_to_direction(float u, float v)
return 2.0f*dot(dir, I)*dir - I;
}
-__device float2 direction_to_mirrorball(float3 dir)
+ccl_device float2 direction_to_mirrorball(float3 dir)
{
/* inverse of mirrorball_to_direction */
dir.y -= 1.0f;
@@ -176,7 +176,7 @@ __device float2 direction_to_mirrorball(float3 dir)
return make_float2(u, v);
}
-__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v)
+ccl_device float3 panorama_to_direction(KernelGlobals *kg, float u, float v)
{
switch(kernel_data.cam.panorama_type) {
case PANORAMA_EQUIRECTANGULAR:
@@ -190,7 +190,7 @@ __device float3 panorama_to_direction(KernelGlobals *kg, float u, float v)
}
}
-__device float2 direction_to_panorama(KernelGlobals *kg, float3 dir)
+ccl_device float2 direction_to_panorama(KernelGlobals *kg, float3 dir)
{
switch(kernel_data.cam.panorama_type) {
case PANORAMA_EQUIRECTANGULAR:
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h
index dc977a8780f..69e7b439e1c 100644
--- a/intern/cycles/kernel/kernel_random.h
+++ b/intern/cycles/kernel/kernel_random.h
@@ -30,7 +30,7 @@ typedef uint RNG;
/* High Dimensional Sobol */
/* van der corput radical inverse */
-__device uint van_der_corput(uint bits)
+ccl_device uint van_der_corput(uint bits)
{
bits = (bits << 16) | (bits >> 16);
bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8);
@@ -41,7 +41,7 @@ __device uint van_der_corput(uint bits)
}
/* sobol radical inverse */
-__device uint sobol(uint i)
+ccl_device uint sobol(uint i)
{
uint r = 0;
@@ -53,7 +53,7 @@ __device uint sobol(uint i)
}
/* inverse of sobol radical inverse */
-__device uint sobol_inverse(uint i)
+ccl_device uint sobol_inverse(uint i)
{
const uint msb = 1U << 31;
uint r = 0;
@@ -67,7 +67,7 @@ __device uint sobol_inverse(uint i)
/* multidimensional sobol with generator matrices
* dimension 0 and 1 are equal to van_der_corput() and sobol() respectively */
-__device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
+ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
{
uint result = 0;
uint i = index;
@@ -80,7 +80,7 @@ __device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
}
/* lookup index and x/y coordinate, assumes m is a power of two */
-__device uint sobol_lookup(const uint m, const uint frame, const uint ex, const uint ey, uint *x, uint *y)
+ccl_device uint sobol_lookup(const uint m, const uint frame, const uint ex, const uint ey, uint *x, uint *y)
{
/* shift is constant per frame */
const uint shift = frame << (m << 1);
@@ -100,7 +100,7 @@ __device uint sobol_lookup(const uint m, const uint frame, const uint ex, const
return index;
}
-__device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension)
+ccl_device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension)
{
#ifdef __CMJ__
if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) {
@@ -131,7 +131,7 @@ __device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int n
#endif
}
-__device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension, float *fx, float *fy)
+ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension, float *fx, float *fy)
{
#ifdef __CMJ__
if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) {
@@ -148,7 +148,7 @@ __device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int nu
}
}
-__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
+ccl_device_inline void path_rng_init(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
{
#ifdef __SOBOL_FULL_SCREEN__
uint px, py;
@@ -183,7 +183,7 @@ __device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state,
#endif
}
-__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
+ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG rng)
{
/* nothing to do */
}
@@ -192,24 +192,24 @@ __device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
/* Linear Congruential Generator */
-__device float path_rng(KernelGlobals *kg, RNG& rng, int sample, int dimension)
+ccl_device float path_rng(KernelGlobals *kg, RNG& rng, int sample, int dimension)
{
}
-__device_inline float path_rng_1D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension)
+ccl_device_inline float path_rng_1D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension)
{
/* implicit mod 2^32 */
rng = (1103515245*(rng) + 12345);
return (float)rng * (1.0f/(float)0xFFFFFFFF);
}
-__device_inline void path_rng_2D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension, float *fx, float *fy)
+ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension, float *fx, float *fy)
{
*fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
*fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);
}
-__device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
+ccl_device void path_rng_init(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
{
/* load state */
*rng = *rng_state;
@@ -225,7 +225,7 @@ __device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sam
}
}
-__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
+ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG rng)
{
/* store state for next sample */
*rng_state = rng;
@@ -233,21 +233,21 @@ __device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
#endif
-__device uint lcg_step_uint(uint *rng)
+ccl_device uint lcg_step_uint(uint *rng)
{
/* implicit mod 2^32 */
*rng = (1103515245*(*rng) + 12345);
return *rng;
}
-__device float lcg_step_float(uint *rng)
+ccl_device float lcg_step_float(uint *rng)
{
/* implicit mod 2^32 */
*rng = (1103515245*(*rng) + 12345);
return (float)*rng * (1.0f/(float)0xFFFFFFFF);
}
-__device uint lcg_init(uint seed)
+ccl_device uint lcg_init(uint seed)
{
uint rng = seed;
lcg_step_uint(&rng);
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index 81630caed9a..77154ce3aef 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -36,7 +36,7 @@ CCL_NAMESPACE_BEGIN
/* ShaderData setup from incoming ray */
#ifdef __OBJECT_MOTION__
-__device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time)
+ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time)
{
if(sd->flag & SD_OBJECT_MOTION) {
sd->ob_tfm = object_fetch_transform_motion(kg, sd->object, time);
@@ -49,7 +49,7 @@ __device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd,
}
#endif
-__device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
const Intersection *isect, const Ray *ray, int bounce)
{
#ifdef __INSTANCING__
@@ -161,7 +161,7 @@ __device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
/* ShaderData setup from BSSRDF scatter */
#ifdef __SUBSURFACE__
-__device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData *sd,
+ccl_device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData *sd,
const Intersection *isect, const Ray *ray)
{
bool backfacing = sd->flag & SD_BACKFACING;
@@ -237,7 +237,7 @@ __device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData
/* ShaderData setup from position sampled on mesh */
-__device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
const float3 P, const float3 Ng, const float3 I,
int shader, int object, int prim, float u, float v, float t, float time, int bounce, int segment)
{
@@ -357,7 +357,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
/* ShaderData setup for displacement */
-__device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
int object, int prim, float u, float v)
{
float3 P, Ng, I = make_float3(0.0f, 0.0f, 0.0f);
@@ -376,7 +376,7 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
/* ShaderData setup from ray into background */
-__device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce)
+ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce)
{
/* vectors */
sd->P = ray->D;
@@ -426,7 +426,7 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData
#ifdef __MULTI_CLOSURE__
-__device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, float *pdf,
+ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, float *pdf,
int skip_bsdf, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight)
{
/* this is the veach one-sample model with balance heuristic, some pdf
@@ -455,7 +455,7 @@ __device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData
#endif
-__device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
+ccl_device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
const float3 omega_in, BsdfEval *eval, float *pdf)
{
#ifdef __MULTI_CLOSURE__
@@ -470,7 +470,7 @@ __device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
#endif
}
-__device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
+ccl_device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
float randu, float randv, BsdfEval *bsdf_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
@@ -534,7 +534,7 @@ __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
#endif
}
-__device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd,
+ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd,
const ShaderClosure *sc, float randu, float randv, BsdfEval *bsdf_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
@@ -550,7 +550,7 @@ __device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd,
return label;
}
-__device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
+ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
{
#ifdef __MULTI_CLOSURE__
for(int i = 0; i< sd->num_closure; i++) {
@@ -564,7 +564,7 @@ __device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughnes
#endif
}
-__device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -585,7 +585,7 @@ __device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
{
float3 alpha = make_float3(1.0f, 1.0f, 1.0f) - shader_bsdf_transparency(kg, sd);
@@ -595,7 +595,7 @@ __device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
return alpha;
}
-__device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -616,7 +616,7 @@ __device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -637,7 +637,7 @@ __device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -658,7 +658,7 @@ __device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -679,7 +679,7 @@ __device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_)
+ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -717,7 +717,7 @@ __device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_facto
#endif
}
-__device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_)
+ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -762,7 +762,7 @@ __device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blu
/* Emission */
-__device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *sc)
+ccl_device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *sc)
{
#ifdef __OSL__
if(kg->osl && sc->prim)
@@ -772,7 +772,7 @@ __device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *
return emissive_simple_eval(sd->Ng, sd->I);
}
-__device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
{
float3 eval;
#ifdef __MULTI_CLOSURE__
@@ -793,7 +793,7 @@ __device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
/* Holdout */
-__device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 weight = make_float3(0.0f, 0.0f, 0.0f);
@@ -816,7 +816,7 @@ __device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
/* Surface Evaluation */
-__device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
float randb, int path_flag, ShaderContext ctx)
{
#ifdef __OSL__
@@ -837,7 +837,7 @@ __device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
/* Background Evaluation */
-__device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag, ShaderContext ctx)
+ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag, ShaderContext ctx)
{
#ifdef __OSL__
if (kg->osl)
@@ -875,7 +875,7 @@ __device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int pa
/* Volume */
-__device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd,
+ccl_device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd,
float3 omega_in, float3 omega_out)
{
#ifdef __MULTI_CLOSURE__
@@ -896,7 +896,7 @@ __device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd,
/* Volume Evaluation */
-__device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
float randb, int path_flag, ShaderContext ctx)
{
#ifdef __SVM__
@@ -911,7 +911,7 @@ __device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
/* Displacement Evaluation */
-__device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx)
+ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx)
{
/* this will modify sd->P */
#ifdef __SVM__
@@ -927,7 +927,7 @@ __device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, Shader
/* Transparent Shadows */
#ifdef __TRANSPARENT_SHADOWS__
-__device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
+ccl_device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
{
int prim = kernel_tex_fetch(__prim_index, isect->prim);
int shader = 0;
@@ -953,7 +953,7 @@ __device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
/* Merging */
#ifdef __BRANCHED_PATH__
-__device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
+ccl_device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
{
/* merge identical closures, better when we sample a single closure at a time */
for(int i = 0; i < sd->num_closure; i++) {
diff --git a/intern/cycles/kernel/kernel_sse41.cpp b/intern/cycles/kernel/kernel_sse41.cpp
new file mode 100644
index 00000000000..0c68fd3651b
--- /dev/null
+++ b/intern/cycles/kernel/kernel_sse41.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2011-2013 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+/* Optimized CPU kernel entry points. This file is compiled with SSE3/SSSE3
+ * optimization flags and nearly all functions inlined, while kernel.cpp
+ * is compiled without for other CPU's. */
+
+#ifdef WITH_OPTIMIZED_KERNEL
+
+/* SSE optimization disabled for now on 32 bit, see bug #36316 */
+#if !(defined(__GNUC__) && (defined(i386) || defined(_M_IX86)))
+#define __KERNEL_SSE2__
+#define __KERNEL_SSE3__
+#define __KERNEL_SSSE3__
+#define __KERNEL_SSE41__
+#endif
+
+#include "kernel.h"
+#include "kernel_compat_cpu.h"
+#include "kernel_math.h"
+#include "kernel_types.h"
+#include "kernel_globals.h"
+#include "kernel_film.h"
+#include "kernel_path.h"
+#include "kernel_displace.h"
+
+CCL_NAMESPACE_BEGIN
+
+/* Path Tracing */
+
+void kernel_cpu_sse41_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride)
+{
+#ifdef __BRANCHED_PATH__
+ if(kernel_data.integrator.branched)
+ kernel_branched_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
+ else
+#endif
+ kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
+}
+
+/* Film */
+
+void kernel_cpu_sse41_convert_to_byte(KernelGlobals *kg, uchar4 *rgba, float *buffer, float sample_scale, int x, int y, int offset, int stride)
+{
+ kernel_film_convert_to_byte(kg, rgba, buffer, sample_scale, x, y, offset, stride);
+}
+
+void kernel_cpu_sse41_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, float *buffer, float sample_scale, int x, int y, int offset, int stride)
+{
+ kernel_film_convert_to_half_float(kg, rgba, buffer, sample_scale, x, y, offset, stride);
+}
+
+/* Shader Evaluate */
+
+void kernel_cpu_sse41_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i)
+{
+ kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, i);
+}
+
+CCL_NAMESPACE_END
+
+#endif
+
diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h
index d16b9328bf2..2326ca18b55 100644
--- a/intern/cycles/kernel/kernel_subsurface.h
+++ b/intern/cycles/kernel/kernel_subsurface.h
@@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN
#define BSSRDF_MULTI_EVAL
-__device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, ShaderData *sd, float *probability)
+ccl_device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, ShaderData *sd, float *probability)
{
/* sum sample weights of bssrdf and bsdf */
float bsdf_sum = 0.0f;
@@ -80,7 +80,7 @@ __device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, Shade
return NULL;
}
-__device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float disk_r, float r, bool all)
+ccl_device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float disk_r, float r, bool all)
{
#ifdef BSSRDF_MULTI_EVAL
/* this is the veach one-sample model with balance heuristic, some pdf
@@ -133,7 +133,7 @@ __device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float
}
/* replace closures with a single diffuse bsdf closure after scatter step */
-__device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weight, bool hit, float3 N)
+ccl_device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weight, bool hit, float3 N)
{
sd->flag &= ~SD_CLOSURE_FLAGS;
sd->randb_closure = 0.0f;
@@ -158,7 +158,7 @@ __device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weigh
}
/* optionally do blurring of color and/or bump mapping, at the cost of a shader evaluation */
-__device float3 subsurface_color_pow(float3 color, float exponent)
+ccl_device float3 subsurface_color_pow(float3 color, float exponent)
{
color = max(color, make_float3(0.0f, 0.0f, 0.0f));
@@ -179,7 +179,7 @@ __device float3 subsurface_color_pow(float3 color, float exponent)
return color;
}
-__device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd, ShaderData *in_sd, int state_flag, float3 *eval, float3 *N)
+ccl_device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd, ShaderData *in_sd, int state_flag, float3 *eval, float3 *N)
{
/* average color and texture blur at outgoing point */
float texture_blur;
@@ -207,7 +207,7 @@ __device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd,
}
/* subsurface scattering step, from a point on the surface to other nearby points on the same object */
-__device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, ShaderData bssrdf_sd[BSSRDF_MAX_HITS],
+ccl_device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, ShaderData bssrdf_sd[BSSRDF_MAX_HITS],
int state_flag, ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all)
{
/* pick random axis in local frame and point on disk */
@@ -313,7 +313,7 @@ __device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, Sh
}
/* subsurface scattering step, from a point on the surface to another nearby point on the same object */
-__device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd,
+ccl_device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd,
int state_flag, ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/kernel_triangle.h b/intern/cycles/kernel/kernel_triangle.h
index 71389e0ec32..d457b67e77e 100644
--- a/intern/cycles/kernel/kernel_triangle.h
+++ b/intern/cycles/kernel/kernel_triangle.h
@@ -17,7 +17,7 @@
CCL_NAMESPACE_BEGIN
/* Point on triangle for Moller-Trumbore triangles */
-__device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float u, float v)
+ccl_device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float u, float v)
{
/* load triangle vertices */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index));
@@ -32,7 +32,7 @@ __device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float
}
/* Sample point on triangle */
-__device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, float randu, float randv)
+ccl_device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, float randu, float randv)
{
/* compute point */
randu = sqrtf(randu);
@@ -44,7 +44,7 @@ __device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, floa
}
/* Normal for Moller-Trumbore triangles */
-__device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int *shader)
+ccl_device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int *shader)
{
#if 0
/* load triangle vertices */
@@ -64,7 +64,7 @@ __device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int
}
/* Return 3 triangle vertex locations */
-__device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[3])
+ccl_device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[3])
{
/* load triangle vertices */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index));
@@ -74,7 +74,7 @@ __device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3
P[2] = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.z)));
}
-__device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, float u, float v)
+ccl_device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, float u, float v)
{
/* load triangle vertices */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index));
@@ -86,7 +86,7 @@ __device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index,
return normalize((1.0f - u - v)*n2 + u*n0 + v*n1);
}
-__device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dPdv, int tri)
+ccl_device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dPdv, int tri)
{
/* fetch triangle vertex coordinates */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri));
@@ -102,7 +102,7 @@ __device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dP
/* attributes */
-__device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
+ccl_device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
{
if(elem == ATTR_ELEMENT_FACE) {
if(dx) *dx = 0.0f;
@@ -145,7 +145,7 @@ __device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd,
}
}
-__device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
+ccl_device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
{
if(elem == ATTR_ELEMENT_FACE) {
if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index c29891ed574..066e5f8dbe1 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -95,6 +95,6 @@ shader node_math(
Value = safe_modulo(Value1, Value2);
if (Clamp)
- Value = clamp(Value1, 0.0, 1.0);
+ Value = clamp(Value, 0.0, 1.0);
}
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index 168127c620c..b2be9deb938 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -45,14 +45,14 @@ CCL_NAMESPACE_BEGIN
/* Stack */
-__device_inline float3 stack_load_float3(float *stack, uint a)
+ccl_device_inline float3 stack_load_float3(float *stack, uint a)
{
kernel_assert(a+2 < SVM_STACK_SIZE);
return make_float3(stack[a+0], stack[a+1], stack[a+2]);
}
-__device_inline void stack_store_float3(float *stack, uint a, float3 f)
+ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
{
kernel_assert(a+2 < SVM_STACK_SIZE);
@@ -61,59 +61,59 @@ __device_inline void stack_store_float3(float *stack, uint a, float3 f)
stack[a+2] = f.z;
}
-__device_inline float stack_load_float(float *stack, uint a)
+ccl_device_inline float stack_load_float(float *stack, uint a)
{
kernel_assert(a < SVM_STACK_SIZE);
return stack[a];
}
-__device_inline float stack_load_float_default(float *stack, uint a, uint value)
+ccl_device_inline float stack_load_float_default(float *stack, uint a, uint value)
{
return (a == (uint)SVM_STACK_INVALID)? __uint_as_float(value): stack_load_float(stack, a);
}
-__device_inline void stack_store_float(float *stack, uint a, float f)
+ccl_device_inline void stack_store_float(float *stack, uint a, float f)
{
kernel_assert(a < SVM_STACK_SIZE);
stack[a] = f;
}
-__device_inline int stack_load_int(float *stack, uint a)
+ccl_device_inline int stack_load_int(float *stack, uint a)
{
kernel_assert(a < SVM_STACK_SIZE);
return __float_as_int(stack[a]);
}
-__device_inline float stack_load_int_default(float *stack, uint a, uint value)
+ccl_device_inline float stack_load_int_default(float *stack, uint a, uint value)
{
return (a == (uint)SVM_STACK_INVALID)? (int)value: stack_load_int(stack, a);
}
-__device_inline void stack_store_int(float *stack, uint a, int i)
+ccl_device_inline void stack_store_int(float *stack, uint a, int i)
{
kernel_assert(a < SVM_STACK_SIZE);
stack[a] = __int_as_float(i);
}
-__device_inline bool stack_valid(uint a)
+ccl_device_inline bool stack_valid(uint a)
{
return a != (uint)SVM_STACK_INVALID;
}
/* Reading Nodes */
-__device_inline uint4 read_node(KernelGlobals *kg, int *offset)
+ccl_device_inline uint4 read_node(KernelGlobals *kg, int *offset)
{
uint4 node = kernel_tex_fetch(__svm_nodes, *offset);
(*offset)++;
return node;
}
-__device_inline float4 read_node_float(KernelGlobals *kg, int *offset)
+ccl_device_inline float4 read_node_float(KernelGlobals *kg, int *offset)
{
uint4 node = kernel_tex_fetch(__svm_nodes, *offset);
float4 f = make_float4(__uint_as_float(node.x), __uint_as_float(node.y), __uint_as_float(node.z), __uint_as_float(node.w));
@@ -121,13 +121,13 @@ __device_inline float4 read_node_float(KernelGlobals *kg, int *offset)
return f;
}
-__device_inline float4 fetch_node_float(KernelGlobals *kg, int offset)
+ccl_device_inline float4 fetch_node_float(KernelGlobals *kg, int offset)
{
uint4 node = kernel_tex_fetch(__svm_nodes, offset);
return make_float4(__uint_as_float(node.x), __uint_as_float(node.y), __uint_as_float(node.z), __uint_as_float(node.w));
}
-__device_inline void decode_node_uchar4(uint i, uint *x, uint *y, uint *z, uint *w)
+ccl_device_inline void decode_node_uchar4(uint i, uint *x, uint *y, uint *z, uint *w)
{
if(x) *x = (i & 0xFF);
if(y) *y = ((i >> 8) & 0xFF);
@@ -182,7 +182,7 @@ CCL_NAMESPACE_BEGIN
/* Main Interpreter Loop */
-__device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, float randb, int path_flag)
+ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, float randb, int path_flag)
{
float stack[SVM_STACK_SIZE];
float closure_weight = 1.0f;
diff --git a/intern/cycles/kernel/svm/svm_attribute.h b/intern/cycles/kernel/svm/svm_attribute.h
index 8e71e7cdd56..90409e16477 100644
--- a/intern/cycles/kernel/svm/svm_attribute.h
+++ b/intern/cycles/kernel/svm/svm_attribute.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Attribute Node */
-__device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd,
+ccl_device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd,
uint4 node, NodeAttributeType *type,
NodeAttributeType *mesh_type, AttributeElement *elem, int *offset, uint *out_offset)
{
@@ -52,7 +52,7 @@ __device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd,
*type = (NodeAttributeType)node.w;
}
-__device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
NodeAttributeType type, mesh_type;
AttributeElement elem;
@@ -84,7 +84,7 @@ __device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uin
}
}
-__device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
NodeAttributeType type, mesh_type;
AttributeElement elem;
@@ -120,7 +120,7 @@ __device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *st
}
}
-__device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
NodeAttributeType type, mesh_type;
AttributeElement elem;
diff --git a/intern/cycles/kernel/svm/svm_blackbody.h b/intern/cycles/kernel/svm/svm_blackbody.h
index 2fc2c770a83..63dbf27d35e 100644
--- a/intern/cycles/kernel/svm/svm_blackbody.h
+++ b/intern/cycles/kernel/svm/svm_blackbody.h
@@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN
/* Blackbody Node */
-__device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset)
+ccl_device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset)
{
/* Output */
float3 color_rgb = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/svm/svm_brick.h b/intern/cycles/kernel/svm/svm_brick.h
index 19b4b5e779f..7cac922d8a6 100644
--- a/intern/cycles/kernel/svm/svm_brick.h
+++ b/intern/cycles/kernel/svm/svm_brick.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Brick */
-__device_noinline float brick_noise(int n) /* fast integer noise */
+ccl_device_noinline float brick_noise(int n) /* fast integer noise */
{
int nn;
n = (n >> 13) ^ n;
@@ -26,7 +26,7 @@ __device_noinline float brick_noise(int n) /* fast integer noise */
return 0.5f * ((float)nn / 1073741824.0f);
}
-__device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, float bias,
+ccl_device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, float bias,
float brick_width, float row_height, float offset_amount, int offset_frequency,
float squash_amount, int squash_frequency)
{
@@ -56,7 +56,7 @@ __device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, flo
y > (row_height - mortar_size)) ? 1.0f : 0.0f);
}
-__device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint4 node3 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_brightness.h b/intern/cycles/kernel/svm/svm_brightness.h
index 3e977dcbe1b..9b330b3213f 100644
--- a/intern/cycles/kernel/svm/svm_brightness.h
+++ b/intern/cycles/kernel/svm/svm_brightness.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node)
+ccl_device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node)
{
uint bright_offset, contrast_offset;
float3 color = stack_load_float3(stack, in_color);
diff --git a/intern/cycles/kernel/svm/svm_camera.h b/intern/cycles/kernel/svm/svm_camera.h
index 76f50e196eb..bfe9289fa02 100644
--- a/intern/cycles/kernel/svm/svm_camera.h
+++ b/intern/cycles/kernel/svm/svm_camera.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_vector, uint out_zdepth, uint out_distance)
+ccl_device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_vector, uint out_zdepth, uint out_distance)
{
float distance;
float zdepth;
diff --git a/intern/cycles/kernel/svm/svm_checker.h b/intern/cycles/kernel/svm/svm_checker.h
index 70fe2ac5a92..ebc48e16d68 100644
--- a/intern/cycles/kernel/svm/svm_checker.h
+++ b/intern/cycles/kernel/svm/svm_checker.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Checker */
-__device_noinline float svm_checker(float3 p, float scale)
+ccl_device_noinline float svm_checker(float3 p, float scale)
{
p *= scale;
@@ -34,7 +34,7 @@ __device_noinline float svm_checker(float3 p, float scale)
return ((xi % 2 == yi % 2) == (zi % 2))? 1.0f: 0.0f;
}
-__device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint co_offset, color1_offset, color2_offset, scale_offset;
uint color_offset, fac_offset;
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index 0d4716ab078..2c6fb5deca4 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Closure Nodes */
-__device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract)
+ccl_device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract)
{
if(type == CLOSURE_BSDF_SHARP_GLASS_ID) {
if(refract) {
@@ -49,7 +49,7 @@ __device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type,
}
}
-__device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, ClosureType type, float mix_weight)
+ccl_device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, ClosureType type, float mix_weight)
{
#ifdef __MULTI_CLOSURE__
ShaderClosure *sc = &sd->closure[sd->num_closure];
@@ -70,7 +70,7 @@ __device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, Clo
#endif
}
-__device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float mix_weight)
+ccl_device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float mix_weight)
{
#ifdef __MULTI_CLOSURE__
ShaderClosure *sc = &sd->closure[sd->num_closure];
@@ -93,7 +93,7 @@ __device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float m
#endif
}
-__device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, float randb, int path_flag, int *offset)
+ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, float randb, int path_flag, int *offset)
{
uint type, param1_offset, param2_offset;
@@ -456,7 +456,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
}
}
-__device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag)
+ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag)
{
uint type, param1_offset, param2_offset;
@@ -499,7 +499,7 @@ __device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *
}
}
-__device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -522,7 +522,7 @@ __device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node
sd->flag |= SD_EMISSION;
}
-__device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -543,7 +543,7 @@ __device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 no
#endif
}
-__device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -566,7 +566,7 @@ __device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
sd->flag |= SD_HOLDOUT;
}
-__device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -591,7 +591,7 @@ __device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, u
/* Closure Nodes */
-__device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
+ccl_device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
{
#ifdef __MULTI_CLOSURE__
if(sd->num_closure < MAX_CLOSURE)
@@ -601,13 +601,13 @@ __device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight
#endif
}
-__device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b)
+ccl_device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b)
{
float3 weight = make_float3(__uint_as_float(r), __uint_as_float(g), __uint_as_float(b));
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *sd, uint r, uint g, uint b)
+ccl_device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *sd, uint r, uint g, uint b)
{
float3 weight = make_float3(__uint_as_float(r), __uint_as_float(g), __uint_as_float(b));
@@ -617,14 +617,14 @@ __device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_closure_weight(ShaderData *sd, float *stack, uint weight_offset)
+ccl_device void svm_node_closure_weight(ShaderData *sd, float *stack, uint weight_offset)
{
float3 weight = stack_load_float3(stack, weight_offset);
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint color_offset = node.y;
uint strength_offset = node.z;
@@ -639,7 +639,7 @@ __device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_mix_closure(ShaderData *sd, float *stack,
+ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack,
uint4 node, int *offset, float *randb)
{
#ifdef __MULTI_CLOSURE__
@@ -675,7 +675,7 @@ __device void svm_node_mix_closure(ShaderData *sd, float *stack,
#endif
}
-__device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused,
+ccl_device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused,
uint node_jump, int *offset, float *randb, float *closure_weight)
{
#ifdef __MULTI_CLOSURE__
@@ -699,7 +699,7 @@ __device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused,
/* (Bump) normal */
-__device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal)
+ccl_device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal)
{
float3 normal = stack_load_float3(stack, in_direction);
sd->N = normal;
diff --git a/intern/cycles/kernel/svm/svm_convert.h b/intern/cycles/kernel/svm/svm_convert.h
index 22f4651689d..2503912c5c6 100644
--- a/intern/cycles/kernel/svm/svm_convert.h
+++ b/intern/cycles/kernel/svm/svm_convert.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Conversion Nodes */
-__device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint from, uint to)
+ccl_device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint from, uint to)
{
switch(type) {
case NODE_CONVERT_FI: {
diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h
index d0bac647a7c..6cd5ee4b375 100644
--- a/intern/cycles/kernel/svm/svm_displace.h
+++ b/intern/cycles/kernel/svm/svm_displace.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Bump Node */
-__device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
#ifdef __RAY_DIFFERENTIALS__
/* get normal input */
@@ -62,7 +62,7 @@ __device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack,
/* Displacement Node */
-__device void svm_node_set_displacement(ShaderData *sd, float *stack, uint fac_offset)
+ccl_device void svm_node_set_displacement(ShaderData *sd, float *stack, uint fac_offset)
{
float d = stack_load_float(stack, fac_offset);
sd->P += sd->N*d*0.1f; /* todo: get rid of this factor */
diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h
index 549c0351d83..0a3d576cfe1 100644
--- a/intern/cycles/kernel/svm/svm_fresnel.h
+++ b/intern/cycles/kernel/svm/svm_fresnel.h
@@ -18,27 +18,33 @@ CCL_NAMESPACE_BEGIN
/* Fresnel Node */
-__device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint out_offset)
+ccl_device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint node)
{
+ uint normal_offset, out_offset;
+ decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL);
float eta = (stack_valid(ior_offset))? stack_load_float(stack, ior_offset): __uint_as_float(ior_value);
+ float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
+
eta = fmaxf(eta, 1.0f + 1e-5f);
eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
- float f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta);
+ float f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta);
stack_store_float(stack, out_offset, f);
}
/* Layer Weight Node */
-__device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
{
uint blend_offset = node.y;
uint blend_value = node.z;
- float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value);
- uint type, out_offset;
- decode_node_uchar4(node.w, &type, &out_offset, NULL, NULL);
+ uint type, normal_offset, out_offset;
+ decode_node_uchar4(node.w, &type, &normal_offset, &out_offset, NULL);
+
+ float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value);
+ float3 normal_in = (stack_valid(normal_offset))? stack_load_float3(stack, normal_offset): sd->N;
float f;
@@ -46,10 +52,10 @@ __device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
float eta = fmaxf(1.0f - blend, 1e-5f);
eta = (sd->flag & SD_BACKFACING)? eta: 1.0f/eta;
- f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta);
+ f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta);
}
else {
- f = fabsf(dot(sd->I, sd->N));
+ f = fabsf(dot(sd->I, normal_in));
if(blend != 0.5f) {
blend = clamp(blend, 0.0f, 1.0f-1e-5f);
diff --git a/intern/cycles/kernel/svm/svm_gamma.h b/intern/cycles/kernel/svm/svm_gamma.h
index ef1581fba8d..c4749e7b936 100644
--- a/intern/cycles/kernel/svm/svm_gamma.h
+++ b/intern/cycles/kernel/svm/svm_gamma.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_gamma(ShaderData *sd, float *stack, uint in_gamma, uint in_color, uint out_color)
+ccl_device void svm_node_gamma(ShaderData *sd, float *stack, uint in_gamma, uint in_color, uint out_color)
{
float3 color = stack_load_float3(stack, in_color);
float gamma = stack_load_float(stack, in_gamma);
diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h
index 818d8694453..ad0cacb027a 100644
--- a/intern/cycles/kernel/svm/svm_geometry.h
+++ b/intern/cycles/kernel/svm/svm_geometry.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Geometry Node */
-__device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
float3 data;
@@ -38,7 +38,7 @@ __device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack,
stack_store_float3(stack, out_offset, data);
}
-__device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -55,7 +55,7 @@ __device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float
#endif
}
-__device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -74,7 +74,7 @@ __device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float
/* Object Info */
-__device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
float data;
@@ -94,7 +94,7 @@ __device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *sta
/* Particle Info */
-__device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
switch(type) {
case NODE_INFO_PAR_INDEX: {
@@ -146,7 +146,7 @@ __device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *s
/* Hair Info */
-__device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
float data;
float3 data3;
diff --git a/intern/cycles/kernel/svm/svm_gradient.h b/intern/cycles/kernel/svm/svm_gradient.h
index 1c0fe511f9b..a4b3c0583f7 100644
--- a/intern/cycles/kernel/svm/svm_gradient.h
+++ b/intern/cycles/kernel/svm/svm_gradient.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Gradient */
-__device float svm_gradient(float3 p, NodeGradientType type)
+ccl_device float svm_gradient(float3 p, NodeGradientType type)
{
float x, y, z;
@@ -57,7 +57,7 @@ __device float svm_gradient(float3 p, NodeGradientType type)
return 0.0f;
}
-__device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node)
{
uint type, co_offset, color_offset, fac_offset;
diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h
index e16fb7582c1..11dfc4f096b 100644
--- a/intern/cycles/kernel/svm/svm_hsv.h
+++ b/intern/cycles/kernel/svm/svm_hsv.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_color_offset, uint fac_offset, uint out_color_offset, int *offset)
+ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_color_offset, uint fac_offset, uint out_color_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index e18fe7c53a7..58e5775265a 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -21,14 +21,14 @@ CCL_NAMESPACE_BEGIN
/* For OpenCL all images are packed in a single array, and we do manual lookup
* and interpolation. */
-__device_inline float4 svm_image_texture_read(KernelGlobals *kg, int offset)
+ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int offset)
{
uchar4 r = kernel_tex_fetch(__tex_image_packed, offset);
float f = 1.0f/255.0f;
return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
}
-__device_inline int svm_image_texture_wrap_periodic(int x, int width)
+ccl_device_inline int svm_image_texture_wrap_periodic(int x, int width)
{
x %= width;
if(x < 0)
@@ -36,19 +36,19 @@ __device_inline int svm_image_texture_wrap_periodic(int x, int width)
return x;
}
-__device_inline int svm_image_texture_wrap_clamp(int x, int width)
+ccl_device_inline int svm_image_texture_wrap_clamp(int x, int width)
{
return clamp(x, 0, width-1);
}
-__device_inline float svm_image_texture_frac(float x, int *ix)
+ccl_device_inline float svm_image_texture_frac(float x, int *ix)
{
int i = float_to_int(x) - ((x < 0.0f)? 1: 0);
*ix = i;
return x - (float)i;
}
-__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
+ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
{
/* first slots are used by float textures, which are not supported here */
if(id < TEX_NUM_FLOAT_IMAGES)
@@ -110,7 +110,7 @@ __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, u
#else
-__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
+ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
{
float4 r;
@@ -257,7 +257,7 @@ __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, u
#endif
-__device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint id = node.y;
uint co_offset, out_offset, alpha_offset, srgb;
@@ -274,7 +274,7 @@ __device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack
stack_store_float(stack, alpha_offset, f.w);
}
-__device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
/* get object space normal */
float3 N = sd->N;
@@ -363,7 +363,7 @@ __device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *s
}
-__device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint id = node.y;
uint co_offset, out_offset, alpha_offset, srgb;
diff --git a/intern/cycles/kernel/svm/svm_invert.h b/intern/cycles/kernel/svm/svm_invert.h
index 4c40afeadd9..eb47e9ad4ab 100644
--- a/intern/cycles/kernel/svm/svm_invert.h
+++ b/intern/cycles/kernel/svm/svm_invert.h
@@ -16,12 +16,12 @@
CCL_NAMESPACE_BEGIN
-__device float invert(float color, float factor)
+ccl_device float invert(float color, float factor)
{
return factor*(1.0f - color) + (1.0f - factor) * color;
}
-__device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color)
+ccl_device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color)
{
float factor = stack_load_float(stack, in_fac);
float3 color = stack_load_float3(stack, in_color);
diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h
index ff6776d751e..e7afa2d2200 100644
--- a/intern/cycles/kernel/svm/svm_light_path.h
+++ b/intern/cycles/kernel/svm/svm_light_path.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Light Path Node */
-__device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint out_offset, int path_flag)
+ccl_device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint out_offset, int path_flag)
{
float info = 0.0f;
@@ -40,7 +40,7 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint
/* Light Falloff Node */
-__device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node)
{
uint strength_offset, out_offset, smooth_offset;
diff --git a/intern/cycles/kernel/svm/svm_magic.h b/intern/cycles/kernel/svm/svm_magic.h
index 7a5eba3f564..b661f5cacf8 100644
--- a/intern/cycles/kernel/svm/svm_magic.h
+++ b/intern/cycles/kernel/svm/svm_magic.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Magic */
-__device_noinline float3 svm_magic(float3 p, int n, float distortion)
+ccl_device_noinline float3 svm_magic(float3 p, int n, float distortion)
{
float x = sinf((p.x + p.y + p.z)*5.0f);
float y = cosf((-p.x + p.y - p.z)*5.0f);
@@ -87,7 +87,7 @@ __device_noinline float3 svm_magic(float3 p, int n, float distortion)
return make_float3(0.5f - x, 0.5f - y, 0.5f - z);
}
-__device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint depth;
uint scale_offset, distortion_offset, co_offset, fac_offset, color_offset;
diff --git a/intern/cycles/kernel/svm/svm_mapping.h b/intern/cycles/kernel/svm/svm_mapping.h
index fcdd92dd575..c9fa8502dd1 100644
--- a/intern/cycles/kernel/svm/svm_mapping.h
+++ b/intern/cycles/kernel/svm/svm_mapping.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Mapping Node */
-__device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
+ccl_device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
{
float3 v = stack_load_float3(stack, vec_offset);
@@ -32,7 +32,7 @@ __device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack,
stack_store_float3(stack, out_offset, r);
}
-__device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
+ccl_device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
{
float3 v = stack_load_float3(stack, vec_offset);
diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h
index d4863dd6216..bb46d443a6b 100644
--- a/intern/cycles/kernel/svm/svm_math.h
+++ b/intern/cycles/kernel/svm/svm_math.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device float svm_math(NodeMath type, float Fac1, float Fac2)
+ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
{
float Fac;
@@ -64,12 +64,12 @@ __device float svm_math(NodeMath type, float Fac1, float Fac2)
return Fac;
}
-__device float average_fac(float3 v)
+ccl_device float average_fac(float3 v)
{
return (fabsf(v.x) + fabsf(v.y) + fabsf(v.z))/3.0f;
}
-__device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, float3 Vector1, float3 Vector2)
+ccl_device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, float3 Vector1, float3 Vector2)
{
if(type == NODE_VECTOR_MATH_ADD) {
*Vector = Vector1 + Vector2;
@@ -104,7 +104,7 @@ __device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, f
/* Nodes */
-__device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint f1_offset, uint f2_offset, int *offset)
+ccl_device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint f1_offset, uint f2_offset, int *offset)
{
NodeMath type = (NodeMath)itype;
float f1 = stack_load_float(stack, f1_offset);
@@ -116,7 +116,7 @@ __device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uin
stack_store_float(stack, node1.y, f);
}
-__device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint v1_offset, uint v2_offset, int *offset)
+ccl_device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint v1_offset, uint v2_offset, int *offset)
{
NodeVectorMath type = (NodeVectorMath)itype;
float3 v1 = stack_load_float3(stack, v1_offset);
diff --git a/intern/cycles/kernel/svm/svm_mix.h b/intern/cycles/kernel/svm/svm_mix.h
index 506f772dba5..0eeb4cf9b05 100644
--- a/intern/cycles/kernel/svm/svm_mix.h
+++ b/intern/cycles/kernel/svm/svm_mix.h
@@ -16,22 +16,22 @@
CCL_NAMESPACE_BEGIN
-__device float3 svm_mix_blend(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_blend(float t, float3 col1, float3 col2)
{
return interp(col1, col2, t);
}
-__device float3 svm_mix_add(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_add(float t, float3 col1, float3 col2)
{
return interp(col1, col1 + col2, t);
}
-__device float3 svm_mix_mul(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_mul(float t, float3 col1, float3 col2)
{
return interp(col1, col1 * col2, t);
}
-__device float3 svm_mix_screen(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_screen(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
float3 one = make_float3(1.0f, 1.0f, 1.0f);
@@ -40,7 +40,7 @@ __device float3 svm_mix_screen(float t, float3 col1, float3 col2)
return one - (tm3 + t*(one - col2))*(one - col1);
}
-__device float3 svm_mix_overlay(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_overlay(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -64,12 +64,12 @@ __device float3 svm_mix_overlay(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_sub(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_sub(float t, float3 col1, float3 col2)
{
return interp(col1, col1 - col2, t);
}
-__device float3 svm_mix_div(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_div(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -82,22 +82,22 @@ __device float3 svm_mix_div(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_diff(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_diff(float t, float3 col1, float3 col2)
{
return interp(col1, fabs(col1 - col2), t);
}
-__device float3 svm_mix_dark(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_dark(float t, float3 col1, float3 col2)
{
return min(col1, col2*t);
}
-__device float3 svm_mix_light(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_light(float t, float3 col1, float3 col2)
{
return max(col1, col2*t);
}
-__device float3 svm_mix_dodge(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_dodge(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
@@ -132,7 +132,7 @@ __device float3 svm_mix_dodge(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_burn(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_burn(float t, float3 col1, float3 col2)
{
float tmp, tm = 1.0f - t;
@@ -171,7 +171,7 @@ __device float3 svm_mix_burn(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_hue(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_hue(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
@@ -188,7 +188,7 @@ __device float3 svm_mix_hue(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_sat(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_sat(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -206,7 +206,7 @@ __device float3 svm_mix_sat(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_val(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_val(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -218,7 +218,7 @@ __device float3 svm_mix_val(float t, float3 col1, float3 col2)
return hsv_to_rgb(hsv);
}
-__device float3 svm_mix_color(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_color(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
float3 hsv2 = rgb_to_hsv(col2);
@@ -235,7 +235,7 @@ __device float3 svm_mix_color(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_soft(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_soft(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -245,7 +245,7 @@ __device float3 svm_mix_soft(float t, float3 col1, float3 col2)
return tm*col1 + t*((one - col1)*col2*col1 + col1*scr);
}
-__device float3 svm_mix_linear(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_linear(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
@@ -267,7 +267,7 @@ __device float3 svm_mix_linear(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_clamp(float3 col)
+ccl_device float3 svm_mix_clamp(float3 col)
{
float3 outcol = col;
@@ -278,7 +278,7 @@ __device float3 svm_mix_clamp(float3 col)
return outcol;
}
-__device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
+ccl_device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
{
float t = clamp(fac, 0.0f, 1.0f);
@@ -309,7 +309,7 @@ __device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
/* Node */
-__device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, uint fac_offset, uint c1_offset, uint c2_offset, int *offset)
+ccl_device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, uint fac_offset, uint c1_offset, uint c2_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_musgrave.h b/intern/cycles/kernel/svm/svm_musgrave.h
index 65dcf1a9f83..c67dc8297e4 100644
--- a/intern/cycles/kernel/svm/svm_musgrave.h
+++ b/intern/cycles/kernel/svm/svm_musgrave.h
@@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN
* from "Texturing and Modelling: A procedural approach"
*/
-__device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
+ccl_device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
{
float rmd;
float value = 0.0f;
@@ -53,7 +53,7 @@ __device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float
* octaves: number of frequencies in the fBm
*/
-__device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
+ccl_device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
{
float rmd;
float value = 1.0f;
@@ -82,7 +82,7 @@ __device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis ba
* offset: raises the terrain from `sea level'
*/
-__device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset)
+ccl_device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset)
{
float value, increment, rmd;
float pwHL = powf(lacunarity, -H);
@@ -117,7 +117,7 @@ __device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis b
* offset: raises the terrain from `sea level'
*/
-__device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
+ccl_device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
{
float result, signal, weight, rmd;
float pwHL = powf(lacunarity, -H);
@@ -154,7 +154,7 @@ __device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseB
* offset: raises the terrain from `sea level'
*/
-__device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
+ccl_device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
{
float result, signal, weight;
float pwHL = powf(lacunarity, -H);
@@ -181,7 +181,7 @@ __device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseB
/* Shader */
-__device float svm_musgrave(NodeMusgraveType type, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float scale, float3 p)
+ccl_device float svm_musgrave(NodeMusgraveType type, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float scale, float3 p)
{
NodeNoiseBasis basis = NODE_NOISE_PERLIN;
p *= scale;
@@ -200,7 +200,7 @@ __device float svm_musgrave(NodeMusgraveType type, float dimension, float lacuna
return 0.0f;
}
-__device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint4 node3 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_noise.h b/intern/cycles/kernel/svm/svm_noise.h
index a55c635b679..2055b0e3ec7 100644
--- a/intern/cycles/kernel/svm/svm_noise.h
+++ b/intern/cycles/kernel/svm/svm_noise.h
@@ -32,17 +32,17 @@
CCL_NAMESPACE_BEGIN
-__device int quick_floor(float x)
+ccl_device int quick_floor(float x)
{
return float_to_int(x) - ((x < 0) ? 1 : 0);
}
-__device float bits_to_01(uint bits)
+ccl_device float bits_to_01(uint bits)
{
return bits * (1.0f/(float)0xFFFFFFFF);
}
-__device uint hash(uint kx, uint ky, uint kz)
+ccl_device uint hash(uint kx, uint ky, uint kz)
{
// define some handy macros
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
@@ -71,34 +71,34 @@ __device uint hash(uint kx, uint ky, uint kz)
#undef final
}
-__device int imod(int a, int b)
+ccl_device int imod(int a, int b)
{
a %= b;
return a < 0 ? a + b : a;
}
-__device uint phash(int kx, int ky, int kz, int3 p)
+ccl_device uint phash(int kx, int ky, int kz, int3 p)
{
return hash(imod(kx, p.x), imod(ky, p.y), imod(kz, p.z));
}
-__device float floorfrac(float x, int* i)
+ccl_device float floorfrac(float x, int* i)
{
*i = quick_floor(x);
return x - *i;
}
-__device float fade(float t)
+ccl_device float fade(float t)
{
return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);
}
-__device float nerp(float t, float a, float b)
+ccl_device float nerp(float t, float a, float b)
{
return (1.0f - t) * a + t * b;
}
-__device float grad(int hash, float x, float y, float z)
+ccl_device float grad(int hash, float x, float y, float z)
{
// use vectors pointing to the edges of the cube
int h = hash & 15;
@@ -107,12 +107,12 @@ __device float grad(int hash, float x, float y, float z)
return ((h&1) ? -u : u) + ((h&2) ? -v : v);
}
-__device float scale3(float result)
+ccl_device float scale3(float result)
{
return 0.9820f * result;
}
-__device_noinline float perlin(float x, float y, float z)
+ccl_device_noinline float perlin(float x, float y, float z)
{
int X; float fx = floorfrac(x, &X);
int Y; float fy = floorfrac(y, &Y);
@@ -138,7 +138,7 @@ __device_noinline float perlin(float x, float y, float z)
return (isfinite(r))? r: 0.0f;
}
-__device_noinline float perlin_periodic(float x, float y, float z, float3 pperiod)
+ccl_device_noinline float perlin_periodic(float x, float y, float z, float3 pperiod)
{
int X; float fx = floorfrac(x, &X);
int Y; float fy = floorfrac(y, &Y);
@@ -171,20 +171,20 @@ __device_noinline float perlin_periodic(float x, float y, float z, float3 pperio
}
/* perlin noise in range 0..1 */
-__device float noise(float3 p)
+ccl_device float noise(float3 p)
{
float r = perlin(p.x, p.y, p.z);
return 0.5f*r + 0.5f;
}
/* perlin noise in range -1..1 */
-__device float snoise(float3 p)
+ccl_device float snoise(float3 p)
{
return perlin(p.x, p.y, p.z);
}
/* cell noise */
-__device_noinline float cellnoise(float3 p)
+ccl_device_noinline float cellnoise(float3 p)
{
uint ix = quick_floor(p.x);
uint iy = quick_floor(p.y);
@@ -193,7 +193,7 @@ __device_noinline float cellnoise(float3 p)
return bits_to_01(hash(ix, iy, iz));
}
-__device float3 cellnoise_color(float3 p)
+ccl_device float3 cellnoise_color(float3 p)
{
float r = cellnoise(p);
float g = cellnoise(make_float3(p.y, p.x, p.z));
@@ -203,14 +203,14 @@ __device float3 cellnoise_color(float3 p)
}
/* periodic perlin noise in range 0..1 */
-__device float pnoise(float3 p, float3 pperiod)
+ccl_device float pnoise(float3 p, float3 pperiod)
{
float r = perlin_periodic(p.x, p.y, p.z, pperiod);
return 0.5f*r + 0.5f;
}
/* periodic perlin noise in range -1..1 */
-__device float psnoise(float3 p, float3 pperiod)
+ccl_device float psnoise(float3 p, float3 pperiod)
{
return perlin_periodic(p.x, p.y, p.z, pperiod);
}
diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h
index acb3f20246e..02583131704 100644
--- a/intern/cycles/kernel/svm/svm_noisetex.h
+++ b/intern/cycles/kernel/svm/svm_noisetex.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Noise */
-__device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color)
+ccl_device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color)
{
NodeNoiseBasis basis = NODE_NOISE_PERLIN;
int hard = 0;
@@ -41,7 +41,7 @@ __device_inline void svm_noise(float3 p, float scale, float detail, float distor
noise_turbulence(make_float3(p.y, p.z, p.x), basis, detail, hard));
}
-__device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint co_offset, scale_offset, detail_offset, distortion_offset, fac_offset, color_offset;
diff --git a/intern/cycles/kernel/svm/svm_normal.h b/intern/cycles/kernel/svm/svm_normal.h
index dd7506bb5fc..8695031b8b9 100644
--- a/intern/cycles/kernel/svm/svm_normal.h
+++ b/intern/cycles/kernel/svm/svm_normal.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset)
+ccl_device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_ramp.h b/intern/cycles/kernel/svm/svm_ramp.h
index 3cb23a2b2dd..55eee3d24c3 100644
--- a/intern/cycles/kernel/svm/svm_ramp.h
+++ b/intern/cycles/kernel/svm/svm_ramp.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool interpolate)
+ccl_device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool interpolate)
{
f = clamp(f, 0.0f, 1.0f)*(RAMP_TABLE_SIZE-1);
@@ -35,7 +35,7 @@ __device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool int
return a;
}
-__device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint fac_offset, color_offset, alpha_offset;
uint interpolate = node.z;
@@ -53,7 +53,7 @@ __device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack,
*offset += RAMP_TABLE_SIZE;
}
-__device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint fac_offset = node.y;
uint color_offset = node.z;
@@ -72,7 +72,7 @@ __device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stac
*offset += RAMP_TABLE_SIZE;
}
-__device void svm_node_vector_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_vector_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint fac_offset = node.y;
uint color_offset = node.z;
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
index 130890fdc8e..0f68ecbea03 100644
--- a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
+++ b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint hue_in, uint saturation_in, uint value_in, int *offset)
+ccl_device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint hue_in, uint saturation_in, uint value_in, int *offset)
{
uint4 node1 = read_node(kg, offset);
uint color_out = node1.y;
@@ -32,7 +32,7 @@ __device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *sta
stack_store_float3(stack, color_out, color);
}
-__device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint color_in, uint hue_out, uint saturation_out, int *offset)
+ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint color_in, uint hue_out, uint saturation_out, int *offset)
{
uint4 node1 = read_node(kg, offset);
uint value_out = node1.y;
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_rgb.h b/intern/cycles/kernel/svm/svm_sepcomb_rgb.h
index 5c3d95435f2..34c4449ecdb 100644
--- a/intern/cycles/kernel/svm/svm_sepcomb_rgb.h
+++ b/intern/cycles/kernel/svm/svm_sepcomb_rgb.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, uint color_index, uint out_offset)
+ccl_device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, uint color_index, uint out_offset)
{
float color = stack_load_float(stack, in_offset);
@@ -24,7 +24,7 @@ __device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset,
stack_store_float(stack, out_offset+color_index, color);
}
-__device void svm_node_separate_rgb(ShaderData *sd, float *stack, uint icolor_offset, uint color_index, uint out_offset)
+ccl_device void svm_node_separate_rgb(ShaderData *sd, float *stack, uint icolor_offset, uint color_index, uint out_offset)
{
float3 color = stack_load_float3(stack, icolor_offset);
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h
index 81b5f1a201f..1e3552647bd 100644
--- a/intern/cycles/kernel/svm/svm_sky.h
+++ b/intern/cycles/kernel/svm/svm_sky.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Sky texture */
-__device float sky_angle_between(float thetav, float phiv, float theta, float phi)
+ccl_device float sky_angle_between(float thetav, float phiv, float theta, float phi)
{
float cospsi = sinf(thetav)*sinf(theta)*cosf(phi - phiv) + cosf(thetav)*cosf(theta);
return safe_acosf(cospsi);
@@ -28,7 +28,7 @@ __device float sky_angle_between(float thetav, float phiv, float theta, float ph
* "A Practical Analytic Model for Daylight"
* A. J. Preetham, Peter Shirley, Brian Smits
*/
-__device float sky_perez_function(float *lam, float theta, float gamma)
+ccl_device float sky_perez_function(float *lam, float theta, float gamma)
{
float ctheta = cosf(theta);
float cgamma = cosf(gamma);
@@ -36,7 +36,7 @@ __device float sky_perez_function(float *lam, float theta, float gamma)
return (1.0f + lam[0]*expf(lam[1]/ctheta)) * (1.0f + lam[2]*expf(lam[3]*gamma) + lam[4]*cgamma*cgamma);
}
-__device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
+ccl_device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
float sunphi, float suntheta,
float radiance_x, float radiance_y, float radiance_z,
float *config_x, float *config_y, float *config_z)
@@ -66,7 +66,7 @@ __device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
* "An Analytic Model for Full Spectral Sky-Dome Radiance"
* Lukas Hosek, Alexander Wilkie
*/
-__device float sky_radiance_internal(float *configuration, float theta, float gamma)
+ccl_device float sky_radiance_internal(float *configuration, float theta, float gamma)
{
float ctheta = cosf(theta);
float cgamma = cosf(gamma);
@@ -80,7 +80,7 @@ __device float sky_radiance_internal(float *configuration, float theta, float ga
(configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
}
-__device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
+ccl_device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
float sunphi, float suntheta,
float radiance_x, float radiance_y, float radiance_z,
float *config_x, float *config_y, float *config_z)
@@ -105,7 +105,7 @@ __device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
return xyz_to_rgb(x, y, z) * (M_2PI_F/683);
}
-__device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
/* Define variables */
float sunphi, suntheta, radiance_x, radiance_y, radiance_z;
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index 9f88389fcb1..3044cbf81e0 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Texture Coordinate Node */
-__device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
{
float3 data;
@@ -78,7 +78,7 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_fla
stack_store_float3(stack, out_offset, data);
}
-__device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -142,7 +142,7 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int
#endif
}
-__device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -206,7 +206,7 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int
#endif
}
-__device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint color_offset, strength_offset, normal_offset, space;
decode_node_uchar4(node.y, &color_offset, &strength_offset, &normal_offset, &space);
@@ -280,7 +280,7 @@ __device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stac
stack_store_float3(stack, normal_offset, N);
}
-__device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint tangent_offset, direction_type, axis;
decode_node_uchar4(node.y, &tangent_offset, &direction_type, &axis, NULL);
diff --git a/intern/cycles/kernel/svm/svm_texture.h b/intern/cycles/kernel/svm/svm_texture.h
index 7f3e09a481d..8ced8390b0b 100644
--- a/intern/cycles/kernel/svm/svm_texture.h
+++ b/intern/cycles/kernel/svm/svm_texture.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Voronoi Distances */
-__device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, float e)
+ccl_device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, float e)
{
#if 0
if(distance_metric == NODE_VORONOI_DISTANCE_SQUARED)
@@ -44,7 +44,7 @@ __device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, fl
/* Voronoi / Worley like */
-__device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2)
+ccl_device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2)
{
float da[4];
float3 pa[4];
@@ -120,29 +120,29 @@ __device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2)
return result;
}
-__device float voronoi_F1(float3 p) { return voronoi_Fn(p, 0.0f, 0, -1).w; }
-__device float voronoi_F2(float3 p) { return voronoi_Fn(p, 0.0f, 1, -1).w; }
-__device float voronoi_F3(float3 p) { return voronoi_Fn(p, 0.0f, 2, -1).w; }
-__device float voronoi_F4(float3 p) { return voronoi_Fn(p, 0.0f, 3, -1).w; }
-__device float voronoi_F1F2(float3 p) { return voronoi_Fn(p, 0.0f, 0, 1).w; }
+ccl_device float voronoi_F1(float3 p) { return voronoi_Fn(p, 0.0f, 0, -1).w; }
+ccl_device float voronoi_F2(float3 p) { return voronoi_Fn(p, 0.0f, 1, -1).w; }
+ccl_device float voronoi_F3(float3 p) { return voronoi_Fn(p, 0.0f, 2, -1).w; }
+ccl_device float voronoi_F4(float3 p) { return voronoi_Fn(p, 0.0f, 3, -1).w; }
+ccl_device float voronoi_F1F2(float3 p) { return voronoi_Fn(p, 0.0f, 0, 1).w; }
-__device float voronoi_Cr(float3 p)
+ccl_device float voronoi_Cr(float3 p)
{
/* crackle type pattern, just a scale/clamp of F2-F1 */
float t = 10.0f*voronoi_F1F2(p);
return (t > 1.0f)? 1.0f: t;
}
-__device float voronoi_F1S(float3 p) { return 2.0f*voronoi_F1(p) - 1.0f; }
-__device float voronoi_F2S(float3 p) { return 2.0f*voronoi_F2(p) - 1.0f; }
-__device float voronoi_F3S(float3 p) { return 2.0f*voronoi_F3(p) - 1.0f; }
-__device float voronoi_F4S(float3 p) { return 2.0f*voronoi_F4(p) - 1.0f; }
-__device float voronoi_F1F2S(float3 p) { return 2.0f*voronoi_F1F2(p) - 1.0f; }
-__device float voronoi_CrS(float3 p) { return 2.0f*voronoi_Cr(p) - 1.0f; }
+ccl_device float voronoi_F1S(float3 p) { return 2.0f*voronoi_F1(p) - 1.0f; }
+ccl_device float voronoi_F2S(float3 p) { return 2.0f*voronoi_F2(p) - 1.0f; }
+ccl_device float voronoi_F3S(float3 p) { return 2.0f*voronoi_F3(p) - 1.0f; }
+ccl_device float voronoi_F4S(float3 p) { return 2.0f*voronoi_F4(p) - 1.0f; }
+ccl_device float voronoi_F1F2S(float3 p) { return 2.0f*voronoi_F1F2(p) - 1.0f; }
+ccl_device float voronoi_CrS(float3 p) { return 2.0f*voronoi_Cr(p) - 1.0f; }
/* Noise Bases */
-__device float noise_basis(float3 p, NodeNoiseBasis basis)
+ccl_device float noise_basis(float3 p, NodeNoiseBasis basis)
{
/* Only Perlin enabled for now, others break CUDA compile by making kernel
* too big, with compile using > 4GB, due to everything being inlined. */
@@ -173,7 +173,7 @@ __device float noise_basis(float3 p, NodeNoiseBasis basis)
/* Soft/Hard Noise */
-__device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard)
+ccl_device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard)
{
float t = noise_basis(p, basis);
return (hard)? fabsf(2.0f*t - 1.0f): t;
@@ -181,7 +181,7 @@ __device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard)
/* Turbulence */
-__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard)
+ccl_device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard)
{
float fscale = 1.0f;
float amp = 1.0f;
diff --git a/intern/cycles/kernel/svm/svm_value.h b/intern/cycles/kernel/svm/svm_value.h
index cd5a2e0d871..7beed065288 100644
--- a/intern/cycles/kernel/svm/svm_value.h
+++ b/intern/cycles/kernel/svm/svm_value.h
@@ -18,12 +18,12 @@ CCL_NAMESPACE_BEGIN
/* Value Nodes */
-__device void svm_node_value_f(KernelGlobals *kg, ShaderData *sd, float *stack, uint ivalue, uint out_offset)
+ccl_device void svm_node_value_f(KernelGlobals *kg, ShaderData *sd, float *stack, uint ivalue, uint out_offset)
{
stack_store_float(stack, out_offset, __uint_as_float(ivalue));
}
-__device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_offset, int *offset)
+ccl_device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_vector_transform.h b/intern/cycles/kernel/svm/svm_vector_transform.h
index 95ef8e3e558..1e3fc2fa03b 100644
--- a/intern/cycles/kernel/svm/svm_vector_transform.h
+++ b/intern/cycles/kernel/svm/svm_vector_transform.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Vector Transform */
-__device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint itype, ifrom, ito;
uint vector_in, vector_out;
diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h
index c9ebea2bceb..604fd3404c5 100644
--- a/intern/cycles/kernel/svm/svm_voronoi.h
+++ b/intern/cycles/kernel/svm/svm_voronoi.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Voronoi */
-__device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, float3 p)
+ccl_device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, float3 p)
{
/* compute distance and point coordinate of 4 nearest neighbours */
float4 dpa0 = voronoi_Fn(p*scale, 1.0f, 0, -1);
@@ -39,7 +39,7 @@ __device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale,
return make_float4(color.x, color.y, color.z, fac);
}
-__device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint coloring = node.y;
uint scale_offset, co_offset, fac_offset, color_offset;
diff --git a/intern/cycles/kernel/svm/svm_wave.h b/intern/cycles/kernel/svm/svm_wave.h
index d906266bcf9..3749135f8c7 100644
--- a/intern/cycles/kernel/svm/svm_wave.h
+++ b/intern/cycles/kernel/svm/svm_wave.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Wave */
-__device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float detail, float distortion, float dscale)
+ccl_device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float detail, float distortion, float dscale)
{
float n;
@@ -35,7 +35,7 @@ __device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float
return 0.5f + 0.5f * sinf(n);
}
-__device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h
index f9dd24dacef..dca4003b89a 100644
--- a/intern/cycles/kernel/svm/svm_wavelength.h
+++ b/intern/cycles/kernel/svm/svm_wavelength.h
@@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN
/* Wavelength to RGB */
-__device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out)
+ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out)
{
// CIE colour matching functions xBar, yBar, and zBar for
// wavelengths from 380 through 780 nanometers, every 5
diff --git a/intern/cycles/kernel/svm/svm_wireframe.h b/intern/cycles/kernel/svm/svm_wireframe.h
index 9ecb81847d7..e560e6303cc 100644
--- a/intern/cycles/kernel/svm/svm_wireframe.h
+++ b/intern/cycles/kernel/svm/svm_wireframe.h
@@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN
/* Wireframe Node */
-__device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_size, uint out_fac, uint use_pixel_size)
+ccl_device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_size, uint out_fac, uint use_pixel_size)
{
/* Input Data */
float size = stack_load_float(stack, in_size);
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 5fb648cec5f..44a050ca530 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -184,6 +184,12 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pixels[0] = (f == 0.0f)? 1e10f: f*scale_exposure;
}
}
+ else if(type == PASS_MIST) {
+ for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
+ float f = *in;
+ pixels[0] = clamp(f*scale_exposure, 0.0f, 1.0f);
+ }
+ }
else {
for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
float f = *in;
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 8ebdf3cc220..dfa737115e2 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -75,7 +75,8 @@ enum ShaderNodeSpecialType {
SHADER_SPECIAL_TYPE_PROXY,
SHADER_SPECIAL_TYPE_MIX_CLOSURE,
SHADER_SPECIAL_TYPE_AUTOCONVERT,
- SHADER_SPECIAL_TYPE_GEOMETRY
+ SHADER_SPECIAL_TYPE_GEOMETRY,
+ SHADER_SPECIAL_TYPE_SCRIPT
};
/* Enum
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 621d52bbbbf..daf75c81396 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3166,12 +3166,17 @@ FresnelNode::FresnelNode()
void FresnelNode::compile(SVMCompiler& compiler)
{
+ ShaderInput *normal_in = input("Normal");
ShaderInput *ior_in = input("IOR");
ShaderOutput *fac_out = output("Fac");
compiler.stack_assign(ior_in);
compiler.stack_assign(fac_out);
- compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), fac_out->stack_offset);
+
+ if(normal_in->link)
+ compiler.stack_assign(normal_in);
+
+ compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), compiler.encode_uchar4(normal_in->stack_offset, fac_out->stack_offset));
}
void FresnelNode::compile(OSLCompiler& compiler)
@@ -3193,8 +3198,12 @@ LayerWeightNode::LayerWeightNode()
void LayerWeightNode::compile(SVMCompiler& compiler)
{
+ ShaderInput *normal_in = input("Normal");
ShaderInput *blend_in = input("Blend");
+ if(normal_in->link)
+ compiler.stack_assign(normal_in);
+
if(blend_in->link)
compiler.stack_assign(blend_in);
@@ -3202,14 +3211,14 @@ void LayerWeightNode::compile(SVMCompiler& compiler)
if(!fresnel_out->links.empty()) {
compiler.stack_assign(fresnel_out);
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
- compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, fresnel_out->stack_offset));
+ compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, normal_in->stack_offset, fresnel_out->stack_offset));
}
ShaderOutput *facing_out = output("Facing");
if(!facing_out->links.empty()) {
compiler.stack_assign(facing_out);
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
- compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, facing_out->stack_offset));
+ compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, normal_in->stack_offset, facing_out->stack_offset));
}
}
@@ -3719,6 +3728,7 @@ void SetNormalNode::compile(OSLCompiler& compiler)
OSLScriptNode::OSLScriptNode()
: ShaderNode("osl_script")
{
+ special_type = SHADER_SPECIAL_TYPE_SCRIPT;
}
void OSLScriptNode::compile(SVMCompiler& compiler)
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index 0479dd9af74..6fb96a3290c 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -253,9 +253,9 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
Transform mtfm_pre = ob->motion.pre;
Transform mtfm_post = ob->motion.post;
- if(!mesh->attributes.find(ATTR_STD_MOTION_PRE))
+ if(!(mesh->attributes.find(ATTR_STD_MOTION_PRE) || mesh->curve_attributes.find(ATTR_STD_MOTION_PRE)))
mtfm_pre = mtfm_pre * itfm;
- if(!mesh->attributes.find(ATTR_STD_MOTION_POST))
+ if(!(mesh->attributes.find(ATTR_STD_MOTION_POST) || mesh->curve_attributes.find(ATTR_STD_MOTION_POST)))
mtfm_post = mtfm_post * itfm;
memcpy(&objects_vector[i*OBJECT_VECTOR_SIZE+0], &mtfm_pre, sizeof(float4)*3);
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 26af60572f6..8dbff224225 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -217,7 +217,6 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
uint shader_flag_size = scene->shaders.size()*4;
uint *shader_flag = dscene->shader_flag.resize(shader_flag_size);
uint i = 0;
- bool has_surface_bssrdf = false;
bool has_converter_blackbody = false;
foreach(Shader *shader, scene->shaders) {
@@ -231,8 +230,6 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
flag |= SD_HAS_VOLUME;
if(shader->homogeneous_volume)
flag |= SD_HOMOGENEOUS_VOLUME;
- if(shader->has_surface_bssrdf)
- has_surface_bssrdf = true;
if(shader->has_bssrdf_bump)
flag |= SD_HAS_BSSRDF_BUMP;
if(shader->has_converter_blackbody)
diff --git a/intern/cycles/render/sky_model.h b/intern/cycles/render/sky_model.h
index 4f0833aef5a..3814543c8b6 100644
--- a/intern/cycles/render/sky_model.h
+++ b/intern/cycles/render/sky_model.h
@@ -136,7 +136,7 @@ and solar radii: 'arhosekskymodelstate_alienworld_alloc_init()'.
See the notes about the "Alien World" functionality provided further down for a
discussion of the usefulness and limits of that second initalisation function.
-Sky model states that have been initialised with either function behave in a
+Sky model states that have been initialized with either function behave in a
completely identical fashion during use and cleanup.
Using the model to generate skydome samples
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index 9bdd5b29a8e..8b13a006673 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -22,7 +22,7 @@
CCL_NAMESPACE_BEGIN
-__device float color_srgb_to_scene_linear(float c)
+ccl_device float color_srgb_to_scene_linear(float c)
{
if(c < 0.04045f)
return (c < 0.0f)? 0.0f: c * (1.0f/12.92f);
@@ -30,7 +30,7 @@ __device float color_srgb_to_scene_linear(float c)
return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
}
-__device float color_scene_linear_to_srgb(float c)
+ccl_device float color_scene_linear_to_srgb(float c)
{
if(c < 0.0031308f)
return (c < 0.0f)? 0.0f: c * 12.92f;
@@ -38,7 +38,7 @@ __device float color_scene_linear_to_srgb(float c)
return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
}
-__device float3 rgb_to_hsv(float3 rgb)
+ccl_device float3 rgb_to_hsv(float3 rgb)
{
float cmax, cmin, h, s, v, cdelta;
float3 c;
@@ -77,7 +77,7 @@ __device float3 rgb_to_hsv(float3 rgb)
return make_float3(h, s, v);
}
-__device float3 hsv_to_rgb(float3 hsv)
+ccl_device float3 hsv_to_rgb(float3 hsv)
{
float i, f, p, q, t, h, s, v;
float3 rgb;
@@ -112,7 +112,7 @@ __device float3 hsv_to_rgb(float3 hsv)
return rgb;
}
-__device float3 xyY_to_xyz(float x, float y, float Y)
+ccl_device float3 xyY_to_xyz(float x, float y, float Y)
{
float X, Z;
@@ -125,7 +125,7 @@ __device float3 xyY_to_xyz(float x, float y, float Y)
return make_float3(X, Y, Z);
}
-__device float3 xyz_to_rgb(float x, float y, float z)
+ccl_device float3 xyz_to_rgb(float x, float y, float z)
{
return make_float3(3.240479f * x + -1.537150f * y + -0.498535f * z,
-0.969256f * x + 1.875991f * y + 0.041556f * z,
@@ -134,7 +134,7 @@ __device float3 xyz_to_rgb(float x, float y, float z)
#ifndef __KERNEL_OPENCL__
-__device float3 color_srgb_to_scene_linear(float3 c)
+ccl_device float3 color_srgb_to_scene_linear(float3 c)
{
return make_float3(
color_srgb_to_scene_linear(c.x),
@@ -142,7 +142,7 @@ __device float3 color_srgb_to_scene_linear(float3 c)
color_srgb_to_scene_linear(c.z));
}
-__device float3 color_scene_linear_to_srgb(float3 c)
+ccl_device float3 color_scene_linear_to_srgb(float3 c)
{
return make_float3(
color_scene_linear_to_srgb(c.x),
@@ -152,7 +152,7 @@ __device float3 color_scene_linear_to_srgb(float3 c)
#endif
-__device float linear_rgb_to_gray(float3 c)
+ccl_device float linear_rgb_to_gray(float3 c)
{
return c.x*0.2126f + c.y*0.7152f + c.z*0.0722f;
}
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 987ef4f17ac..851c67b1189 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -89,12 +89,12 @@ CCL_NAMESPACE_BEGIN
#ifndef __KERNEL_OPENCL__
-__device_inline float fmaxf(float a, float b)
+ccl_device_inline float fmaxf(float a, float b)
{
return (a > b)? a: b;
}
-__device_inline float fminf(float a, float b)
+ccl_device_inline float fminf(float a, float b)
{
return (a < b)? a: b;
}
@@ -105,63 +105,63 @@ __device_inline float fminf(float a, float b)
#ifndef __KERNEL_GPU__
-__device_inline int max(int a, int b)
+ccl_device_inline int max(int a, int b)
{
return (a > b)? a: b;
}
-__device_inline int min(int a, int b)
+ccl_device_inline int min(int a, int b)
{
return (a < b)? a: b;
}
-__device_inline float max(float a, float b)
+ccl_device_inline float max(float a, float b)
{
return (a > b)? a: b;
}
-__device_inline float min(float a, float b)
+ccl_device_inline float min(float a, float b)
{
return (a < b)? a: b;
}
-__device_inline double max(double a, double b)
+ccl_device_inline double max(double a, double b)
{
return (a > b)? a: b;
}
-__device_inline double min(double a, double b)
+ccl_device_inline double min(double a, double b)
{
return (a < b)? a: b;
}
#endif
-__device_inline float min4(float a, float b, float c, float d)
+ccl_device_inline float min4(float a, float b, float c, float d)
{
return min(min(a, b), min(c, d));
}
-__device_inline float max4(float a, float b, float c, float d)
+ccl_device_inline float max4(float a, float b, float c, float d)
{
return max(max(a, b), max(c, d));
}
#ifndef __KERNEL_OPENCL__
-__device_inline int clamp(int a, int mn, int mx)
+ccl_device_inline int clamp(int a, int mn, int mx)
{
return min(max(a, mn), mx);
}
-__device_inline float clamp(float a, float mn, float mx)
+ccl_device_inline float clamp(float a, float mn, float mx)
{
return min(max(a, mn), mx);
}
#endif
-__device_inline int float_to_int(float f)
+ccl_device_inline int float_to_int(float f)
{
#if defined(__KERNEL_SSE2__) && !defined(_MSC_VER)
return _mm_cvtt_ss2si(_mm_load_ss(&f));
@@ -170,22 +170,22 @@ __device_inline int float_to_int(float f)
#endif
}
-__device_inline int floor_to_int(float f)
+ccl_device_inline int floor_to_int(float f)
{
return float_to_int(floorf(f));
}
-__device_inline int ceil_to_int(float f)
+ccl_device_inline int ceil_to_int(float f)
{
return float_to_int(ceilf(f));
}
-__device_inline float signf(float f)
+ccl_device_inline float signf(float f)
{
return (f < 0.0f)? -1.0f: 1.0f;
}
-__device_inline float nonzerof(float f, float eps)
+ccl_device_inline float nonzerof(float f, float eps)
{
if(fabsf(f) < eps)
return signf(f)*eps;
@@ -193,7 +193,7 @@ __device_inline float nonzerof(float f, float eps)
return f;
}
-__device_inline float smoothstepf(float f)
+ccl_device_inline float smoothstepf(float f)
{
float ff = f*f;
return (3.0f*ff - 2.0f*ff*f);
@@ -203,7 +203,7 @@ __device_inline float smoothstepf(float f)
#ifndef __KERNEL_OPENCL__
-__device_inline bool is_zero(const float2 a)
+ccl_device_inline bool is_zero(const float2 a)
{
return (a.x == 0.0f && a.y == 0.0f);
}
@@ -212,7 +212,7 @@ __device_inline bool is_zero(const float2 a)
#ifndef __KERNEL_OPENCL__
-__device_inline float average(const float2 a)
+ccl_device_inline float average(const float2 a)
{
return (a.x + a.y)*(1.0f/2.0f);
}
@@ -221,85 +221,85 @@ __device_inline float average(const float2 a)
#ifndef __KERNEL_OPENCL__
-__device_inline float2 operator-(const float2 a)
+ccl_device_inline float2 operator-(const float2 a)
{
return make_float2(-a.x, -a.y);
}
-__device_inline float2 operator*(const float2 a, const float2 b)
+ccl_device_inline float2 operator*(const float2 a, const float2 b)
{
return make_float2(a.x*b.x, a.y*b.y);
}
-__device_inline float2 operator*(const float2 a, float f)
+ccl_device_inline float2 operator*(const float2 a, float f)
{
return make_float2(a.x*f, a.y*f);
}
-__device_inline float2 operator*(float f, const float2 a)
+ccl_device_inline float2 operator*(float f, const float2 a)
{
return make_float2(a.x*f, a.y*f);
}
-__device_inline float2 operator/(float f, const float2 a)
+ccl_device_inline float2 operator/(float f, const float2 a)
{
return make_float2(f/a.x, f/a.y);
}
-__device_inline float2 operator/(const float2 a, float f)
+ccl_device_inline float2 operator/(const float2 a, float f)
{
float invf = 1.0f/f;
return make_float2(a.x*invf, a.y*invf);
}
-__device_inline float2 operator/(const float2 a, const float2 b)
+ccl_device_inline float2 operator/(const float2 a, const float2 b)
{
return make_float2(a.x/b.x, a.y/b.y);
}
-__device_inline float2 operator+(const float2 a, const float2 b)
+ccl_device_inline float2 operator+(const float2 a, const float2 b)
{
return make_float2(a.x+b.x, a.y+b.y);
}
-__device_inline float2 operator-(const float2 a, const float2 b)
+ccl_device_inline float2 operator-(const float2 a, const float2 b)
{
return make_float2(a.x-b.x, a.y-b.y);
}
-__device_inline float2 operator+=(float2& a, const float2 b)
+ccl_device_inline float2 operator+=(float2& a, const float2 b)
{
return a = a + b;
}
-__device_inline float2 operator*=(float2& a, const float2 b)
+ccl_device_inline float2 operator*=(float2& a, const float2 b)
{
return a = a * b;
}
-__device_inline float2 operator*=(float2& a, float f)
+ccl_device_inline float2 operator*=(float2& a, float f)
{
return a = a * f;
}
-__device_inline float2 operator/=(float2& a, const float2 b)
+ccl_device_inline float2 operator/=(float2& a, const float2 b)
{
return a = a / b;
}
-__device_inline float2 operator/=(float2& a, float f)
+ccl_device_inline float2 operator/=(float2& a, float f)
{
float invf = 1.0f/f;
return a = a * invf;
}
-__device_inline float dot(const float2 a, const float2 b)
+ccl_device_inline float dot(const float2 a, const float2 b)
{
return a.x*b.x + a.y*b.y;
}
-__device_inline float cross(const float2 a, const float2 b)
+ccl_device_inline float cross(const float2 a, const float2 b)
{
return (a.x*b.y - a.y*b.x);
}
@@ -308,58 +308,58 @@ __device_inline float cross(const float2 a, const float2 b)
#ifndef __KERNEL_OPENCL__
-__device_inline bool operator==(const int2 a, const int2 b)
+ccl_device_inline bool operator==(const int2 a, const int2 b)
{
return (a.x == b.x && a.y == b.y);
}
-__device_inline float len(const float2 a)
+ccl_device_inline float len(const float2 a)
{
return sqrtf(dot(a, a));
}
-__device_inline float2 normalize(const float2 a)
+ccl_device_inline float2 normalize(const float2 a)
{
return a/len(a);
}
-__device_inline float2 normalize_len(const float2 a, float *t)
+ccl_device_inline float2 normalize_len(const float2 a, float *t)
{
*t = len(a);
return a/(*t);
}
-__device_inline bool operator==(const float2 a, const float2 b)
+ccl_device_inline bool operator==(const float2 a, const float2 b)
{
return (a.x == b.x && a.y == b.y);
}
-__device_inline bool operator!=(const float2 a, const float2 b)
+ccl_device_inline bool operator!=(const float2 a, const float2 b)
{
return !(a == b);
}
-__device_inline float2 min(float2 a, float2 b)
+ccl_device_inline float2 min(float2 a, float2 b)
{
return make_float2(min(a.x, b.x), min(a.y, b.y));
}
-__device_inline float2 max(float2 a, float2 b)
+ccl_device_inline float2 max(float2 a, float2 b)
{
return make_float2(max(a.x, b.x), max(a.y, b.y));
}
-__device_inline float2 clamp(float2 a, float2 mn, float2 mx)
+ccl_device_inline float2 clamp(float2 a, float2 mn, float2 mx)
{
return min(max(a, mn), mx);
}
-__device_inline float2 fabs(float2 a)
+ccl_device_inline float2 fabs(float2 a)
{
return make_float2(fabsf(a.x), fabsf(a.y));
}
-__device_inline float2 as_float2(const float4 a)
+ccl_device_inline float2 as_float2(const float4 a)
{
return make_float2(a.x, a.y);
}
@@ -368,7 +368,7 @@ __device_inline float2 as_float2(const float4 a)
#ifndef __KERNEL_GPU__
-__device_inline void print_float2(const char *label, const float2& a)
+ccl_device_inline void print_float2(const char *label, const float2& a)
{
printf("%s: %.8f %.8f\n", label, (double)a.x, (double)a.y);
}
@@ -377,7 +377,7 @@ __device_inline void print_float2(const char *label, const float2& a)
#ifndef __KERNEL_OPENCL__
-__device_inline float2 interp(float2 a, float2 b, float t)
+ccl_device_inline float2 interp(float2 a, float2 b, float t)
{
return a + t*(b - a);
}
@@ -388,84 +388,88 @@ __device_inline float2 interp(float2 a, float2 b, float t)
#ifndef __KERNEL_OPENCL__
-__device_inline float3 operator-(const float3 a)
+ccl_device_inline float3 operator-(const float3 a)
{
return make_float3(-a.x, -a.y, -a.z);
}
-__device_inline float3 operator*(const float3 a, const float3 b)
+ccl_device_inline float3 operator*(const float3 a, const float3 b)
{
return make_float3(a.x*b.x, a.y*b.y, a.z*b.z);
}
-__device_inline float3 operator*(const float3 a, float f)
+ccl_device_inline float3 operator*(const float3 a, float f)
{
return make_float3(a.x*f, a.y*f, a.z*f);
}
-__device_inline float3 operator*(float f, const float3 a)
+ccl_device_inline float3 operator*(float f, const float3 a)
{
return make_float3(a.x*f, a.y*f, a.z*f);
}
-__device_inline float3 operator/(float f, const float3 a)
+ccl_device_inline float3 operator/(float f, const float3 a)
{
return make_float3(f/a.x, f/a.y, f/a.z);
}
-__device_inline float3 operator/(const float3 a, float f)
+ccl_device_inline float3 operator/(const float3 a, float f)
{
float invf = 1.0f/f;
return make_float3(a.x*invf, a.y*invf, a.z*invf);
}
-__device_inline float3 operator/(const float3 a, const float3 b)
+ccl_device_inline float3 operator/(const float3 a, const float3 b)
{
return make_float3(a.x/b.x, a.y/b.y, a.z/b.z);
}
-__device_inline float3 operator+(const float3 a, const float3 b)
+ccl_device_inline float3 operator+(const float3 a, const float3 b)
{
return make_float3(a.x+b.x, a.y+b.y, a.z+b.z);
}
-__device_inline float3 operator-(const float3 a, const float3 b)
+ccl_device_inline float3 operator-(const float3 a, const float3 b)
{
return make_float3(a.x-b.x, a.y-b.y, a.z-b.z);
}
-__device_inline float3 operator+=(float3& a, const float3 b)
+ccl_device_inline float3 operator+=(float3& a, const float3 b)
{
return a = a + b;
}
-__device_inline float3 operator*=(float3& a, const float3 b)
+ccl_device_inline float3 operator*=(float3& a, const float3 b)
{
return a = a * b;
}
-__device_inline float3 operator*=(float3& a, float f)
+ccl_device_inline float3 operator*=(float3& a, float f)
{
return a = a * f;
}
-__device_inline float3 operator/=(float3& a, const float3 b)
+ccl_device_inline float3 operator/=(float3& a, const float3 b)
{
return a = a / b;
}
-__device_inline float3 operator/=(float3& a, float f)
+ccl_device_inline float3 operator/=(float3& a, float f)
{
float invf = 1.0f/f;
return a = a * invf;
}
-__device_inline float dot(const float3 a, const float3 b)
+ccl_device_inline float dot(const float3 a, const float3 b)
{
+#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
+ return _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7F));
+#else
return a.x*b.x + a.y*b.y + a.z*b.z;
+#endif
}
-__device_inline float3 cross(const float3 a, const float3 b)
+ccl_device_inline float3 cross(const float3 a, const float3 b)
{
float3 r = make_float3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x);
return r;
@@ -473,26 +477,35 @@ __device_inline float3 cross(const float3 a, const float3 b)
#endif
-__device_inline float len(const float3 a)
+ccl_device_inline float len(const float3 a)
{
+#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
+ return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(a.m128, a.m128, 0x7F)));
+#else
return sqrtf(dot(a, a));
+#endif
}
-__device_inline float len_squared(const float3 a)
+ccl_device_inline float len_squared(const float3 a)
{
return dot(a, a);
}
#ifndef __KERNEL_OPENCL__
-__device_inline float3 normalize(const float3 a)
+ccl_device_inline float3 normalize(const float3 a)
{
+#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
+ __m128 norm = _mm_sqrt_ps(_mm_dp_ps(a.m128, a.m128, 0x7F));
+ return _mm_div_ps(a.m128, norm);
+#else
return a/len(a);
+#endif
}
#endif
-__device_inline float3 normalize_len(const float3 a, float *t)
+ccl_device_inline float3 normalize_len(const float3 a, float *t)
{
*t = len(a);
return a/(*t);
@@ -500,7 +513,7 @@ __device_inline float3 normalize_len(const float3 a, float *t)
#ifndef __KERNEL_OPENCL__
-__device_inline bool operator==(const float3 a, const float3 b)
+ccl_device_inline bool operator==(const float3 a, const float3 b)
{
#ifdef __KERNEL_SSE__
return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 7) == 7;
@@ -509,12 +522,12 @@ __device_inline bool operator==(const float3 a, const float3 b)
#endif
}
-__device_inline bool operator!=(const float3 a, const float3 b)
+ccl_device_inline bool operator!=(const float3 a, const float3 b)
{
return !(a == b);
}
-__device_inline float3 min(float3 a, float3 b)
+ccl_device_inline float3 min(float3 a, float3 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_ps(a.m128, b.m128);
@@ -523,7 +536,7 @@ __device_inline float3 min(float3 a, float3 b)
#endif
}
-__device_inline float3 max(float3 a, float3 b)
+ccl_device_inline float3 max(float3 a, float3 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_ps(a.m128, b.m128);
@@ -532,12 +545,12 @@ __device_inline float3 max(float3 a, float3 b)
#endif
}
-__device_inline float3 clamp(float3 a, float3 mn, float3 mx)
+ccl_device_inline float3 clamp(float3 a, float3 mn, float3 mx)
{
return min(max(a, mn), mx);
}
-__device_inline float3 fabs(float3 a)
+ccl_device_inline float3 fabs(float3 a)
{
#ifdef __KERNEL_SSE__
__m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));
@@ -549,29 +562,29 @@ __device_inline float3 fabs(float3 a)
#endif
-__device_inline float3 float2_to_float3(const float2 a)
+ccl_device_inline float3 float2_to_float3(const float2 a)
{
return make_float3(a.x, a.y, 0.0f);
}
-__device_inline float3 float4_to_float3(const float4 a)
+ccl_device_inline float3 float4_to_float3(const float4 a)
{
return make_float3(a.x, a.y, a.z);
}
-__device_inline float4 float3_to_float4(const float3 a)
+ccl_device_inline float4 float3_to_float4(const float3 a)
{
return make_float4(a.x, a.y, a.z, 1.0f);
}
#ifndef __KERNEL_GPU__
-__device_inline void print_float3(const char *label, const float3& a)
+ccl_device_inline void print_float3(const char *label, const float3& a)
{
printf("%s: %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z);
}
-__device_inline float3 rcp(const float3& a)
+ccl_device_inline float3 rcp(const float3& a)
{
#ifdef __KERNEL_SSE__
float4 r = _mm_rcp_ps(a.m128);
@@ -583,12 +596,12 @@ __device_inline float3 rcp(const float3& a)
#endif
-__device_inline float3 interp(float3 a, float3 b, float t)
+ccl_device_inline float3 interp(float3 a, float3 b, float t)
{
return a + t*(b - a);
}
-__device_inline bool is_zero(const float3 a)
+ccl_device_inline bool is_zero(const float3 a)
{
#ifdef __KERNEL_SSE__
return a == make_float3(0.0f);
@@ -597,7 +610,7 @@ __device_inline bool is_zero(const float3 a)
#endif
}
-__device_inline float reduce_add(const float3 a)
+ccl_device_inline float reduce_add(const float3 a)
{
#ifdef __KERNEL_SSE__
return (a.x + a.y + a.z);
@@ -606,7 +619,7 @@ __device_inline float reduce_add(const float3 a)
#endif
}
-__device_inline float average(const float3 a)
+ccl_device_inline float average(const float3 a)
{
return reduce_add(a)*(1.0f/3.0f);
}
@@ -639,7 +652,7 @@ template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& b)
#ifndef __KERNEL_OPENCL__
-__device_inline float4 operator-(const float4& a)
+ccl_device_inline float4 operator-(const float4& a)
{
#ifdef __KERNEL_SSE__
__m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
@@ -649,7 +662,7 @@ __device_inline float4 operator-(const float4& a)
#endif
}
-__device_inline float4 operator*(const float4& a, const float4& b)
+ccl_device_inline float4 operator*(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_mul_ps(a.m128, b.m128);
@@ -658,7 +671,7 @@ __device_inline float4 operator*(const float4& a, const float4& b)
#endif
}
-__device_inline float4 operator*(const float4& a, float f)
+ccl_device_inline float4 operator*(const float4& a, float f)
{
#ifdef __KERNEL_SSE__
return a * make_float4(f);
@@ -667,12 +680,12 @@ __device_inline float4 operator*(const float4& a, float f)
#endif
}
-__device_inline float4 operator*(float f, const float4& a)
+ccl_device_inline float4 operator*(float f, const float4& a)
{
return a * f;
}
-__device_inline float4 rcp(const float4& a)
+ccl_device_inline float4 rcp(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 r = _mm_rcp_ps(a.m128);
@@ -682,12 +695,12 @@ __device_inline float4 rcp(const float4& a)
#endif
}
-__device_inline float4 operator/(const float4& a, float f)
+ccl_device_inline float4 operator/(const float4& a, float f)
{
return a * (1.0f/f);
}
-__device_inline float4 operator/(const float4& a, const float4& b)
+ccl_device_inline float4 operator/(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return a * rcp(b);
@@ -697,7 +710,7 @@ __device_inline float4 operator/(const float4& a, const float4& b)
}
-__device_inline float4 operator+(const float4& a, const float4& b)
+ccl_device_inline float4 operator+(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_add_ps(a.m128, b.m128);
@@ -706,7 +719,7 @@ __device_inline float4 operator+(const float4& a, const float4& b)
#endif
}
-__device_inline float4 operator-(const float4& a, const float4& b)
+ccl_device_inline float4 operator-(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_sub_ps(a.m128, b.m128);
@@ -715,22 +728,22 @@ __device_inline float4 operator-(const float4& a, const float4& b)
#endif
}
-__device_inline float4 operator+=(float4& a, const float4& b)
+ccl_device_inline float4 operator+=(float4& a, const float4& b)
{
return a = a + b;
}
-__device_inline float4 operator*=(float4& a, const float4& b)
+ccl_device_inline float4 operator*=(float4& a, const float4& b)
{
return a = a * b;
}
-__device_inline float4 operator/=(float4& a, float f)
+ccl_device_inline float4 operator/=(float4& a, float f)
{
return a = a / f;
}
-__device_inline int4 operator<(const float4& a, const float4& b)
+ccl_device_inline int4 operator<(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmplt_ps(a.m128, b.m128)); /* todo: avoid cvt */
@@ -739,7 +752,7 @@ __device_inline int4 operator<(const float4& a, const float4& b)
#endif
}
-__device_inline int4 operator>=(float4 a, float4 b)
+ccl_device_inline int4 operator>=(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmpge_ps(a.m128, b.m128)); /* todo: avoid cvt */
@@ -748,7 +761,7 @@ __device_inline int4 operator>=(float4 a, float4 b)
#endif
}
-__device_inline int4 operator<=(const float4& a, const float4& b)
+ccl_device_inline int4 operator<=(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmple_ps(a.m128, b.m128)); /* todo: avoid cvt */
@@ -757,7 +770,7 @@ __device_inline int4 operator<=(const float4& a, const float4& b)
#endif
}
-__device_inline bool operator==(const float4 a, const float4 b)
+ccl_device_inline bool operator==(const float4 a, const float4 b)
{
#ifdef __KERNEL_SSE__
return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 15) == 15;
@@ -766,7 +779,7 @@ __device_inline bool operator==(const float4 a, const float4 b)
#endif
}
-__device_inline float4 cross(const float4& a, const float4& b)
+ccl_device_inline float4 cross(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return (shuffle<1,2,0,0>(a)*shuffle<2,0,1,0>(b)) - (shuffle<2,0,1,0>(a)*shuffle<1,2,0,0>(b));
@@ -775,7 +788,7 @@ __device_inline float4 cross(const float4& a, const float4& b)
#endif
}
-__device_inline bool is_zero(const float4& a)
+ccl_device_inline bool is_zero(const float4& a)
{
#ifdef __KERNEL_SSE__
return a == make_float4(0.0f);
@@ -784,7 +797,7 @@ __device_inline bool is_zero(const float4& a)
#endif
}
-__device_inline float reduce_add(const float4& a)
+ccl_device_inline float reduce_add(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = shuffle<1,0,3,2>(a) + a;
@@ -794,27 +807,27 @@ __device_inline float reduce_add(const float4& a)
#endif
}
-__device_inline float average(const float4& a)
+ccl_device_inline float average(const float4& a)
{
return reduce_add(a) * 0.25f;
}
-__device_inline float dot(const float4& a, const float4& b)
+ccl_device_inline float dot(const float4& a, const float4& b)
{
return reduce_add(a * b);
}
-__device_inline float len(const float4 a)
+ccl_device_inline float len(const float4 a)
{
return sqrtf(dot(a, a));
}
-__device_inline float4 normalize(const float4 a)
+ccl_device_inline float4 normalize(const float4 a)
{
return a/len(a);
}
-__device_inline float4 min(float4 a, float4 b)
+ccl_device_inline float4 min(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_ps(a.m128, b.m128);
@@ -823,7 +836,7 @@ __device_inline float4 min(float4 a, float4 b)
#endif
}
-__device_inline float4 max(float4 a, float4 b)
+ccl_device_inline float4 max(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_ps(a.m128, b.m128);
@@ -836,7 +849,7 @@ __device_inline float4 max(float4 a, float4 b)
#ifndef __KERNEL_GPU__
-__device_inline float4 select(const int4& mask, const float4& a, const float4& b)
+ccl_device_inline float4 select(const int4& mask, const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
/* blendv is sse4, and apparently broken on vs2008 */
@@ -846,7 +859,7 @@ __device_inline float4 select(const int4& mask, const float4& a, const float4& b
#endif
}
-__device_inline float4 reduce_min(const float4& a)
+ccl_device_inline float4 reduce_min(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = min(shuffle<1,0,3,2>(a), a);
@@ -856,7 +869,7 @@ __device_inline float4 reduce_min(const float4& a)
#endif
}
-__device_inline float4 reduce_max(const float4& a)
+ccl_device_inline float4 reduce_max(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = max(shuffle<1,0,3,2>(a), a);
@@ -867,7 +880,7 @@ __device_inline float4 reduce_max(const float4& a)
}
#if 0
-__device_inline float4 reduce_add(const float4& a)
+ccl_device_inline float4 reduce_add(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = shuffle<1,0,3,2>(a) + a;
@@ -878,7 +891,7 @@ __device_inline float4 reduce_add(const float4& a)
}
#endif
-__device_inline void print_float4(const char *label, const float4& a)
+ccl_device_inline void print_float4(const char *label, const float4& a)
{
printf("%s: %.8f %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z, (double)a.w);
}
@@ -889,7 +902,7 @@ __device_inline void print_float4(const char *label, const float4& a)
#ifndef __KERNEL_OPENCL__
-__device_inline int3 min(int3 a, int3 b)
+ccl_device_inline int3 min(int3 a, int3 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_epi32(a.m128, b.m128);
@@ -898,7 +911,7 @@ __device_inline int3 min(int3 a, int3 b)
#endif
}
-__device_inline int3 max(int3 a, int3 b)
+ccl_device_inline int3 max(int3 a, int3 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_epi32(a.m128, b.m128);
@@ -907,7 +920,7 @@ __device_inline int3 max(int3 a, int3 b)
#endif
}
-__device_inline int3 clamp(const int3& a, int mn, int mx)
+ccl_device_inline int3 clamp(const int3& a, int mn, int mx)
{
#ifdef __KERNEL_SSE__
return min(max(a, make_int3(mn)), make_int3(mx));
@@ -916,7 +929,7 @@ __device_inline int3 clamp(const int3& a, int mn, int mx)
#endif
}
-__device_inline int3 clamp(const int3& a, int3& mn, int mx)
+ccl_device_inline int3 clamp(const int3& a, int3& mn, int mx)
{
#ifdef __KERNEL_SSE__
return min(max(a, mn), make_int3(mx));
@@ -929,7 +942,7 @@ __device_inline int3 clamp(const int3& a, int3& mn, int mx)
#ifndef __KERNEL_GPU__
-__device_inline void print_int3(const char *label, const int3& a)
+ccl_device_inline void print_int3(const char *label, const int3& a)
{
printf("%s: %d %d %d\n", label, a.x, a.y, a.z);
}
@@ -940,7 +953,7 @@ __device_inline void print_int3(const char *label, const int3& a)
#ifndef __KERNEL_GPU__
-__device_inline int4 operator+(const int4& a, const int4& b)
+ccl_device_inline int4 operator+(const int4& a, const int4& b)
{
#ifdef __KERNEL_SSE__
return _mm_add_epi32(a.m128, b.m128);
@@ -949,12 +962,12 @@ __device_inline int4 operator+(const int4& a, const int4& b)
#endif
}
-__device_inline int4 operator+=(int4& a, const int4& b)
+ccl_device_inline int4 operator+=(int4& a, const int4& b)
{
return a = a + b;
}
-__device_inline int4 operator>>(const int4& a, int i)
+ccl_device_inline int4 operator>>(const int4& a, int i)
{
#ifdef __KERNEL_SSE__
return _mm_srai_epi32(a.m128, i);
@@ -963,7 +976,7 @@ __device_inline int4 operator>>(const int4& a, int i)
#endif
}
-__device_inline int4 min(int4 a, int4 b)
+ccl_device_inline int4 min(int4 a, int4 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_epi32(a.m128, b.m128);
@@ -972,7 +985,7 @@ __device_inline int4 min(int4 a, int4 b)
#endif
}
-__device_inline int4 max(int4 a, int4 b)
+ccl_device_inline int4 max(int4 a, int4 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_epi32(a.m128, b.m128);
@@ -981,12 +994,12 @@ __device_inline int4 max(int4 a, int4 b)
#endif
}
-__device_inline int4 clamp(const int4& a, const int4& mn, const int4& mx)
+ccl_device_inline int4 clamp(const int4& a, const int4& mn, const int4& mx)
{
return min(max(a, mn), mx);
}
-__device_inline int4 select(const int4& mask, const int4& a, const int4& b)
+ccl_device_inline int4 select(const int4& mask, const int4& a, const int4& b)
{
#ifdef __KERNEL_SSE__
__m128 m = _mm_cvtepi32_ps(mask);
@@ -996,7 +1009,7 @@ __device_inline int4 select(const int4& mask, const int4& a, const int4& b)
#endif
}
-__device_inline void print_int4(const char *label, const int4& a)
+ccl_device_inline void print_int4(const char *label, const int4& a)
{
printf("%s: %d %d %d %d\n", label, a.x, a.y, a.z, a.w);
}
@@ -1007,49 +1020,49 @@ __device_inline void print_int4(const char *label, const int4& a)
#ifndef __KERNEL_OPENCL__
-__device_inline int as_int(uint i)
+ccl_device_inline int as_int(uint i)
{
union { uint ui; int i; } u;
u.ui = i;
return u.i;
}
-__device_inline uint as_uint(int i)
+ccl_device_inline uint as_uint(int i)
{
union { uint ui; int i; } u;
u.i = i;
return u.ui;
}
-__device_inline uint as_uint(float f)
+ccl_device_inline uint as_uint(float f)
{
union { uint i; float f; } u;
u.f = f;
return u.i;
}
-__device_inline int __float_as_int(float f)
+ccl_device_inline int __float_as_int(float f)
{
union { int i; float f; } u;
u.f = f;
return u.i;
}
-__device_inline float __int_as_float(int i)
+ccl_device_inline float __int_as_float(int i)
{
union { int i; float f; } u;
u.i = i;
return u.f;
}
-__device_inline uint __float_as_uint(float f)
+ccl_device_inline uint __float_as_uint(float f)
{
union { uint i; float f; } u;
u.f = f;
return u.i;
}
-__device_inline float __uint_as_float(uint i)
+ccl_device_inline float __uint_as_float(uint i)
{
union { uint i; float f; } u;
u.i = i;
@@ -1065,7 +1078,7 @@ template<class A, class B> A lerp(const A& a, const A& b, const B& t)
/* Triangle */
-__device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3)
+ccl_device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3)
{
return len(cross(v3 - v2, v1 - v2))*0.5f;
}
@@ -1074,7 +1087,7 @@ __device_inline float triangle_area(const float3 v1, const float3 v2, const floa
/* Orthonormal vectors */
-__device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b)
+ccl_device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b)
{
#if 0
if(fabsf(N.y) >= 0.999f) {
@@ -1100,7 +1113,7 @@ __device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b)
/* Color division */
-__device_inline float3 safe_divide_color(float3 a, float3 b)
+ccl_device_inline float3 safe_divide_color(float3 a, float3 b)
{
float x, y, z;
@@ -1111,7 +1124,7 @@ __device_inline float3 safe_divide_color(float3 a, float3 b)
return make_float3(x, y, z);
}
-__device_inline float3 safe_divide_even_color(float3 a, float3 b)
+ccl_device_inline float3 safe_divide_even_color(float3 a, float3 b)
{
float x, y, z;
@@ -1149,7 +1162,7 @@ __device_inline float3 safe_divide_even_color(float3 a, float3 b)
/* Rotation of point around axis and angle */
-__device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
+ccl_device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
{
float costheta = cosf(angle);
float sintheta = sinf(angle);
@@ -1172,12 +1185,12 @@ __device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
/* NaN-safe math ops */
-__device_inline float safe_sqrtf(float f)
+ccl_device_inline float safe_sqrtf(float f)
{
return sqrtf(max(f, 0.0f));
}
-__device float safe_asinf(float a)
+ccl_device float safe_asinf(float a)
{
if(a <= -1.0f)
return -M_PI_2_F;
@@ -1187,7 +1200,7 @@ __device float safe_asinf(float a)
return asinf(a);
}
-__device float safe_acosf(float a)
+ccl_device float safe_acosf(float a)
{
if(a <= -1.0f)
return M_PI_F;
@@ -1197,7 +1210,7 @@ __device float safe_acosf(float a)
return acosf(a);
}
-__device float compatible_powf(float x, float y)
+ccl_device float compatible_powf(float x, float y)
{
/* GPU pow doesn't accept negative x, do manual checks here */
if(x < 0.0f) {
@@ -1212,7 +1225,7 @@ __device float compatible_powf(float x, float y)
return powf(x, y);
}
-__device float safe_powf(float a, float b)
+ccl_device float safe_powf(float a, float b)
{
if(b == 0.0f)
return 1.0f;
@@ -1224,7 +1237,7 @@ __device float safe_powf(float a, float b)
return compatible_powf(a, b);
}
-__device float safe_logf(float a, float b)
+ccl_device float safe_logf(float a, float b)
{
if(a < 0.0f || b < 0.0f)
return 0.0f;
@@ -1232,19 +1245,19 @@ __device float safe_logf(float a, float b)
return logf(a)/logf(b);
}
-__device float safe_divide(float a, float b)
+ccl_device float safe_divide(float a, float b)
{
return (b != 0.0f)? a/b: 0.0f;
}
-__device float safe_modulo(float a, float b)
+ccl_device float safe_modulo(float a, float b)
{
return (b != 0.0f)? fmodf(a, b): 0.0f;
}
/* Ray Intersection */
-__device bool ray_sphere_intersect(
+ccl_device bool ray_sphere_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 sphere_P, float sphere_radius,
float3 *isect_P, float *isect_t)
@@ -1276,7 +1289,7 @@ __device bool ray_sphere_intersect(
return false;
}
-__device bool ray_aligned_disk_intersect(
+ccl_device bool ray_aligned_disk_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 disk_P, float disk_radius,
float3 *isect_P, float *isect_t)
@@ -1305,7 +1318,7 @@ __device bool ray_aligned_disk_intersect(
return true;
}
-__device bool ray_triangle_intersect(
+ccl_device bool ray_triangle_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 v0, float3 v1, float3 v2,
float3 *isect_P, float *isect_t)
@@ -1348,7 +1361,7 @@ __device bool ray_triangle_intersect(
return true;
}
-__device bool ray_quad_intersect(
+ccl_device bool ray_quad_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 quad_P, float3 quad_u, float3 quad_v,
float3 *isect_P, float *isect_t)
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 345c76bdfab..8b249106913 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -195,6 +195,11 @@ bool system_cpu_support_sse3()
return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3;
}
+bool system_cpu_support_sse41()
+{
+ CPUCapabilities& caps = system_cpu_capabilities();
+ return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3 && caps.sse41;
+}
#else
bool system_cpu_support_sse2()
diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h
index 333782c2d01..64cfa4906b3 100644
--- a/intern/cycles/util/util_system.h
+++ b/intern/cycles/util/util_system.h
@@ -26,6 +26,7 @@ string system_cpu_brand_string();
int system_cpu_bits();
bool system_cpu_support_sse2();
bool system_cpu_support_sse3();
+bool system_cpu_support_sse41();
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index e5a5ac8cddf..14a81ecbb05 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -136,7 +136,7 @@ void TaskPool::stop()
assert(num == 0);
}
-bool TaskPool::cancelled()
+bool TaskPool::canceled()
{
return do_cancel;
}
@@ -366,7 +366,7 @@ void DedicatedTaskPool::stop()
assert(num == 0);
}
-bool DedicatedTaskPool::cancelled()
+bool DedicatedTaskPool::canceled()
{
return do_cancel;
}
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h
index 22515e3e433..42a1e2f5a58 100644
--- a/intern/cycles/util/util_task.h
+++ b/intern/cycles/util/util_task.h
@@ -66,7 +66,7 @@ public:
void cancel(); /* cancel all tasks, keep worker threads running */
void stop(); /* stop all worker threads */
- bool cancelled(); /* for worker threads, test if cancelled */
+ bool canceled(); /* for worker threads, test if canceled */
protected:
friend class TaskScheduler;
@@ -142,7 +142,7 @@ public:
void cancel(); /* cancel all tasks, keep worker thread running */
void stop(); /* stop worker thread */
- bool cancelled(); /* for worker thread, test if cancelled */
+ bool canceled(); /* for worker thread, test if canceled */
protected:
void num_decrease(int done);
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index 01655bdf9bc..1b6315ba484 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -43,7 +43,7 @@ typedef struct Transform {
*
* For the DecompMotionTransform we drop scale from pre/post. */
-typedef struct __may_alias MotionTransform {
+typedef struct ccl_may_alias MotionTransform {
Transform pre;
Transform mid;
Transform post;
@@ -57,7 +57,7 @@ typedef struct DecompMotionTransform {
/* Functions */
-__device_inline float3 transform_perspective(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_perspective(const Transform *t, const float3 a)
{
float4 b = make_float4(a.x, a.y, a.z, 1.0f);
float3 c = make_float3(dot(t->x, b), dot(t->y, b), dot(t->z, b));
@@ -66,7 +66,7 @@ __device_inline float3 transform_perspective(const Transform *t, const float3 a)
return (w != 0.0f)? c/w: make_float3(0.0f, 0.0f, 0.0f);
}
-__device_inline float3 transform_point(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_point(const Transform *t, const float3 a)
{
float3 c = make_float3(
a.x*t->x.x + a.y*t->x.y + a.z*t->x.z + t->x.w,
@@ -76,7 +76,7 @@ __device_inline float3 transform_point(const Transform *t, const float3 a)
return c;
}
-__device_inline float3 transform_direction(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_direction(const Transform *t, const float3 a)
{
float3 c = make_float3(
a.x*t->x.x + a.y*t->x.y + a.z*t->x.z,
@@ -86,7 +86,7 @@ __device_inline float3 transform_direction(const Transform *t, const float3 a)
return c;
}
-__device_inline float3 transform_direction_transposed(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_direction_transposed(const Transform *t, const float3 a)
{
float3 x = make_float3(t->x.x, t->y.x, t->z.x);
float3 y = make_float3(t->x.y, t->y.y, t->z.y);
@@ -95,7 +95,7 @@ __device_inline float3 transform_direction_transposed(const Transform *t, const
return make_float3(dot(x, a), dot(y, a), dot(z, a));
}
-__device_inline Transform transform_transpose(const Transform a)
+ccl_device_inline Transform transform_transpose(const Transform a)
{
Transform t;
@@ -107,7 +107,7 @@ __device_inline Transform transform_transpose(const Transform a)
return t;
}
-__device_inline Transform make_transform(float a, float b, float c, float d,
+ccl_device_inline Transform make_transform(float a, float b, float c, float d,
float e, float f, float g, float h,
float i, float j, float k, float l,
float m, float n, float o, float p)
@@ -124,7 +124,7 @@ __device_inline Transform make_transform(float a, float b, float c, float d,
#ifndef __KERNEL_GPU__
-__device_inline Transform operator*(const Transform a, const Transform b)
+ccl_device_inline Transform operator*(const Transform a, const Transform b)
{
Transform c = transform_transpose(b);
Transform t;
@@ -137,7 +137,7 @@ __device_inline Transform operator*(const Transform a, const Transform b)
return t;
}
-__device_inline void print_transform(const char *label, const Transform& t)
+ccl_device_inline void print_transform(const char *label, const Transform& t)
{
print_float4(label, t.x);
print_float4(label, t.y);
@@ -146,7 +146,7 @@ __device_inline void print_transform(const char *label, const Transform& t)
printf("\n");
}
-__device_inline Transform transform_translate(float3 t)
+ccl_device_inline Transform transform_translate(float3 t)
{
return make_transform(
1, 0, 0, t.x,
@@ -155,12 +155,12 @@ __device_inline Transform transform_translate(float3 t)
0, 0, 0, 1);
}
-__device_inline Transform transform_translate(float x, float y, float z)
+ccl_device_inline Transform transform_translate(float x, float y, float z)
{
return transform_translate(make_float3(x, y, z));
}
-__device_inline Transform transform_scale(float3 s)
+ccl_device_inline Transform transform_scale(float3 s)
{
return make_transform(
s.x, 0, 0, 0,
@@ -169,12 +169,12 @@ __device_inline Transform transform_scale(float3 s)
0, 0, 0, 1);
}
-__device_inline Transform transform_scale(float x, float y, float z)
+ccl_device_inline Transform transform_scale(float x, float y, float z)
{
return transform_scale(make_float3(x, y, z));
}
-__device_inline Transform transform_perspective(float fov, float n, float f)
+ccl_device_inline Transform transform_perspective(float fov, float n, float f)
{
Transform persp = make_transform(
1, 0, 0, 0,
@@ -189,7 +189,7 @@ __device_inline Transform transform_perspective(float fov, float n, float f)
return scale * persp;
}
-__device_inline Transform transform_rotate(float angle, float3 axis)
+ccl_device_inline Transform transform_rotate(float angle, float3 axis)
{
float s = sinf(angle);
float c = cosf(angle);
@@ -216,7 +216,7 @@ __device_inline Transform transform_rotate(float angle, float3 axis)
0.0f, 0.0f, 0.0f, 1.0f);
}
-__device_inline Transform transform_euler(float3 euler)
+ccl_device_inline Transform transform_euler(float3 euler)
{
return
transform_rotate(euler.x, make_float3(1.0f, 0.0f, 0.0f)) *
@@ -224,33 +224,33 @@ __device_inline Transform transform_euler(float3 euler)
transform_rotate(euler.z, make_float3(0.0f, 0.0f, 1.0f));
}
-__device_inline Transform transform_orthographic(float znear, float zfar)
+ccl_device_inline Transform transform_orthographic(float znear, float zfar)
{
return transform_scale(1.0f, 1.0f, 1.0f / (zfar-znear)) *
transform_translate(0.0f, 0.0f, -znear);
}
-__device_inline Transform transform_identity()
+ccl_device_inline Transform transform_identity()
{
return transform_scale(1.0f, 1.0f, 1.0f);
}
-__device_inline bool operator==(const Transform& A, const Transform& B)
+ccl_device_inline bool operator==(const Transform& A, const Transform& B)
{
return memcmp(&A, &B, sizeof(Transform)) == 0;
}
-__device_inline bool operator!=(const Transform& A, const Transform& B)
+ccl_device_inline bool operator!=(const Transform& A, const Transform& B)
{
return !(A == B);
}
-__device_inline float3 transform_get_column(const Transform *t, int column)
+ccl_device_inline float3 transform_get_column(const Transform *t, int column)
{
return make_float3(t->x[column], t->y[column], t->z[column]);
}
-__device_inline void transform_set_column(Transform *t, int column, float3 value)
+ccl_device_inline void transform_set_column(Transform *t, int column, float3 value)
{
t->x[column] = value.x;
t->y[column] = value.y;
@@ -259,7 +259,7 @@ __device_inline void transform_set_column(Transform *t, int column, float3 value
Transform transform_inverse(const Transform& a);
-__device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
+ccl_device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
{
/* the epsilon here is quite arbitrary, but this function is only used for
* surface area and bump, where we except it to not be so sensitive */
@@ -283,7 +283,7 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
return false;
}
-__device_inline bool transform_negative_scale(const Transform& tfm)
+ccl_device_inline bool transform_negative_scale(const Transform& tfm)
{
float3 c0 = transform_get_column(&tfm, 0);
float3 c1 = transform_get_column(&tfm, 1);
@@ -292,7 +292,7 @@ __device_inline bool transform_negative_scale(const Transform& tfm)
return (dot(cross(c0, c1), c2) < 0.0f);
}
-__device_inline Transform transform_clear_scale(const Transform& tfm)
+ccl_device_inline Transform transform_clear_scale(const Transform& tfm)
{
Transform ntfm = tfm;
@@ -307,7 +307,7 @@ __device_inline Transform transform_clear_scale(const Transform& tfm)
/* Motion Transform */
-__device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
+ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
{
/* use simpe nlerp instead of slerp. it's faster and almost the same */
return normalize((1.0f - t)*q1 + t*q2);
@@ -333,7 +333,7 @@ __device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
#endif
}
-__device_inline Transform transform_quick_inverse(Transform M)
+ccl_device_inline Transform transform_quick_inverse(Transform M)
{
/* possible optimization: can we avoid doing this altogether and construct
* the inverse matrix directly from negated translation, transposed rotation,
@@ -356,7 +356,7 @@ __device_inline Transform transform_quick_inverse(Transform M)
return R;
}
-__device_inline void transform_compose(Transform *tfm, const Transform *decomp)
+ccl_device_inline void transform_compose(Transform *tfm, const Transform *decomp)
{
/* rotation */
float q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc;
@@ -395,7 +395,7 @@ __device_inline void transform_compose(Transform *tfm, const Transform *decomp)
/* Disabled for now, need arc-length parametrization for constant speed motion.
* #define CURVED_MOTION_INTERPOLATE */
-__device void transform_motion_interpolate(Transform *tfm, const DecompMotionTransform *motion, float t)
+ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionTransform *motion, float t)
{
/* possible optimization: is it worth it adding a check to skip scaling?
* it's probably quite uncommon to have scaling objects. or can we skip
@@ -447,7 +447,7 @@ __device void transform_motion_interpolate(Transform *tfm, const DecompMotionTra
#ifndef __KERNEL_GPU__
-__device_inline bool operator==(const MotionTransform& A, const MotionTransform& B)
+ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransform& B)
{
return (A.pre == B.pre && A.post == B.post);
}
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index a8f514864db..3fa1df6ab44 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -23,38 +23,40 @@
#endif
+/* Bitness */
+
+#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
+#define __KERNEL_64_BIT__
+#endif
+
/* Qualifiers for kernel code shared by CPU and GPU */
#ifndef __KERNEL_GPU__
-#define __device static inline
-#define __device_noinline static
-#define __global
-#define __local
-#define __shared
-#define __constant
+#define ccl_device static inline
+#define ccl_device_noinline static
+#define ccl_global
+#define ccl_constant
#if defined(_WIN32) && !defined(FREE_WINDOWS)
-#define __device_inline static __forceinline
-#define __align(...) __declspec(align(__VA_ARGS__))
-#define __may_alias
+#define ccl_device_inline static __forceinline
+#ifdef __KERNEL_64_BIT__
+#define ccl_align(...) __declspec(align(__VA_ARGS__))
+#else
+#define ccl_align(...) /* not support for function arguments (error C2719) */
+#endif
+#define ccl_may_alias
#else
-#define __device_inline static inline __attribute__((always_inline))
+#define ccl_device_inline static inline __attribute__((always_inline))
#ifndef FREE_WINDOWS64
#define __forceinline inline __attribute__((always_inline))
#endif
-#define __align(...) __attribute__((aligned(__VA_ARGS__)))
-#define __may_alias __attribute__((__may_alias__))
+#define ccl_align(...) __attribute__((aligned(__VA_ARGS__)))
+#define ccl_may_alias __attribute__((__may_alias__))
#endif
#endif
-/* Bitness */
-
-#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
-#define __KERNEL_64_BIT__
-#endif
-
/* SIMD Types */
#ifndef __KERNEL_GPU__
@@ -97,6 +99,10 @@
#include <tmmintrin.h> /* SSSE 3 */
#endif
+#ifdef __KERNEL_SSE41__
+#include <smmintrin.h> /* SSE 4.1 */
+#endif
+
#else
/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
@@ -190,7 +196,7 @@ struct int2 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) int3 {
+struct ccl_align(16) int3 {
union {
__m128i m128;
struct { int x, y, z, w; };
@@ -201,7 +207,7 @@ struct __align(16) int3 {
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
-struct int3 {
+struct ccl_align(16) int3 {
int x, y, z, w;
#endif
@@ -210,7 +216,7 @@ struct int3 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) int4 {
+struct ccl_align(16) int4 {
union {
__m128i m128;
struct { int x, y, z, w; };
@@ -221,7 +227,7 @@ struct __align(16) int4 {
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
-struct int4 {
+struct ccl_align(16) int4 {
int x, y, z, w;
#endif
@@ -258,7 +264,7 @@ struct float2 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) float3 {
+struct ccl_align(16) float3 {
union {
__m128 m128;
struct { float x, y, z, w; };
@@ -269,7 +275,7 @@ struct __align(16) float3 {
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
-struct float3 {
+struct ccl_align(16) float3 {
float x, y, z, w;
#endif
@@ -278,7 +284,7 @@ struct float3 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) float4 {
+struct ccl_align(16) float4 {
union {
__m128 m128;
struct { float x, y, z, w; };
@@ -289,7 +295,7 @@ struct __align(16) float4 {
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
-struct float4 {
+struct ccl_align(16) float4 {
float x, y, z, w;
#endif
@@ -305,31 +311,31 @@ struct float4 {
*
* OpenCL does not support C++ class, so we use these instead. */
-__device_inline uchar2 make_uchar2(uchar x, uchar y)
+ccl_device_inline uchar2 make_uchar2(uchar x, uchar y)
{
uchar2 a = {x, y};
return a;
}
-__device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z)
+ccl_device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z)
{
uchar3 a = {x, y, z};
return a;
}
-__device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w)
+ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w)
{
uchar4 a = {x, y, z, w};
return a;
}
-__device_inline int2 make_int2(int x, int y)
+ccl_device_inline int2 make_int2(int x, int y)
{
int2 a = {x, y};
return a;
}
-__device_inline int3 make_int3(int x, int y, int z)
+ccl_device_inline int3 make_int3(int x, int y, int z)
{
#ifdef __KERNEL_SSE__
int3 a;
@@ -341,7 +347,7 @@ __device_inline int3 make_int3(int x, int y, int z)
return a;
}
-__device_inline int4 make_int4(int x, int y, int z, int w)
+ccl_device_inline int4 make_int4(int x, int y, int z, int w)
{
#ifdef __KERNEL_SSE__
int4 a;
@@ -353,31 +359,31 @@ __device_inline int4 make_int4(int x, int y, int z, int w)
return a;
}
-__device_inline uint2 make_uint2(uint x, uint y)
+ccl_device_inline uint2 make_uint2(uint x, uint y)
{
uint2 a = {x, y};
return a;
}
-__device_inline uint3 make_uint3(uint x, uint y, uint z)
+ccl_device_inline uint3 make_uint3(uint x, uint y, uint z)
{
uint3 a = {x, y, z};
return a;
}
-__device_inline uint4 make_uint4(uint x, uint y, uint z, uint w)
+ccl_device_inline uint4 make_uint4(uint x, uint y, uint z, uint w)
{
uint4 a = {x, y, z, w};
return a;
}
-__device_inline float2 make_float2(float x, float y)
+ccl_device_inline float2 make_float2(float x, float y)
{
float2 a = {x, y};
return a;
}
-__device_inline float3 make_float3(float x, float y, float z)
+ccl_device_inline float3 make_float3(float x, float y, float z)
{
#ifdef __KERNEL_SSE__
float3 a;
@@ -389,7 +395,7 @@ __device_inline float3 make_float3(float x, float y, float z)
return a;
}
-__device_inline float4 make_float4(float x, float y, float z, float w)
+ccl_device_inline float4 make_float4(float x, float y, float z, float w)
{
#ifdef __KERNEL_SSE__
float4 a;
@@ -401,12 +407,12 @@ __device_inline float4 make_float4(float x, float y, float z, float w)
return a;
}
-__device_inline int align_up(int offset, int alignment)
+ccl_device_inline int align_up(int offset, int alignment)
{
return (offset + alignment - 1) & ~(alignment - 1);
}
-__device_inline int3 make_int3(int i)
+ccl_device_inline int3 make_int3(int i)
{
#ifdef __KERNEL_SSE__
int3 a;
@@ -418,7 +424,7 @@ __device_inline int3 make_int3(int i)
return a;
}
-__device_inline int4 make_int4(int i)
+ccl_device_inline int4 make_int4(int i)
{
#ifdef __KERNEL_SSE__
int4 a;
@@ -430,7 +436,7 @@ __device_inline int4 make_int4(int i)
return a;
}
-__device_inline float3 make_float3(float f)
+ccl_device_inline float3 make_float3(float f)
{
#ifdef __KERNEL_SSE__
float3 a;
@@ -442,7 +448,7 @@ __device_inline float3 make_float3(float f)
return a;
}
-__device_inline float4 make_float4(float f)
+ccl_device_inline float4 make_float4(float f)
{
#ifdef __KERNEL_SSE__
float4 a;
@@ -454,7 +460,7 @@ __device_inline float4 make_float4(float f)
return a;
}
-__device_inline float4 make_float4(const int4& i)
+ccl_device_inline float4 make_float4(const int4& i)
{
#ifdef __KERNEL_SSE__
float4 a;
@@ -466,7 +472,7 @@ __device_inline float4 make_float4(const int4& i)
return a;
}
-__device_inline int4 make_int4(const float3& f)
+ccl_device_inline int4 make_int4(const float3& f)
{
#ifdef __KERNEL_SSE__
int4 a;
@@ -489,17 +495,17 @@ __device_inline int4 make_int4(const float3& f)
/* faster version for SSSE3 */
typedef __m128i shuffle_swap_t;
-__device_inline const shuffle_swap_t shuffle_swap_identity(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_identity(void)
{
return _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
}
-__device_inline const shuffle_swap_t shuffle_swap_swap(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_swap(void)
{
return _mm_set_epi8(7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8);
}
-__device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t& shuf)
+ccl_device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t& shuf)
{
return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf));
}
@@ -509,17 +515,17 @@ __device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t&
/* somewhat slower version for SSE2 */
typedef int shuffle_swap_t;
-__device_inline const shuffle_swap_t shuffle_swap_identity(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_identity(void)
{
return 0;
}
-__device_inline const shuffle_swap_t shuffle_swap_swap(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_swap(void)
{
return 1;
}
-__device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf)
+ccl_device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf)
{
/* shuffle value must be a constant, so we need to branch */
if(shuf)
@@ -530,12 +536,12 @@ __device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf)
#endif
-template<size_t i0, size_t i1, size_t i2, size_t i3> __device_inline const __m128 shuffle(const __m128& a, const __m128& b)
+template<size_t i0, size_t i1, size_t i2, size_t i3> ccl_device_inline const __m128 shuffle(const __m128& a, const __m128& b)
{
return _mm_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0));
}
-template<size_t i0, size_t i1, size_t i2, size_t i3> __device_inline const __m128 shuffle(const __m128& b)
+template<size_t i0, size_t i1, size_t i2, size_t i3> ccl_device_inline const __m128 shuffle(const __m128& b)
{
return _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(b), _MM_SHUFFLE(i3, i2, i1, i0)));
}
@@ -554,7 +560,7 @@ struct half4 { half x, y, z, w; };
#ifdef __KERNEL_CUDA__
-__device_inline void float4_store_half(half *h, const float4 *f, float scale)
+ccl_device_inline void float4_store_half(half *h, const float4 *f, float scale)
{
h[0] = __float2half_rn(f->x * scale);
h[1] = __float2half_rn(f->y * scale);
@@ -564,7 +570,7 @@ __device_inline void float4_store_half(half *h, const float4 *f, float scale)
#else
-__device_inline void float4_store_half(half *h, const float4 *f, float scale)
+ccl_device_inline void float4_store_half(half *h, const float4 *f, float scale)
{
#ifndef __KERNEL_SSE2__
for(int i = 0; i < 4; i++) {
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index 3b0180fd71a..459bee48e0e 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -2,7 +2,7 @@
* compatibility macros to make every ffmpeg installation appear
* like the most current installation (wrapping some functionality sometimes)
* it also includes all ffmpeg header files at once, no need to do it
- * seperately.
+ * separately.
*
* Copyright (c) 2011 Peter Schlaile
*
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 3873bae1eea..beca24fc5e9 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -44,7 +44,6 @@ set(SRC
intern/GHOST_ISystemPaths.cpp
intern/GHOST_ModifierKeys.cpp
intern/GHOST_Path-api.cpp
- intern/GHOST_Path-api.cpp
intern/GHOST_Rect.cpp
intern/GHOST_System.cpp
intern/GHOST_TimerManager.cpp
@@ -132,17 +131,10 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
# ack, this is still system dependant
if(APPLE)
- if(WITH_COCOA)
- list(APPEND SRC
- intern/GHOST_SystemPathsCocoa.mm
- intern/GHOST_SystemPathsCocoa.h
- )
- else()
- list(APPEND SRC
- intern/GHOST_SystemPathsCarbon.cpp
- intern/GHOST_SystemPathsCarbon.h
- )
- endif()
+ list(APPEND SRC
+ intern/GHOST_SystemPathsCocoa.mm
+ intern/GHOST_SystemPathsCocoa.h
+ )
elseif(UNIX)
list(APPEND SRC
@@ -173,41 +165,26 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
endif()
elseif(APPLE)
- if(WITH_COCOA)
- list(APPEND SRC
- intern/GHOST_DisplayManagerCocoa.mm
- intern/GHOST_SystemCocoa.mm
- intern/GHOST_SystemPathsCocoa.mm
- intern/GHOST_WindowCocoa.mm
-
- intern/GHOST_DisplayManagerCocoa.h
- intern/GHOST_SystemCocoa.h
- intern/GHOST_SystemPathsCocoa.h
- intern/GHOST_WindowCocoa.h
- )
-
- if(WITH_INPUT_NDOF)
- list(APPEND SRC
- intern/GHOST_NDOFManagerCocoa.mm
- intern/GHOST_NDOFManagerCocoa.h
- )
- list(APPEND SRC_NDOF3DCONNEXION
- intern/GHOST_NDOFManager3Dconnexion.c
- intern/GHOST_NDOFManager3Dconnexion.h
- )
- endif()
+ list(APPEND SRC
+ intern/GHOST_DisplayManagerCocoa.mm
+ intern/GHOST_SystemCocoa.mm
+ intern/GHOST_SystemPathsCocoa.mm
+ intern/GHOST_WindowCocoa.mm
+
+ intern/GHOST_DisplayManagerCocoa.h
+ intern/GHOST_SystemCocoa.h
+ intern/GHOST_SystemPathsCocoa.h
+ intern/GHOST_WindowCocoa.h
+ )
- else()
+ if(WITH_INPUT_NDOF)
list(APPEND SRC
- intern/GHOST_DisplayManagerCarbon.cpp
- intern/GHOST_SystemCarbon.cpp
- intern/GHOST_SystemPathsCarbon.cpp
- intern/GHOST_WindowCarbon.cpp
-
- intern/GHOST_DisplayManagerCarbon.h
- intern/GHOST_SystemCarbon.h
- intern/GHOST_SystemPathsCarbon.h
- intern/GHOST_WindowCarbon.h
+ intern/GHOST_NDOFManagerCocoa.mm
+ intern/GHOST_NDOFManagerCocoa.h
+ )
+ list(APPEND SRC_NDOF3DCONNEXION
+ intern/GHOST_NDOFManager3Dconnexion.c
+ intern/GHOST_NDOFManager3Dconnexion.h
)
endif()
@@ -324,6 +301,6 @@ add_definitions(-DGLEW_STATIC)
blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}")
# workaround for apple clang mangling extern "C" symbols
-if(WITH_INPUT_NDOF AND WITH_COCOA)
+if(WITH_INPUT_NDOF AND APPLE)
blender_add_lib(bf_intern_ghostndof3dconnexion "${SRC_NDOF3DCONNEXION}" "${INC}" "${INC_SYS}")
endif()
diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript
index fed8cd7aa3c..df4efe60a11 100644
--- a/intern/ghost/SConscript
+++ b/intern/ghost/SConscript
@@ -55,7 +55,6 @@ incs += ' ' + env['BF_OPENGL_INC']
if env['WITH_GHOST_SDL']:
for f in pf:
try:
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'Win32.cpp')
sources.remove('intern' + os.sep + f + 'X11.cpp')
except ValueError:
@@ -66,7 +65,6 @@ elif window_system in ('linux', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'f
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'Win32.cpp')
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
@@ -94,34 +92,19 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'X11.cpp')
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
elif window_system == 'darwin':
- if env['WITH_GHOST_COCOA']:
- if env['WITH_BF_QUICKTIME']:
- defs.append('WITH_QUICKTIME')
- if env['USE_QTKIT']:
- defs.append('USE_QTKIT')
- for f in pf:
- try:
- sources.remove('intern' + os.sep + f + 'Win32.cpp')
- sources.remove('intern' + os.sep + f + 'X11.cpp')
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
- sources.remove('intern' + os.sep + f + 'SDL.cpp')
- except ValueError:
- pass
- else:
- for f in pf:
- try:
- sources.remove('intern' + os.sep + f + 'Win32.cpp')
- sources.remove('intern' + os.sep + f + 'X11.cpp')
- sources.remove('intern' + os.sep + f + 'Cocoa.mm')
- sources.remove('intern' + os.sep + f + 'SDL.cpp')
- except ValueError:
- pass
-
+ if env['WITH_BF_QUICKTIME']:
+ defs.append('WITH_QUICKTIME')
+ for f in pf:
+ try:
+ sources.remove('intern' + os.sep + f + 'Win32.cpp')
+ sources.remove('intern' + os.sep + f + 'X11.cpp')
+ sources.remove('intern' + os.sep + f + 'SDL.cpp')
+ except ValueError:
+ pass
else:
print "Unknown window system specified."
Exit()
@@ -155,7 +138,7 @@ if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-v
if window_system in ('win32-vc', 'win64-vc'):
env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15]) #, cc_compileflags=env['CCFLAGS'].append('/WX') )
-elif env['WITH_GHOST_COCOA']: # always use default-Apple-gcc for objC language, for gnu-compilers do not support it fully yet
+elif window_system == 'darwin': # always use default-Apple-gcc for objC language, for gnu-compilers do not support it fully yet
env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15], cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++' )
print "GHOST COCOA WILL BE COMPILED WITH APPLE GCC"
if env['WITH_BF_3DMOUSE']:
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp
deleted file mode 100644
index 25e9123dae6..00000000000
--- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_DisplayManagerCarbon.cpp
- * \ingroup GHOST
- */
-
-
-/**
- * Copyright (C) 2001 NaN Technologies B.V.
- * \author Maarten Gribnau
- * \date September 21, 2001
- */
-
-#include "GHOST_DisplayManagerCarbon.h"
-#include "GHOST_Debug.h"
-
-// We do not support multiple monitors at the moment
-
-
-GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(void)
-{
- if (::CGGetActiveDisplayList(0, NULL, &m_numDisplays) != CGDisplayNoErr)
- {
- m_numDisplays = 0;
- m_displayIDs = NULL;
- }
- if (m_numDisplays > 0)
- {
- m_displayIDs = new CGDirectDisplayID[m_numDisplays];
- GHOST_ASSERT((m_displayIDs != NULL), "GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(): memory allocation failed");
- ::CGGetActiveDisplayList(m_numDisplays, m_displayIDs, &m_numDisplays);
- }
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplays(GHOST_TUns8& numDisplays) const
-{
- numDisplays = (GHOST_TUns8) m_numDisplays;
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getNumDisplaySettings(): only main display is supported");
-
- CFArrayRef displayModes;
- displayModes = ::CGDisplayAvailableModes(m_displayIDs[display]);
- CFIndex numModes = ::CFArrayGetCount(displayModes);
- numSettings = (GHOST_TInt32)numModes;
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getDisplaySetting(): only main display is supported");
-
- CFArrayRef displayModes;
- CGDirectDisplayID d = m_displayIDs[display];
- displayModes = ::CGDisplayAvailableModes(d);
- //CFIndex numModes = ::CFArrayGetCount(displayModes);/*unused*/
- //GHOST_TInt32 numSettings = (GHOST_TInt32)numModes; /*unused*/
- CFDictionaryRef displayModeValues = (CFDictionaryRef) ::CFArrayGetValueAtIndex(displayModes, index);
-
- setting.xPixels = getValue(displayModeValues, kCGDisplayWidth);
- setting.yPixels = getValue(displayModeValues, kCGDisplayHeight);
- setting.bpp = getValue(displayModeValues, kCGDisplayBitsPerPixel);
- setting.frequency = getValue(displayModeValues, kCGDisplayRefreshRate);
-
-#ifdef GHOST_DEBUG
- printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
-#endif // GHOST_DEBUG
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(): only main display is supported");
-
- CFDictionaryRef displayModeValues = ::CGDisplayCurrentMode(m_displayIDs[display]);
-
- setting.xPixels = getValue(displayModeValues, kCGDisplayWidth);
- setting.yPixels = getValue(displayModeValues, kCGDisplayHeight);
- setting.bpp = getValue(displayModeValues, kCGDisplayBitsPerPixel);
- setting.frequency = getValue(displayModeValues, kCGDisplayRefreshRate);
-
-#ifdef GHOST_DEBUG
- printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
-#endif // GHOST_DEBUG
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting)
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): only main display is supported");
-
-#ifdef GHOST_DEBUG
- printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): requested settings:\n");
- printf(" setting.xPixels=%d\n", setting.xPixels);
- printf(" setting.yPixels=%d\n", setting.yPixels);
- printf(" setting.bpp=%d\n", setting.bpp);
- printf(" setting.frequency=%d\n", setting.frequency);
-#endif // GHOST_DEBUG
-
- CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate(
- m_displayIDs[display],
- (size_t)setting.bpp,
- (size_t)setting.xPixels,
- (size_t)setting.yPixels,
- (CGRefreshRate)setting.frequency,
- NULL);
-
-#ifdef GHOST_DEBUG
- printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): switching to:\n");
- printf(" setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth));
- printf(" setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight));
- printf(" setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel));
- printf(" setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate));
-#endif // GHOST_DEBUG
-
- CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
-
- return err == CGDisplayNoErr ? GHOST_kSuccess : GHOST_kFailure;
-}
-
-
-long GHOST_DisplayManagerCarbon::getValue(CFDictionaryRef values, CFStringRef key) const
-{
- CFNumberRef numberValue = (CFNumberRef) CFDictionaryGetValue(values, key);
-
- if (!numberValue)
- {
- return -1;
- }
-
- long intValue;
-
- if (!CFNumberGetValue(numberValue, kCFNumberLongType, &intValue))
- {
- return -1;
- }
-
- return intValue;
-}
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.h b/intern/ghost/intern/GHOST_DisplayManagerCarbon.h
deleted file mode 100644
index 1ac6540b7bd..00000000000
--- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_DisplayManagerCarbon.h
- * \ingroup GHOST
- * Declaration of GHOST_DisplayManagerCarbon class.
- */
-
-#ifndef __GHOST_DISPLAYMANAGERCARBON_H__
-#define __GHOST_DISPLAYMANAGERCARBON_H__
-
-#ifndef __APPLE__
-#error Apple only!
-#endif // __APPLE__
-
-#include "GHOST_DisplayManager.h"
-
-#define __CARBONSOUND__
-#include <Carbon/Carbon.h>
-
-/**
- * Manages system displays (Mac OSX/Carbon implementation).
- * \see GHOST_DisplayManager
- * \author Maarten Gribnau
- * \date September 21, 2001
- */
-class GHOST_DisplayManagerCarbon : public GHOST_DisplayManager
-{
-public:
- /**
- * Constructor.
- */
- GHOST_DisplayManagerCarbon(void);
-
- /**
- * Returns the number of display devices on this system.
- * \param numDisplays The number of displays on this system.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getNumDisplays(GHOST_TUns8& numDisplays) const;
-
- /**
- * Returns the number of display settings for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param setting The number of settings of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
-
- /**
- * Returns the current setting for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param index The setting index to be returned.
- * \param setting The setting of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
-
- /**
- * Returns the current setting for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param setting The current setting of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
-
- /**
- * Changes the current setting for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param setting The current setting of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting);
-
-protected:
- /**
- * Returns a value from a dictionary.
- * \param values Dictionary to return value from.
- * \param key Key to return value for.
- * \return The value for this key.
- */
- long getValue(CFDictionaryRef values, CFStringRef key) const;
-
- /** Cached number of displays. */
- CGDisplayCount m_numDisplays;
- /** Cached display id's for each display. */
- CGDirectDisplayID *m_displayIDs;
-};
-
-
-#endif // __GHOST_DISPLAYMANAGERCARBON_H__
-
diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp
index f6973caad03..009753cb29e 100644
--- a/intern/ghost/intern/GHOST_ISystem.cpp
+++ b/intern/ghost/intern/GHOST_ISystem.cpp
@@ -46,11 +46,7 @@
# include "GHOST_SystemWin32.h"
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
-# include "GHOST_SystemCocoa.h"
-# else
-# include "GHOST_SystemCarbon.h"
-# endif
+# include "GHOST_SystemCocoa.h"
# else
# include "GHOST_SystemX11.h"
# endif
@@ -72,11 +68,7 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
m_system = new GHOST_SystemWin32();
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
m_system = new GHOST_SystemCocoa();
-# else
- m_system = new GHOST_SystemCarbon();
-# endif
# else
m_system = new GHOST_SystemX11();
# endif
diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp
index ae9a8e49057..581467fb666 100644
--- a/intern/ghost/intern/GHOST_ISystemPaths.cpp
+++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp
@@ -42,11 +42,7 @@
# include "GHOST_SystemPathsWin32.h"
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
# include "GHOST_SystemPathsCocoa.h"
-# else
-# include "GHOST_SystemPathsCarbon.h"
-# endif
# else
# include "GHOST_SystemPathsX11.h"
# endif
@@ -64,11 +60,7 @@ GHOST_TSuccess GHOST_ISystemPaths::create()
m_systemPaths = new GHOST_SystemPathsWin32();
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
m_systemPaths = new GHOST_SystemPathsCocoa();
-# else
- m_systemPaths = new GHOST_SystemPathsCarbon();
-# endif
# else
m_systemPaths = new GHOST_SystemPathsX11();
# endif
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
deleted file mode 100644
index 6e72e26beb4..00000000000
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ /dev/null
@@ -1,1241 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemCarbon.cpp
- * \ingroup GHOST
- */
-
-
-/**
- * Copyright (C) 2001 NaN Technologies B.V.
- * \author Maarten Gribnau
- * \date May 7, 2001
- */
-
-#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include "GHOST_SystemCarbon.h"
-
-#include "GHOST_DisplayManagerCarbon.h"
-#include "GHOST_EventKey.h"
-#include "GHOST_EventButton.h"
-#include "GHOST_EventCursor.h"
-#include "GHOST_EventWheel.h"
-#ifdef WITH_INPUT_NDOF
-#include "GHOST_EventNDOF.h"
-#endif
-
-#include "GHOST_TimerManager.h"
-#include "GHOST_TimerTask.h"
-#include "GHOST_WindowManager.h"
-#include "GHOST_WindowCarbon.h"
-#include "GHOST_NDOFManager.h"
-#include "AssertMacros.h"
-
-/* blender class and types events */
-enum {
- kEventClassBlender = 'blnd'
-};
-
-enum {
- kEventBlenderNdofAxis = 1,
- kEventBlenderNdofButtons = 2
-};
-
-const EventTypeSpec kEvents[] =
-{
- { kEventClassAppleEvent, kEventAppleEvent },
-#if 0
- { kEventClassApplication, kEventAppActivated },
- { kEventClassApplication, kEventAppDeactivated },
- #endif
- { kEventClassKeyboard, kEventRawKeyDown },
- { kEventClassKeyboard, kEventRawKeyRepeat },
- { kEventClassKeyboard, kEventRawKeyUp },
- { kEventClassKeyboard, kEventRawKeyModifiersChanged },
-
- { kEventClassMouse, kEventMouseDown },
- { kEventClassMouse, kEventMouseUp },
- { kEventClassMouse, kEventMouseMoved },
- { kEventClassMouse, kEventMouseDragged },
- { kEventClassMouse, kEventMouseWheelMoved },
-
- { kEventClassWindow, kEventWindowClickZoomRgn }, /* for new zoom behaviour */
- { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */
- { kEventClassWindow, kEventWindowExpand }, /* for new zoom behaviour */
- { kEventClassWindow, kEventWindowExpandAll }, /* for new zoom behaviour */
-
- { kEventClassWindow, kEventWindowClose },
- { kEventClassWindow, kEventWindowActivated },
- { kEventClassWindow, kEventWindowDeactivated },
- { kEventClassWindow, kEventWindowUpdate },
- { kEventClassWindow, kEventWindowBoundsChanged },
-
- { kEventClassBlender, kEventBlenderNdofAxis },
- { kEventClassBlender, kEventBlenderNdofButtons }
-
-
-
-};
-
-
-
-static GHOST_TButtonMask convertButton(EventMouseButton button)
-{
- switch (button) {
- case kEventMouseButtonPrimary:
- return GHOST_kButtonMaskLeft;
- case kEventMouseButtonSecondary:
- return GHOST_kButtonMaskRight;
- case kEventMouseButtonTertiary:
- default:
- return GHOST_kButtonMaskMiddle;
- }
-}
-
-static GHOST_TKey convertKey(int rawCode)
-{
- /* This bit of magic converts the rawCode into a virtual
- * Mac key based on the current keyboard mapping, but
- * without regard to the modifiers (so we don't get 'a'
- * and 'A' for example.
- */
- static UInt32 dummy = 0;
- Handle transData = (Handle) GetScriptManagerVariable(smKCHRCache);
- unsigned char vk = KeyTranslate(transData, rawCode, &dummy);
- /* Map numpad based on rawcodes first, otherwise they
- * look like non-numpad events.
- * Added too: mapping the number keys, for french keyboards etc (ton)
- */
- // printf("GHOST: vk: %d %c raw: %d\n", vk, vk, rawCode);
-
- switch (rawCode) {
- case 18: return GHOST_kKey1;
- case 19: return GHOST_kKey2;
- case 20: return GHOST_kKey3;
- case 21: return GHOST_kKey4;
- case 23: return GHOST_kKey5;
- case 22: return GHOST_kKey6;
- case 26: return GHOST_kKey7;
- case 28: return GHOST_kKey8;
- case 25: return GHOST_kKey9;
- case 29: return GHOST_kKey0;
-
- case 82: return GHOST_kKeyNumpad0;
- case 83: return GHOST_kKeyNumpad1;
- case 84: return GHOST_kKeyNumpad2;
- case 85: return GHOST_kKeyNumpad3;
- case 86: return GHOST_kKeyNumpad4;
- case 87: return GHOST_kKeyNumpad5;
- case 88: return GHOST_kKeyNumpad6;
- case 89: return GHOST_kKeyNumpad7;
- case 91: return GHOST_kKeyNumpad8;
- case 92: return GHOST_kKeyNumpad9;
- case 65: return GHOST_kKeyNumpadPeriod;
- case 76: return GHOST_kKeyNumpadEnter;
- case 69: return GHOST_kKeyNumpadPlus;
- case 78: return GHOST_kKeyNumpadMinus;
- case 67: return GHOST_kKeyNumpadAsterisk;
- case 75: return GHOST_kKeyNumpadSlash;
- }
-
- if ((vk >= 'a') && (vk <= 'z')) {
- return (GHOST_TKey) (vk - 'a' + GHOST_kKeyA);
- }
- else if ((vk >= '0') && (vk <= '9')) {
- return (GHOST_TKey) (vk - '0' + GHOST_kKey0);
- }
- else if (vk == 16) {
- switch (rawCode) {
- case 122: return GHOST_kKeyF1;
- case 120: return GHOST_kKeyF2;
- case 99: return GHOST_kKeyF3;
- case 118: return GHOST_kKeyF4;
- case 96: return GHOST_kKeyF5;
- case 97: return GHOST_kKeyF6;
- case 98: return GHOST_kKeyF7;
- case 100: return GHOST_kKeyF8;
- case 101: return GHOST_kKeyF9;
- case 109: return GHOST_kKeyF10;
- case 103: return GHOST_kKeyF11;
- case 111: return GHOST_kKeyF12; // Never get, is used for ejecting the CD!
- }
- }
- else {
- switch (vk) {
- case kUpArrowCharCode: return GHOST_kKeyUpArrow;
- case kDownArrowCharCode: return GHOST_kKeyDownArrow;
- case kLeftArrowCharCode: return GHOST_kKeyLeftArrow;
- case kRightArrowCharCode: return GHOST_kKeyRightArrow;
-
- case kReturnCharCode: return GHOST_kKeyEnter;
- case kBackspaceCharCode: return GHOST_kKeyBackSpace;
- case kDeleteCharCode: return GHOST_kKeyDelete;
- case kEscapeCharCode: return GHOST_kKeyEsc;
- case kTabCharCode: return GHOST_kKeyTab;
- case kSpaceCharCode: return GHOST_kKeySpace;
-
- case kHomeCharCode: return GHOST_kKeyHome;
- case kEndCharCode: return GHOST_kKeyEnd;
- case kPageUpCharCode: return GHOST_kKeyUpPage;
- case kPageDownCharCode: return GHOST_kKeyDownPage;
-
- case '-': return GHOST_kKeyMinus;
- case '=': return GHOST_kKeyEqual;
- case ',': return GHOST_kKeyComma;
- case '.': return GHOST_kKeyPeriod;
- case '/': return GHOST_kKeySlash;
- case ';': return GHOST_kKeySemicolon;
- case '\'': return GHOST_kKeyQuote;
- case '\\': return GHOST_kKeyBackslash;
- case '[': return GHOST_kKeyLeftBracket;
- case ']': return GHOST_kKeyRightBracket;
- case '`': return GHOST_kKeyAccentGrave;
- }
- }
-
- // printf("GHOST: unknown key: %d %d\n", vk, rawCode);
-
- return GHOST_kKeyUnknown;
-}
-
-/* MacOSX returns a Roman charset with kEventParamKeyMacCharCodes
- * as defined here: http://developer.apple.com/documentation/mac/Text/Text-516.html
- * I am not sure how international this works...
- * For cross-platform convention, we'll use the Latin ascii set instead.
- * As defined at: http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html
- *
- */
-static unsigned char convertRomanToLatin(unsigned char ascii)
-{
-
- if (ascii < 128) return ascii;
-
- switch (ascii) {
- case 128: return 142;
- case 129: return 143;
- case 130: return 128;
- case 131: return 201;
- case 132: return 209;
- case 133: return 214;
- case 134: return 220;
- case 135: return 225;
- case 136: return 224;
- case 137: return 226;
- case 138: return 228;
- case 139: return 227;
- case 140: return 229;
- case 141: return 231;
- case 142: return 233;
- case 143: return 232;
- case 144: return 234;
- case 145: return 235;
- case 146: return 237;
- case 147: return 236;
- case 148: return 238;
- case 149: return 239;
- case 150: return 241;
- case 151: return 243;
- case 152: return 242;
- case 153: return 244;
- case 154: return 246;
- case 155: return 245;
- case 156: return 250;
- case 157: return 249;
- case 158: return 251;
- case 159: return 252;
- case 160: return 0;
- case 161: return 176;
- case 162: return 162;
- case 163: return 163;
- case 164: return 167;
- case 165: return 183;
- case 166: return 182;
- case 167: return 223;
- case 168: return 174;
- case 169: return 169;
- case 170: return 174;
- case 171: return 180;
- case 172: return 168;
- case 173: return 0;
- case 174: return 198;
- case 175: return 216;
- case 176: return 0;
- case 177: return 177;
- case 178: return 0;
- case 179: return 0;
- case 180: return 165;
- case 181: return 181;
- case 182: return 0;
- case 183: return 0;
- case 184: return 215;
- case 185: return 0;
- case 186: return 0;
- case 187: return 170;
- case 188: return 186;
- case 189: return 0;
- case 190: return 230;
- case 191: return 248;
- case 192: return 191;
- case 193: return 161;
- case 194: return 172;
- case 195: return 0;
- case 196: return 0;
- case 197: return 0;
- case 198: return 0;
- case 199: return 171;
- case 200: return 187;
- case 201: return 201;
- case 202: return 0;
- case 203: return 192;
- case 204: return 195;
- case 205: return 213;
- case 206: return 0;
- case 207: return 0;
- case 208: return 0;
- case 209: return 0;
- case 210: return 0;
-
- case 214: return 247;
-
- case 229: return 194;
- case 230: return 202;
- case 231: return 193;
- case 232: return 203;
- case 233: return 200;
- case 234: return 205;
- case 235: return 206;
- case 236: return 207;
- case 237: return 204;
- case 238: return 211;
- case 239: return 212;
- case 240: return 0;
- case 241: return 210;
- case 242: return 218;
- case 243: return 219;
- case 244: return 217;
- case 245: return 0;
- case 246: return 0;
- case 247: return 0;
- case 248: return 0;
- case 249: return 0;
- case 250: return 0;
-
-
- default: return 0;
- }
-
-}
-
-
-/***/
-
-GHOST_SystemCarbon::GHOST_SystemCarbon() :
- m_modifierMask(0)
-{
- m_displayManager = new GHOST_DisplayManagerCarbon();
- GHOST_ASSERT(m_displayManager, "GHOST_SystemCarbon::GHOST_SystemCarbon(): m_displayManager==0\n");
- m_displayManager->initialize();
-
- UnsignedWide micros;
- ::Microseconds(&micros);
- m_start_time = UnsignedWideToUInt64(micros) / 1000;
- m_ignoreWindowSizedMessages = false;
-}
-
-GHOST_SystemCarbon::~GHOST_SystemCarbon()
-{
-}
-
-
-GHOST_TUns64 GHOST_SystemCarbon::getMilliSeconds() const
-{
- UnsignedWide micros;
- ::Microseconds(&micros);
- UInt64 millis;
- millis = UnsignedWideToUInt64(micros);
- return (millis / 1000) - m_start_time;
-}
-
-GHOST_TUns8 GHOST_SystemCarbon::getNumDisplays() const
-{
- // We do not support multiple monitors at the moment
- return 1;
-}
-
-
-void GHOST_SystemCarbon::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
-{
- BitMap screenBits;
- Rect bnds = GetQDGlobalsScreenBits(&screenBits)->bounds;
- width = bnds.right - bnds.left;
- height = bnds.bottom - bnds.top;
-}
-
-void GHOST_SystemCarbon::getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
-{
- /* TODO */
- getMainDisplayDimensions(width, height);
-}
-
-GHOST_IWindow *GHOST_SystemCarbon::createWindow(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
- bool stereoVisual,
- const bool exclusive,
- const GHOST_TUns16 numOfAASamples,
- const GHOST_TEmbedderWindowID parentWindow)
-{
- GHOST_IWindow *window = 0;
-
- window = new GHOST_WindowCarbon(title, left, top, width, height, state, type);
-
- if (window) {
- if (window->getValid()) {
- // Store the pointer to the window
- GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
- m_windowManager->addWindow(window);
- m_windowManager->setActiveWindow(window);
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
- }
- else {
- GHOST_PRINT("GHOST_SystemCarbon::createWindow(): window invalid\n");
- delete window;
- window = 0;
- }
- }
- else {
- GHOST_PRINT("GHOST_SystemCarbon::createWindow(): could not create window\n");
- }
- return window;
-}
-
-GHOST_TSuccess GHOST_SystemCarbon::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow **window, const bool stereoVisual)
-{
- GHOST_TSuccess success = GHOST_kFailure;
-
- // need yo make this Carbon all on 10.5 for fullscreen to work correctly
- CGCaptureAllDisplays();
-
- success = GHOST_System::beginFullScreen(setting, window, stereoVisual);
-
- if (success != GHOST_kSuccess) {
- // fullscreen failed for other reasons, release
- CGReleaseAllDisplays();
- }
-
- return success;
-}
-
-GHOST_TSuccess GHOST_SystemCarbon::endFullScreen(void)
-{
- CGReleaseAllDisplays();
- return GHOST_System::endFullScreen();
-}
-
-/* this is an old style low level event queue.
- * As we want to handle our own timers, this is ok.
- * the full screen hack should be removed */
-bool GHOST_SystemCarbon::processEvents(bool waitForEvent)
-{
- bool anyProcessed = false;
- EventRef event;
-
-// SetMouseCoalescingEnabled(false, NULL);
-
- do {
- GHOST_TimerManager *timerMgr = getTimerManager();
-
- if (waitForEvent) {
- GHOST_TUns64 next = timerMgr->nextFireTime();
- double timeOut;
-
- if (next == GHOST_kFireTimeNever) {
- timeOut = kEventDurationForever;
- }
- else {
- timeOut = (double)(next - getMilliSeconds()) / 1000.0;
- if (timeOut < 0.0)
- timeOut = 0.0;
- }
-
- ::ReceiveNextEvent(0, NULL, timeOut, false, &event);
- }
-
- if (timerMgr->fireTimers(getMilliSeconds())) {
- anyProcessed = true;
- }
-
- if (getFullScreen()) {
- // Check if the full-screen window is dirty
- GHOST_IWindow *window = m_windowManager->getFullScreenWindow();
- if (((GHOST_WindowCarbon *)window)->getFullScreenDirty()) {
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
- anyProcessed = true;
- }
- }
-
- /* end loop when no more events available */
- while (::ReceiveNextEvent(0, NULL, 0, true, &event) == noErr) {
- OSStatus status = ::SendEventToEventTarget(event, ::GetEventDispatcherTarget());
- if (status == noErr) {
- anyProcessed = true;
- }
- else {
- UInt32 i = ::GetEventClass(event);
-
- /* Ignore 'cgs ' class, no documentation on what they
- * are, but we get a lot of them
- */
- if (i != 'cgs ') {
- if (i != 'tblt') { // tablet event. we use the one packaged in the mouse event
- ; //printf("Missed - Class: '%.4s', Kind: %d\n", &i, ::GetEventKind(event));
- }
- }
- }
- ::ReleaseEvent(event);
- }
- } while (waitForEvent && !anyProcessed);
-
- return anyProcessed;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const
-{
- Point mouseLoc;
- // Get the position of the mouse in the active port
- ::GetGlobalMouse(&mouseLoc);
- // Convert the coordinates to screen coordinates
- x = (GHOST_TInt32)mouseLoc.h;
- y = (GHOST_TInt32)mouseLoc.v;
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
-{
- float xf = (float)x, yf = (float)y;
-
- CGAssociateMouseAndMouseCursorPosition(false);
- CGSetLocalEventsSuppressionInterval(0);
- CGWarpMouseCursorPosition(CGPointMake(xf, yf));
- CGAssociateMouseAndMouseCursorPosition(true);
-
-//this doesn't work properly, see game engine mouse-look scripts
-// CGWarpMouseCursorPosition(CGPointMake(xf, yf));
- // this call below sends event, but empties other events (like shift)
- // CGPostMouseEvent(CGPointMake(xf, yf), TRUE, 1, FALSE, 0);
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::getModifierKeys(GHOST_ModifierKeys& keys) const
-{
- UInt32 modifiers = ::GetCurrentKeyModifiers();
-
- keys.set(GHOST_kModifierKeyOS, (modifiers & cmdKey) ? true : false);
- keys.set(GHOST_kModifierKeyLeftAlt, (modifiers & optionKey) ? true : false);
- keys.set(GHOST_kModifierKeyLeftShift, (modifiers & shiftKey) ? true : false);
- keys.set(GHOST_kModifierKeyLeftControl, (modifiers & controlKey) ? true : false);
-
- return GHOST_kSuccess;
-}
-
-/* XXX, incorrect for multibutton mice */
-GHOST_TSuccess GHOST_SystemCarbon::getButtons(GHOST_Buttons& buttons) const
-{
- Boolean theOnlyButtonIsDown = ::Button();
- buttons.clear();
- buttons.set(GHOST_kButtonMaskLeft, theOnlyButtonIsDown);
- return GHOST_kSuccess;
-}
-
-#define FIRSTFILEBUFLG 512
-static bool g_hasFirstFile = false;
-static char g_firstFileBuf[512];
-
-extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
-{
- if (g_hasFirstFile) {
- strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
- buf[FIRSTFILEBUFLG - 1] = '\0';
- return 1;
- }
- else {
- return 0;
- }
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerLaunch(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon;
-
- return noErr;
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon;
- AEDescList docs;
- SInt32 ndocs;
- OSErr err;
-
- err = AEGetParamDesc(event, keyDirectObject, typeAEList, &docs);
- if (err != noErr) return err;
-
- err = AECountItems(&docs, &ndocs);
- if (err == noErr) {
- int i;
-
- for (i = 0; i < ndocs; i++) {
- FSSpec fss;
- AEKeyword kwd;
- DescType actType;
- Size actSize;
-
- err = AEGetNthPtr(&docs, i + 1, typeFSS, &kwd, &actType, &fss, sizeof(fss), &actSize);
- if (err != noErr)
- break;
-
- if (i == 0) {
- FSRef fsref;
-
- if (FSpMakeFSRef(&fss, &fsref) != noErr)
- break;
- if (FSRefMakePath(&fsref, (UInt8 *) g_firstFileBuf, sizeof(g_firstFileBuf)) != noErr)
- break;
-
- g_hasFirstFile = true;
- }
- }
- }
-
- AEDisposeDesc(&docs);
-
- return err;
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerPrintDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon;
-
- return noErr;
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerQuit(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) refCon;
-
- sys->pushEvent(new GHOST_Event(sys->getMilliSeconds(), GHOST_kEventQuit, NULL) );
-
- return noErr;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::init()
-{
-
- GHOST_TSuccess success = GHOST_System::init();
- if (success) {
- /*
- * Initialize the cursor to the standard arrow shape (so that we can change it later on).
- * This initializes the cursor's visibility counter to 0.
- */
- ::InitCursor();
-
- MenuRef windMenu;
- ::CreateStandardWindowMenu(0, &windMenu);
- ::InsertMenu(windMenu, 0);
- ::DrawMenuBar();
-
- ::InstallApplicationEventHandler(sEventHandlerProc, GetEventTypeCount(kEvents), kEvents, this, &m_handler);
-
- ::AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, sAEHandlerLaunch, (SInt32) this, false);
- ::AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, sAEHandlerOpenDocs, (SInt32) this, false);
- ::AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, sAEHandlerPrintDocs, (SInt32) this, false);
- ::AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, sAEHandlerQuit, (SInt32) this, false);
-
- }
- return success;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::exit()
-{
- return GHOST_System::exit();
-}
-
-
-OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
-{
- WindowRef windowRef;
- GHOST_WindowCarbon *window;
- OSStatus err = eventNotHandledErr;
-
- // Check if the event was send to a GHOST window
- ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &windowRef);
- window = (GHOST_WindowCarbon *) ::GetWRefCon(windowRef);
- if (!validWindow(window)) {
- return err;
- }
-
- //if (!getFullScreen()) {
- err = noErr;
- switch (::GetEventKind(event))
- {
- case kEventWindowClose:
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) );
- break;
- case kEventWindowActivated:
- m_windowManager->setActiveWindow(window);
- window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) );
- break;
- case kEventWindowDeactivated:
- m_windowManager->setWindowInactive(window);
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) );
- break;
- case kEventWindowUpdate:
- //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n");
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
- break;
- case kEventWindowBoundsChanged:
- if (!m_ignoreWindowSizedMessages)
- {
- window->updateDrawingContext();
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
- }
- break;
- default:
- err = eventNotHandledErr;
- break;
- }
-// }
- //else {
- //window = (GHOST_WindowCarbon*) m_windowManager->getFullScreenWindow();
- //GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen window event, " << window << "\n");
- //::RemoveEventFromQueue(::GetMainEventQueue(), event);
- //}
-
- return err;
-}
-
-OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event)
-{
- GHOST_IWindow *window = m_windowManager->getActiveWindow();
- TabletPointRec tabletPointRecord;
- TabletProximityRec tabletProximityRecord;
- UInt32 anInt32;
- GHOST_TabletData& ct = ((GHOST_WindowCarbon *)window)->GetCarbonTabletData();
- OSStatus err = eventNotHandledErr;
-
- ct.Pressure = 0;
- ct.Xtilt = 0;
- ct.Ytilt = 0;
-
- // is there an embedded tablet event inside this mouse event?
- if (noErr == GetEventParameter(event, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, (void *)&anInt32))
- {
- // yes there is one!
- // Embedded tablet events can either be a proximity or pointer event.
- if (anInt32 == kEventTabletPoint)
- {
- //GHOST_PRINT("Embedded pointer event!\n");
-
- // Extract the tablet Pointer Event. If there is no Tablet Pointer data
- // in this event, then this call will return an error. Just ignore the
- // error and go on. This can occur when a proximity event is embedded in
- // a mouse event and you did not check the mouse event to see which type
- // of tablet event was embedded.
- if (noErr == GetEventParameter(event, kEventParamTabletPointRec,
- typeTabletPointRec, NULL,
- sizeof(TabletPointRec),
- NULL, (void *)&tabletPointRecord))
- {
- ct.Pressure = tabletPointRecord.pressure / 65535.0f;
- ct.Xtilt = tabletPointRecord.tiltX / 32767.0f; /* can be positive or negative */
- ct.Ytilt = tabletPointRecord.tiltY / 32767.0f; /* can be positive or negative */
- }
- }
- else {
- //GHOST_PRINT("Embedded proximity event\n");
-
- // Extract the Tablet Proximity record from the event.
- if (noErr == GetEventParameter(event, kEventParamTabletProximityRec,
- typeTabletProximityRec, NULL,
- sizeof(TabletProximityRec),
- NULL, (void *)&tabletProximityRecord))
- {
- if (tabletProximityRecord.enterProximity) {
- //pointer is entering tablet area proximity
-
- switch (tabletProximityRecord.pointerType)
- {
- case 1: /* stylus */
- ct.Active = GHOST_kTabletModeStylus;
- break;
- case 2: /* puck, not supported so far */
- ct.Active = GHOST_kTabletModeNone;
- break;
- case 3: /* eraser */
- ct.Active = GHOST_kTabletModeEraser;
- break;
- default:
- ct.Active = GHOST_kTabletModeNone;
- break;
- }
- }
- else {
- // pointer is leaving - return to mouse
- ct.Active = GHOST_kTabletModeNone;
- }
- }
- }
- err = noErr;
- }
- return err;
-}
-
-OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event)
-{
- OSStatus err = eventNotHandledErr;
- GHOST_IWindow *window = m_windowManager->getActiveWindow();
- UInt32 kind = ::GetEventKind(event);
-
- switch (kind)
- {
- case kEventMouseDown:
- case kEventMouseUp:
- // Handle Mac application responsibilities
- if ((kind == kEventMouseDown) && handleMouseDown(event)) {
- err = noErr;
- }
- else {
- GHOST_TEventType type = (kind == kEventMouseDown) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
- EventMouseButton button;
-
- /* Window still gets mouse up after command-H */
- if (m_windowManager->getActiveWindow()) {
- // handle any tablet events that may have come with the mouse event (optional)
- handleTabletEvent(event);
-
- ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
- pushEvent(new GHOST_EventButton(getMilliSeconds(), type, window, convertButton(button)));
- err = noErr;
- }
- }
- break;
-
- case kEventMouseMoved:
- case kEventMouseDragged:
- {
- Point mousePos;
-
- if (window) {
- //handle any tablet events that may have come with the mouse event (optional)
- handleTabletEvent(event);
-
- ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
- pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v));
- err = noErr;
- }
- break;
- }
- case kEventMouseWheelMoved:
- {
- OSStatus status;
- //UInt32 modifiers;
- EventMouseWheelAxis axis;
- SInt32 delta;
- //status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers);
- //GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
- status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis);
- GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
- if (axis == kEventMouseWheelAxisY)
- {
- status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta);
- GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
- /*
- * Limit mouse wheel delta to plus and minus one.
- */
- delta = delta > 0 ? 1 : -1;
- pushEvent(new GHOST_EventWheel(getMilliSeconds(), window, delta));
- err = noErr;
- }
- }
- break;
- }
-
- return err;
-}
-
-
-OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event)
-{
- OSStatus err = eventNotHandledErr;
- GHOST_IWindow *window = m_windowManager->getActiveWindow();
- UInt32 kind = ::GetEventKind(event);
- UInt32 modifiers;
- UInt32 rawCode;
- GHOST_TKey key;
- unsigned char ascii;
-
- /* Can happen, very rarely - seems to only be when command-H makes
- * the window go away and we still get an HKey up.
- */
- if (!window) {
- //::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode);
- //key = convertKey(rawCode);
- return err;
- }
-
- err = noErr;
- switch (kind) {
- case kEventRawKeyDown:
- case kEventRawKeyRepeat:
- case kEventRawKeyUp:
- ::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode);
- ::GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &ascii);
-
- key = convertKey(rawCode);
- ascii = convertRomanToLatin(ascii);
-
- // if (key!=GHOST_kKeyUnknown) {
- GHOST_TEventType type;
- if (kind == kEventRawKeyDown) {
- type = GHOST_kEventKeyDown;
- }
- else if (kind == kEventRawKeyRepeat) {
- type = GHOST_kEventKeyDown; /* XXX, fixme */
- }
- else {
- type = GHOST_kEventKeyUp;
- }
- pushEvent(new GHOST_EventKey(getMilliSeconds(), type, window, key, ascii, NULL) );
-// }
- break;
-
- case kEventRawKeyModifiersChanged:
- /* ugh */
- ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
- if ((modifiers & shiftKey) != (m_modifierMask & shiftKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & shiftKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) );
- }
- if ((modifiers & controlKey) != (m_modifierMask & controlKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & controlKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) );
- }
- if ((modifiers & optionKey) != (m_modifierMask & optionKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
- }
- if ((modifiers & cmdKey) != (m_modifierMask & cmdKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyOS) );
- }
-
- m_modifierMask = modifiers;
- break;
-
- default:
- err = eventNotHandledErr;
- break;
- }
-
- return err;
-}
-
-
-bool GHOST_SystemCarbon::handleMouseDown(EventRef event)
-{
- WindowPtr window;
- short part;
- BitMap screenBits;
- bool handled = true;
- GHOST_WindowCarbon *ghostWindow;
- Point mousePos = {0, 0};
-
- ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
-
- part = ::FindWindow(mousePos, &window);
- ghostWindow = (GHOST_WindowCarbon *) ::GetWRefCon(window);
-
- switch (part) {
- case inMenuBar:
- handleMenuCommand(::MenuSelect(mousePos));
- break;
-
- case inDrag:
- /*
- * The DragWindow() routine creates a lot of kEventWindowBoundsChanged
- * events. By setting m_ignoreWindowSizedMessages these are suppressed.
- * \see GHOST_SystemCarbon::handleWindowEvent(EventRef event)
- */
- /* even worse: scale window also generates a load of events, and nothing
- * is handled (read: client's event proc called) until you release mouse (ton) */
-
- GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window");
- m_ignoreWindowSizedMessages = true;
- ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds);
- m_ignoreWindowSizedMessages = false;
-
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, ghostWindow) );
-
- break;
-
- case inContent:
- if (window != ::FrontWindow()) {
- ::SelectWindow(window);
- /*
- * We add a mouse down event on the newly actived window
- */
- //GHOST_PRINT("GHOST_SystemCarbon::handleMouseDown(): adding mouse down event, " << ghostWindow << "\n");
- EventMouseButton button;
- ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
- pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonDown, ghostWindow, convertButton(button)));
- }
- else {
- handled = false;
- }
- break;
-
- case inGoAway:
- GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
- if (::TrackGoAway(window, mousePos))
- {
- // todo: add option-close, because it's in the HIG
- // if (event.modifiers & optionKey) {
- // Close the clean documents, others will be confirmed one by one.
- //}
- // else {
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, ghostWindow));
- //}
- }
- break;
-
- case inGrow:
- GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
- ::ResizeWindow(window, mousePos, NULL, NULL);
- break;
-
- case inZoomIn:
- case inZoomOut:
- GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
- if (::TrackBox(window, mousePos, part)) {
- int macState;
-
- macState = ghostWindow->getMac_windowState();
- if (macState == 0)
- ::ZoomWindow(window, part, true);
- else
- if (macState == 2) { // always ok
- ::ZoomWindow(window, part, true);
- ghostWindow->setMac_windowState(1);
- }
- else { // need to force size again
- // GHOST_TUns32 scr_x,scr_y; /*unused*/
- Rect outAvailableRect;
-
- ghostWindow->setMac_windowState(2);
- ::GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect);
-
- //this->getMainDisplayDimensions(scr_x,scr_y);
- ::SizeWindow(window, outAvailableRect.right - outAvailableRect.left, outAvailableRect.bottom - outAvailableRect.top - 1, false);
- ::MoveWindow(window, outAvailableRect.left, outAvailableRect.top, true);
- }
-
- }
- break;
-
- default:
- handled = false;
- break;
- }
-
- return handled;
-}
-
-
-bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult)
-{
- short menuID;
- short menuItem;
- UInt32 command;
- bool handled;
- OSErr err;
-
- menuID = HiWord(menuResult);
- menuItem = LoWord(menuResult);
-
- err = ::GetMenuItemCommandID(::GetMenuHandle(menuID), menuItem, &command);
-
- handled = false;
-
- if (err || command == 0) {
- }
- else {
- switch (command) {
- }
- }
-
- ::HiliteMenu(0);
- return handled;
-}
-
-
-OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData)
-{
- GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) userData;
- OSStatus err = eventNotHandledErr;
- GHOST_IWindow *window;
-#ifdef WITH_INPUT_NDOF
- GHOST_TEventNDOFData data;
-#endif
- UInt32 kind;
-
- switch (::GetEventClass(event))
- {
- case kEventClassAppleEvent:
- EventRecord eventrec;
- if (ConvertEventRefToEventRecord(event, &eventrec)) {
- err = AEProcessAppleEvent(&eventrec);
- }
- break;
- case kEventClassMouse:
- err = sys->handleMouseEvent(event);
- break;
- case kEventClassWindow:
- err = sys->handleWindowEvent(event);
- break;
- case kEventClassKeyboard:
- err = sys->handleKeyEvent(event);
- break;
- case kEventClassBlender:
-#ifdef WITH_INPUT_NDOF
- window = sys->m_windowManager->getActiveWindow();
- sys->m_ndofManager->GHOST_NDOFGetDatas(data);
- kind = ::GetEventKind(event);
-
- switch (kind)
- {
- case 1:
- sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data));
- // printf("motion\n");
- break;
- case 2:
- sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFButton, window, data));
-// printf("button\n");
- break;
- }
-#endif
- err = noErr;
- break;
- default:
- ;
- break;
- }
-
- return err;
-}
-
-GHOST_TUns8 *GHOST_SystemCarbon::getClipboard(bool selection) const
-{
- PasteboardRef inPasteboard;
- PasteboardItemID itemID;
- CFDataRef flavorData;
- OSStatus err = noErr;
- GHOST_TUns8 *temp_buff;
- CFRange range;
- OSStatus syncFlags;
-
- err = PasteboardCreate(kPasteboardClipboard, &inPasteboard);
- if (err != noErr) { return NULL; }
-
- syncFlags = PasteboardSynchronize(inPasteboard);
- /* as we always get in a new string, we can safely ignore sync flags if not an error*/
- if (syncFlags < 0) { return NULL; }
-
-
- err = PasteboardGetItemIdentifier(inPasteboard, 1, &itemID);
- if (err != noErr) { return NULL; }
-
- err = PasteboardCopyItemFlavorData(inPasteboard, itemID, CFSTR("public.utf8-plain-text"), &flavorData);
- if (err != noErr) { return NULL; }
-
- range = CFRangeMake(0, CFDataGetLength(flavorData));
-
- temp_buff = (GHOST_TUns8 *) malloc(range.length + 1);
-
- CFDataGetBytes(flavorData, range, (UInt8 *)temp_buff);
-
- temp_buff[range.length] = '\0';
-
- if (temp_buff) {
- return temp_buff;
- }
- else {
- return NULL;
- }
-}
-
-void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const
-{
- if (selection) {return; } // for copying the selection, used on X11
-
- PasteboardRef inPasteboard;
- CFDataRef textData = NULL;
- OSStatus err = noErr; /*For error checking*/
- OSStatus syncFlags;
-
- err = PasteboardCreate(kPasteboardClipboard, &inPasteboard);
- if (err != noErr) { return; }
-
- syncFlags = PasteboardSynchronize(inPasteboard);
- /* as we always put in a new string, we can safely ignore sync flags */
- if (syncFlags < 0) { return; }
-
- err = PasteboardClear(inPasteboard);
- if (err != noErr) { return; }
-
- textData = CFDataCreate(kCFAllocatorDefault, (UInt8 *)buffer, strlen(buffer));
-
- if (textData) {
- err = PasteboardPutItemFlavor(inPasteboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), textData, 0);
- if (err != noErr) {
- if (textData) { CFRelease(textData); }
- return;
- }
- }
-
- if (textData) {
- CFRelease(textData);
- }
-}
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h
deleted file mode 100644
index 9faf5423205..00000000000
--- a/intern/ghost/intern/GHOST_SystemCarbon.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemCarbon.h
- * \ingroup GHOST
- * Declaration of GHOST_SystemCarbon class.
- */
-
-#ifndef __GHOST_SYSTEMCARBON_H__
-#define __GHOST_SYSTEMCARBON_H__
-
-#ifndef __APPLE__
-#error Apple OSX only!
-#endif // __APPLE__
-
-#define __CARBONSOUND__
-#include <Carbon/Carbon.h>
-
-#include "GHOST_System.h"
-
-class GHOST_EventCursor;
-class GHOST_EventKey;
-class GHOST_EventWindow;
-
-/**
- * OSX/Carbon Implementation of GHOST_System class.
- * \see GHOST_System.
- * \author Maarten Gribnau
- * \date May 21, 2001
- */
-class GHOST_SystemCarbon : public GHOST_System {
-public:
- /**
- * Constructor.
- */
- GHOST_SystemCarbon();
-
- /**
- * Destructor.
- */
- ~GHOST_SystemCarbon();
-
- /***************************************************************************************
- ** Time(r) functionality
- ***************************************************************************************/
-
- /**
- * Returns the system time.
- * Returns the number of milliseconds since the start of the system process.
- * Based on ANSI clock() routine.
- * \return The number of milliseconds.
- */
- virtual GHOST_TUns64 getMilliSeconds() const;
-
- /***************************************************************************************
- ** Display/window management functionality
- ***************************************************************************************/
-
- /**
- * Returns the number of displays on this system.
- * \return The number of displays.
- */
- virtual GHOST_TUns8 getNumDisplays() const;
-
- /**
- * Returns the dimensions of the main display on this system.
- * \return The dimension of the main display.
- */
- virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
-
- /**
- * Returns the combine dimensions of all monitors.
- * \return The dimension of the workspace.
- */
- virtual void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
-
- /**
- * Create a new window.
- * The new window is added to the list of windows managed.
- * Never explicitly delete the window, use disposeWindow() instead.
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
- * \param left The coordinate of the left edge of the window.
- * \param top The coordinate of the top edge of the window.
- * \param width The width the window.
- * \param height The height the window.
- * \param state The state of the window when opened.
- * \param type The type of drawing context installed in this window.
- * \param parentWindow Parent (embedder) window
- * \return The new window (or 0 if creation failed).
- */
- virtual GHOST_IWindow *createWindow(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
- const bool stereoVisual,
- const bool exclusive = false,
- const GHOST_TUns16 numOfAASamples = 0,
- const GHOST_TEmbedderWindowID parentWindow = 0
- );
-
- virtual GHOST_TSuccess beginFullScreen(
- const GHOST_DisplaySetting& setting,
- GHOST_IWindow **window,
- const bool stereoVisual
- );
-
- virtual GHOST_TSuccess endFullScreen(void);
-
- /***************************************************************************************
- ** Event management functionality
- ***************************************************************************************/
-
- /**
- * Gets events from the system and stores them in the queue.
- * \param waitForEvent Flag to wait for an event (or return immediately).
- * \return Indication of the presence of events.
- */
- virtual bool processEvents(bool waitForEvent);
-
- /***************************************************************************************
- ** Cursor management functionality
- ***************************************************************************************/
-
- /**
- * Returns the current location of the cursor (location in screen coordinates)
- * \param x The x-coordinate of the cursor.
- * \param y The y-coordinate of the cursor.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const;
-
- /**
- * Updates the location of the cursor (location in screen coordinates).
- * \param x The x-coordinate of the cursor.
- * \param y The y-coordinate of the cursor.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y);
-
- /***************************************************************************************
- ** Access to mouse button and keyboard states.
- ***************************************************************************************/
-
- /**
- * Returns the state of all modifier keys.
- * \param keys The state of all modifier keys (true == pressed).
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys& keys) const;
-
- /**
- * Returns the state of the mouse buttons (ouside the message queue).
- * \param buttons The state of the buttons.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getButtons(GHOST_Buttons& buttons) const;
-
- /**
- * Returns Clipboard data
- * \param selection Indicate which buffer to return
- * \return Returns the selected buffer
- */
- virtual GHOST_TUns8 *getClipboard(bool selection) const;
-
- /**
- * Puts buffer to system clipboard
- * \param buffer The buffer to be copied
- * \param selection Indicates which buffer to copy too, only used on X11
- */
- virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
-
- /**
- * \see GHOST_ISystem
- */
- int toggleConsole(int action) {
- return 0;
- }
-
-protected:
- /**
- * Initializes the system.
- * For now, it justs registers the window class (WNDCLASS).
- * \return A success value.
- */
- virtual GHOST_TSuccess init();
-
- /**
- * Closes the system down.
- * \return A success value.
- */
- virtual GHOST_TSuccess exit();
-
-
- /**
- * Handles a tablet event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleTabletEvent(EventRef event);
- /**
- * Handles a mouse event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleMouseEvent(EventRef event);
-
- /**
- * Handles a key event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleKeyEvent(EventRef event);
-
- /**
- * Handles a window event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleWindowEvent(EventRef event);
-
- /**
- * Handles all basic Mac application stuff for a mouse down event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- bool handleMouseDown(EventRef event);
-
- /**
- * Handles a Mac menu command.
- * \param menuResult A Mac menu/item identifier.
- * \return Indication whether the event was handled.
- */
- bool handleMenuCommand(GHOST_TInt32 menuResult);
-
- /* callback for blender generated events */
- // static OSStatus blendEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData);
-
-
- /**
- * Callback for Carbon when it has events.
- */
- static OSStatus sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData);
-
- /** Apple Event Handlers */
- static OSErr sAEHandlerLaunch(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
- static OSErr sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
- static OSErr sAEHandlerPrintDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
- static OSErr sAEHandlerQuit(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
-
- /**
- * Callback for Mac Timer tasks that expire.
- * \param tmTask Pointer to the timer task that expired.
- */
- //static void s_timerCallback(TMTaskPtr tmTask);
-
- /** Event handler reference. */
- EventHandlerRef m_handler;
-
- /** Start time at initialization. */
- GHOST_TUns64 m_start_time;
-
- /** State of the modifiers. */
- UInt32 m_modifierMask;
-
- /** Ignores window size messages (when window is dragged). */
- bool m_ignoreWindowSizedMessages;
-};
-
-#endif // __GHOST_SYSTEMCARBON_H__
-
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index fcf39523917..c60ded15d6c 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -57,156 +57,6 @@
#include "AssertMacros.h"
#pragma mark KeyMap, mouse converters
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
-/* Keycodes not defined in Tiger */
-/*
- * Summary:
- * Virtual keycodes
- *
- * Discussion:
- * These constants are the virtual keycodes defined originally in
- * Inside Mac Volume V, pg. V-191. They identify physical keys on a
- * keyboard. Those constants with "ANSI" in the name are labeled
- * according to the key position on an ANSI-standard US keyboard.
- * For example, kVK_ANSI_A indicates the virtual keycode for the key
- * with the letter 'A' in the US keyboard layout. Other keyboard
- * layouts may have the 'A' key label on a different physical key;
- * in this case, pressing 'A' will generate a different virtual
- * keycode.
- */
-enum {
- kVK_ANSI_A = 0x00,
- kVK_ANSI_S = 0x01,
- kVK_ANSI_D = 0x02,
- kVK_ANSI_F = 0x03,
- kVK_ANSI_H = 0x04,
- kVK_ANSI_G = 0x05,
- kVK_ANSI_Z = 0x06,
- kVK_ANSI_X = 0x07,
- kVK_ANSI_C = 0x08,
- kVK_ANSI_V = 0x09,
- kVK_ANSI_B = 0x0B,
- kVK_ANSI_Q = 0x0C,
- kVK_ANSI_W = 0x0D,
- kVK_ANSI_E = 0x0E,
- kVK_ANSI_R = 0x0F,
- kVK_ANSI_Y = 0x10,
- kVK_ANSI_T = 0x11,
- kVK_ANSI_1 = 0x12,
- kVK_ANSI_2 = 0x13,
- kVK_ANSI_3 = 0x14,
- kVK_ANSI_4 = 0x15,
- kVK_ANSI_6 = 0x16,
- kVK_ANSI_5 = 0x17,
- kVK_ANSI_Equal = 0x18,
- kVK_ANSI_9 = 0x19,
- kVK_ANSI_7 = 0x1A,
- kVK_ANSI_Minus = 0x1B,
- kVK_ANSI_8 = 0x1C,
- kVK_ANSI_0 = 0x1D,
- kVK_ANSI_RightBracket = 0x1E,
- kVK_ANSI_O = 0x1F,
- kVK_ANSI_U = 0x20,
- kVK_ANSI_LeftBracket = 0x21,
- kVK_ANSI_I = 0x22,
- kVK_ANSI_P = 0x23,
- kVK_ANSI_L = 0x25,
- kVK_ANSI_J = 0x26,
- kVK_ANSI_Quote = 0x27,
- kVK_ANSI_K = 0x28,
- kVK_ANSI_Semicolon = 0x29,
- kVK_ANSI_Backslash = 0x2A,
- kVK_ANSI_Comma = 0x2B,
- kVK_ANSI_Slash = 0x2C,
- kVK_ANSI_N = 0x2D,
- kVK_ANSI_M = 0x2E,
- kVK_ANSI_Period = 0x2F,
- kVK_ANSI_Grave = 0x32,
- kVK_ANSI_KeypadDecimal = 0x41,
- kVK_ANSI_KeypadMultiply = 0x43,
- kVK_ANSI_KeypadPlus = 0x45,
- kVK_ANSI_KeypadClear = 0x47,
- kVK_ANSI_KeypadDivide = 0x4B,
- kVK_ANSI_KeypadEnter = 0x4C,
- kVK_ANSI_KeypadMinus = 0x4E,
- kVK_ANSI_KeypadEquals = 0x51,
- kVK_ANSI_Keypad0 = 0x52,
- kVK_ANSI_Keypad1 = 0x53,
- kVK_ANSI_Keypad2 = 0x54,
- kVK_ANSI_Keypad3 = 0x55,
- kVK_ANSI_Keypad4 = 0x56,
- kVK_ANSI_Keypad5 = 0x57,
- kVK_ANSI_Keypad6 = 0x58,
- kVK_ANSI_Keypad7 = 0x59,
- kVK_ANSI_Keypad8 = 0x5B,
- kVK_ANSI_Keypad9 = 0x5C
-};
-
-/* keycodes for keys that are independent of keyboard layout*/
-enum {
- kVK_Return = 0x24,
- kVK_Tab = 0x30,
- kVK_Space = 0x31,
- kVK_Delete = 0x33,
- kVK_Escape = 0x35,
- kVK_Command = 0x37,
- kVK_Shift = 0x38,
- kVK_CapsLock = 0x39,
- kVK_Option = 0x3A,
- kVK_Control = 0x3B,
- kVK_RightShift = 0x3C,
- kVK_RightOption = 0x3D,
- kVK_RightControl = 0x3E,
- kVK_Function = 0x3F,
- kVK_F17 = 0x40,
- kVK_VolumeUp = 0x48,
- kVK_VolumeDown = 0x49,
- kVK_Mute = 0x4A,
- kVK_F18 = 0x4F,
- kVK_F19 = 0x50,
- kVK_F20 = 0x5A,
- kVK_F5 = 0x60,
- kVK_F6 = 0x61,
- kVK_F7 = 0x62,
- kVK_F3 = 0x63,
- kVK_F8 = 0x64,
- kVK_F9 = 0x65,
- kVK_F11 = 0x67,
- kVK_F13 = 0x69,
- kVK_F16 = 0x6A,
- kVK_F14 = 0x6B,
- kVK_F10 = 0x6D,
- kVK_F12 = 0x6F,
- kVK_F15 = 0x71,
- kVK_Help = 0x72,
- kVK_Home = 0x73,
- kVK_PageUp = 0x74,
- kVK_ForwardDelete = 0x75,
- kVK_F4 = 0x76,
- kVK_End = 0x77,
- kVK_F2 = 0x78,
- kVK_PageDown = 0x79,
- kVK_F1 = 0x7A,
- kVK_LeftArrow = 0x7B,
- kVK_RightArrow = 0x7C,
- kVK_DownArrow = 0x7D,
- kVK_UpArrow = 0x7E
-};
-
-/* ISO keyboards only*/
-enum {
- kVK_ISO_Section = 0x0A
-};
-
-/* JIS keyboards only*/
-enum {
- kVK_JIS_Yen = 0x5D,
- kVK_JIS_Underscore = 0x5E,
- kVK_JIS_KeypadComma = 0x5F,
- kVK_JIS_Eisu = 0x66,
- kVK_JIS_Kana = 0x68
-};
-#endif
static GHOST_TButtonMask convertButton(int button)
{
@@ -361,47 +211,28 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
return (GHOST_TKey) (recvChar - 'a' + GHOST_kKeyA);
}
else {
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
- KeyboardLayoutRef keyLayout;
- UCKeyboardLayout *uchrData;
-
- KLGetCurrentKeyboardLayout(&keyLayout);
- KLGetKeyboardLayoutProperty(keyLayout, kKLuchrData, (const void **)
- &uchrData);
- /*get actual character value of the "remappable" keys in int'l keyboards,
- if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
- then fallback on using the received charactersIgnoringModifiers */
- if (uchrData)
- {
- UInt32 deadKeyState=0;
- UniCharCount actualStrLength=0;
-
- UCKeyTranslate(uchrData, rawCode, keyAction, 0,
- LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar);
-
- }
-#else
- /* Leopard and Snow Leopard 64bit compatible API*/
- CFDataRef uchrHandle; /*the keyboard layout*/
- TISInputSourceRef kbdTISHandle;
+
+ /* Leopard and Snow Leopard 64bit compatible API*/
+ CFDataRef uchrHandle; /*the keyboard layout*/
+ TISInputSourceRef kbdTISHandle;
+
+ kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource();
+ uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData);
+ CFRelease(kbdTISHandle);
+
+ /*get actual character value of the "remappable" keys in int'l keyboards,
+ if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
+ then fallback on using the received charactersIgnoringModifiers */
+ if (uchrHandle)
+ {
+ UInt32 deadKeyState=0;
+ UniCharCount actualStrLength=0;
- kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource();
- uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData);
- CFRelease(kbdTISHandle);
+ UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0,
+ LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar);
- /*get actual character value of the "remappable" keys in int'l keyboards,
- if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
- then fallback on using the received charactersIgnoringModifiers */
- if (uchrHandle)
- {
- UInt32 deadKeyState=0;
- UniCharCount actualStrLength=0;
-
- UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0,
- LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar);
-
- }
-#endif
+ }
+
switch (recvChar) {
case '-': return GHOST_kKeyMinus;
case '=': return GHOST_kKeyEqual;
@@ -424,26 +255,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
#pragma mark defines for 10.6 api not documented in 10.5
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
-enum {
- /* The following event types are available on some hardware on 10.5.2 and later */
- NSEventTypeGesture = 29,
- NSEventTypeMagnify = 30,
- NSEventTypeSwipe = 31,
- NSEventTypeRotate = 18,
- NSEventTypeBeginGesture = 19,
- NSEventTypeEndGesture = 20
-};
-
-@interface NSEvent(GestureEvents)
-- (float)magnification; // change in magnification.
-#else
-@interface NSEvent(GestureEvents)
-- (CGFloat)magnification; // change in magnification on 10.5.2 or later.
-@end
-
-#endif
-
#pragma mark Utility functions
@@ -464,29 +275,6 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
}
}
-#if defined(WITH_QUICKTIME) && !defined(USE_QTKIT)
-//Need to place this quicktime function in an ObjC file
-//It is used to avoid memory leak when raising the quicktime "compression settings" standard dialog
-extern "C" {
- struct bContext;
- struct wmOperator;
- extern int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op);
-
-
-int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
-{
- int result;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- result = fromcocoa_request_qtcodec_settings(C, op);
-
- [pool drain];
- return result;
-}
-};
-#endif
-
-
#pragma mark Cocoa objects
/**
@@ -517,7 +305,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
- //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be cancelled
+ //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be canceled
//Note that Cmd+Q is already handled by keyhandler
if (systemCocoa->handleQuitRequest() == GHOST_kExitNow)
return NSTerminateCancel;//NSTerminateNow;
@@ -525,7 +313,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
return NSTerminateCancel;
}
-// To avoid cancelling a log off process, we must use Cocoa termination process
+// To avoid canceling a log off process, we must use Cocoa termination process
// And this function is the only chance to perform clean up
// So WM_exit needs to be called directly, as the event loop will never run before termination
- (void)applicationWillTerminate:(NSNotification *)aNotification
diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp b/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp
deleted file mode 100644
index 7d43392a79c..00000000000
--- a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Damien Plisson 2010
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemPathsCarbon.cpp
- * \ingroup GHOST
- */
-
-
-#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include "GHOST_SystemPathsCarbon.h"
-
-
-/***/
-
-GHOST_SystemPathsCarbon::GHOST_SystemPathsCarbon()
-{
-}
-
-GHOST_SystemPathsCarbon::~GHOST_SystemPathsCarbon()
-{
-}
-
-const GHOST_TUns8 *GHOST_SystemPathsCarbon::getSystemDir(int, const char *versionstr) const
-{
- static char systemPath[1024];
-
- snprintf(systemPath, sizeof(systemPath), "/Library/Application Support/Blender/%s", versionstr);
-
- return (GHOST_TUns8*)systemPath;
-}
-
-const GHOST_TUns8 *GHOST_SystemPathsCarbon::getUserDir(int, const char *versionstr) const
-{
- static char usrPath[1024];
- char *env = getenv("HOME");
-
- if (env) {
- snprintf(usrPath, sizeof(usrPath), "%s/Library/Application Support/Blender/%s", env, versionstr);
- return (GHOST_TUns8*)usrPath;
- }
- else
- return NULL;
-}
-
-const GHOST_TUns8 *GHOST_SystemPathsCarbon::getBinaryDir() const
-{
- CFURLRef bundleURL;
- CFStringRef pathStr;
- static char path[256];
- CFBundleRef mainBundle = CFBundleGetMainBundle();
-
- bundleURL = CFBundleCopyBundleURL(mainBundle);
- pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
- CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII);
- CFRelease(pathStr);
- CFRelease(bundleURL);
- return (GHOST_TUns8 *)path;
-}
-
-void GHOST_SystemPathsCarbon::addToSystemRecentFiles(const char *filename) const
-{
- /* XXXXX TODO: Implementation for Carbon if possible */
-
-}
diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.h b/intern/ghost/intern/GHOST_SystemPathsCarbon.h
deleted file mode 100644
index 9d9a3a22564..00000000000
--- a/intern/ghost/intern/GHOST_SystemPathsCarbon.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ***** 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) 2010 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Damien Plisson 2010
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemPathsCarbon.h
- * \ingroup GHOST
- */
-
-
-#ifndef __GHOST_SYSTEMPATHSCARBON_H__
-#define __GHOST_SYSTEMPATHSCARBON_H__
-
-#ifndef __APPLE__
-#error Apple OSX only!
-#endif // __APPLE__
-
-#include <Carbon/Carbon.h>
-
-#include "GHOST_SystemPaths.h"
-
-/**
- * OSX/Carbon Implementation of GHOST_SystemPaths class.
- * \see GHOST_System.
- * \author Andrea Weikert
- * \date Aug 1, 2010
- */
-class GHOST_SystemPathsCarbon : public GHOST_SystemPaths {
-public:
- /**
- * Constructor.
- */
- GHOST_SystemPathsCarbon();
-
- /**
- * Destructor.
- */
- ~GHOST_SystemPathsCarbon();
-
- /**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, including versioning.
- * \return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- virtual const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const;
-
- /**
- * Determine the base dir in which user configuration is stored, including versioning.
- * If needed, it will create the base directory.
- * \return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- virtual const GHOST_TUns8 *getUserDir(int version, const char *versionstr) const;
-
- /**
- * Determine the directory of the current binary
- * \return Unsigned char string pointing to the binary dir
- */
- virtual const GHOST_TUns8 *getBinaryDir() const;
-
- /**
- * Add the file to the operating system most recently used files
- */
- void addToSystemRecentFiles(const char *filename) const;
-};
-
-#endif // __GHOST_SYSTEMPATHSCARBON_H__
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp
deleted file mode 100644
index 36d45b4790c..00000000000
--- a/intern/ghost/intern/GHOST_WindowCarbon.cpp
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_WindowCarbon.cpp
- * \ingroup GHOST
- */
-
-
-/**
- * Copyright (C) 2001 NaN Technologies B.V.
- * \author Maarten Gribnau
- * \date May 10, 2001
- */
-
-#include "GHOST_WindowCarbon.h"
-#include "GHOST_Debug.h"
-
-AGLContext GHOST_WindowCarbon::s_firstaglCtx = NULL;
-#ifdef GHOST_DRAW_CARBON_GUTTER
-const GHOST_TInt32 GHOST_WindowCarbon::s_sizeRectSize = 16;
-#endif //GHOST_DRAW_CARBON_GUTTER
-
-static const GLint sPreferredFormatWindow[10] = {
- AGL_RGBA,
- AGL_DOUBLEBUFFER,
- AGL_ACCELERATED,
- AGL_DEPTH_SIZE, 32,
- AGL_NONE,
-};
-
-static const GLint sPreferredFormatFullScreen[11] = {
- AGL_RGBA,
- AGL_DOUBLEBUFFER,
- AGL_ACCELERATED,
- AGL_FULLSCREEN,
- AGL_DEPTH_SIZE, 32,
- AGL_NONE,
-};
-
-
-
-WindowRef ugly_hack = NULL;
-
-const EventTypeSpec kWEvents[] = {
- { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */
-};
-
-static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData)
-{
- WindowRef mywindow;
- GHOST_WindowCarbon *ghost_window;
- OSStatus err;
- int theState;
-
- if (::GetEventKind(event) == kEventWindowZoom) {
- err = ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(mywindow), NULL, &mywindow);
- ghost_window = (GHOST_WindowCarbon *) GetWRefCon(mywindow);
- theState = ghost_window->getMac_windowState();
- if (theState == 1)
- ghost_window->setMac_windowState(2);
- else if (theState == 2)
- ghost_window->setMac_windowState(1);
-
- }
- return eventNotHandledErr;
-}
-
-GHOST_WindowCarbon::GHOST_WindowCarbon(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
- const bool stereoVisual,
- const GHOST_TUns16 numOfAASamples
- ) :
- GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone),
- m_windowRef(0),
- m_grafPtr(0),
- m_aglCtx(0),
- m_customCursor(0),
- m_fullScreenDirty(false)
-{
- Str255 title255;
- OSStatus err;
-
- //fprintf(stderr," main screen top %i left %i height %i width %i\n", top, left, height, width);
-
- if (state >= GHOST_kWindowState8Normal) {
- if (state == GHOST_kWindowState8Normal) state = GHOST_kWindowStateNormal;
- else if (state == GHOST_kWindowState8Maximized) state = GHOST_kWindowStateMaximized;
- else if (state == GHOST_kWindowState8Minimized) state = GHOST_kWindowStateMinimized;
- else if (state == GHOST_kWindowState8FullScreen) state = GHOST_kWindowStateFullScreen;
-
- // state = state - 8; this was the simple version of above code, doesnt work in gcc 4.0
-
- setMac_windowState(1);
- }
- else
- setMac_windowState(0);
-
- if (state != GHOST_kWindowStateFullScreen) {
- Rect bnds = { top, left, top + height, left + width };
- // Boolean visible = (state == GHOST_kWindowStateNormal) || (state == GHOST_kWindowStateMaximized); /*unused*/
- gen2mac(title, title255);
-
- err = ::CreateNewWindow(kDocumentWindowClass,
- kWindowStandardDocumentAttributes + kWindowLiveResizeAttribute,
- &bnds,
- &m_windowRef);
-
- if (err != noErr) {
- fprintf(stderr, " error creating window %i \n", (int)err);
- }
- else {
-
- ::SetWRefCon(m_windowRef, (SInt32) this);
- setTitle(title);
- err = InstallWindowEventHandler(m_windowRef, myWEventHandlerProc, GetEventTypeCount(kWEvents), kWEvents, NULL, NULL);
- if (err != noErr) {
- fprintf(stderr, " error creating handler %i \n", (int)err);
- }
- else {
- // ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL);
- ::ShowWindow(m_windowRef);
- ::MoveWindow(m_windowRef, left, top, true);
-
- }
- }
- if (m_windowRef) {
- m_grafPtr = ::GetWindowPort(m_windowRef);
- setDrawingContextType(type);
- updateDrawingContext();
- activateDrawingContext();
- }
- if (ugly_hack == NULL) {
- ugly_hack = m_windowRef;
- // when started from commandline, window remains in the back... also for play anim
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- SetFrontProcess(&psn);
- }
- }
- else {
-#if 0
- Rect bnds = { top, left, top + height, left + width };
- gen2mac("", title255);
- m_windowRef = ::NewCWindow(
- nil, // Storage
- &bnds, // Bounding rectangle of the window
- title255, // Title of the window
- 0, // Window initially visible
- plainDBox, // procID
- (WindowRef) - 1L, // Put window before all other windows
- 0, // Window has minimize box
- (SInt32) this); // Store a pointer to the class in the refCon
-#endif
- //GHOST_PRINT("GHOST_WindowCarbon::GHOST_WindowCarbon(): creating full-screen OpenGL context\n");
- setDrawingContextType(GHOST_kDrawingContextTypeOpenGL);
- installDrawingContext(GHOST_kDrawingContextTypeOpenGL);
- updateDrawingContext();
- activateDrawingContext();
-
- m_tablet.Active = GHOST_kTabletModeNone;
- }
-}
-
-
-GHOST_WindowCarbon::~GHOST_WindowCarbon()
-{
- if (m_customCursor) delete m_customCursor;
-
- if (ugly_hack == m_windowRef) ugly_hack = NULL;
-
- // printf("GHOST_WindowCarbon::~GHOST_WindowCarbon(): removing drawing context\n");
- if (ugly_hack == NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone);
- if (m_windowRef) {
- ::DisposeWindow(m_windowRef);
- m_windowRef = 0;
- }
-}
-
-bool GHOST_WindowCarbon::getValid() const
-{
- bool valid;
- if (!m_fullScreen) {
- valid = (m_windowRef != 0) && (m_grafPtr != 0) && ::IsValidWindowPtr(m_windowRef);
- }
- else {
- valid = true;
- }
- return valid;
-}
-
-
-void GHOST_WindowCarbon::setTitle(const STR_String& title)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setTitle(): window invalid");
- Str255 title255;
- gen2mac(title, title255);
- ::SetWTitle(m_windowRef, title255);
-}
-
-
-void GHOST_WindowCarbon::getTitle(STR_String& title) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getTitle(): window invalid");
- Str255 title255;
- ::GetWTitle(m_windowRef, title255);
- mac2gen(title255, title);
-}
-
-
-void GHOST_WindowCarbon::getWindowBounds(GHOST_Rect& bounds) const
-{
- OSStatus success;
- Rect rect;
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getWindowBounds(): window invalid");
- success = ::GetWindowBounds(m_windowRef, kWindowStructureRgn, &rect);
- bounds.m_b = rect.bottom;
- bounds.m_l = rect.left;
- bounds.m_r = rect.right;
- bounds.m_t = rect.top;
-}
-
-
-void GHOST_WindowCarbon::getClientBounds(GHOST_Rect& bounds) const
-{
- Rect rect;
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getClientBounds(): window invalid");
- //::GetPortBounds(m_grafPtr, &rect);
- ::GetWindowBounds(m_windowRef, kWindowContentRgn, &rect);
-
- bounds.m_b = rect.bottom;
- bounds.m_l = rect.left;
- bounds.m_r = rect.right;
- bounds.m_t = rect.top;
-
- // Subtract gutter height from bottom
-#ifdef GHOST_DRAW_CARBON_GUTTER
- if ((bounds.m_b - bounds.m_t) > s_sizeRectSize)
- {
- bounds.m_b -= s_sizeRectSize;
- }
- else {
- bounds.m_t = bounds.m_b;
- }
-#endif //GHOST_DRAW_CARBON_GUTTER
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setClientWidth(GHOST_TUns32 width)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientWidth(): window invalid");
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
- if (((GHOST_TUns32)cBnds.getWidth()) != width) {
- ::SizeWindow(m_windowRef, width, cBnds.getHeight(), true);
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setClientHeight(GHOST_TUns32 height)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientHeight(): window invalid");
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
-#ifdef GHOST_DRAW_CARBON_GUTTER
- if (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize) {
- ::SizeWindow(m_windowRef, cBnds.getWidth(), height + s_sizeRectSize, true);
- }
-#else //GHOST_DRAW_CARBON_GUTTER
- if (((GHOST_TUns32)cBnds.getHeight()) != height) {
- ::SizeWindow(m_windowRef, cBnds.getWidth(), height, true);
- }
-#endif //GHOST_DRAW_CARBON_GUTTER
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setClientSize(GHOST_TUns32 width, GHOST_TUns32 height)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientSize(): window invalid");
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
-#ifdef GHOST_DRAW_CARBON_GUTTER
- if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
- (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize))
- {
- ::SizeWindow(m_windowRef, width, height + s_sizeRectSize, true);
- }
-#else //GHOST_DRAW_CARBON_GUTTER
- if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
- (((GHOST_TUns32)cBnds.getHeight()) != height)) {
- ::SizeWindow(m_windowRef, width, height, true);
- }
-#endif //GHOST_DRAW_CARBON_GUTTER
- return GHOST_kSuccess;
-}
-
-
-GHOST_TWindowState GHOST_WindowCarbon::getState() const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getState(): window invalid");
- GHOST_TWindowState state;
- if (::IsWindowVisible(m_windowRef) == false) {
- state = GHOST_kWindowStateMinimized;
- }
- else if (::IsWindowInStandardState(m_windowRef, nil, nil)) {
- state = GHOST_kWindowStateMaximized;
- }
- else {
- state = GHOST_kWindowStateNormal;
- }
- return state;
-}
-
-
-void GHOST_WindowCarbon::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::screenToClient(): window invalid");
- Point point;
- point.h = inX;
- point.v = inY;
- GrafPtr oldPort;
- ::GetPort(&oldPort);
- ::SetPort(m_grafPtr);
- ::GlobalToLocal(&point);
- ::SetPort(oldPort);
- outX = point.h;
- outY = point.v;
-}
-
-
-void GHOST_WindowCarbon::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::clientToScreen(): window invalid");
- Point point;
- point.h = inX;
- point.v = inY;
- GrafPtr oldPort;
- ::GetPort(&oldPort);
- ::SetPort(m_grafPtr);
- ::LocalToGlobal(&point);
- ::SetPort(oldPort);
- outX = point.h;
- outY = point.v;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setState(GHOST_TWindowState state)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setState(): window invalid");
- switch (state) {
- case GHOST_kWindowStateMinimized:
- ::HideWindow(m_windowRef);
- break;
- case GHOST_kWindowStateModified:
- SetWindowModified(m_windowRef, 1);
- break;
- case GHOST_kWindowStateUnModified:
- SetWindowModified(m_windowRef, 0);
- break;
- case GHOST_kWindowStateMaximized:
- case GHOST_kWindowStateNormal:
- default:
- ::ShowWindow(m_windowRef);
- break;
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setOrder(GHOST_TWindowOrder order)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setOrder(): window invalid");
- if (order == GHOST_kWindowOrderTop) {
- //::BringToFront(m_windowRef); is wrong, front window should be active for input too
- ::SelectWindow(m_windowRef);
- }
- else {
- /* doesnt work if you do this with a mouseclick */
- ::SendBehind(m_windowRef, nil);
- }
- return GHOST_kSuccess;
-}
-
-/*#define WAIT_FOR_VSYNC 1*/
-#ifdef WAIT_FOR_VSYNC
-#include <OpenGL/OpenGL.h>
-#endif
-
-GHOST_TSuccess GHOST_WindowCarbon::swapBuffers()
-{
-#ifdef WAIT_FOR_VSYNC
-/* wait for vsync, to avoid tearing artifacts */
- long VBL = 1;
- CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL);
-#endif
-
- GHOST_TSuccess succeeded = GHOST_kSuccess;
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_aglCtx) {
- ::aglSwapBuffers(m_aglCtx);
- }
- else {
- succeeded = GHOST_kFailure;
- }
- }
- return succeeded;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::updateDrawingContext()
-{
- GHOST_TSuccess succeeded = GHOST_kSuccess;
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_aglCtx) {
- ::aglUpdateContext(m_aglCtx);
- }
- else {
- succeeded = GHOST_kFailure;
- }
- }
- return succeeded;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::activateDrawingContext()
-{
- GHOST_TSuccess succeeded = GHOST_kSuccess;
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_aglCtx) {
- ::aglSetCurrentContext(m_aglCtx);
-#ifdef GHOST_DRAW_CARBON_GUTTER
- // Restrict drawing to non-gutter area
- ::aglEnable(m_aglCtx, AGL_BUFFER_RECT);
- GHOST_Rect bnds;
- getClientBounds(bnds);
- GLint b[4] =
- {
- bnds.m_l,
- bnds.m_t + s_sizeRectSize,
- bnds.m_r - bnds.m_l,
- bnds.m_b - bnds.m_t
- };
- GLboolean result = ::aglSetInteger(m_aglCtx, AGL_BUFFER_RECT, b);
-#endif //GHOST_DRAW_CARBON_GUTTER
- }
- else {
- succeeded = GHOST_kFailure;
- }
- }
- return succeeded;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::installDrawingContext(GHOST_TDrawingContextType type)
-{
- GHOST_TSuccess success = GHOST_kFailure;
- switch (type) {
- case GHOST_kDrawingContextTypeOpenGL:
- {
- if (!getValid()) break;
-
- AGLPixelFormat pixelFormat;
- if (!m_fullScreen) {
- pixelFormat = ::aglChoosePixelFormat(0, 0, sPreferredFormatWindow);
- m_aglCtx = ::aglCreateContext(pixelFormat, s_firstaglCtx);
- if (!m_aglCtx) break;
- if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx;
- success = ::aglSetDrawable(m_aglCtx, m_grafPtr) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure;
- }
- else {
- //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL\n");
- GDHandle device = ::GetMainDevice(); pixelFormat = ::aglChoosePixelFormat(&device, 1, sPreferredFormatFullScreen);
- m_aglCtx = ::aglCreateContext(pixelFormat, 0);
- if (!m_aglCtx) break;
- if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx;
- //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): created OpenGL context\n");
- //::CGGetActiveDisplayList(0, NULL, &m_numDisplays)
- success = ::aglSetFullScreen(m_aglCtx, m_fullScreenWidth, m_fullScreenHeight, 75, 0) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure;
-#if 0
- if (success == GHOST_kSuccess) {
- GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL succeeded\n");
- }
- else {
- GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL failed\n");
- }
-#endif
- }
- ::aglDestroyPixelFormat(pixelFormat);
- }
- break;
-
- case GHOST_kDrawingContextTypeNone:
- success = GHOST_kSuccess;
- break;
-
- default:
- break;
- }
- return success;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::removeDrawingContext()
-{
- GHOST_TSuccess success = GHOST_kFailure;
- switch (m_drawingContextType) {
- case GHOST_kDrawingContextTypeOpenGL:
- if (m_aglCtx) {
- aglSetCurrentContext(NULL);
- aglSetDrawable(m_aglCtx, NULL);
- //aglDestroyContext(m_aglCtx);
- if (s_firstaglCtx == m_aglCtx) s_firstaglCtx = NULL;
- success = ::aglDestroyContext(m_aglCtx) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure;
- m_aglCtx = 0;
- }
- break;
- case GHOST_kDrawingContextTypeNone:
- success = GHOST_kSuccess;
- break;
- default:
- break;
- }
- return success;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::invalidate()
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::invalidate(): window invalid");
- if (!m_fullScreen) {
- Rect rect;
- ::GetPortBounds(m_grafPtr, &rect);
- ::InvalWindowRect(m_windowRef, &rect);
- }
- else {
- //EventRef event;
- //OSStatus status = ::CreateEvent(NULL, kEventClassWindow, kEventWindowUpdate, 0, 0, &event);
- //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): created event " << status << " \n");
- //status = ::SetEventParameter(event, kEventParamDirectObject, typeWindowRef, sizeof(WindowRef), this);
- //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): set event parameter " << status << " \n");
- //status = ::PostEventToQueue(::GetMainEventQueue(), event, kEventPriorityStandard);
- //status = ::SendEventToEventTarget(event, ::GetApplicationEventTarget());
- //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): added event to queue " << status << " \n");
- m_fullScreenDirty = true;
- }
- return GHOST_kSuccess;
-}
-
-
-void GHOST_WindowCarbon::gen2mac(const STR_String& in, Str255 out) const
-{
- STR_String tempStr = in;
- int num = tempStr.Length();
- if (num > 255) num = 255;
- ::memcpy(out + 1, tempStr.Ptr(), num);
- out[0] = num;
-}
-
-
-void GHOST_WindowCarbon::mac2gen(const Str255 in, STR_String& out) const
-{
- char tmp[256];
- ::memcpy(tmp, in + 1, in[0]);
- tmp[in[0]] = '\0';
- out = tmp;
-}
-
-void GHOST_WindowCarbon::loadCursor(bool visible, GHOST_TStandardCursor cursor) const
-{
- static bool systemCursorVisible = true;
-
- if (visible != systemCursorVisible) {
- if (visible) {
- ::ShowCursor();
- systemCursorVisible = true;
- }
- else {
- ::HideCursor();
- systemCursorVisible = false;
- }
- }
-
- if (cursor == GHOST_kStandardCursorCustom && m_customCursor) {
- ::SetCursor(m_customCursor);
- }
- else {
- int carbon_cursor;
-
-#define GCMAP(ghostCursor, carbonCursor) case ghostCursor: carbon_cursor = carbonCursor; break
- switch (cursor) {
- default:
- GCMAP(GHOST_kStandardCursorDefault, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorRightArrow, kThemeAliasArrowCursor);
- GCMAP(GHOST_kStandardCursorLeftArrow, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorInfo, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorDestroy, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorHelp, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorCycle, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorSpray, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorWait, kThemeWatchCursor);
- GCMAP(GHOST_kStandardCursorText, kThemeIBeamCursor);
- GCMAP(GHOST_kStandardCursorCrosshair, kThemeCrossCursor);
- GCMAP(GHOST_kStandardCursorUpDown, kThemeClosedHandCursor);
- GCMAP(GHOST_kStandardCursorLeftRight, kThemeClosedHandCursor);
- GCMAP(GHOST_kStandardCursorTopSide, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorBottomSide, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorLeftSide, kThemeResizeLeftCursor);
- GCMAP(GHOST_kStandardCursorRightSide, kThemeResizeRightCursor);
- GCMAP(GHOST_kStandardCursorTopLeftCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorTopRightCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorBottomRightCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorBottomLeftCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorCopy, kThemeCopyArrowCursor);
- };
-#undef GCMAP
-
- ::SetThemeCursor(carbon_cursor);
- }
-}
-
-
-bool GHOST_WindowCarbon::getFullScreenDirty()
-{
- return m_fullScreen && m_fullScreenDirty;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorVisibility(bool visible)
-{
- if (::FrontWindow() == m_windowRef) {
- loadCursor(visible, getCursorShape());
- }
-
- return GHOST_kSuccess;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorShape(GHOST_TStandardCursor shape)
-{
- if (m_customCursor) {
- delete m_customCursor;
- m_customCursor = 0;
- }
-
- if (::FrontWindow() == m_windowRef) {
- loadCursor(getCursorVisibility(), shape);
- }
-
- return GHOST_kSuccess;
-}
-
-#if 0 /* UNUSED */
-/** Reverse the bits in a GHOST_TUns8 */
-static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
-{
- ch = ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA);
- ch = ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC);
- ch = ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0);
- return ch;
-}
-#endif
-
-
-/** Reverse the bits in a GHOST_TUns16 */
-static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
-{
- shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA);
- shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC);
- shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0);
- shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00);
- return shrt;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
- int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color)
-{
- int y;
-
- if (m_customCursor) {
- delete m_customCursor;
- m_customCursor = 0;
- }
-
- m_customCursor = new Cursor;
- if (!m_customCursor) return GHOST_kFailure;
-
- for (y = 0; y < 16; y++) {
-#if !defined(__LITTLE_ENDIAN__)
- m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8));
- m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y] << 0) | (mask[2 * y + 1] << 8));
-#else
- m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8));
- m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y + 1] << 0) | (mask[2 * y] << 8));
-#endif
-
- }
-
- m_customCursor->hotSpot.h = hotX;
- m_customCursor->hotSpot.v = hotY;
-
- if (::FrontWindow() == m_windowRef) {
- loadCursor(getCursorVisibility(), GHOST_kStandardCursorCustom);
- }
-
- return GHOST_kSuccess;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2], int hotX, int hotY)
-{
- return setWindowCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *) mask, 16, 16, hotX, hotY, 0, 1);
-}
-
-
-void GHOST_WindowCarbon::setMac_windowState(short value)
-{
- mac_windowState = value;
-}
-
-short GHOST_WindowCarbon::getMac_windowState()
-{
- return mac_windowState;
-}
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.h b/intern/ghost/intern/GHOST_WindowCarbon.h
deleted file mode 100644
index 16f305e93c5..00000000000
--- a/intern/ghost/intern/GHOST_WindowCarbon.h
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_WindowCarbon.h
- * \ingroup GHOST
- * Declaration of GHOST_WindowCarbon class.
- */
-
-#ifndef __GHOST_WINDOWCARBON_H__
-#define __GHOST_WINDOWCARBON_H__
-
-#ifndef __APPLE__
-#error Apple OSX only!
-#endif // __APPLE__
-
-#include "GHOST_Window.h"
-#include "STR_String.h"
-
-#define __CARBONSOUND__
-#include <Carbon/Carbon.h>
-
-#include <AGL/agl.h>
-
-
-/**
- * Window on Mac OSX/Carbon.
- * Carbon windows have a size widget in the lower right corner of the window.
- * To force it to be visible, the height of the client rectangle is reduced so
- * that applications do not draw in that area. GHOST will manage that area
- * which is called the gutter.
- * When OpenGL contexts are active, GHOST will use AGL_BUFFER_RECT to prevent
- * OpenGL drawing outside the reduced client rectangle.
- * \author Maarten Gribnau
- * \date May 23, 2001
- */
-class GHOST_WindowCarbon : public GHOST_Window {
-public:
- /**
- * Constructor.
- * Creates a new window and opens it.
- * To check if the window was created properly, use the getValid() method.
- * \param title The text shown in the title bar of the window.
- * \param left The coordinate of the left edge of the window.
- * \param top The coordinate of the top edge of the window.
- * \param width The width the window.
- * \param height The height the window.
- * \param state The state the window is initially opened with.
- * \param type The type of drawing context installed in this window.
- * \param stereoVisual Stereo visual for quad buffered stereo.
- */
- GHOST_WindowCarbon(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
- const bool stereoVisual = false,
- const GHOST_TUns16 numOfAASamples = 0
- );
-
- /**
- * Destructor.
- * Closes the window and disposes resources allocated.
- */
- virtual ~GHOST_WindowCarbon();
-
- /**
- * Returns indication as to whether the window is valid.
- * \return The validity of the window.
- */
- virtual bool getValid() const;
-
- /**
- * Sets the title displayed in the title bar.
- * \param title The title to display in the title bar.
- */
- virtual void setTitle(const STR_String& title);
-
- /**
- * Returns the title displayed in the title bar.
- * \param title The title displayed in the title bar.
- */
- virtual void getTitle(STR_String& title) const;
-
- /**
- * Returns the window rectangle dimensions.
- * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
- * \param bounds The bounding rectangle of the window.
- */
- virtual void getWindowBounds(GHOST_Rect& bounds) const;
-
- /**
- * Returns the client rectangle dimensions.
- * The left and top members of the rectangle are always zero.
- * \param bounds The bounding rectangle of the cleient area of the window.
- */
- virtual void getClientBounds(GHOST_Rect& bounds) const;
-
- /**
- * Resizes client rectangle width.
- * \param width The new width of the client area of the window.
- */
- virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width);
-
- /**
- * Resizes client rectangle height.
- * \param height The new height of the client area of the window.
- */
- virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height);
-
- /**
- * Resizes client rectangle.
- * \param width The new width of the client area of the window.
- * \param height The new height of the client area of the window.
- */
- virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height);
-
- /**
- * Returns the state of the window (normal, minimized, maximized).
- * \return The state of the window.
- */
- virtual GHOST_TWindowState getState() const;
-
- /**
- * Converts a point in screen coordinates to client rectangle coordinates
- * \param inX The x-coordinate on the screen.
- * \param inY The y-coordinate on the screen.
- * \param outX The x-coordinate in the client rectangle.
- * \param outY The y-coordinate in the client rectangle.
- */
- virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
-
- /**
- * Converts a point in screen coordinates to client rectangle coordinates
- * \param inX The x-coordinate in the client rectangle.
- * \param inY The y-coordinate in the client rectangle.
- * \param outX The x-coordinate on the screen.
- * \param outY The y-coordinate on the screen.
- */
- virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
-
- /**
- * Sets the state of the window (normal, minimized, maximized).
- * \param state The state of the window.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setState(GHOST_TWindowState state);
-
- /**
- * Sets the order of the window (bottom, top).
- * \param order The order of the window.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
-
- /**
- * Swaps front and back buffers of a window.
- * \return A boolean success indicator.
- */
- virtual GHOST_TSuccess swapBuffers();
-
- /**
- * Updates the drawing context of this window. Needed
- * whenever the window is changed.
- * \return Indication of success.
- */
- GHOST_TSuccess updateDrawingContext();
-
- /**
- * Activates the drawing context of this window.
- * \return A boolean success indicator.
- */
- virtual GHOST_TSuccess activateDrawingContext();
-
- virtual void loadCursor(bool visible, GHOST_TStandardCursor cursor) const;
-
- /**
- * Returns the dirty state of the window when in full-screen mode.
- * \return Whether it is dirty.
- */
- virtual bool getFullScreenDirty();
-
- /* accessor for fullscreen window */
- virtual void setMac_windowState(short value);
- virtual short getMac_windowState();
-
-
- const GHOST_TabletData *GetTabletData()
- {
- return &m_tablet;
- }
-
- GHOST_TabletData& GetCarbonTabletData()
- {
- return m_tablet;
- }
-
- GHOST_TSuccess beginFullScreen() const {return GHOST_kFailure;}
-
- GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;}
-
-protected:
- /**
- * Tries to install a rendering context in this window.
- * \param type The type of rendering context installed.
- * \return Indication as to whether installation has succeeded.
- */
- virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
-
- /**
- * Removes the current drawing context.
- * \return Indication as to whether removal has succeeded.
- */
- virtual GHOST_TSuccess removeDrawingContext();
-
- /**
- * Invalidates the contents of this window.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess invalidate();
-
- /**
- * Sets the cursor visibility on the window using
- * native window system calls.
- */
- virtual GHOST_TSuccess setWindowCursorVisibility(bool visible);
-
- /**
- * Sets the cursor shape on the window using
- * native window system calls.
- */
- virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
-
- /**
- * Sets the cursor shape on the window using
- * native window system calls.
- */
- virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
- int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color);
-
- virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
-
- /**
- * Converts a string object to a Mac Pascal string.
- * \param in The string object to be converted.
- * \param out The converted string.
- */
- virtual void gen2mac(const STR_String& in, Str255 out) const;
-
- /**
- * Converts a Mac Pascal string to a string object.
- * \param in The string to be converted.
- * \param out The converted string object.
- */
- virtual void mac2gen(const Str255 in, STR_String& out) const;
-
- WindowRef m_windowRef;
- CGrafPtr m_grafPtr;
- AGLContext m_aglCtx;
-
- /** The first created OpenGL context (for sharing display lists) */
- static AGLContext s_firstaglCtx;
-
- Cursor *m_customCursor;
-
- GHOST_TabletData m_tablet;
-
- /** When running in full-screen this tells whether to refresh the window. */
- bool m_fullScreenDirty;
-
- /** specific MacOs X full screen window setting as we use partially system mechanism
- * values : 0 not maximizable default
- * 1 normal state
- * 2 maximized state
- *
- * this will be reworked when rebuilding GHOST carbon to use new OS X apis
- * in order to be unified with GHOST fullscreen/maximised settings
- *
- * (lukep)
- **/
-
- short mac_windowState;
-
-
- /**
- * The width/height of the size rectangle in the lower right corner of a
- * Mac/Carbon window. This is also the height of the gutter area.
- */
-#ifdef GHOST_DRAW_CARBON_GUTTER
- static const GHOST_TInt32 s_sizeRectSize;
-#endif // GHOST_DRAW_CARBON_GUTTER
-};
-
-#endif // __GHOST_WINDOWCARBON_H__
-
diff --git a/intern/ghost/test/CMakeLists.txt b/intern/ghost/test/CMakeLists.txt
index 455fff74a5c..84b6f663ff2 100644
--- a/intern/ghost/test/CMakeLists.txt
+++ b/intern/ghost/test/CMakeLists.txt
@@ -122,6 +122,7 @@ add_library(bli_lib
"../../../source/blender/blenlib/intern/listbase.c"
"../../../source/blender/blenlib/intern/math_color.c"
"../../../source/blender/blenlib/intern/storage.c"
+ "../../../source/blender/blenlib/intern/task.c"
"../../../source/blender/blenlib/intern/threads.c"
"../../../source/blender/blenlib/intern/time.c"
"../../../source/blender/blenlib/intern/path_util.c"
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index b7a59da7813..1d041ba5380 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -39,6 +39,9 @@ set(SRC
MEM_guardedalloc.h
./intern/mallocn_intern.h
+
+ # only so the header is known by cmake
+ ../atomic/atomic_ops.h
)
if(WIN32 AND NOT UNIX)
diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
index 35caebcc5e8..44f51a34134 100644
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@ -61,6 +61,7 @@ static void (*thread_unlock_callback)(void) = NULL;
#define MEMHEAD_FROM_PTR(ptr) (((MemHead*) vmemh) - 1)
#define PTR_FROM_MEMHEAD(memhead) (memhead + 1)
+#define MEMHEAD_IS_MMAP(memhead) ((memhead)->len & (size_t) 1)
#ifdef __GNUC__
__attribute__ ((format(printf, 1, 2)))
@@ -112,13 +113,13 @@ void MEM_lockfree_freeN(void *vmemh)
atomic_sub_u(&totblock, 1);
atomic_sub_z(&mem_in_use, len);
- if (memh->len & (size_t) 1) {
+ if (MEMHEAD_IS_MMAP(memh)) {
atomic_sub_z(&mmap_in_use, len);
#if defined(WIN32)
/* our windows mmap implementation is not thread safe */
mem_lock_thread();
#endif
- if (munmap(memh, memh->len + sizeof(MemHead)))
+ if (munmap(memh, len + sizeof(MemHead)))
printf("Couldn't unmap memory\n");
#if defined(WIN32)
mem_unlock_thread();
@@ -136,8 +137,14 @@ void *MEM_lockfree_dupallocN(const void *vmemh)
{
void *newp = NULL;
if (vmemh) {
+ MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
const size_t prev_size = MEM_allocN_len(vmemh);
- newp = MEM_lockfree_mallocN(prev_size, "dupli_malloc");
+ if (MEMHEAD_IS_MMAP(memh)) {
+ newp = MEM_lockfree_mapallocN(prev_size, "dupli_mapalloc");
+ }
+ else {
+ newp = MEM_lockfree_mallocN(prev_size, "dupli_malloc");
+ }
memcpy(newp, vmemh, prev_size);
}
return newp;
diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c
index 6f03188a579..3096c589101 100644
--- a/intern/guardedalloc/intern/mmap_win.c
+++ b/intern/guardedalloc/intern/mmap_win.c
@@ -182,14 +182,14 @@ static void mmap_addtail(volatile mmapListBase *listbase, void *vlink)
{
struct mmapLink *link = vlink;
- if (link == 0) return;
- if (listbase == 0) return;
+ if (link == NULL) return;
+ if (listbase == NULL) return;
link->next = 0;
link->prev = listbase->last;
if (listbase->last) ((struct mmapLink *)listbase->last)->next = link;
- if (listbase->first == 0) listbase->first = link;
+ if (listbase->first == NULL) listbase->first = link;
listbase->last = link;
}
@@ -197,8 +197,8 @@ static void mmap_remlink(volatile mmapListBase *listbase, void *vlink)
{
struct mmapLink *link = vlink;
- if (link == 0) return;
- if (listbase == 0) return;
+ if (link == NULL) return;
+ if (listbase == NULL) return;
if (link->next) link->next->prev = link->prev;
if (link->prev) link->prev->next = link->next;
@@ -211,8 +211,8 @@ static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr)
{
MemMap *mm;
- if (ptr == 0) return NULL;
- if (listbase == 0) return NULL;
+ if (ptr == NULL) return NULL;
+ if (listbase == NULL) return NULL;
mm = (MemMap *)listbase->first;
while (mm) {
diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt
index 1f14a0e7a6a..3599aa68545 100644
--- a/intern/locale/CMakeLists.txt
+++ b/intern/locale/CMakeLists.txt
@@ -45,3 +45,11 @@ if(WITH_INTERNATIONAL)
endif()
blender_add_lib(bf_intern_locale "${SRC}" "${INC}" "${INC_SYS}")
+
+# -----------------------------------------------------------------------------
+# Build msgfmt executable
+set(MSFFMT_SRC
+ msgfmt.cc
+)
+
+add_executable(msgfmt ${MSFFMT_SRC})
diff --git a/intern/locale/SConscript b/intern/locale/SConscript
index f60bd90fb38..4136ac8237d 100644
--- a/intern/locale/SConscript
+++ b/intern/locale/SConscript
@@ -37,3 +37,56 @@ if env['WITH_BF_INTERNATIONAL']:
incs += ' ' + env['BF_BOOST_INC']
env.BlenderLib( 'bf_intern_locale', sources, Split(incs), defs, libtype=['intern','player'], priority=[10, 185])
+
+if env['WITH_BF_INTERNATIONAL']:
+ import os
+ from os.path import dirname
+
+ def normpath(path):
+ return os.path.abspath(os.path.normpath(path))
+
+ # build directory
+ source_dir = Dir('.').srcnode().path
+ root_build_dir = normpath(env['BF_BUILDDIR'])
+ root_source_dir = dirname(dirname(normpath(source_dir)))
+ po_dir = os.path.join(root_source_dir, "release", "datafiles", "locale", "po")
+ build_dir = os.path.join(root_build_dir, 'locale')
+
+ if os.path.exists(po_dir):
+ # create directory if needed
+ if not os.path.exists(build_dir):
+ os.makedirs(build_dir)
+
+ msgfmt_tool = env.Clone()
+ msgfmt_tool.Append(LINKFLAGS = env['PLATFORM_LINKFLAGS'])
+
+ targetpath = root_build_dir + '/msgfmt'
+
+ msgfmt_target = msgfmt_tool.Program(target = targetpath, source = ['msgfmt.cc'])
+
+ locale = env.Clone()
+
+ msgfmt_executable = targetpath
+ if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
+ msgfmt_executable += ".exe"
+
+ # dependencies
+ dependencies = [msgfmt_target]
+
+ # add command for each locale
+ all_mo_files = []
+ for f in os.listdir(po_dir):
+ if not f.endswith(".po"):
+ continue
+
+ po_file = os.path.join(po_dir, f)
+ mo_file = os.path.join(build_dir, os.path.splitext(f)[0] + ".mo")
+
+ command = "\"%s\" \"%s\" \"%s\"" % (msgfmt_executable, po_file, mo_file)
+
+ locale.Command(mo_file, po_file, command)
+ locale.Depends(mo_file, dependencies)
+
+ all_mo_files.append(mo_file)
+
+ env.Depends("boost_locale_wrapper.cpp", all_mo_files)
diff --git a/intern/locale/msgfmt.cc b/intern/locale/msgfmt.cc
new file mode 100644
index 00000000000..17720adfa48
--- /dev/null
+++ b/intern/locale/msgfmt.cc
@@ -0,0 +1,369 @@
+// Written by Sergey Sharybin <sergey.vfx@gmail.com>
+// Added support for contexts
+//
+// Based on Python script msgfmt.py from Python source
+// code tree, which was written by Written by
+// Martin v. Löwis <loewis@informatik.hu-berlin.de>
+//
+// Generate binary message catalog from textual translation description.
+//
+// This program converts a textual Uniforum-style message catalog (.po file) into
+// a binary GNU catalog (.mo file). This is essentially the same function as the
+// GNU msgfmt program, however, it is a simpler implementation.
+//
+// Usage: msgfmt input.po output.po
+
+#include <algorithm>
+#include <cctype>
+#include <fstream>
+#include <functional>
+#include <iostream>
+#include <map>
+#include <stdlib.h>
+#include <string>
+#include <vector>
+
+namespace {
+
+std::map<std::string, std::string> MESSAGES;
+
+bool starts_with(const std::string &string,
+ const std::string &prefix) {
+ return prefix.size() <= string.size() &&
+ string.compare(0, prefix.size(), prefix) == 0;
+}
+
+std::string ltrim(const std::string &s) {
+ std::string result = s;
+ result.erase(result.begin(),
+ std::find_if(result.begin(),
+ result.end(),
+ std::not1(std::ptr_fun<int, int>(std::isspace))));
+ return result;
+}
+
+std::string rtrim(const std::string &s) {
+ std::string result = s;
+ result.erase(
+ std::find_if(result.rbegin(),
+ result.rend(),
+ std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
+ result.end());
+ return result;
+}
+
+std::string trim(const std::string &s) {
+ return ltrim(rtrim(s));
+}
+
+std::string unescape(const std::string &s) {
+ std::string result;
+ std::string::const_iterator it = s.begin();
+ while (it != s.end()) {
+ char current_char = *it++;
+ if (current_char == '\\' && it != s.end()) {
+ char next_char = *it++;
+ if (next_char == '\\') {
+ current_char = '\\';
+ } else if (next_char == 'n') {
+ current_char = '\n';
+ } else if (next_char == 't') {
+ current_char = '\t';
+ } else {
+ current_char = next_char;
+ }
+ }
+ result += current_char;
+ }
+
+ if (result[0] == '"' && result[result.size() - 1] == '"') {
+ result = result.substr(1, result.size() - 2);
+ }
+
+ return result;
+}
+
+// Add a non-fuzzy translation to the dictionary.
+void add(const std::string &msgctxt,
+ const std::string &msgid,
+ const std::string &msgstr,
+ bool fuzzy) {
+ if (fuzzy == false && msgstr.empty() == false) {
+ if (msgctxt.empty()) {
+ MESSAGES[msgid] = msgstr;
+ } else {
+ MESSAGES[msgctxt + (char)0x04 + msgid] = msgstr;
+ }
+ }
+}
+
+template<typename TKey, typename TValue>
+void get_keys(std::map<TKey, TValue> map,
+ std::vector<TKey> *keys) {
+ for (typename std::map<TKey, TValue>::iterator it = map.begin();
+ it != map.end();
+ it++) {
+ keys->push_back(it->first);
+ }
+}
+
+std::string intToBytes(int value) {
+ std::string result;
+ for (unsigned int i = 0; i < sizeof(value); i++) {
+ result += (unsigned char) ((value >> (i * 8)) & 0xff);
+ }
+ return result;
+}
+
+typedef enum {
+ SECTION_NONE = 0,
+ SECTION_CTX = 1,
+ SECTION_ID = 2,
+ SECTION_STR = 3
+} eSectionType;
+
+struct Offset {
+ unsigned int o1, l1, o2, l2;
+};
+
+// Return the generated output.
+std::string generate(void) {
+ // The keys are sorted in the .mo file
+ std::vector<std::string> keys;
+
+ // Get list of sorted keys.
+ get_keys(MESSAGES, &keys);
+ std::sort(keys.begin(), keys.end());
+
+ std::vector<Offset> offsets;
+ std::string ids = "", strs = "";
+ for (std::vector<std::string>::iterator it = keys.begin();
+ it != keys.end();
+ it++) {
+ std::string &id = *it;
+ // For each string, we need size and file offset. Each string is NUL
+ // terminated; the NUL does not count into the size.
+ Offset offset = {(unsigned int) ids.size(),
+ (unsigned int) id.size(),
+ (unsigned int) strs.size(),
+ (unsigned int) MESSAGES[id].size()};
+ offsets.push_back(offset);
+ ids += id + '\0';
+ strs += MESSAGES[id] + '\0';
+ }
+
+ // The header is 7 32-bit unsigned integers. We don't use hash tables, so
+ // the keys start right after the index tables.
+ // translated string.
+ int keystart = 7 * 4 + 16 * keys.size();
+ // and the values start after the keys
+ int valuestart = keystart + ids.size();
+ std::vector<int> koffsets;
+ std::vector<int> voffsets;
+ // The string table first has the list of keys, then the list of values.
+ // Each entry has first the size of the string, then the file offset.
+ for (std::vector<Offset>::iterator it = offsets.begin();
+ it != offsets.end();
+ it++) {
+ Offset &offset = *it;
+ koffsets.push_back(offset.l1);
+ koffsets.push_back(offset.o1 + keystart);
+ voffsets.push_back(offset.l2);
+ voffsets.push_back(offset.o2 + valuestart);
+ }
+
+ std::vector<int> all_offsets;
+ all_offsets.reserve(koffsets.size() + voffsets.size());
+ all_offsets.insert(all_offsets.end(), koffsets.begin(), koffsets.end());
+ all_offsets.insert(all_offsets.end(), voffsets.begin(), voffsets.end());
+
+ std::string output = "";
+ output += intToBytes(0x950412de); // Magic
+ output += intToBytes(0x0); // Version
+ output += intToBytes(keys.size()); // # of entries
+ output += intToBytes(7 * 4); // start of key index
+ output += intToBytes(7 * 4 + keys.size() * 8); // start of value index
+ output += intToBytes(0); // Size of hash table
+ output += intToBytes(0); // Offset of hash table
+
+ for (std::vector<int>::iterator it = all_offsets.begin();
+ it != all_offsets.end();
+ it++) {
+ int offset = *it;
+ output += intToBytes(offset);
+ }
+
+ output += ids;
+ output += strs;
+
+ return output;
+}
+
+void make(const char *input_file_name,
+ const char *output_file_name) {
+ std::map<std::string, std::string> messages;
+
+ // Start off assuming Latin-1, so everything decodes without failure,
+ // until we know the exact encoding.
+ // TODO(sergey): Support encoding.
+ // const char *encoding = "latin-1";
+
+ eSectionType section = SECTION_NONE;
+ bool fuzzy = false;
+ bool is_plural = false;
+ std::string msgctxt, msgid, msgstr;
+
+ std::ifstream input_file_stream(input_file_name);
+
+ // Parse the catalog.
+ int lno = 0;
+ for (std::string l; getline(input_file_stream, l); ) {
+ lno++;
+ // If we get a comment line after a msgstr, this is a new entry.
+ if (l[0] == '#' && section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ section = SECTION_NONE;
+ msgctxt = "";
+ fuzzy = false;
+ }
+ // Record a fuzzy mark.
+ if (starts_with(l, "#,") && l.find("fuzzy") != std::string::npos) {
+ fuzzy = 1;
+ }
+ // Skip comments
+ if (l[0] == '#') {
+ continue;
+ }
+ // Now we are in a msgid section, output previous section.
+ if (starts_with(l, "msgctxt")) {
+ if (section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ }
+ section = SECTION_CTX;
+ l = l.substr(7, l.size() - 7);
+ msgctxt = msgid = msgstr = "";
+ }
+ else if (starts_with(l, "msgid") && !starts_with(l, "msgid_plural")) {
+ if (section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ msgctxt = "";
+ if (msgid == "") {
+#if 0
+ // See whether there is an encoding declaration.
+ p = HeaderParser();
+ charset = p.parsestr(msgstr.decode(encoding)).get_content_charset();
+ if (charset) {
+ encoding = charset;
+ }
+#else
+ // Not ported to C++ yet.
+ std::cerr << "Encoding declarations are not supported yet.\n"
+ << std::endl;
+ abort();
+#endif
+ }
+ }
+ section = SECTION_ID;
+ l = l.substr(5, l.size() - 5);
+ msgid = msgstr = "";
+ is_plural = false;
+ } else if (starts_with(l, "msgid_plural")) {
+ // This is a message with plural forms.
+ if (section != SECTION_ID) {
+ std::cerr << "msgid_plural not preceeded by msgid on"
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ l = l.substr(12, l.size() - 12);
+ msgid += '\0'; // separator of singular and plural
+ is_plural = true;
+ } else if (starts_with(l, "msgstr")) {
+ // Now we are in a msgstr section
+ section = SECTION_STR;
+ if (starts_with(l, "msgstr[")) {
+ if (is_plural == false) {
+ std::cerr << "plural without msgid_plural on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ int bracket_position = l.find(']');
+ if (bracket_position == std::string::npos) {
+ std::cerr << "Syntax error on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ l = l.substr(bracket_position, l.size() - bracket_position);
+ if (msgstr != "") {
+ msgstr += '\0'; // Separator of the various plural forms;
+ }
+ } else {
+ if (is_plural) {
+ std::cerr << "indexed msgstr required for plural on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ l = l.substr(6, l.size() - 6);
+ }
+ }
+ // Skip empty lines.
+ l = trim(l);
+ if (l.empty()) {
+ continue;
+ }
+ l = unescape(l);
+ if (section == SECTION_CTX) {
+ // TODO(sergey): Support encoding.
+ // msgid += l.encode(encoding);
+ msgctxt += l;
+ }
+ else if (section == SECTION_ID) {
+ // TODO(sergey): Support encoding.
+ // msgid += l.encode(encoding);
+ msgid += l;
+ } else if (section == SECTION_STR) {
+ // TODO(sergey): Support encoding.
+ // msgstr += l.encode(encoding)
+ msgstr += l;
+ } else {
+ std::cerr << "Syntax error on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ // Add last entry
+ if (section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ }
+ }
+
+ // Compute output
+ std::string output = generate();
+
+ std::ofstream output_file_stream(output_file_name,
+ std::ios::out | std::ios::binary);
+ output_file_stream << output;
+}
+
+} // namespace
+
+int main(int argc, char **argv) {
+ if (argc != 3) {
+ printf("Usage: %s <input.po> <output.mo>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ const char *input_file = argv[1];
+ const char *output_file = argv[2];
+
+ make(input_file, output_file);
+
+ return EXIT_SUCCESS;
+}
diff --git a/intern/rigidbody/CMakeLists.txt b/intern/rigidbody/CMakeLists.txt
index 80ea567c9f5..f01ca127b3f 100644
--- a/intern/rigidbody/CMakeLists.txt
+++ b/intern/rigidbody/CMakeLists.txt
@@ -24,12 +24,11 @@
set(INC
.
../../source/blender/gpu
- ../../extern/bullet2/src
../../extern/HACD
)
set(INC_SYS
-
+ ${BULLET_INCLUDE_DIRS}
)
set(SRC
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index 6c794e805da..5eff4fa60a2 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -1254,11 +1254,7 @@ rbConstraint *RB_constraint_new_fixed(float pivot[3], float orn[4], rbRigidBody
make_constraint_transforms(transform1, transform2, body1, body2, pivot, orn);
- btGeneric6DofConstraint *con = new btGeneric6DofConstraint(*body1, *body2, transform1, transform2, true);
-
- /* lock all axes */
- for (int i = 0; i < 6; i++)
- con->setLimit(i, 0, 0);
+ btFixedConstraint *con = new btFixedConstraint(*body1, *body2, transform1, transform2);
return (rbConstraint *)con;
}
diff --git a/release/bin/blender-softwaregl b/release/bin/blender-softwaregl
index 970a7870760..8628dca2202 100755
--- a/release/bin/blender-softwaregl
+++ b/release/bin/blender-softwaregl
@@ -1,7 +1,6 @@
#!/bin/sh
-BF_DIST_BIN=`dirname "$0"`
-BF_PROGRAM="blender" # BF_PROGRAM=`basename "$0"`-bin
-exitcode=0
+BF_DIST_BIN=$(dirname "$0")
+BF_PROGRAM="blender" # BF_PROGRAM=$(basename "$0")-bin
LD_LIBRARY_PATH=${BF_DIST_BIN}/lib:${LD_LIBRARY_PATH}
@@ -20,6 +19,4 @@ XLIB_SKIP_ARGB_VISUALS=1
export LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARYN64_PATH LD_LIBRARY_PATH_64 LD_PRELOAD XLIB_SKIP_ARGB_VISUALS
-"$BF_DIST_BIN/$BF_PROGRAM" ${1+"$@"}
-exitcode=$?
-exit $exitcode
+exec "$BF_DIST_BIN/$BF_PROGRAM" ${1+"$@"}
diff --git a/release/bin/blender-thumbnailer.py b/release/bin/blender-thumbnailer.py
index 8b93eebdeec..22e811c538e 100755
--- a/release/bin/blender-thumbnailer.py
+++ b/release/bin/blender-thumbnailer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# ##### BEGIN GPL LICENSE BLOCK #####
#
diff --git a/release/darwin/README_codesigning.txt b/release/darwin/README_codesigning.txt
new file mode 100644
index 00000000000..d2ead00da8a
--- /dev/null
+++ b/release/darwin/README_codesigning.txt
@@ -0,0 +1,25 @@
+Tutorial for codesigning Blender releases on OSX ( atm. i do manually when needed ):
+
+1. You need to obtain the certificates for blender foundation, they can bw pulled at Apple developer account for BF
+2. Run the following commands from terminal:
+
+codesign -s <IDENTITY> <path_to_blender.app> --resource-rules <path_to_blender_source>/release/darwin/codesigning_rules_blender.plist --deep
+
+codesign -s <IDENTITY> <path_to_blenderplayer.app> --resource-rules <path_to_blender_source>/release/darwin/codesigning_rules_player.plist --deep
+
+
+3. Checking:
+
+codesign -vv <path_to_blenderplayer.app>
+codesign -vv <path_to_blender.app>
+
+The result should be something like:
+
+<build_path>/blender.app: valid on disk
+<build_path>/blender.app: satisfies its Designated Requirement
+
+<build_path>/blenderplayer.app: valid on disk
+<build_path>/blenderplayer.app: satisfies its Designated Requirement
+
+Jens Verwiebe
+
diff --git a/release/darwin/codesigning_rules_blender.plist b/release/darwin/codesigning_rules_blender.plist
new file mode 100644
index 00000000000..b3baba80bbb
--- /dev/null
+++ b/release/darwin/codesigning_rules_blender.plist
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>rules</key>
+ <dict>
+ <!-- Exclude datafiles, python and scripts -->
+ <key>^MacOS/2.69</key>
+ <false/>
+ <key>^Resources/</key>
+ <true/>
+ </dict>
+</dict>
+</plist>
diff --git a/release/darwin/codesigning_rules_player.plist b/release/darwin/codesigning_rules_player.plist
new file mode 100644
index 00000000000..2a85041f307
--- /dev/null
+++ b/release/darwin/codesigning_rules_player.plist
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>rules</key>
+ <dict>
+ <!-- Exclude datafiles, python and scripts -->
+ <key>^MacOS/2.69</key>
+ <false/>
+ <!-- Exclude Resources for placing game.blend and own icons -->
+ <key>^Resources/</key>
+ <false/>
+ </dict>
+</dict>
+</plist>
diff --git a/release/datafiles/blender_icons.sh b/release/datafiles/blender_icons.sh
index 9c2cedaaf6c..62746d0ab7e 100755
--- a/release/datafiles/blender_icons.sh
+++ b/release/datafiles/blender_icons.sh
@@ -1,8 +1,8 @@
#!/bin/sh
# This script updates icons from the SVG file
-BASEDIR=$(dirname $0)
+BASEDIR=$(dirname "$0")
-inkscape $BASEDIR/blender_icons.svg --export-dpi=90 --without-gui --export-png=$BASEDIR/blender_icons16.png
-inkscape $BASEDIR/blender_icons.svg --export-dpi=180 --without-gui --export-png=$BASEDIR/blender_icons32.png
+inkscape "$BASEDIR/blender_icons.svg" --export-dpi=90 --without-gui --export-png="$BASEDIR/blender_icons16.png"
+inkscape "$BASEDIR/blender_icons.svg" --export-dpi=180 --without-gui --export-png="$BASEDIR/blender_icons32.png"
diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg
index fef2b047474..27b93f6b10f 100644
--- a/release/datafiles/blender_icons.svg
+++ b/release/datafiles/blender_icons.svg
@@ -27061,11 +27061,11 @@
objecttolerance="10000"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="8"
- inkscape:cx="336.81018"
- inkscape:cy="34.425847"
+ inkscape:zoom="11.313708"
+ inkscape:cx="256.37124"
+ inkscape:cy="2.0121538"
inkscape:document-units="px"
- inkscape:current-layer="g24559-2"
+ inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1366"
inkscape:window-height="695"
@@ -33313,222 +33313,225 @@
inkscape:connector-curvature="0" />
</g>
</a>
- <path
- inkscape:connector-curvature="0"
- id="path19537-6"
- d="m 12,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19539-5"
- d="m 33,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 L 35,2 33,2 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19541-3"
- d="m 54,2 0,1 2,0 0,1 1,0 0,-1.25 -1,0 L 56,2 54,2 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 L 57,5 56,5 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19543-9"
- d="m 75,2 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19545-2"
- d="m 96,2 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19547-4"
- d="m 118,2 0,0.75 -1,0 0,3.25 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 -1.25,0 0,-1 1.5,0 0,-1 -1.5,0 z m 0,3 1,0 0,1 -1,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19549-6"
- d="m 138,2 0,1 2,0 0,1 -1,0 0,3 1,0 0,-2.75 1,0 0,-1.25 0,-1 -3,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19551-18"
- d="m 159.75,2 0,1 -0.5,0 0,1 0.5,0 0,1 -0.75,0 0,1 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 0.5,0 0,-1 -0.5,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z m 0,2 1,0 0,1 -1,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19553-2"
- d="m 180.75,2 0,1 -0.75,0 0,1 0.75,0 0,1 1.25,0 0,1 -1.5,0 0,1 1.5,0 0,-0.75 1,0 0,-3.25 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cccccccccccccccccc"
- id="path19555-1"
- d="m 202.75,2 0,1 -0.75,0 0,3 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-3 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,3 -1,0 0,-3 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
- d="m 514,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- id="path19559-1" />
- <path
- inkscape:connector-curvature="0"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
- d="m 476,2 0,1 2,0 0,1 1,0 0,-1.25 -1,0 0,-0.75 -2,0 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.25 -1,0 z"
- id="path19561-9" />
- <path
- inkscape:connector-curvature="0"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
- d="m 497,2 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
- id="path19563-7" />
- <path
- inkscape:connector-curvature="0"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
- d="m 518,2 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
- id="path19565-6" />
- <path
- inkscape:connector-curvature="0"
- id="path19577-2"
- d="m 200,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19579-9"
- d="m 244,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19581-5"
- d="m 265,2 0,1 2,0 0,1 1,0 0,-1.25 -1,0 0,-0.75 -2,0 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.25 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19583-2"
- d="m 286,2 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19585-0"
- d="m 307,2 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19587-0"
- d="m 329,2 0,0.75 -1,0 0,3.25 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 -1.25,0 0,-1 1.5,0 0,-1 -1.5,0 z m 0,3 1,0 0,1 -1,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19589-3"
- d="m 349,2 0,1 2,0 0,1 -1,0 0,3 1,0 0,-2.75 1,0 0,-1.25 0,-1 -3,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19591-9"
- d="m 370.75,2 0,1 -0.5,0 0,1 0.5,0 0,1 -0.75,0 0,1 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 0.5,0 0,-1 -0.5,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z m 0,2 1,0 0,1 -1,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19593-1"
- d="m 391.75,2 0,1 -0.75,0 0,1 0.75,0 0,1 1.25,0 0,1 -1.5,0 0,1 1.5,0 0,-0.75 1,0 0,-3.25 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19595-8"
- d="m 413.75,2 0,1 -0.75,0 0,3 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-3 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,3 -1,0 0,-3 z m 0.25,1 0,1 0.5,0 0,-1 -0.5,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19597-1"
- d="m 221,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
- d="m 224,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- id="path19599-9" />
- <path
- inkscape:connector-curvature="0"
- id="path19601-5"
- d="m 242,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19603-3"
- d="m 263,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19605-2"
- d="m 284,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19607-5"
- d="m 305,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19609-2"
- d="m 326,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19611-5"
- d="m 347,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19613-8"
- d="m 368,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19615-6"
- d="m 389,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19617-7"
- d="m 409,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19619-7"
- d="m 435,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19621-2"
- d="m 430,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19623-2"
- d="m 451,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
- d="m 455,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- id="path19625-9" />
- <path
- inkscape:connector-curvature="0"
- id="path19627-4"
- d="m 472,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path19629-1"
- d="m 493,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- id="path11036-9"
- d="m 536,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
- <path
- inkscape:connector-curvature="0"
- style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
- d="m 541,2 0,0.75 -1,0 0,3.25 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 -1.25,0 0,-1 1.5,0 0,-1 -1.5,0 z m 0,3 1,0 0,1 -1,0 0,-1 z"
- id="path11038-6" />
+ <g
+ id="g15986">
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 12,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19537-6"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 33,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 L 35,2 33,2 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path19539-5"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 54,2 0,1 2,0 0,1 1,0 0,-1.25 -1,0 L 56,2 54,2 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 L 57,5 56,5 z"
+ id="path19541-3"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 75,2 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
+ id="path19543-9"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 96,2 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
+ id="path19545-2"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 118,2 0,0.75 -1,0 0,3.25 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 -1.25,0 0,-1 1.5,0 0,-1 -1.5,0 z m 0,3 1,0 0,1 -1,0 0,-1 z"
+ id="path19547-4"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 138,2 0,1 2,0 0,1 -1,0 0,3 1,0 0,-2.75 1,0 0,-1.25 0,-1 -3,0 z"
+ id="path19549-6"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 159.75,2 0,1 -0.5,0 0,1 0.5,0 0,1 -0.75,0 0,1 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 0.5,0 0,-1 -0.5,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z m 0,2 1,0 0,1 -1,0 0,-1 z"
+ id="path19551-18"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 180.75,2 0,1 -0.75,0 0,1 0.75,0 0,1 1.25,0 0,1 -1.5,0 0,1 1.5,0 0,-0.75 1,0 0,-3.25 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z"
+ id="path19553-2"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 202.75,2 0,1 -0.75,0 0,3 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-3 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,3 -1,0 0,-3 z"
+ id="path19555-1"
+ sodipodi:nodetypes="cccccccccccccccccc"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path19559-1"
+ d="m 514,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path19561-9"
+ d="m 476,2 0,1 2,0 0,1 1,0 0,-1.25 -1,0 0,-0.75 -2,0 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.25 -1,0 z"
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path19563-7"
+ d="m 497,2 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path19565-6"
+ d="m 518,2 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 200,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19577-2"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 244,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path19579-9"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 265,2 0,1 2,0 0,1 1,0 0,-1.25 -1,0 0,-0.75 -2,0 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.25 -1,0 z"
+ id="path19581-5"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 286,2 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
+ id="path19583-2"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 307,2 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
+ id="path19585-0"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 329,2 0,0.75 -1,0 0,3.25 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 -1.25,0 0,-1 1.5,0 0,-1 -1.5,0 z m 0,3 1,0 0,1 -1,0 0,-1 z"
+ id="path19587-0"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 349,2 0,1 2,0 0,1 -1,0 0,3 1,0 0,-2.75 1,0 0,-1.25 0,-1 -3,0 z"
+ id="path19589-3"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 370.75,2 0,1 -0.5,0 0,1 0.5,0 0,1 -0.75,0 0,1 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 0.5,0 0,-1 -0.5,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z m 0,2 1,0 0,1 -1,0 0,-1 z"
+ id="path19591-9"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 391.75,2 0,1 -0.75,0 0,1 0.75,0 0,1 1.25,0 0,1 -1.5,0 0,1 1.5,0 0,-0.75 1,0 0,-3.25 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,1 -1,0 0,-1 z"
+ id="path19593-1"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 413.75,2 0,1 -0.75,0 0,3 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-3 -0.75,0 0,-1 -1.5,0 z m 0.25,1 1,0 0,3 -1,0 0,-3 z m 0.25,1 0,1 0.5,0 0,-1 -0.5,0 z"
+ id="path19595-8"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 221,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19597-1"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path19599-9"
+ d="m 224,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 242,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19601-5"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 263,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19603-3"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 284,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19605-2"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 305,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19607-5"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 326,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19609-2"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 347,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19611-5"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 368,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19613-8"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 389,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19615-6"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 409,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path19617-7"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 435,2 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
+ id="path19619-7"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 430,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path19621-2"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 451,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path19623-2"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path19625-9"
+ d="m 455,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 472,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path19627-4"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 493,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path19629-1"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 536,2 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path11036-9"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path11038-6"
+ d="m 541,2 0,0.75 -1,0 0,3.25 0.75,0 0,1 1.5,0 0,-1 0.75,0 0,-1 -0.75,0 0,-1 -1.25,0 0,-1 1.5,0 0,-1 -1.5,0 z m 0,3 1,0 0,1 -1,0 0,-1 z"
+ style="fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ </g>
<g
id="g11125-9"
transform="translate(547,1)"
@@ -33681,7 +33684,7 @@
<g
style="color:#000000;fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="g41041-8"
- transform="translate(0,634)">
+ transform="translate(0,636)">
<path
id="path41043-2"
d="m 12,1 0,1 -1,0 0,1 1,0 0,3 1,0 0,-5 -1,0 z"
diff --git a/release/datafiles/blender_icons16.png b/release/datafiles/blender_icons16.png
index 24d95d7ec5c..2f2f8deed68 100644
--- a/release/datafiles/blender_icons16.png
+++ b/release/datafiles/blender_icons16.png
Binary files differ
diff --git a/release/datafiles/blender_icons32.png b/release/datafiles/blender_icons32.png
index 3f8901fafd9..8b469238735 100644
--- a/release/datafiles/blender_icons32.png
+++ b/release/datafiles/blender_icons32.png
Binary files differ
diff --git a/release/datafiles/fonts/droidsans.ttf.gz b/release/datafiles/fonts/droidsans.ttf.gz
index 81683e6379f..c76cf67992c 100644
--- a/release/datafiles/fonts/droidsans.ttf.gz
+++ b/release/datafiles/fonts/droidsans.ttf.gz
Binary files differ
diff --git a/release/datafiles/locale b/release/datafiles/locale
new file mode 160000
+Subproject d3e0405103f9ccabb8e567a8c69e9d4015aaa3b
diff --git a/release/datafiles/prvicons.sh b/release/datafiles/prvicons.sh
index 1a82b4db71c..95546ff0a4a 100755
--- a/release/datafiles/prvicons.sh
+++ b/release/datafiles/prvicons.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# This script updates icons from the SVG file
-BASEDIR=$(dirname $0)
+BASEDIR=$(dirname "$0")
-inkscape $BASEDIR/prvicons.svg --without-gui --export-png=$BASEDIR/prvicons.png
+inkscape "$BASEDIR/prvicons.svg" --without-gui --export-png="$BASEDIR/prvicons.png"
diff --git a/release/datafiles/splash.png b/release/datafiles/splash.png
index 4ee82bcbb62..ad0028ee0b4 100644
--- a/release/datafiles/splash.png
+++ b/release/datafiles/splash.png
Binary files differ
diff --git a/release/scripts/addons b/release/scripts/addons
new file mode 160000
+Subproject 4d8cb6c294727ff10afeb548759f629b0c2169d
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
new file mode 160000
+Subproject 4fe6a9e046f9578a0dadb1186269ac5e406a8c1
diff --git a/release/scripts/freestyle/style_modules/parameter_editor.py b/release/scripts/freestyle/style_modules/parameter_editor.py
index dd6206fff99..83bd8dbda5e 100644
--- a/release/scripts/freestyle/style_modules/parameter_editor.py
+++ b/release/scripts/freestyle/style_modules/parameter_editor.py
@@ -32,7 +32,7 @@ from freestyle import BackboneStretcherShader, BezierCurveShader, BinaryPredicat
FalseBP1D, FalseUP1D, GuidingLinesShader, Interface0DIterator, Nature, Noise, Normal2DF0D, Operators, \
PolygonalizationShader, QuantitativeInvisibilityF1D, QuantitativeInvisibilityUP1D, SamplingShader, \
SpatialNoiseShader, StrokeAttribute, StrokeShader, TipRemoverShader, TrueBP1D, TrueUP1D, UnaryPredicate0D, \
- UnaryPredicate1D, VertexOrientation2DF0D, WithinImageBoundaryUP1D, ContextFunctions
+ UnaryPredicate1D, VertexOrientation2DF0D, WithinImageBoundaryUP1D, ContextFunctions, TVertex
from Functions0D import CurveMaterialF0D
from PredicatesU1D import pyNatureUP1D
from logical_operators import AndUP1D, NotUP1D, OrUP1D
@@ -1085,6 +1085,8 @@ def iter_three_segments(stroke):
it3.increment()
it4.increment()
+def is_tvertex(svertex):
+ return type(svertex.viewvertex) is TVertex
class StrokeCleaner(StrokeShader):
def shade(self, stroke):
@@ -1092,7 +1094,10 @@ class StrokeCleaner(StrokeShader):
seg1 = sv2.point - sv1.point
seg2 = sv3.point - sv2.point
seg3 = sv4.point - sv3.point
- if seg1.dot(seg2) < 0.0 and seg2.dot(seg3) < 0.0:
+ if not ((is_tvertex(sv2.first_svertex) and is_tvertex(sv2.second_svertex)) or
+ (is_tvertex(sv3.first_svertex) and is_tvertex(sv3.second_svertex))):
+ continue
+ if seg1.dot(seg2) < 0.0 and seg2.dot(seg3) < 0.0 and seg2.length < 0.01:
#print(sv2.first_svertex.viewvertex)
#print(sv2.second_svertex.viewvertex)
#print(sv3.first_svertex.viewvertex)
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py
index 2ac7d4c85aa..e76bcc02751 100644
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@ -35,6 +35,7 @@ error_duplicates = False
error_encoding = False
addons_fake_modules = {}
+
def paths():
# RELEASE SCRIPTS: official scripts distributed in Blender releases
addon_paths = _bpy.utils.script_paths("addons")
@@ -128,7 +129,7 @@ def modules_refresh(module_cache=addons_fake_modules):
mod.__file__ = mod_path
mod.__time__ = os.path.getmtime(mod_path)
except:
- print("AST error in module %s" % mod_name)
+ print("AST error parsing bl_info for %s" % mod_name)
import traceback
traceback.print_exc()
raise
@@ -408,7 +409,6 @@ def module_bl_info(mod, info_basis={"name": "",
"location": "",
"description": "",
"wiki_url": "",
- "tracker_url": "",
"support": 'COMMUNITY',
"category": "",
"warning": "",
diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py
index fd6087b38e6..9730a05c2d2 100644
--- a/release/scripts/modules/animsys_refactor.py
+++ b/release/scripts/modules/animsys_refactor.py
@@ -22,7 +22,7 @@
This module has utility functions for renaming
rna values in fcurves and drivers.
-The main function to use is: update_data_paths(...)
+Currently unused, but might become useful later again.
"""
IS_TESTING = False
@@ -216,672 +216,6 @@ def update_data_paths(rna_update):
print("fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new))
-# we could have this data in its own file but no point really
-data_2_56_to_2_59 = (
- ("ClothCollisionSettings", "min_distance", "distance_min"),
- ("ClothCollisionSettings", "self_min_distance", "self_distance_min"),
- ("ClothCollisionSettings", "enable_collision", "use_collision"),
- ("ClothCollisionSettings", "enable_self_collision", "use_self_collision"),
- ("ClothSettings", "pin_cloth", "use_pin_cloth"),
- ("ClothSettings", "stiffness_scaling", "use_stiffness_scale"),
- ("CollisionSettings", "random_damping", "damping_random"),
- ("CollisionSettings", "random_friction", "friction_random"),
- ("CollisionSettings", "inner_thickness", "thickness_inner"),
- ("CollisionSettings", "outer_thickness", "thickness_outer"),
- ("CollisionSettings", "kill_particles", "use_particle_kill"),
- ("Constraint", "proxy_local", "is_proxy_local"),
- ("ActionConstraint", "maximum", "max"),
- ("ActionConstraint", "minimum", "min"),
- ("FollowPathConstraint", "use_fixed_position", "use_fixed_location"),
- ("KinematicConstraint", "chain_length", "chain_count"),
- ("KinematicConstraint", "pos_lock_x", "lock_location_x"),
- ("KinematicConstraint", "pos_lock_y", "lock_location_y"),
- ("KinematicConstraint", "pos_lock_z", "lock_location_z"),
- ("KinematicConstraint", "rot_lock_x", "lock_rotation_x"),
- ("KinematicConstraint", "rot_lock_y", "lock_rotation_y"),
- ("KinematicConstraint", "rot_lock_z", "lock_rotation_z"),
- ("KinematicConstraint", "axis_reference", "reference_axis"),
- ("KinematicConstraint", "use_position", "use_location"),
- ("LimitLocationConstraint", "maximum_x", "max_x"),
- ("LimitLocationConstraint", "maximum_y", "max_y"),
- ("LimitLocationConstraint", "maximum_z", "max_z"),
- ("LimitLocationConstraint", "minimum_x", "min_x"),
- ("LimitLocationConstraint", "minimum_y", "min_y"),
- ("LimitLocationConstraint", "minimum_z", "min_z"),
- ("LimitLocationConstraint", "use_maximum_x", "use_max_x"),
- ("LimitLocationConstraint", "use_maximum_y", "use_max_y"),
- ("LimitLocationConstraint", "use_maximum_z", "use_max_z"),
- ("LimitLocationConstraint", "use_minimum_x", "use_min_x"),
- ("LimitLocationConstraint", "use_minimum_y", "use_min_y"),
- ("LimitLocationConstraint", "use_minimum_z", "use_min_z"),
- ("LimitLocationConstraint", "limit_transform", "use_transform_limit"),
- ("LimitRotationConstraint", "maximum_x", "max_x"),
- ("LimitRotationConstraint", "maximum_y", "max_y"),
- ("LimitRotationConstraint", "maximum_z", "max_z"),
- ("LimitRotationConstraint", "minimum_x", "min_x"),
- ("LimitRotationConstraint", "minimum_y", "min_y"),
- ("LimitRotationConstraint", "minimum_z", "min_z"),
- ("LimitRotationConstraint", "limit_transform", "use_transform_limit"),
- ("LimitScaleConstraint", "maximum_x", "max_x"),
- ("LimitScaleConstraint", "maximum_y", "max_y"),
- ("LimitScaleConstraint", "maximum_z", "max_z"),
- ("LimitScaleConstraint", "minimum_x", "min_x"),
- ("LimitScaleConstraint", "minimum_y", "min_y"),
- ("LimitScaleConstraint", "minimum_z", "min_z"),
- ("LimitScaleConstraint", "use_maximum_x", "use_max_x"),
- ("LimitScaleConstraint", "use_maximum_y", "use_max_y"),
- ("LimitScaleConstraint", "use_maximum_z", "use_max_z"),
- ("LimitScaleConstraint", "use_minimum_x", "use_min_x"),
- ("LimitScaleConstraint", "use_minimum_y", "use_min_y"),
- ("LimitScaleConstraint", "use_minimum_z", "use_min_z"),
- ("LimitScaleConstraint", "limit_transform", "use_transform_limit"),
- ("PivotConstraint", "enabled_rotation_range", "rotation_range"),
- ("PivotConstraint", "use_relative_position", "use_relative_location"),
- ("PythonConstraint", "number_of_targets", "target_count"),
- ("SplineIKConstraint", "chain_length", "chain_count"),
- ("SplineIKConstraint", "chain_offset", "use_chain_offset"),
- ("SplineIKConstraint", "even_divisions", "use_even_divisions"),
- ("SplineIKConstraint", "y_stretch", "use_y_stretch"),
- ("SplineIKConstraint", "xz_scaling_mode", "xz_scale_mode"),
- ("StretchToConstraint", "original_length", "rest_length"),
- ("TrackToConstraint", "target_z", "use_target_z"),
- ("TransformConstraint", "extrapolate_motion", "use_motion_extrapolate"),
- ("FieldSettings", "do_location", "apply_to_location"),
- ("FieldSettings", "do_rotation", "apply_to_rotation"),
- ("FieldSettings", "maximum_distance", "distance_max"),
- ("FieldSettings", "minimum_distance", "distance_min"),
- ("FieldSettings", "radial_maximum", "radial_max"),
- ("FieldSettings", "radial_minimum", "radial_min"),
- ("FieldSettings", "force_2d", "use_2d_force"),
- ("FieldSettings", "do_absorption", "use_absorption"),
- ("FieldSettings", "global_coordinates", "use_global_coords"),
- ("FieldSettings", "guide_path_add", "use_guide_path_add"),
- ("FieldSettings", "multiple_springs", "use_multiple_springs"),
- ("FieldSettings", "use_coordinates", "use_object_coords"),
- ("FieldSettings", "root_coordinates", "use_root_coords"),
- ("ControlFluidSettings", "reverse_frames", "use_reverse_frames"),
- ("DomainFluidSettings", "real_world_size", "simulation_scale"),
- ("DomainFluidSettings", "surface_smoothing", "surface_smooth"),
- ("DomainFluidSettings", "reverse_frames", "use_reverse_frames"),
- ("DomainFluidSettings", "generate_speed_vectors", "use_speed_vectors"),
- ("DomainFluidSettings", "override_time", "use_time_override"),
- ("FluidFluidSettings", "export_animated_mesh", "use_animated_mesh"),
- ("InflowFluidSettings", "export_animated_mesh", "use_animated_mesh"),
- ("InflowFluidSettings", "local_coordinates", "use_local_coords"),
- ("ObstacleFluidSettings", "export_animated_mesh", "use_animated_mesh"),
- ("OutflowFluidSettings", "export_animated_mesh", "use_animated_mesh"),
- ("ParticleFluidSettings", "drops", "use_drops"),
- ("ParticleFluidSettings", "floats", "use_floats"),
- ("Armature", "drawtype", "draw_type"),
- ("Armature", "layer_protection", "layers_protected"),
- ("Armature", "auto_ik", "use_auto_ik"),
- ("Armature", "delay_deform", "use_deform_delay"),
- ("Armature", "deform_envelope", "use_deform_envelopes"),
- ("Armature", "deform_quaternion", "use_deform_preserve_volume"),
- ("Armature", "deform_vertexgroups", "use_deform_vertex_groups"),
- ("Armature", "x_axis_mirror", "use_mirror_x"),
- ("Curve", "width", "offset"),
- ("Image", "animation_speed", "fps"),
- ("Image", "animation_end", "frame_end"),
- ("Image", "animation_start", "frame_start"),
- ("Image", "animated", "use_animation"),
- ("Image", "clamp_x", "use_clamp_x"),
- ("Image", "clamp_y", "use_clamp_y"),
- ("Image", "premultiply", "use_premultiply"),
- ("AreaLamp", "shadow_ray_sampling_method", "shadow_ray_sample_method"),
- ("AreaLamp", "only_shadow", "use_only_shadow"),
- ("AreaLamp", "shadow_layer", "use_shadow_layer"),
- ("AreaLamp", "umbra", "use_umbra"),
- ("PointLamp", "shadow_ray_sampling_method", "shadow_ray_sample_method"),
- ("PointLamp", "only_shadow", "use_only_shadow"),
- ("PointLamp", "shadow_layer", "use_shadow_layer"),
- ("PointLamp", "sphere", "use_sphere"),
- ("SpotLamp", "shadow_ray_sampling_method", "shadow_ray_sample_method"),
- ("SpotLamp", "auto_clip_end", "use_auto_clip_end"),
- ("SpotLamp", "auto_clip_start", "use_auto_clip_start"),
- ("SpotLamp", "only_shadow", "use_only_shadow"),
- ("SpotLamp", "shadow_layer", "use_shadow_layer"),
- ("SpotLamp", "sphere", "use_sphere"),
- ("SunLamp", "only_shadow", "use_only_shadow"),
- ("SunLamp", "shadow_layer", "use_shadow_layer"),
- ("Material", "z_offset", "offset_z"),
- ("Material", "shadow_casting_alpha", "shadow_cast_alpha"),
- ("Material", "cast_approximate", "use_cast_approximate"),
- ("Material", "cast_buffer_shadows", "use_cast_buffer_shadows"),
- ("Material", "cast_shadows_only", "use_cast_shadows_only"),
- ("Material", "face_texture", "use_face_texture"),
- ("Material", "face_texture_alpha", "use_face_texture_alpha"),
- ("Material", "full_oversampling", "use_full_oversampling"),
- ("Material", "light_group_exclusive", "use_light_group_exclusive"),
- ("Material", "object_color", "use_object_color"),
- ("Material", "only_shadow", "use_only_shadow"),
- ("Material", "ray_shadow_bias", "use_ray_shadow_bias"),
- ("Material", "traceable", "use_raytrace"),
- ("Material", "shadeless", "use_shadeless"),
- ("Material", "tangent_shading", "use_tangent_shading"),
- ("Material", "transparency", "use_transparency"),
- ("Material", "receive_transparent_shadows", "use_transparent_shadows"),
- ("Material", "vertex_color_light", "use_vertex_color_light"),
- ("Material", "vertex_color_paint", "use_vertex_color_paint"),
- ("Mesh", "autosmooth_angle", "auto_smooth_angle"),
- ("Mesh", "autosmooth", "use_auto_smooth"),
- ("Object", "max_draw_type", "draw_type"),
- ("Object", "use_dupli_verts_rotation", "use_dupli_vertices_rotation"),
- ("Object", "shape_key_edit_mode", "use_shape_key_edit_mode"),
- ("Object", "slow_parent", "use_slow_parent"),
- ("Object", "time_offset_add_parent", "use_time_offset_add_parent"),
- ("Object", "time_offset_edit", "use_time_offset_edit"),
- ("Object", "time_offset_parent", "use_time_offset_parent"),
- ("Object", "time_offset_particle", "use_time_offset_particle"),
- ("ParticleSettings", "adaptive_pix", "adaptive_pixel"),
- ("ParticleSettings", "child_effector", "apply_effector_to_children"),
- ("ParticleSettings", "child_guide", "apply_guide_to_children"),
- ("ParticleSettings", "billboard_split_offset", "billboard_offset_split"),
- ("ParticleSettings", "billboard_random_tilt", "billboard_tilt_random"),
- ("ParticleSettings", "child_length_thres", "child_length_threshold"),
- ("ParticleSettings", "child_random_size", "child_size_random"),
- ("ParticleSettings", "clumppow", "clump_shape"),
- ("ParticleSettings", "damp_factor", "damping"),
- ("ParticleSettings", "draw_as", "draw_method"),
- ("ParticleSettings", "random_factor", "factor_random"),
- ("ParticleSettings", "grid_invert", "invert_grid"),
- ("ParticleSettings", "random_length", "length_random"),
- ("ParticleSettings", "random_lifetime", "lifetime_random"),
- ("ParticleSettings", "billboard_lock", "lock_billboard"),
- ("ParticleSettings", "boids_2d", "lock_boids_to_surface"),
- ("ParticleSettings", "object_aligned_factor", "object_align_factor"),
- ("ParticleSettings", "random_phase_factor", "phase_factor_random"),
- ("ParticleSettings", "ren_as", "render_type"),
- ("ParticleSettings", "rendered_child_nbr", "rendered_child_count"),
- ("ParticleSettings", "random_rotation_factor", "rotation_factor_random"),
- ("ParticleSettings", "rough1", "roughness_1"),
- ("ParticleSettings", "rough1_size", "roughness_1_size"),
- ("ParticleSettings", "rough2", "roughness_2"),
- ("ParticleSettings", "rough2_size", "roughness_2_size"),
- ("ParticleSettings", "rough2_thres", "roughness_2_threshold"),
- ("ParticleSettings", "rough_end_shape", "roughness_end_shape"),
- ("ParticleSettings", "rough_endpoint", "roughness_endpoint"),
- ("ParticleSettings", "random_size", "size_random"),
- ("ParticleSettings", "abs_path_time", "use_absolute_path_time"),
- ("ParticleSettings", "animate_branching", "use_animate_branching"),
- ("ParticleSettings", "branching", "use_branching"),
- ("ParticleSettings", "died", "use_dead"),
- ("ParticleSettings", "die_on_collision", "use_die_on_collision"),
- ("ParticleSettings", "rotation_dynamic", "use_dynamic_rotation"),
- ("ParticleSettings", "even_distribution", "use_even_distribution"),
- ("ParticleSettings", "rand_group", "use_group_pick_random"),
- ("ParticleSettings", "hair_bspline", "use_hair_bspline"),
- ("ParticleSettings", "sizemass", "use_multiply_size_mass"),
- ("ParticleSettings", "react_multiple", "use_react_multiple"),
- ("ParticleSettings", "react_start_end", "use_react_start_end"),
- ("ParticleSettings", "render_adaptive", "use_render_adaptive"),
- ("ParticleSettings", "self_effect", "use_self_effect"),
- ("ParticleSettings", "enable_simplify", "use_simplify"),
- ("ParticleSettings", "size_deflect", "use_size_deflect"),
- ("ParticleSettings", "render_strand", "use_strand_primitive"),
- ("ParticleSettings", "symmetric_branching", "use_symmetric_branching"),
- ("ParticleSettings", "velocity_length", "use_velocity_length"),
- ("ParticleSettings", "whole_group", "use_whole_group"),
- ("CloudsTexture", "noise_size", "noise_scale"),
- ("DistortedNoiseTexture", "noise_size", "noise_scale"),
- ("EnvironmentMapTexture", "filter_size_minimum", "use_filter_size_min"),
- ("EnvironmentMapTexture", "mipmap_gauss", "use_mipmap_gauss"),
- ("ImageTexture", "calculate_alpha", "use_calculate_alpha"),
- ("ImageTexture", "checker_even", "use_checker_even"),
- ("ImageTexture", "checker_odd", "use_checker_odd"),
- ("ImageTexture", "filter_size_minimum", "use_filter_size_min"),
- ("ImageTexture", "flip_axis", "use_flip_axis"),
- ("ImageTexture", "mipmap_gauss", "use_mipmap_gauss"),
- ("ImageTexture", "mirror_x", "use_mirror_x"),
- ("ImageTexture", "mirror_y", "use_mirror_y"),
- ("ImageTexture", "normal_map", "use_normal_map"),
- ("MarbleTexture", "noise_size", "noise_scale"),
- ("MarbleTexture", "noisebasis2", "noise_basis_2"),
- ("MarbleTexture", "noisebasis_2", "noise_basis_2"),
- ("MusgraveTexture", "highest_dimension", "dimension_max"),
- ("MusgraveTexture", "noise_size", "noise_scale"),
- ("StucciTexture", "noise_size", "noise_scale"),
- ("VoronoiTexture", "coloring", "color_mode"),
- ("VoronoiTexture", "noise_size", "noise_scale"),
- ("WoodTexture", "noise_size", "noise_scale"),
- ("WoodTexture", "noisebasis2", "noise_basis_2"),
- ("WoodTexture", "noisebasis_2", "noise_basis_2"),
- ("World", "blend_sky", "use_sky_blend"),
- ("World", "paper_sky", "use_sky_paper"),
- ("World", "real_sky", "use_sky_real"),
- ("ImageUser", "auto_refresh", "use_auto_refresh"),
- ("MaterialHalo", "flares_sub", "flare_subflare_count"),
- ("MaterialHalo", "flare_subsize", "flare_subflare_size"),
- ("MaterialHalo", "line_number", "line_count"),
- ("MaterialHalo", "rings", "ring_count"),
- ("MaterialHalo", "star_tips", "star_tip_count"),
- ("MaterialHalo", "xalpha", "use_extreme_alpha"),
- ("MaterialHalo", "flare_mode", "use_flare_mode"),
- ("MaterialHalo", "vertex_normal", "use_vertex_normal"),
- ("MaterialPhysics", "align_to_normal", "use_normal_align"),
- ("MaterialStrand", "min_size", "size_min"),
- ("MaterialStrand", "blender_units", "use_blender_units"),
- ("MaterialStrand", "surface_diffuse", "use_surface_diffuse"),
- ("MaterialStrand", "tangent_shading", "use_tangent_shading"),
- ("MaterialSubsurfaceScattering", "error_tolerance", "error_threshold"),
- ("MaterialVolume", "depth_cutoff", "depth_threshold"),
- ("MaterialVolume", "lighting_mode", "light_method"),
- ("MaterialVolume", "step_calculation", "step_method"),
- ("MaterialVolume", "external_shadows", "use_external_shadows"),
- ("MaterialVolume", "light_cache", "use_light_cache"),
- ("ArmatureModifier", "multi_modifier", "use_multi_modifier"),
- ("ArrayModifier", "constant_offset_displacement", "constant_offset_displace"),
- ("ArrayModifier", "merge_distance", "merge_threshold"),
- ("ArrayModifier", "relative_offset_displacement", "relative_offset_displace"),
- ("ArrayModifier", "constant_offset", "use_constant_offset"),
- ("ArrayModifier", "merge_adjacent_vertices", "use_merge_vertices"),
- ("ArrayModifier", "merge_end_vertices", "use_merge_vertices_cap"),
- ("ArrayModifier", "add_offset_object", "use_object_offset"),
- ("ArrayModifier", "relative_offset", "use_relative_offset"),
- ("BevelModifier", "only_vertices", "use_only_vertices"),
- ("CastModifier", "from_radius", "use_radius_as_size"),
- ("DisplaceModifier", "midlevel", "mid_level"),
- ("DisplaceModifier", "texture_coordinates", "texture_coords"),
- ("EdgeSplitModifier", "use_sharp", "use_edge_sharp"),
- ("ExplodeModifier", "split_edges", "use_edge_split"),
- ("MirrorModifier", "merge_limit", "merge_threshold"),
- ("MirrorModifier", "mirror_u", "use_mirror_u"),
- ("MirrorModifier", "mirror_v", "use_mirror_v"),
- ("MirrorModifier", "mirror_vertex_groups", "use_mirror_vertex_groups"),
- ("ParticleInstanceModifier", "particle_system_number", "particle_system_index"),
- ("ParticleInstanceModifier", "keep_shape", "use_preserve_shape"),
- ("ShrinkwrapModifier", "cull_back_faces", "use_cull_back_faces"),
- ("ShrinkwrapModifier", "cull_front_faces", "use_cull_front_faces"),
- ("ShrinkwrapModifier", "keep_above_surface", "use_keep_above_surface"),
- ("SimpleDeformModifier", "lock_x_axis", "lock_x"),
- ("SimpleDeformModifier", "lock_y_axis", "lock_y"),
- ("SmokeModifier", "smoke_type", "type"),
- ("SubsurfModifier", "subsurf_uv", "use_subsurf_uv"),
- ("UVProjectModifier", "num_projectors", "projector_count"),
- ("UVProjectModifier", "override_image", "use_image_override"),
- ("WaveModifier", "texture_coordinates", "texture_coords"),
- ("WaveModifier", "x_normal", "use_normal_x"),
- ("WaveModifier", "y_normal", "use_normal_y"),
- ("WaveModifier", "z_normal", "use_normal_z"),
- ("NlaStrip", "blending", "blend_type"),
- ("NlaStrip", "animated_influence", "use_animated_influence"),
- ("NlaStrip", "animated_time", "use_animated_time"),
- ("NlaStrip", "animated_time_cyclic", "use_animated_time_cyclic"),
- ("NlaStrip", "auto_blending", "use_auto_blend"),
- ("CompositorNodeAlphaOver", "convert_premul", "use_premultiply"),
- ("CompositorNodeBlur", "sizex", "size_x"),
- ("CompositorNodeBlur", "sizey", "size_y"),
- ("CompositorNodeChannelMatte", "algorithm", "limit_method"),
- ("CompositorNodeChromaMatte", "acceptance", "tolerance"),
- ("CompositorNodeColorBalance", "correction_formula", "correction_method"),
- ("CompositorNodeColorSpill", "algorithm", "limit_method"),
- ("CompositorNodeColorSpill", "unspill", "use_unspill"),
- ("CompositorNodeCrop", "x2", "max_x"),
- ("CompositorNodeCrop", "y2", "max_y"),
- ("CompositorNodeCrop", "x1", "min_x"),
- ("CompositorNodeCrop", "y1", "min_y"),
- ("CompositorNodeCrop", "crop_size", "use_crop_size"),
- ("CompositorNodeDefocus", "max_blur", "blur_max"),
- ("CompositorNodeDefocus", "gamma_correction", "use_gamma_correction"),
- ("CompositorNodeGlare", "rotate_45", "use_rotate_45"),
- ("CompositorNodeImage", "auto_refresh", "use_auto_refresh"),
- ("CompositorNodeLensdist", "projector", "use_projector"),
- ("CompositorNodeVecBlur", "max_speed", "speed_max"),
- ("CompositorNodeVecBlur", "min_speed", "speed_min"),
- ("ShaderNodeMapping", "maximum", "max"),
- ("ShaderNodeMapping", "minimum", "min"),
- ("ShaderNodeMapping", "clamp_maximum", "use_max"),
- ("ShaderNodeMapping", "clamp_minimum", "use_min"),
- ("ParticleEdit", "add_keys", "default_key_count"),
- ("ParticleEdit", "selection_mode", "select_mode"),
- ("ParticleEdit", "auto_velocity", "use_auto_velocity"),
- ("ParticleEdit", "add_interpolate", "use_default_interpolate"),
- ("ParticleEdit", "emitter_deflect", "use_emitter_deflect"),
- ("ParticleEdit", "fade_time", "use_fade_time"),
- ("ParticleEdit", "keep_lengths", "use_preserve_length"),
- ("ParticleEdit", "keep_root", "use_preserve_root"),
- ("ParticleSystem", "vertex_group_clump_negate", "invert_vertex_group_clump"),
- ("ParticleSystem", "vertex_group_density_negate", "invert_vertex_group_density"),
- ("ParticleSystem", "vertex_group_field_negate", "invert_vertex_group_field"),
- ("ParticleSystem", "vertex_group_kink_negate", "invert_vertex_group_kink"),
- ("ParticleSystem", "vertex_group_length_negate", "invert_vertex_group_length"),
- ("ParticleSystem", "vertex_group_rotation_negate", "invert_vertex_group_rotation"),
- ("ParticleSystem", "vertex_group_roughness1_negate", "invert_vertex_group_roughness_1"),
- ("ParticleSystem", "vertex_group_roughness2_negate", "invert_vertex_group_roughness_2"),
- ("ParticleSystem", "vertex_group_roughness_end_negate", "invert_vertex_group_roughness_end"),
- ("ParticleSystem", "vertex_group_size_negate", "invert_vertex_group_size"),
- ("ParticleSystem", "vertex_group_tangent_negate", "invert_vertex_group_tangent"),
- ("ParticleSystem", "vertex_group_velocity_negate", "invert_vertex_group_velocity"),
- ("ParticleSystem", "hair_dynamics", "use_hair_dynamics"),
- ("ParticleSystem", "keyed_timing", "use_keyed_timing"),
- ("PointDensity", "falloff_softness", "falloff_soft"),
- ("PointDensity", "particle_cache", "particle_cache_space"),
- ("PointDensity", "turbulence_size", "turbulence_scale"),
- ("PointDensity", "turbulence", "use_turbulence"),
- ("PointDensity", "vertices_cache", "vertex_cache_space"),
- ("PoseBone", "ik_lin_weight", "ik_linear_weight"),
- ("PoseBone", "ik_rot_weight", "ik_rotation_weight"),
- ("PoseBone", "ik_limit_x", "use_ik_limit_x"),
- ("PoseBone", "ik_limit_y", "use_ik_limit_y"),
- ("PoseBone", "ik_limit_z", "use_ik_limit_z"),
- ("PoseBone", "ik_lin_control", "use_ik_linear_control"),
- ("PoseBone", "ik_rot_control", "use_ik_rotation_control"),
- ("Bone", "use_hinge", "use_inherit_rotation"),
- ("SPHFluidSettings", "spring_k", "spring_force"),
- ("SPHFluidSettings", "stiffness_k", "stiffness"),
- ("SPHFluidSettings", "stiffness_knear", "stiffness_near"),
- ("SceneGameData", "framing_color", "frame_color"),
- ("SceneGameData", "framing_type", "frame_type"),
- ("SceneGameData", "eye_separation", "stereo_eye_separation"),
- ("SceneGameData", "activity_culling", "use_activity_culling"),
- ("SceneGameData", "auto_start", "use_auto_start"),
- ("SceneGameData", "glsl_extra_textures", "use_glsl_extra_textures"),
- ("SceneGameData", "glsl_lights", "use_glsl_lights"),
- ("SceneGameData", "glsl_nodes", "use_glsl_nodes"),
- ("SceneGameData", "glsl_ramps", "use_glsl_ramps"),
- ("SceneGameData", "glsl_shaders", "use_glsl_shaders"),
- ("SceneGameData", "glsl_shadows", "use_glsl_shadows"),
- ("Sequence", "blend_opacity", "blend_alpha"),
- ("Sequence", "blend_mode", "blend_type"),
- ("Sequence", "frame_final_length", "frame_final_duration"),
- ("Sequence", "use_effect_default_fade", "use_default_fade"),
- ("SequenceColorBalance", "inverse_gain", "invert_gain"),
- ("SequenceColorBalance", "inverse_gamma", "invert_gamma"),
- ("SequenceColorBalance", "inverse_lift", "invert_lift"),
- ("EffectSequence", "multiply_colors", "color_multiply"),
- ("EffectSequence", "de_interlace", "use_deinterlace"),
- ("EffectSequence", "flip_x", "use_flip_x"),
- ("EffectSequence", "flip_y", "use_flip_y"),
- ("EffectSequence", "convert_float", "use_float"),
- ("EffectSequence", "premultiply", "use_premultiply"),
- ("EffectSequence", "proxy_custom_directory", "use_proxy_custom_directory"),
- ("EffectSequence", "proxy_custom_file", "use_proxy_custom_file"),
- ("EffectSequence", "reverse_frames", "use_reverse_frames"),
- ("GlowSequence", "blur_distance", "blur_radius"),
- ("GlowSequence", "only_boost", "use_only_boost"),
- ("SpeedControlSequence", "curve_compress_y", "use_curve_compress_y"),
- ("SpeedControlSequence", "curve_velocity", "use_curve_velocity"),
- ("SpeedControlSequence", "frame_blending", "use_frame_blend"),
- ("TransformSequence", "uniform_scale", "use_uniform_scale"),
- ("ImageSequence", "animation_end_offset", "animation_offset_end"),
- ("ImageSequence", "animation_start_offset", "animation_offset_start"),
- ("ImageSequence", "multiply_colors", "color_multiply"),
- ("ImageSequence", "de_interlace", "use_deinterlace"),
- ("ImageSequence", "flip_x", "use_flip_x"),
- ("ImageSequence", "flip_y", "use_flip_y"),
- ("ImageSequence", "convert_float", "use_float"),
- ("ImageSequence", "premultiply", "use_premultiply"),
- ("ImageSequence", "proxy_custom_directory", "use_proxy_custom_directory"),
- ("ImageSequence", "proxy_custom_file", "use_proxy_custom_file"),
- ("ImageSequence", "reverse_frames", "use_reverse_frames"),
- ("MetaSequence", "animation_end_offset", "animation_offset_end"),
- ("MetaSequence", "animation_start_offset", "animation_offset_start"),
- ("MetaSequence", "multiply_colors", "color_multiply"),
- ("MetaSequence", "de_interlace", "use_deinterlace"),
- ("MetaSequence", "flip_x", "use_flip_x"),
- ("MetaSequence", "flip_y", "use_flip_y"),
- ("MetaSequence", "convert_float", "use_float"),
- ("MetaSequence", "premultiply", "use_premultiply"),
- ("MetaSequence", "proxy_custom_directory", "use_proxy_custom_directory"),
- ("MetaSequence", "proxy_custom_file", "use_proxy_custom_file"),
- ("MetaSequence", "reverse_frames", "use_reverse_frames"),
- ("MovieSequence", "animation_end_offset", "animation_offset_end"),
- ("MovieSequence", "animation_start_offset", "animation_offset_start"),
- ("MovieSequence", "multiply_colors", "color_multiply"),
- ("MovieSequence", "de_interlace", "use_deinterlace"),
- ("MovieSequence", "flip_x", "use_flip_x"),
- ("MovieSequence", "flip_y", "use_flip_y"),
- ("MovieSequence", "convert_float", "use_float"),
- ("MovieSequence", "premultiply", "use_premultiply"),
- ("MovieSequence", "proxy_custom_directory", "use_proxy_custom_directory"),
- ("MovieSequence", "proxy_custom_file", "use_proxy_custom_file"),
- ("MovieSequence", "reverse_frames", "use_reverse_frames"),
- ("MulticamSequence", "animation_end_offset", "animation_offset_end"),
- ("MulticamSequence", "animation_start_offset", "animation_offset_start"),
- ("MulticamSequence", "multiply_colors", "color_multiply"),
- ("MulticamSequence", "de_interlace", "use_deinterlace"),
- ("MulticamSequence", "flip_x", "use_flip_x"),
- ("MulticamSequence", "flip_y", "use_flip_y"),
- ("MulticamSequence", "convert_float", "use_float"),
- ("MulticamSequence", "premultiply", "use_premultiply"),
- ("MulticamSequence", "proxy_custom_directory", "use_proxy_custom_directory"),
- ("MulticamSequence", "proxy_custom_file", "use_proxy_custom_file"),
- ("MulticamSequence", "reverse_frames", "use_reverse_frames"),
- ("SceneSequence", "animation_end_offset", "animation_offset_end"),
- ("SceneSequence", "animation_start_offset", "animation_offset_start"),
- ("SceneSequence", "multiply_colors", "color_multiply"),
- ("SceneSequence", "de_interlace", "use_deinterlace"),
- ("SceneSequence", "flip_x", "use_flip_x"),
- ("SceneSequence", "flip_y", "use_flip_y"),
- ("SceneSequence", "convert_float", "use_float"),
- ("SceneSequence", "premultiply", "use_premultiply"),
- ("SceneSequence", "proxy_custom_directory", "use_proxy_custom_directory"),
- ("SceneSequence", "proxy_custom_file", "use_proxy_custom_file"),
- ("SceneSequence", "reverse_frames", "use_reverse_frames"),
- ("SoundSequence", "animation_end_offset", "animation_offset_end"),
- ("SoundSequence", "animation_start_offset", "animation_offset_start"),
- ("SmokeDomainSettings", "smoke_domain_colli", "collision_extents"),
- ("SmokeDomainSettings", "smoke_cache_high_comp", "point_cache_compress_high_type"),
- ("SmokeDomainSettings", "smoke_cache_comp", "point_cache_compress_type"),
- ("SmokeDomainSettings", "maxres", "resolution_max"),
- ("SmokeDomainSettings", "smoothemitter", "smooth_emitter"),
- ("SmokeDomainSettings", "dissolve_smoke", "use_dissolve_smoke"),
- ("SmokeDomainSettings", "dissolve_smoke_log", "use_dissolve_smoke_log"),
- ("SmokeDomainSettings", "highres", "use_high_resolution"),
- ("SoftBodySettings", "bending", "bend"),
- ("SoftBodySettings", "error_limit", "error_threshold"),
- ("SoftBodySettings", "lcom", "location_mass_center"),
- ("SoftBodySettings", "lrot", "rotation_estimate"),
- ("SoftBodySettings", "lscale", "scale_estimate"),
- ("SoftBodySettings", "maxstep", "step_max"),
- ("SoftBodySettings", "minstep", "step_min"),
- ("SoftBodySettings", "diagnose", "use_diagnose"),
- ("SoftBodySettings", "edge_collision", "use_edge_collision"),
- ("SoftBodySettings", "estimate_matrix", "use_estimate_matrix"),
- ("SoftBodySettings", "face_collision", "use_face_collision"),
- ("SoftBodySettings", "self_collision", "use_self_collision"),
- ("SoftBodySettings", "stiff_quads", "use_stiff_quads"),
- ("TexMapping", "maximum", "max"),
- ("TexMapping", "minimum", "min"),
- ("TexMapping", "has_maximum", "use_max"),
- ("TexMapping", "has_minimum", "use_min"),
- ("TextCharacterFormat", "bold", "use_bold"),
- ("TextCharacterFormat", "italic", "use_italic"),
- ("TextCharacterFormat", "underline", "use_underline"),
- ("TextureSlot", "rgb_to_intensity", "use_rgb_to_intensity"),
- ("TextureSlot", "stencil", "use_stencil"),
- ("LampTextureSlot", "texture_coordinates", "texture_coords"),
- ("LampTextureSlot", "map_color", "use_map_color"),
- ("LampTextureSlot", "map_shadow", "use_map_shadow"),
- ("MaterialTextureSlot", "coloremission_factor", "color_emission_factor"),
- ("MaterialTextureSlot", "colordiff_factor", "diffuse_color_factor"),
- ("MaterialTextureSlot", "x_mapping", "mapping_x"),
- ("MaterialTextureSlot", "y_mapping", "mapping_y"),
- ("MaterialTextureSlot", "z_mapping", "mapping_z"),
- ("MaterialTextureSlot", "colorreflection_factor", "reflection_color_factor"),
- ("MaterialTextureSlot", "colorspec_factor", "specular_color_factor"),
- ("MaterialTextureSlot", "texture_coordinates", "texture_coords"),
- ("MaterialTextureSlot", "colortransmission_factor", "transmission_color_factor"),
- ("MaterialTextureSlot", "from_dupli", "use_from_dupli"),
- ("MaterialTextureSlot", "from_original", "use_from_original"),
- ("MaterialTextureSlot", "map_alpha", "use_map_alpha"),
- ("MaterialTextureSlot", "map_ambient", "use_map_ambient"),
- ("MaterialTextureSlot", "map_colordiff", "use_map_color_diff"),
- ("MaterialTextureSlot", "map_coloremission", "use_map_color_emission"),
- ("MaterialTextureSlot", "map_colorreflection", "use_map_color_reflection"),
- ("MaterialTextureSlot", "map_colorspec", "use_map_color_spec"),
- ("MaterialTextureSlot", "map_colortransmission", "use_map_color_transmission"),
- ("MaterialTextureSlot", "map_density", "use_map_density"),
- ("MaterialTextureSlot", "map_diffuse", "use_map_diffuse"),
- ("MaterialTextureSlot", "map_displacement", "use_map_displacement"),
- ("MaterialTextureSlot", "map_emission", "use_map_emission"),
- ("MaterialTextureSlot", "map_emit", "use_map_emit"),
- ("MaterialTextureSlot", "map_hardness", "use_map_hardness"),
- ("MaterialTextureSlot", "map_mirror", "use_map_mirror"),
- ("MaterialTextureSlot", "map_normal", "use_map_normal"),
- ("MaterialTextureSlot", "map_raymir", "use_map_raymir"),
- ("MaterialTextureSlot", "map_reflection", "use_map_reflect"),
- ("MaterialTextureSlot", "map_scattering", "use_map_scatter"),
- ("MaterialTextureSlot", "map_specular", "use_map_specular"),
- ("MaterialTextureSlot", "map_translucency", "use_map_translucency"),
- ("MaterialTextureSlot", "map_warp", "use_map_warp"),
- ("WorldTextureSlot", "texture_coordinates", "texture_coords"),
- ("WorldTextureSlot", "map_blend", "use_map_blend"),
- ("WorldTextureSlot", "map_horizon", "use_map_horizon"),
- ("WorldTextureSlot", "map_zenith_down", "use_map_zenith_down"),
- ("WorldTextureSlot", "map_zenith_up", "use_map_zenith_up"),
- ("VoxelData", "still_frame_number", "still_frame"),
- ("WorldLighting", "ao_blend_mode", "ao_blend_type"),
- ("WorldLighting", "error_tolerance", "error_threshold"),
- ("WorldLighting", "use_ambient_occlusion", "use_ambient_occlusian"),
- ("WorldLighting", "pixel_cache", "use_cache"),
- ("WorldLighting", "use_environment_lighting", "use_environment_light"),
- ("WorldLighting", "use_indirect_lighting", "use_indirect_light"),
- ("WorldStarsSettings", "color_randomization", "color_random"),
- ("WorldStarsSettings", "min_distance", "distance_min"),
- ("WorldLighting", "falloff", "use_falloff"),
- ("Constraint", "disabled", "is_valid"),
- ("ClampToConstraint", "cyclic", "use_cyclic"),
- ("ImageTexture", "filter", "filter_type"),
- ("ImageTexture", "interpolation", "use_interpolation"),
- ("ImageTexture", "mipmap", "use_mipmap"),
- ("ImageUser", "frames", "frame_duration"),
- ("ImageUser", "offset", "frame_offset"),
- ("ImageUser", "cyclic", "use_cyclic"),
- ("ArmatureModifier", "invert", "invert_vertex_group"),
- ("ArmatureModifier", "quaternion", "use_deform_preserve_volume"),
- ("ArrayModifier", "length", "fit_length"),
- ("BevelModifier", "angle", "angle_limit"),
- ("BuildModifier", "length", "frame_duration"),
- ("BuildModifier", "randomize", "use_random_order"),
- ("CastModifier", "x", "use_x"),
- ("CastModifier", "y", "use_y"),
- ("CastModifier", "z", "use_z"),
- ("ExplodeModifier", "size", "use_size"),
- ("MaskModifier", "invert", "invert_vertex_group"),
- ("MeshDeformModifier", "invert", "invert_vertex_group"),
- ("MeshDeformModifier", "dynamic", "use_dynamic_bind"),
- ("MirrorModifier", "clip", "use_clip"),
- ("MirrorModifier", "x", "use_x"),
- ("MirrorModifier", "y", "use_y"),
- ("MirrorModifier", "z", "use_z"),
- ("ParticleInstanceModifier", "children", "use_children"),
- ("ParticleInstanceModifier", "normal", "use_normal"),
- ("ParticleInstanceModifier", "size", "use_size"),
- ("ShrinkwrapModifier", "negative", "use_negative_direction"),
- ("ShrinkwrapModifier", "positive", "use_positive_direction"),
- ("ShrinkwrapModifier", "x", "use_project_x"),
- ("ShrinkwrapModifier", "y", "use_project_y"),
- ("ShrinkwrapModifier", "z", "use_project_z"),
- ("ShrinkwrapModifier", "mode", "wrap_method"),
- ("SimpleDeformModifier", "mode", "deform_method"),
- ("SimpleDeformModifier", "relative", "use_relative"),
- ("SmoothModifier", "repeat", "iterations"),
- ("SmoothModifier", "x", "use_x"),
- ("SmoothModifier", "y", "use_y"),
- ("SmoothModifier", "z", "use_z"),
- ("SolidifyModifier", "invert", "invert_vertex_group"),
- ("WaveModifier", "cyclic", "use_cyclic"),
- ("WaveModifier", "normals", "use_normal"),
- ("WaveModifier", "x", "use_x"),
- ("WaveModifier", "y", "use_y"),
- ("DampedTrackConstraint", "track", "track_axis"),
- ("FloorConstraint", "sticky", "use_sticky"),
- ("FollowPathConstraint", "forward", "forward_axis"),
- ("FollowPathConstraint", "up", "up_axis"),
- ("LockedTrackConstraint", "lock", "lock_axis"),
- ("LockedTrackConstraint", "track", "track_axis"),
- ("MaintainVolumeConstraint", "axis", "free_axis"),
- ("TrackToConstraint", "track", "track_axis"),
- ("TrackToConstraint", "up", "up_axis"),
- ("GameProperty", "debug", "show_debug"),
- ("Image", "tiles", "use_tiles"),
- ("Lamp", "diffuse", "use_diffuse"),
- ("Lamp", "negative", "use_negative"),
- ("Lamp", "layer", "use_own_layer"),
- ("Lamp", "specular", "use_specular"),
- ("AreaLamp", "dither", "use_dither"),
- ("AreaLamp", "jitter", "use_jitter"),
- ("SpotLamp", "square", "use_square"),
- ("Material", "cubic", "use_cubic"),
- ("Material", "shadows", "use_shadows"),
- ("ParticleSettings", "amount", "count"),
- ("ParticleSettings", "display", "draw_percentage"),
- ("ParticleSettings", "velocity", "show_velocity"),
- ("ParticleSettings", "trand", "use_emit_random"),
- ("ParticleSettings", "parent", "use_parent_particles"),
- ("ParticleSettings", "emitter", "use_render_emitter"),
- ("ParticleSettings", "viewport", "use_simplify_viewport"),
- ("Texture", "brightness", "intensity"),
- ("CloudsTexture", "stype", "cloud_type"),
- ("EnvironmentMapTexture", "filter", "filter_type"),
- ("EnvironmentMapTexture", "mipmap", "use_mipmap"),
- ("MarbleTexture", "stype", "marble_type"),
- ("StucciTexture", "stype", "stucci_type"),
- ("WoodTexture", "stype", "wood_type"),
- ("World", "range", "color_range"),
- ("World", "lighting", "light_settings"),
- ("World", "mist", "mist_settings"),
- ("World", "stars", "star_settings"),
- ("MaterialHalo", "lines", "use_lines"),
- ("MaterialHalo", "ring", "use_ring"),
- ("MaterialHalo", "soft", "use_soft"),
- ("MaterialHalo", "star", "use_star"),
- ("MaterialHalo", "texture", "use_texture"),
- ("MaterialPhysics", "damp", "damping"),
- ("MaterialRaytraceTransparency", "limit", "depth_max"),
- ("NlaStrip", "reversed", "use_reverse"),
- ("CompositorNodeBlur", "bokeh", "use_bokeh"),
- ("CompositorNodeBlur", "gamma", "use_gamma_correction"),
- ("CompositorNodeBlur", "relative", "use_relative"),
- ("CompositorNodeChannelMatte", "high", "limit_max"),
- ("CompositorNodeChannelMatte", "low", "limit_min"),
- ("CompositorNodeChannelMatte", "channel", "matte_channel"),
- ("CompositorNodeChromaMatte", "cutoff", "threshold"),
- ("CompositorNodeColorMatte", "h", "color_hue"),
- ("CompositorNodeColorMatte", "s", "color_saturation"),
- ("CompositorNodeColorMatte", "v", "color_value"),
- ("CompositorNodeDBlur", "wrap", "use_wrap"),
- ("CompositorNodeDefocus", "preview", "use_preview"),
- ("CompositorNodeHueSat", "hue", "color_hue"),
- ("CompositorNodeHueSat", "sat", "color_saturation"),
- ("CompositorNodeHueSat", "val", "color_value"),
- ("CompositorNodeImage", "frames", "frame_duration"),
- ("CompositorNodeImage", "offset", "frame_offset"),
- ("CompositorNodeImage", "start", "frame_start"),
- ("CompositorNodeImage", "cyclic", "use_cyclic"),
- ("CompositorNodeInvert", "alpha", "invert_alpha"),
- ("CompositorNodeInvert", "rgb", "invert_rgb"),
- ("CompositorNodeLensdist", "fit", "use_fit"),
- ("CompositorNodeLensdist", "jitter", "use_jitter"),
- ("CompositorNodeMixRGB", "alpha", "use_alpha"),
- ("CompositorNodeRotate", "filter", "filter_type"),
- ("CompositorNodeTime", "end", "frame_end"),
- ("CompositorNodeTime", "start", "frame_start"),
- ("CompositorNodeVecBlur", "curved", "use_curved"),
- ("ShaderNodeExtendedMaterial", "diffuse", "use_diffuse"),
- ("ShaderNodeExtendedMaterial", "specular", "use_specular"),
- ("ShaderNodeMaterial", "diffuse", "use_diffuse"),
- ("ShaderNodeMaterial", "specular", "use_specular"),
- ("ShaderNodeMixRGB", "alpha", "use_alpha"),
- ("TextureNodeCurveTime", "end", "frame_end"),
- ("TextureNodeCurveTime", "start", "frame_start"),
- ("TextureNodeMixRGB", "alpha", "use_alpha"),
- ("TextureSlot", "negate", "invert"),
- ("TextureSlot", "size", "scale"),
- ("SoftBodySettings", "damp", "damping"),
- ("SequenceCrop", "right", "max_x"),
- ("SequenceCrop", "top", "max_y"),
- ("SequenceCrop", "bottom", "min_x"),
- ("SequenceCrop", "left", "min_y"),
- ("Sequence", "speed_fader", "speed_factor"),
- ("SpeedControlSequence", "global_speed", "multiply_speed"),
- ("SpeedControlSequence", "use_curve_velocity", "use_as_speed"),
- ("SpeedControlSequence", "use_curve_compress_y", "scale_to_length"),
- ("Key", "keys", "key_blocks"),
- )
-
-
if __name__ == "__main__":
# Example, should be called externally
diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
index e9ed9a8de5b..429fea60d7a 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -791,10 +791,10 @@ def dump_src_messages(msgs, reports, settings):
##### Main functions! #####
def dump_messages(do_messages, do_checks, settings):
bl_ver = "Blender " + bpy.app.version_string
- bl_rev = bpy.app.build_revision
+ bl_hash = bpy.app.build_hash or b'0000000000000000000000000000000000000000'
bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(),
"%Y-%m-%dT%H:%M:%S")
- pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_rev, bl_date, bl_date.year,
+ pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_hash, bl_date, bl_date.year,
settings=settings)
msgs = pot.msgs
diff --git a/release/scripts/modules/bl_i18n_utils/merge_po.py b/release/scripts/modules/bl_i18n_utils/merge_po.py
index 610be0f15bd..d7dade22ffd 100755
--- a/release/scripts/modules/bl_i18n_utils/merge_po.py
+++ b/release/scripts/modules/bl_i18n_utils/merge_po.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
# ***** BEGIN GPL LICENSE BLOCK *****
#
diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py
index e40b067f552..300cd7ae955 100644
--- a/release/scripts/modules/bl_i18n_utils/settings.py
+++ b/release/scripts/modules/bl_i18n_utils/settings.py
@@ -146,7 +146,7 @@ PO_MSGSTR = "msgstr "
PO_HEADER_KEY = (DEFAULT_CONTEXT, "")
PO_HEADER_MSGSTR = (
- "Project-Id-Version: {blender_ver} (r{blender_rev})\\n\n"
+ "Project-Id-Version: {blender_ver} ({blender_hash})\\n\n"
"Report-Msgid-Bugs-To: \\n\n"
"POT-Creation-Date: {time}\\n\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\n"
@@ -257,6 +257,16 @@ PYGETTEXT_KEYWORDS = (() +
for it in ("BLF_I18N_MSGID_MULTI_CTXT",))
)
+# Check printf mismatches between msgid and msgstr.
+CHECK_PRINTF_FORMAT = (
+ r"(?!<%)(?:%%)*%" # Begining, with handling for crazy things like '%%%%%s'
+ r"[-+#0]?" # Flags (note: do not add the ' ' (space) flag here, generates too much false positives!)
+ r"(?:\*|[0-9]+)?" # Width
+ r"(?:\.(?:\*|[0-9]+))?" # Precision
+ r"(?:[hljztL]|hh|ll)?" # Length
+ r"[tldiuoxXfFeEgGaAcspn]" # Specifiers (note we have Blender-specific %t and %l ones too)
+)
+
# Should po parser warn when finding a first letter not capitalized?
WARN_MSGID_NOT_CAPITALIZED = True
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py
index 1b6d65d89d0..53146fd0287 100644
--- a/release/scripts/modules/bl_i18n_utils/utils.py
+++ b/release/scripts/modules/bl_i18n_utils/utils.py
@@ -408,10 +408,10 @@ class I18nMessages:
return getattr(collections, 'OrderedDict', dict)()
@classmethod
- def gen_empty_messages(cls, uid, blender_ver, blender_rev, time, year, default_copyright=True, settings=settings):
+ def gen_empty_messages(cls, uid, blender_ver, blender_hash, time, year, default_copyright=True, settings=settings):
"""Generate an empty I18nMessages object (only header is present!)."""
fmt = settings.PO_HEADER_MSGSTR
- msgstr = fmt.format(blender_ver=str(blender_ver), blender_rev=int(blender_rev), time=str(time), uid=str(uid))
+ msgstr = fmt.format(blender_ver=str(blender_ver), blender_hash=blender_hash, time=str(time), uid=str(uid))
comment = ""
if default_copyright:
comment = settings.PO_HEADER_COMMENT_COPYRIGHT.format(year=str(year))
@@ -446,10 +446,10 @@ class I18nMessages:
"""
ret = []
default_context = self.settings.DEFAULT_CONTEXT
- _format = re.compile("%[.0-9]*[tslfd]").findall
+ _format = re.compile(self.settings.CHECK_PRINTF_FORMAT).findall
done_keys = set()
- tmp = {}
rem = set()
+ tmp = {}
for key, msg in self.msgs.items():
msgctxt, msgid, msgstr = msg.msgctxt, msg.msgid, msg.msgstr
real_key = (msgctxt or default_context, msgid)
@@ -462,9 +462,10 @@ class I18nMessages:
elif fix:
tmp[real_key] = msg
done_keys.add(key)
- if '%' in msgid and msgstr and len(_format(msgid)) != len(_format(msgstr)):
+ if '%' in msgid and msgstr and _format(msgid) != _format(msgstr):
if not msg.is_fuzzy:
- ret.append("Error! msg's format entities are not matched in msgid and msgstr ({})".format(real_key))
+ ret.append("Error! msg's format entities are not matched in msgid and msgstr ({} / \"{}\")"
+ "".format(real_key, msgstr))
if fix:
msg.msgstr = ""
for k in rem:
diff --git a/release/scripts/modules/bl_i18n_utils/utils_rtl.py b/release/scripts/modules/bl_i18n_utils/utils_rtl.py
index 0544f93a262..f08d7efdb8e 100755
--- a/release/scripts/modules/bl_i18n_utils/utils_rtl.py
+++ b/release/scripts/modules/bl_i18n_utils/utils_rtl.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
# ***** BEGIN GPL LICENSE BLOCK *****
#
diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py
index d08b9e09dda..a62eaeea143 100755
--- a/release/scripts/modules/blend_render_info.py
+++ b/release/scripts/modules/blend_render_info.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# ##### BEGIN GPL LICENSE BLOCK #####
#
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py
index da1a52e560d..ccc9df93b0d 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -321,7 +321,7 @@ def reduce_dirs(dirs):
"""
dirs = list({_os.path.normpath(_os.path.abspath(d)) for d in dirs})
dirs.sort(key=lambda d: len(d))
- for i in range(len(dirs) -1, -1, -1):
+ for i in range(len(dirs) - 1, -1, -1):
for j in range(i):
print(i, j)
if len(dirs[i]) == len(dirs[j]):
diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py
index ab35d774719..608cd920865 100644
--- a/release/scripts/modules/bpy/utils.py
+++ b/release/scripts/modules/bpy/utils.py
@@ -677,7 +677,7 @@ def make_rna_paths(struct_name, prop_name, enum_name):
if prop_name:
src = src_rna = ".".join((struct_name, prop_name))
if enum_name:
- src = src_enum = "{}:'{}'".format(src_rna, enum_name)
+ src = src_enum = "%s:'%s'" % (src_rna, enum_name)
else:
src = src_rna = struct_name
return src, src_rna, src_enum
diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py
index 1baab5654c6..4b673b2e0de 100644
--- a/release/scripts/modules/bpy_extras/keyconfig_utils.py
+++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py
@@ -151,7 +151,7 @@ def keyconfig_merge(kc1, kc2):
return merged_keymaps
-def _export_properties(prefix, properties, lines=None):
+def _export_properties(prefix, properties, kmi_id, lines=None):
from bpy.types import OperatorProperties
if lines is None:
@@ -171,20 +171,58 @@ def _export_properties(prefix, properties, lines=None):
if pname != "rna_type":
value = getattr(properties, pname)
if isinstance(value, OperatorProperties):
- _export_properties(prefix + "." + pname, value, lines)
+ _export_properties(prefix + "." + pname, value, kmi_id, lines)
elif properties.is_property_set(pname):
value = string_value(value)
if value != "":
- lines.append("%s.%s = %s\n" % (prefix, pname, value))
+ lines.append("set_kmi_prop(%s, '%s', %s, '%s')\n" % (prefix, pname, value, kmi_id))
return lines
+def _kmistr(kmi, is_modal):
+ if is_modal:
+ kmi_id = kmi.propvalue
+ kmi_newfunc = 'new_modal'
+ else:
+ kmi_id = kmi.idname
+ kmi_newfunc = 'new'
+ s = ["kmi = km.keymap_items.%s(\'%s\', \'%s\', \'%s\'" % (kmi_newfunc, kmi_id, kmi.type, kmi.value)]
+
+ if kmi.any:
+ s.append(", any=True")
+ else:
+ if kmi.shift:
+ s.append(", shift=True")
+ if kmi.ctrl:
+ s.append(", ctrl=True")
+ if kmi.alt:
+ s.append(", alt=True")
+ if kmi.oskey:
+ s.append(", oskey=True")
+ if kmi.key_modifier and kmi.key_modifier != 'NONE':
+ s.append(", key_modifier=\'%s\'" % kmi.key_modifier)
+
+ s.append(")\n")
+
+ props = kmi.properties
+
+ if props is not None:
+ _export_properties("kmi.properties", props, kmi_id, s)
+
+ return "".join(s)
+
+
def keyconfig_export(wm, kc, filepath):
f = open(filepath, "w")
f.write("import bpy\n")
f.write("import os\n\n")
+ f.write("def set_kmi_prop(kmiprops, prop, value, kmiid):\n"
+ " if hasattr(kmiprops, prop):\n"
+ " setattr(kmiprops, prop, value)\n"
+ " else:\n"
+ " print(\"Warning: property '%s' not found in keymap item '%s'\" % (prop, kmiid))\n\n")
f.write("wm = bpy.context.window_manager\n")
f.write("kc = wm.keyconfigs.new(os.path.splitext(os.path.basename(__file__))[0])\n\n") # keymap must be created by caller
@@ -216,30 +254,7 @@ def keyconfig_export(wm, kc, filepath):
f.write("# Map %s\n" % km.name)
f.write("km = kc.keymaps.new('%s', space_type='%s', region_type='%s', modal=%s)\n\n" % (km.name, km.space_type, km.region_type, km.is_modal))
for kmi in km.keymap_items:
- if km.is_modal:
- f.write("kmi = km.keymap_items.new_modal('%s', '%s', '%s'" % (kmi.propvalue, kmi.type, kmi.value))
- else:
- f.write("kmi = km.keymap_items.new('%s', '%s', '%s'" % (kmi.idname, kmi.type, kmi.value))
- if kmi.any:
- f.write(", any=True")
- else:
- if kmi.shift:
- f.write(", shift=True")
- if kmi.ctrl:
- f.write(", ctrl=True")
- if kmi.alt:
- f.write(", alt=True")
- if kmi.oskey:
- f.write(", oskey=True")
- if kmi.key_modifier and kmi.key_modifier != 'NONE':
- f.write(", key_modifier='%s'" % kmi.key_modifier)
- f.write(")\n")
-
- props = kmi.properties
-
- if props is not None:
- f.write("".join(_export_properties("kmi.properties", props)))
-
+ f.write(_kmistr(kmi, km.is_modal))
f.write("\n")
f.close()
@@ -250,50 +265,22 @@ def keyconfig_test(kc):
def testEntry(kc, entry, src=None, parent=None):
result = False
- def kmistr(kmi):
- if km.is_modal:
- s = ["kmi = km.keymap_items.new_modal(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value)]
- else:
- s = ["kmi = km.keymap_items.new(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value)]
-
- if kmi.any:
- s.append(", any=True")
- else:
- if kmi.shift:
- s.append(", shift=True")
- if kmi.ctrl:
- s.append(", ctrl=True")
- if kmi.alt:
- s.append(", alt=True")
- if kmi.oskey:
- s.append(", oskey=True")
- if kmi.key_modifier and kmi.key_modifier != 'NONE':
- s.append(", key_modifier=\'%s\'" % kmi.key_modifier)
-
- s.append(")\n")
-
- props = kmi.properties
-
- if props is not None:
- _export_properties("kmi.properties", props, s)
-
- return "".join(s).strip()
-
idname, spaceid, regionid, children = entry
km = kc.keymaps.find(idname, space_type=spaceid, region_type=regionid)
if km:
km = km.active()
+ is_modal = km.is_modal
if src:
for item in km.keymap_items:
if src.compare(item):
print("===========")
print(parent.name)
- print(kmistr(src))
+ print(_kmistr(src, is_modal).strip())
print(km.name)
- print(kmistr(item))
+ print(_kmistr(item, is_modal).strip())
result = True
for child in children:
@@ -312,8 +299,8 @@ def keyconfig_test(kc):
if src.compare(item):
print("===========")
print(km.name)
- print(kmistr(src))
- print(kmistr(item))
+ print(_kmistr(src, is_modal).strip())
+ print(_kmistr(item, is_modal).strip())
result = True
for child in children:
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index 7ce5aff581a..a14f0128444 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -201,6 +201,10 @@ class AddObjectHelper:
subtype='EULER',
)
+ @classmethod
+ def poll(self, context):
+ return context.scene.library is None
+
def object_add_grid_scale(context):
"""
diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py
index 60b11884e30..3643ad89ea6 100644
--- a/release/scripts/modules/rna_info.py
+++ b/release/scripts/modules/rna_info.py
@@ -98,6 +98,7 @@ class InfoStructRNA:
)
global_lookup = {}
+
def __init__(self, rna_type):
self.bl_rna = rna_type
diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py
index ea75bfde809..83f2647c5b2 100644
--- a/release/scripts/modules/sys_info.py
+++ b/release/scripts/modules/sys_info.py
@@ -67,7 +67,20 @@ def write_sysinfo(op):
# build info
output.write("\nBlender:\n")
output.write(lilies)
- output.write("version %s, revision %r. %r\n" % (bpy.app.version_string, bpy.app.build_revision, bpy.app.build_type))
+ if bpy.app.build_branch and bpy.app.build_branch != "Unknown":
+ output.write("version %s, branch %r, commit date %r %r, hash %r, %r\n" %
+ (bpy.app.version_string,
+ bpy.app.build_branch,
+ bpy.app.build_commit_date,
+ bpy.app.build_commit_time,
+ bpy.app.build_hash,
+ bpy.app.build_type))
+ else:
+ output.write("version %s, revision %r. %r\n" %
+ (bpy.app.version_string,
+ bpy.app.build_change,
+ bpy.app.build_type))
+
output.write("build date: %r, %r\n" % (bpy.app.build_date, bpy.app.build_time))
output.write("platform: %r\n" % (bpy.app.build_platform))
output.write("binary path: %r\n" % (bpy.app.binary_path))
diff --git a/release/scripts/presets/keyconfig/3dsmax.py b/release/scripts/presets/keyconfig/3dsmax.py
index 42a928cf80f..f484ecd44b5 100644
--- a/release/scripts/presets/keyconfig/3dsmax.py
+++ b/release/scripts/presets/keyconfig/3dsmax.py
@@ -255,7 +255,8 @@ kmi.properties.direction = 'CHILD'
kmi.properties.extend = True
kmi = km.keymap_items.new('pose.select_linked', 'L', 'PRESS', alt=True)
kmi = km.keymap_items.new('pose.select_grouped', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('pose.select_flip_active', 'F', 'PRESS', shift=True)
+kmi = km.keymap_items.new('pose.select_mirror', 'F', 'PRESS', shift=True)
+kmi.properties.only_active = True
kmi = km.keymap_items.new('pose.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True)
kmi = km.keymap_items.new('pose.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('pose.ik_add', 'I', 'PRESS', shift=True)
@@ -686,7 +687,7 @@ kmi = km.keymap_items.new('transform.translate', 'W', 'PRESS', shift=True)
kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY')
kmi = km.keymap_items.new('transform.rotate', 'E', 'PRESS', shift=True)
kmi = km.keymap_items.new('transform.resize', 'R', 'PRESS', shift=True)
-kmi = km.keymap_items.new('transform.warp', 'Q', 'PRESS', shift=True)
+kmi = km.keymap_items.new('transform.bend', 'Q', 'PRESS', shift=True)
kmi = km.keymap_items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True)
kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True)
kmi = km.keymap_items.new('transform.select_orientation', 'SPACE', 'PRESS', alt=True)
@@ -1062,7 +1063,6 @@ kmi = km.keymap_items.new('node.hide_toggle', 'H', 'PRESS')
kmi = km.keymap_items.new('node.mute_toggle', 'M', 'PRESS')
kmi = km.keymap_items.new('node.preview_toggle', 'H', 'PRESS', shift=True)
kmi = km.keymap_items.new('node.hide_socket_toggle', 'H', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('node.show_cyclic_dependencies', 'C', 'PRESS')
kmi = km.keymap_items.new('node.view_all', 'HOME', 'PRESS')
kmi = km.keymap_items.new('node.view_selected', 'NUMPAD_PERIOD', 'PRESS')
kmi = km.keymap_items.new('node.select_border', 'B', 'PRESS')
diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py
index 21fd757c4e5..1b8648731aa 100644
--- a/release/scripts/presets/keyconfig/maya.py
+++ b/release/scripts/presets/keyconfig/maya.py
@@ -315,7 +315,8 @@ kmi.properties.direction = 'CHILD'
kmi.properties.extend = True
kmi = km.keymap_items.new('pose.select_linked', 'L', 'PRESS')
kmi = km.keymap_items.new('pose.select_grouped', 'G', 'PRESS', shift=True)
-kmi = km.keymap_items.new('pose.select_flip_active', 'F', 'PRESS', shift=True)
+kmi = km.keymap_items.new('pose.select_mirror', 'F', 'PRESS', shift=True)
+kmi.properties.only_active = True
kmi = km.keymap_items.new('pose.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True)
kmi = km.keymap_items.new('pose.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('pose.ik_add', 'I', 'PRESS', shift=True)
@@ -697,8 +698,10 @@ km = kc.keymaps.new('Knife Tool Modal Map', space_type='EMPTY', region_type='WIN
kmi = km.keymap_items.new_modal('CANCEL', 'ESC', 'ANY', any=True)
kmi = km.keymap_items.new_modal('PANNING', 'LEFTMOUSE', 'ANY', alt=True)
+kmi = km.keymap_items.new_modal('PANNING', 'MIDDLEMOUSE', 'ANY', alt=True)
+kmi = km.keymap_items.new_modal('PANNING', 'RIGHTMOUSE', 'ANY', alt=True)
kmi = km.keymap_items.new_modal('ADD_CUT', 'LEFTMOUSE', 'PRESS', any=True)
-kmi = km.keymap_items.new_modal('CANCEL', 'RIGHTMOUSE', 'ANY', any=True)
+kmi = km.keymap_items.new_modal('CANCEL', 'RIGHTMOUSE', 'ANY')
kmi = km.keymap_items.new_modal('CONFIRM', 'RET', 'PRESS', any=True)
kmi = km.keymap_items.new_modal('CONFIRM', 'NUMPAD_ENTER', 'PRESS', any=True)
kmi = km.keymap_items.new_modal('CONFIRM', 'SPACE', 'PRESS', any=True)
@@ -1474,7 +1477,6 @@ kmi = km.keymap_items.new('node.hide_toggle', 'H', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('node.mute_toggle', 'M', 'PRESS')
kmi = km.keymap_items.new('node.preview_toggle', 'H', 'PRESS', shift=True)
kmi = km.keymap_items.new('node.hide_socket_toggle', 'H', 'PRESS', shift=True, ctrl=True)
-kmi = km.keymap_items.new('node.show_cyclic_dependencies', 'C', 'PRESS')
kmi = km.keymap_items.new('node.view_all', 'A', 'PRESS')
kmi = km.keymap_items.new('node.delete', 'BACK_SPACE', 'PRESS')
kmi = km.keymap_items.new('node.delete', 'DEL', 'PRESS')
@@ -1587,8 +1589,11 @@ kmi = km.keymap_items.new('action.view_all', 'A', 'PRESS')
kmi = km.keymap_items.new('action.view_selected', 'F', 'PRESS')
kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS')
kmi = km.keymap_items.new('transform.transform', 'W', 'PRESS')
+kmi.properties.mode = 'TIME_TRANSLATE'
kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_M', 'ANY')
+kmi.properties.mode = 'TIME_TRANSLATE'
kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS')
+kmi.properties.mode = 'TIME_SCALE'
kmi = km.keymap_items.new('transform.transform', 'T', 'PRESS', shift=True)
kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True)
@@ -1662,6 +1667,7 @@ kmi = km.keymap_items.new('nla.fmodifier_add', 'M', 'PRESS', shift=True, ctrl=Tr
kmi = km.keymap_items.new('transform.transform', 'W', 'PRESS')
kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_M', 'ANY')
kmi = km.keymap_items.new('transform.transform', 'R', 'PRESS')
+kmi.properties.mode = 'TIME_SCALE'
kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('nla.select_all_toggle', 'LEFTMOUSE', 'DOUBLE_CLICK')
diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py
index 6193611504e..41f39b90464 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -281,15 +281,3 @@ class ClearUselessActions(Operator):
self.report({'INFO'}, "Removed %d empty and/or fake-user only Actions"
% removed)
return {'FINISHED'}
-
-
-class UpdateAnimData(Operator):
- """Update data paths from 2.56 and previous versions, """ \
- """modifying data paths of drivers and fcurves"""
- bl_idname = "anim.update_data_paths"
- bl_label = "Update Animation Data"
-
- def execute(self, context):
- import animsys_refactor
- animsys_refactor.update_data_paths(animsys_refactor.data_2_56_to_2_59)
- return {'FINISHED'}
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index 77978c71ed9..0814d0144ab 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -222,7 +222,7 @@ class NODE_OT_add_search(NodeAddOperator, Operator):
self.create_node(context, item.nodetype)
if self.use_transform:
- bpy.ops.transform.translate('INVOKE_DEFAULT')
+ bpy.ops.transform.translate('INVOKE_DEFAULT', remove_on_cancel=True)
return {'FINISHED'}
else:
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 05dfd882180..ae6ec3946f1 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -221,7 +221,7 @@ class ExecutePreset(Operator):
class AddPresetRender(AddPresetBase, Operator):
- """Add a Render Preset"""
+ """Add or remove a Render Preset"""
bl_idname = "render.preset_add"
bl_label = "Add Render Preset"
preset_menu = "RENDER_MT_presets"
@@ -247,7 +247,7 @@ class AddPresetRender(AddPresetBase, Operator):
class AddPresetCamera(AddPresetBase, Operator):
- """Add a Camera Preset"""
+ """Add or remove a Camera Preset"""
bl_idname = "camera.preset_add"
bl_label = "Add Camera Preset"
preset_menu = "CAMERA_MT_presets"
@@ -266,7 +266,7 @@ class AddPresetCamera(AddPresetBase, Operator):
class AddPresetSSS(AddPresetBase, Operator):
- """Add a Subsurface Scattering Preset"""
+ """Add or remove a Subsurface Scattering Preset"""
bl_idname = "material.sss_preset_add"
bl_label = "Add SSS Preset"
preset_menu = "MATERIAL_MT_sss_presets"
@@ -294,7 +294,7 @@ class AddPresetSSS(AddPresetBase, Operator):
class AddPresetCloth(AddPresetBase, Operator):
- """Add a Cloth Preset"""
+ """Add or remove a Cloth Preset"""
bl_idname = "cloth.preset_add"
bl_label = "Add Cloth Preset"
preset_menu = "CLOTH_MT_presets"
@@ -316,7 +316,7 @@ class AddPresetCloth(AddPresetBase, Operator):
class AddPresetFluid(AddPresetBase, Operator):
- """Add a Fluid Preset"""
+ """Add or remove a Fluid Preset"""
bl_idname = "fluid.preset_add"
bl_label = "Add Fluid Preset"
preset_menu = "FLUID_MT_presets"
@@ -334,7 +334,7 @@ class AddPresetFluid(AddPresetBase, Operator):
class AddPresetSunSky(AddPresetBase, Operator):
- """Add a Sky & Atmosphere Preset"""
+ """Add or remove a Sky & Atmosphere Preset"""
bl_idname = "lamp.sunsky_preset_add"
bl_label = "Add Sunsky Preset"
preset_menu = "LAMP_MT_sunsky_presets"
@@ -363,7 +363,7 @@ class AddPresetSunSky(AddPresetBase, Operator):
class AddPresetInteraction(AddPresetBase, Operator):
- """Add an Application Interaction Preset"""
+ """Add or remove an Application Interaction Preset"""
bl_idname = "wm.interaction_preset_add"
bl_label = "Add Interaction Preset"
preset_menu = "USERPREF_MT_interaction_presets"
@@ -389,7 +389,7 @@ class AddPresetInteraction(AddPresetBase, Operator):
class AddPresetTrackingCamera(AddPresetBase, Operator):
- """Add a Tracking Camera Intrinsics Preset"""
+ """Add or remove a Tracking Camera Intrinsics Preset"""
bl_idname = "clip.camera_preset_add"
bl_label = "Add Camera Preset"
preset_menu = "CLIP_MT_camera_presets"
@@ -412,7 +412,7 @@ class AddPresetTrackingCamera(AddPresetBase, Operator):
class AddPresetTrackingTrackColor(AddPresetBase, Operator):
- """Add a Clip Track Color Preset"""
+ """Add or remove a Clip Track Color Preset"""
bl_idname = "clip.track_color_preset_add"
bl_label = "Add Track Color Preset"
preset_menu = "CLIP_MT_track_color_presets"
@@ -430,7 +430,7 @@ class AddPresetTrackingTrackColor(AddPresetBase, Operator):
class AddPresetTrackingSettings(AddPresetBase, Operator):
- """Add a motion tracking settings preset"""
+ """Add or remove a motion tracking settings preset"""
bl_idname = "clip.tracking_settings_preset_add"
bl_label = "Add Tracking Settings Preset"
preset_menu = "CLIP_MT_tracking_settings_presets"
@@ -459,7 +459,7 @@ class AddPresetTrackingSettings(AddPresetBase, Operator):
class AddPresetNodeColor(AddPresetBase, Operator):
- """Add a Node Color Preset"""
+ """Add or remove a Node Color Preset"""
bl_idname = "node.node_color_preset_add"
bl_label = "Add Node Color Preset"
preset_menu = "NODE_MT_node_color_presets"
@@ -477,7 +477,7 @@ class AddPresetNodeColor(AddPresetBase, Operator):
class AddPresetInterfaceTheme(AddPresetBase, Operator):
- """Add a theme preset"""
+ """Add or remove a theme preset"""
bl_idname = "wm.interface_theme_preset_add"
bl_label = "Add Theme Preset"
preset_menu = "USERPREF_MT_interface_theme_presets"
@@ -485,7 +485,7 @@ class AddPresetInterfaceTheme(AddPresetBase, Operator):
class AddPresetKeyconfig(AddPresetBase, Operator):
- """Add a Key-config Preset"""
+ """Add or remove a Key-config Preset"""
bl_idname = "wm.keyconfig_preset_add"
bl_label = "Add Keyconfig Preset"
preset_menu = "USERPREF_MT_keyconfigs"
@@ -508,7 +508,7 @@ class AddPresetKeyconfig(AddPresetBase, Operator):
class AddPresetOperator(AddPresetBase, Operator):
- """Add an Operator Preset"""
+ """Add or remove an Operator Preset"""
bl_idname = "wm.operator_preset_add"
bl_label = "Operator Preset"
preset_menu = "WM_MT_operator_presets"
diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
index 6d1f35fe937..04c28500089 100644
--- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
+++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py
@@ -115,11 +115,17 @@ class PlayRenderedAnim(Operator):
cmd = [player_path]
# extra options, fps controls etc.
+ if scene.use_preview_range:
+ frame_start = scene.frame_preview_start
+ frame_end = scene.frame_preview_end
+ else:
+ frame_start = scene.frame_start
+ frame_end = scene.frame_end
if preset in {'BLENDER24', 'INTERNAL'}:
opts = ["-a",
"-f", str(rd.fps), str(rd.fps_base),
- "-s", str(scene.frame_start),
- "-e", str(scene.frame_end),
+ "-s", str(frame_start),
+ "-e", str(frame_end),
"-j", str(scene.frame_step),
file]
cmd.extend(opts)
diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py
index e0b5526e220..2ec095d2e7b 100644
--- a/release/scripts/startup/bl_operators/view3d.py
+++ b/release/scripts/startup/bl_operators/view3d.py
@@ -29,6 +29,11 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
bl_label = "Extrude Individual and Move"
bl_idname = "view3d.edit_mesh_extrude_individual_move"
+ @classmethod
+ def poll(cls, context):
+ obj = context.active_object
+ return obj.mode == 'EDIT'
+
def execute(self, context):
mesh = context.object.data
select_mode = context.tool_settings.mesh_select_mode
@@ -62,7 +67,13 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
bl_label = "Extrude and Move on Normals"
bl_idname = "view3d.edit_mesh_extrude_move_normal"
- def execute(self, context):
+ @classmethod
+ def poll(cls, context):
+ obj = context.active_object
+ return obj.mode == 'EDIT'
+
+ @staticmethod
+ def extrude_region(context, use_vert_normals):
mesh = context.object.data
totface = mesh.total_face_sel
@@ -70,10 +81,15 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
#~ totvert = mesh.total_vert_sel
if totface >= 1:
- bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
- TRANSFORM_OT_translate={
- "constraint_orientation": 'NORMAL',
- "constraint_axis": (False, False, True)})
+ if use_vert_normals:
+ bpy.ops.mesh.extrude_region_shrink_fatten('INVOKE_REGION_WIN',
+ TRANSFORM_OT_shrink_fatten={})
+ else:
+ bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
+ TRANSFORM_OT_translate={
+ "constraint_orientation": 'NORMAL',
+ "constraint_axis": (False, False, True)})
+
elif totedge == 1:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
@@ -88,6 +104,26 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
# and cause this one not to be freed. [#24671]
return {'FINISHED'}
+ def execute(self, context):
+ return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, False)
+
+ def invoke(self, context, event):
+ return self.execute(context)
+
+
+class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
+ "Extrude and move along individual normals"
+ bl_label = "Extrude and Move on Individual Normals"
+ bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten"
+
+ @classmethod
+ def poll(cls, context):
+ obj = context.active_object
+ return obj.mode == 'EDIT'
+
+ def execute(self, context):
+ return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True)
+
def invoke(self, context, event):
return self.execute(context)
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 5a249159d86..4b954e81ee1 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1298,10 +1298,10 @@ class WM_OT_blenderplayer_start(Operator):
# handle some UI options as command line arguments
args.extend([
- "-g", "show_framerate=%d" % gs.show_framerate_profile,
- "-g", "show_profile=%d" % gs.show_framerate_profile,
- "-g", "show_properties=%d" % gs.show_debug_properties,
- "-g", "ignore_deprecation_warnings=%d" % (not gs.use_deprecation_warnings),
+ "-g", "show_framerate", "=", "%d" % gs.show_framerate_profile,
+ "-g", "show_profile", "=", "%d" % gs.show_framerate_profile,
+ "-g", "show_properties", "=", "%d" % gs.show_debug_properties,
+ "-g", "ignore_deprecation_warnings", "=", "%d" % (not gs.use_deprecation_warnings),
])
# finish the call with the path to the blend file
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index e01764a5496..a274453a472 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -121,9 +121,9 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
row = layout.row()
- rows = 2
+ rows = 1
if group:
- rows = 5
+ rows = 4
row.template_list("UI_UL_list", "bone_groups", pose, "bone_groups", pose.bone_groups, "active_index", rows=rows)
col = row.column(align=True)
@@ -184,7 +184,7 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
# list of poses in pose library
row = layout.row()
row.template_list("UI_UL_list", "pose_markers", poselib, "pose_markers",
- poselib.pose_markers, "active_index", rows=5)
+ poselib.pose_markers, "active_index", rows=3)
# column of operators for active pose
# - goes beside list
diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index 117a662cd07..2171ce67fd3 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -307,6 +307,10 @@ class DATA_PT_font(CurveButtonsPanel, Panel):
#layout.prop(text, "font")
+ row = layout.split(percentage=0.25)
+ row.label(text="Body Text:")
+ row.prop(text, "body", text="")
+
split = layout.split()
col = split.column()
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index a703222ecd0..f59d479c509 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -191,9 +191,9 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
ob = context.object
group = ob.vertex_groups.active
- rows = 2
+ rows = 1
if group:
- rows = 5
+ rows = 4
row = layout.row()
row.template_list("MESH_UL_vgroups", "", ob, "vertex_groups", ob.vertex_groups, "active_index", rows=rows)
@@ -250,9 +250,9 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
row = layout.row()
- rows = 2
+ rows = 1
if kb:
- rows = 5
+ rows = 4
row.template_list("MESH_UL_shape_keys", "", key, "key_blocks", ob, "active_shape_key_index", rows=rows)
col = row.column()
@@ -329,17 +329,17 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
layout = self.layout
me = context.mesh
+ lay = me.uv_textures.active
row = layout.row()
col = row.column()
- col.template_list("MESH_UL_uvmaps_vcols", "uvmaps", me, "uv_textures", me.uv_textures, "active_index", rows=2)
+ col.template_list("MESH_UL_uvmaps_vcols", "uvmaps", me, "uv_textures", me.uv_textures, "active_index", rows=1)
col = row.column(align=True)
col.operator("mesh.uv_texture_add", icon='ZOOMIN', text="")
col.operator("mesh.uv_texture_remove", icon='ZOOMOUT', text="")
- lay = me.uv_textures.active
if lay:
layout.prop(lay, "name")
@@ -352,17 +352,17 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
layout = self.layout
me = context.mesh
+ lay = me.vertex_colors.active
row = layout.row()
col = row.column()
- col.template_list("MESH_UL_uvmaps_vcols", "vcols", me, "vertex_colors", me.vertex_colors, "active_index", rows=2)
+ col.template_list("MESH_UL_uvmaps_vcols", "vcols", me, "vertex_colors", me.vertex_colors, "active_index", rows=1)
col = row.column(align=True)
col.operator("mesh.vertex_color_add", icon='ZOOMIN', text="")
col.operator("mesh.vertex_color_remove", icon='ZOOMOUT', text="")
- lay = me.vertex_colors.active
if lay:
layout.prop(lay, "name")
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 9bfc14f1f28..288330084b9 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1099,7 +1099,14 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "use_z_symmetry")
def TRIANGULATE(self, layout, ob, md):
- layout.prop(md, "use_beauty")
+ row = layout.row()
+
+ col = row.column()
+ col.label(text="Quad Method:")
+ col.prop(md, "quad_method", text="")
+ col = row.column()
+ col.label(text="Ngon Method:")
+ col.prop(md, "ngon_method", text="")
def UV_WARP(self, layout, ob, md):
split = layout.split()
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index a96441a26e5..a57567ae79e 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -193,7 +193,7 @@ class RENDERLAYER_PT_freestyle_lineset(RenderLayerFreestyleEditorButtonsPanel, P
layout.active = rl.use_freestyle
row = layout.row()
- rows = 5 if lineset else 2
+ rows = 4 if lineset else 1
row.template_list("RENDERLAYER_UL_linesets", "", freestyle, "linesets", freestyle.linesets, "active_index", rows=rows)
sub = row.column(align=True)
diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py
index 45f3471ad35..203e5078ee4 100644
--- a/release/scripts/startup/bl_ui/properties_mask_common.py
+++ b/release/scripts/startup/bl_ui/properties_mask_common.py
@@ -82,7 +82,7 @@ class MASK_PT_layers:
mask = sc.mask
active_layer = mask.layers.active
- rows = 5 if active_layer else 2
+ rows = 4 if active_layer else 1
row = layout.row()
row.template_list("MASK_UL_layers", "", mask, "layers",
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index bb0b137da0a..344074c5893 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -124,7 +124,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
if ob:
row = layout.row()
- row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=2)
+ row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1)
col = row.column(align=True)
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 6b317c49487..cbebdafbf2e 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -236,7 +236,7 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
col = split.column()
if obj_type not in {'CAMERA', 'EMPTY'}:
- col.label(text="Maximum draw type:")
+ col.label(text="Maximum Draw Type:")
col.prop(obj, "draw_type", text="")
col = split.column()
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 0d526514b5c..f8a37e2768f 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -98,7 +98,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
row = layout.row()
row.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
- ob.particle_systems, "active_index", rows=2)
+ ob.particle_systems, "active_index", rows=1)
col = row.column(align=True)
col.operator("object.particle_system_add", icon='ZOOMIN', text="")
@@ -211,12 +211,12 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
row.active = part.distribution != 'GRID'
row.prop(part, "count")
- if part.type == 'HAIR' and not part.use_advanced_hair:
+ if part.type == 'HAIR':
row.prop(part, "hair_length")
-
- row = layout.row()
- row.prop(part, "use_modifier_stack")
- return
+ if not part.use_advanced_hair:
+ row = layout.row()
+ row.prop(part, "use_modifier_stack")
+ return
if part.type != 'HAIR':
split = layout.split()
@@ -642,7 +642,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
layout.label(text="Fluid interaction:")
row = layout.row()
- row.template_list("UI_UL_list", "particle_targets", psys, "targets", psys, "active_particle_target_index")
+ row.template_list("UI_UL_list", "particle_targets", psys, "targets", psys, "active_particle_target_index", rows=4)
col = row.column()
sub = col.row()
@@ -730,7 +730,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
row.label(text="")
row = layout.row()
- row.template_list("UI_UL_list", "particle_boids_rules", state, "rules", state, "active_boid_rule_index")
+ row.template_list("UI_UL_list", "particle_boids_rules", state, "rules", state, "active_boid_rule_index", rows=4)
col = row.column()
sub = col.row()
@@ -1214,28 +1214,34 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
ob = context.object
psys = context.particle_system
- split = layout.split(percentage=0.85)
+ col = layout.column()
+ row = col.row(align=True)
+ row.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density")
+ row.prop(psys, "invert_vertex_group_density", text="", toggle=True, icon='ARROW_LEFTRIGHT')
- col = split.column()
- col.label(text="Vertex Group:")
- col.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density")
- col.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length")
- col.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump")
- col.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink")
- col.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1")
- col.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2")
- col.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End")
+ row = col.row(align=True)
+ row.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length")
+ row.prop(psys, "invert_vertex_group_length", text="", toggle=True, icon='ARROW_LEFTRIGHT')
- col = split.column()
- col.label(text="Negate:")
- col.alignment = 'RIGHT'
- col.prop(psys, "invert_vertex_group_density", text="")
- col.prop(psys, "invert_vertex_group_length", text="")
- col.prop(psys, "invert_vertex_group_clump", text="")
- col.prop(psys, "invert_vertex_group_kink", text="")
- col.prop(psys, "invert_vertex_group_roughness_1", text="")
- col.prop(psys, "invert_vertex_group_roughness_2", text="")
- col.prop(psys, "invert_vertex_group_roughness_end", text="")
+ row = col.row(align=True)
+ row.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump")
+ row.prop(psys, "invert_vertex_group_clump", text="", toggle=True, icon='ARROW_LEFTRIGHT')
+
+ row = col.row(align=True)
+ row.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink")
+ row.prop(psys, "invert_vertex_group_kink", text="", toggle=True, icon='ARROW_LEFTRIGHT')
+
+ row = col.row(align=True)
+ row.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1")
+ row.prop(psys, "invert_vertex_group_roughness_1", text="", toggle=True, icon='ARROW_LEFTRIGHT')
+
+ row = col.row(align=True)
+ row.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2")
+ row.prop(psys, "invert_vertex_group_roughness_2", text="", toggle=True, icon='ARROW_LEFTRIGHT')
+
+ row = col.row(align=True)
+ row.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End")
+ row.prop(psys, "invert_vertex_group_roughness_end", text="", toggle=True, icon='ARROW_LEFTRIGHT')
# Commented out vertex groups don't work and are still waiting for better implementation
# row = layout.row()
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index 22c71c233c2..4b4c331d2d8 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -107,7 +107,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
if not cachetype == 'RIGID_BODY':
row = layout.row()
row.template_list("UI_UL_list", "point_caches", cache, "point_caches",
- cache.point_caches, "active_index", rows=2)
+ cache.point_caches, "active_index", rows=1)
col = row.column(align=True)
col.operator("ptcache.add", icon='ZOOMIN', text="")
col.operator("ptcache.remove", icon='ZOOMOUT', text="")
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 75c4caa57bd..f0c7a532414 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -80,7 +80,7 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
row = layout.row()
row.template_list("PHYSICS_UL_dynapaint_surfaces", "", canvas, "canvas_surfaces",
- canvas.canvas_surfaces, "active_index", rows=2)
+ canvas.canvas_surfaces, "active_index", rows=1)
col = row.column(align=True)
col.operator("dpaint.surface_slot_add", icon='ZOOMIN', text="")
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 288f95ca4b0..5e54287ac33 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -67,9 +67,11 @@ class RENDER_PT_render(RenderButtonsPanel, Panel):
row = layout.row(align=True)
row.operator("render.render", text="Render", icon='RENDER_STILL')
row.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
- row.operator("render.play_rendered_anim", text="Play", icon='PLAY')
+ row.operator("sound.mixdown", text="Audio", icon='PLAY_AUDIO')
- layout.prop(rd, "display_mode", text="Display")
+ split = layout.split(1 / 3)
+ split.operator("render.play_rendered_anim", text="Play", icon='PLAY')
+ split.prop(rd, "display_mode", text="Display")
class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
@@ -317,13 +319,6 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
sub.row().prop(rd, "field_order", expand=True)
sub.prop(rd, "use_fields_still", text="Still")
- col = split.column()
- col.prop(rd, "use_edge_enhance")
- sub = col.column()
- sub.active = rd.use_edge_enhance
- sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
- sub.prop(rd, "edge_color", text="")
-
class RENDER_PT_stamp(RenderButtonsPanel, Panel):
bl_label = "Stamp"
@@ -395,10 +390,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
layout.template_image_settings(image_settings, color_management=False)
- if file_format == 'QUICKTIME_CARBON':
- layout.operator("scene.render_data_set_quicktime_codec")
-
- elif file_format == 'QUICKTIME_QTKIT':
+ if file_format == 'QUICKTIME':
quicktime = rd.quicktime
split = layout.split()
diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py b/release/scripts/startup/bl_ui/properties_render_layer.py
index 2514cca8c0f..dcc4508f086 100644
--- a/release/scripts/startup/bl_ui/properties_render_layer.py
+++ b/release/scripts/startup/bl_ui/properties_render_layer.py
@@ -57,7 +57,8 @@ class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel):
rd = scene.render
row = layout.row()
- row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2)
+ col = row.column()
+ col.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=1)
col = row.column(align=True)
col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
@@ -112,7 +113,6 @@ class RENDERLAYER_PT_layer_options(RenderLayerButtonsPanel, Panel):
col = split.column()
col.prop(rl, "use_sky")
- col.prop(rl, "use_edge_enhance")
col.prop(rl, "use_strand")
if bpy.app.build_options.freestyle:
row = col.row()
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index a04283de8bf..91a5abd0ad0 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -94,7 +94,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
row = layout.row()
col = row.column()
- col.template_list("UI_UL_list", "keying_sets", scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
+ col.template_list("UI_UL_list", "keying_sets", scene, "keying_sets", scene.keying_sets, "active_index", rows=1)
col = row.column(align=True)
col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
@@ -138,7 +138,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
row = layout.row()
col = row.column()
- col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=2)
+ col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=1)
col = row.column(align=True)
col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
@@ -227,8 +227,6 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel):
col.prop(ffmpeg, "audio_channels", text="")
col.prop(ffmpeg, "audio_mixrate", text="Rate")
- layout.operator("sound.mixdown")
-
class SCENE_PT_physics(SceneButtonsPanel, Panel):
bl_label = "Gravity"
diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py
index 0b8d8a45a08..0b6ce41eb5d 100644
--- a/release/scripts/startup/bl_ui/properties_world.py
+++ b/release/scripts/startup/bl_ui/properties_world.py
@@ -244,34 +244,6 @@ class WORLD_PT_mist(WorldButtonsPanel, Panel):
layout.prop(world.mist_settings, "falloff")
-class WORLD_PT_stars(WorldButtonsPanel, Panel):
- bl_label = "Stars"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw_header(self, context):
- world = context.world
-
- self.layout.prop(world.star_settings, "use_stars", text="")
-
- def draw(self, context):
- layout = self.layout
-
- world = context.world
-
- layout.active = world.star_settings.use_stars
-
- split = layout.split()
-
- col = split.column()
- col.prop(world.star_settings, "size")
- col.prop(world.star_settings, "color_random", text="Colors")
-
- col = split.column()
- col.prop(world.star_settings, "distance_min", text="Min. Dist")
- col.prop(world.star_settings, "average_separation", text="Separation")
-
-
class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "world"
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 540b707cf93..3db8697a457 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -352,14 +352,6 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
col.label(text="Refine:")
col.prop(settings, "refine_intrinsics", text="")
- col = layout.column(align=True)
- col.active = not settings.use_tripod_solver
- col.prop(settings, "use_fallback_reconstruction",
- text="Allow Fallback")
- sub = col.column(align=True)
- sub.active = settings.use_fallback_reconstruction
- sub.prop(settings, "reconstruction_success_threshold")
-
class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel):
bl_space_type = 'CLIP_EDITOR'
@@ -507,7 +499,7 @@ class CLIP_PT_objects(CLIP_PT_clip_view_panel, Panel):
row = layout.row()
row.template_list("CLIP_UL_tracking_objects", "", tracking, "objects",
- tracking, "active_object_index", rows=3)
+ tracking, "active_object_index", rows=1)
sub = row.column(align=True)
@@ -577,6 +569,8 @@ class CLIP_PT_track(CLIP_PT_tracking_panel, Panel):
if act_track.use_custom_color:
row.prop(act_track, "color", text="")
+ layout.prop(act_track, "weight")
+
if act_track.has_bundle:
label_text = "Average Error: %.4f" % (act_track.average_error)
layout.label(text=label_text)
@@ -783,7 +777,7 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
row = layout.row()
row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks",
- stab, "active_track_index", rows=3)
+ stab, "active_track_index", rows=2)
sub = row.column(align=True)
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index 2d0b1c93d13..61e2f10a057 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -46,6 +46,11 @@ class GRAPH_HT_header(Header):
dopesheet_filter(layout, context)
+ layout.prop(st, "use_normalization", text="Normalize")
+ row = layout.row()
+ row.active = st.use_normalization
+ row.prop(st, "use_auto_normalization", text="Auto")
+
layout.prop(st, "auto_snap", text="")
layout.prop(st, "pivot_point", text="", icon_only=True)
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 17ed7b44cf1..397b74116c2 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -106,7 +106,6 @@ class IMAGE_MT_select(Menu):
layout.operator("uv.select_all").action = 'TOGGLE'
layout.operator("uv.select_all", text="Inverse").action = 'INVERT'
- layout.operator("uv.select_split")
layout.separator()
@@ -728,7 +727,7 @@ class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel):
tex_slot_mask = brush.mask_texture_slot
col = layout.column()
-
+
col.label(text="Curve:")
row = col.row(align=True)
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index 5a570d18312..a7a648e3c44 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -37,7 +37,6 @@ class INFO_HT_header(Header):
if context.area.show_menus:
sub = row.row(align=True)
sub.menu("INFO_MT_file")
- sub.menu("INFO_MT_add")
if rd.use_game_engine:
sub.menu("INFO_MT_game")
else:
@@ -79,35 +78,6 @@ class INFO_HT_header(Header):
row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
row.label(text=scene.statistics(), translate=False)
- # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!!
- """
- sinfo = context.space_data
- row = layout.row(align=True)
- row.prop(sinfo, "show_report_debug", text="Debug")
- row.prop(sinfo, "show_report_info", text="Info")
- row.prop(sinfo, "show_report_operator", text="Operators")
- row.prop(sinfo, "show_report_warning", text="Warnings")
- row.prop(sinfo, "show_report_error", text="Errors")
-
- row = layout.row()
- row.enabled = sinfo.show_report_operator
- row.operator("info.report_replay")
-
- row.menu("INFO_MT_report")
- """
-
-
-class INFO_MT_report(Menu):
- bl_label = "Report"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("console.select_all_toggle")
- layout.operator("console.select_border")
- layout.operator("console.report_delete")
- layout.operator("console.report_copy")
-
class INFO_MT_file(Menu):
bl_label = "File"
@@ -199,132 +169,6 @@ class INFO_MT_file_external_data(Menu):
layout.operator("file.find_missing_files")
-class INFO_MT_mesh_add(Menu):
- bl_idname = "INFO_MT_mesh_add"
- bl_label = "Mesh"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
- layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
- layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
- layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
- layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
- layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder")
- layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
- layout.separator()
- layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
- layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
- layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus")
-
-
-class INFO_MT_curve_add(Menu):
- bl_idname = "INFO_MT_curve_add"
- bl_label = "Curve"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
- layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
- layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
- layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
- layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
-
-
-class INFO_MT_surface_add(Menu):
- bl_idname = "INFO_MT_surface_add"
- bl_label = "Surface"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
- layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
- layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
- layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
- layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
- layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
-
-
-class INFO_MT_edit_curve_add(Menu):
- bl_idname = "INFO_MT_edit_curve_add"
- bl_label = "Add"
-
- def draw(self, context):
- is_surf = context.active_object.type == 'SURFACE'
-
- layout = self.layout
- layout.operator_context = 'EXEC_REGION_WIN'
-
- if is_surf:
- INFO_MT_surface_add.draw(self, context)
- else:
- INFO_MT_curve_add.draw(self, context)
-
-
-class INFO_MT_armature_add(Menu):
- bl_idname = "INFO_MT_armature_add"
- bl_label = "Armature"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator_context = 'EXEC_REGION_WIN'
- layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
-
-
-class INFO_MT_add(Menu):
- bl_label = "Add"
-
- def draw(self, context):
- layout = self.layout
-
- # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context.
-
- # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
- # "align_view" to work on first call (see [#32719]).
- layout.operator_context = 'EXEC_REGION_WIN'
-
- #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
- layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
-
- #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
- layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
- #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
- layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
- layout.operator_context = 'EXEC_REGION_WIN'
- layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
- layout.separator()
-
- layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
- layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
- layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
- layout.separator()
-
- layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
- layout.separator()
-
- layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
- layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
- layout.separator()
-
- layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
- layout.separator()
-
- if len(bpy.data.groups) > 10:
- layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
- else:
- layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
-
-
class INFO_MT_game(Menu):
bl_label = "Game"
@@ -394,22 +238,21 @@ class INFO_MT_help(Menu):
layout = self.layout
layout.operator("wm.url_open", text="Manual", icon='HELP').url = "http://wiki.blender.org/index.php/Doc:2.6/Manual"
- layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://www.blender.org/development/release-logs/blender-269"
+ layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70"
layout.separator()
layout.operator("wm.url_open", text="Blender Website", icon='URL').url = "http://www.blender.org"
layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = "http://www.blender.org/e-shop"
- layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/community/get-involved"
+ layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/get-involved/"
layout.operator("wm.url_open", text="User Community", icon='URL').url = "http://www.blender.org/community/user-community"
layout.separator()
- layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse"
+ layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://developer.blender.org/maniphest/task/create/?project=2&type=Bug"
layout.separator()
layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = bpy.types.WM_OT_doc_view._prefix
layout.operator("wm.operator_cheat_sheet", icon='TEXT')
layout.operator("wm.sysinfo", icon='TEXT')
layout.separator()
- layout.operator("anim.update_data_paths", text="FCurve/Driver Version fix", icon='HELP')
layout.operator("logic.texface_convert", text="TexFace to Material Convert", icon='GAME')
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 1721eacd8ac..46234b638eb 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -105,7 +105,7 @@ class NODE_HT_header(Header):
row = layout.row(align=True)
row.prop(toolsettings, "use_snap", text="")
row.prop(toolsettings, "snap_node_element", text="", icon_only=True)
- if toolsettings.snap_node_element != 'INCREMENT':
+ if toolsettings.snap_node_element != 'GRID':
row.prop(toolsettings, "snap_target", text="")
row = layout.row(align=True)
@@ -169,6 +169,7 @@ class NODE_MT_select(Menu):
layout = self.layout
layout.operator("node.select_border")
+ layout.operator("node.select_circle")
layout.separator()
layout.operator("node.select_all").action = 'TOGGLE'
@@ -233,7 +234,6 @@ class NODE_MT_node(Menu):
layout.separator()
- layout.operator("node.show_cyclic_dependencies")
layout.operator("node.read_renderlayers")
layout.operator("node.read_fullsamplelayers")
@@ -364,7 +364,7 @@ class NODE_PT_backdrop(Panel):
col.prop(snode, "backdrop_x", text="X")
col.prop(snode, "backdrop_y", text="Y")
col.operator("node.backimage_move", text="Move")
-
+
layout.operator("node.backimage_fit", text="Fit")
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index ea88d35b4e9..6f28bcb2225 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -416,6 +416,10 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel):
sub.prop(strip, "blend_alpha", text="Opacity", slider=True)
row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_ON' if strip.mute else 'RESTRICT_VIEW_OFF', text="")
row.prop(strip, "lock", toggle=True, icon='LOCKED' if strip.lock else 'UNLOCKED', text="")
+ else:
+ row = layout.row(align=True)
+ row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_ON' if strip.mute else 'RESTRICT_VIEW_OFF')
+ row.prop(strip, "lock", toggle=True, icon='LOCKED' if strip.lock else 'UNLOCKED')
col = layout.column()
sub = col.column()
diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py
index 41ded2fe768..32cb1009492 100644
--- a/release/scripts/startup/bl_ui/space_text.py
+++ b/release/scripts/startup/bl_ui/space_text.py
@@ -49,7 +49,7 @@ class TEXT_HT_header(Header):
sub.alert = True
sub.operator("text.resolve_conflict", text="", icon='HELP')
- row.template_ID(st, "text", new="text.new", unlink="text.unlink")
+ row.template_ID(st, "text", new="text.new", unlink="text.unlink", open="text.open")
row = layout.row(align=True)
row.prop(st, "show_line_numbers", text="")
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index de8be9dff99..4cb67181fdb 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -40,7 +40,9 @@ class TIME_HT_header(Header):
row.menu("TIME_MT_frame")
row.menu("TIME_MT_playback")
- layout.prop(scene, "use_preview_range", text="", toggle=True)
+ row = layout.row(align=True)
+ row.prop(scene, "use_preview_range", text="", toggle=True)
+ row.prop(scene, "lock_frame_selection_to_range", text="", toggle=True)
row = layout.row(align=True)
if not scene.use_preview_range:
@@ -227,6 +229,11 @@ def marker_menu_generic(layout):
layout.operator("marker.rename", text="Rename Marker")
layout.operator("marker.move", text="Grab/Move Marker")
+ layout.separator()
+
+ layout.operator("screen.marker_jump", text="Jump to Next Marker").next = True
+ layout.operator("screen.marker_jump", text="Jump to Previous Marker").next = False
+
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 1e9c9e7ff7e..e21656c3259 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -268,12 +268,16 @@ class USERPREF_PT_edit(Panel):
col = row.column()
col.label(text="Grease Pencil:")
+ col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
+ col.separator()
col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
- col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
+ col.separator()
col.prop(edit, "use_grease_pencil_smooth_stroke", text="Smooth Stroke")
col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
col.separator()
+ col.prop(edit, "grease_pencil_default_color", text="Default Color")
+ col.separator()
col.separator()
col.separator()
col.label(text="Playback:")
@@ -1251,15 +1255,15 @@ class USERPREF_PT_addons(Panel):
split.label(text=' ' + info["warning"], icon='ERROR')
user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
- tot_row = bool(info["wiki_url"]) + bool(info["tracker_url"]) + bool(user_addon)
+ tot_row = bool(info["wiki_url"]) + bool(user_addon)
if tot_row:
split = colsub.row().split(percentage=0.15)
split.label(text="Internet:")
if info["wiki_url"]:
split.operator("wm.url_open", text="Documentation", icon='HELP').url = info["wiki_url"]
- if info["tracker_url"]:
- split.operator("wm.url_open", text="Report a Bug", icon='URL').url = info["tracker_url"]
+ tracker_url = "http://developer.blender.org/maniphest/task/create/?project=3&type=Bug"
+ split.operator("wm.url_open", text="Report a Bug", icon='URL').url = tracker_url
if user_addon:
split.operator("wm.addon_remove", text="Remove", icon='CANCEL').module = mod.__name__
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 056859af3b4..81da0c3edde 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -54,6 +54,17 @@ class VIEW3D_HT_header(Header):
elif mode_string not in {'EDIT_TEXT', 'SCULPT'}:
sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
+ if mode_string == 'OBJECT':
+ sub.menu("INFO_MT_add", text="Add")
+ elif mode_string == 'EDIT_MESH':
+ sub.menu("INFO_MT_mesh_add", text="Add")
+ elif mode_string == 'EDIT_CURVE':
+ sub.menu("INFO_MT_curve_add", text="Add")
+ elif mode_string == 'EDIT_SURFACE':
+ sub.menu("INFO_MT_surface_add", text="Add")
+ elif mode_string == 'EDIT_METABALL':
+ sub.menu("INFO_MT_metaball_add", text="Add")
+
if edit_object:
sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
elif obj:
@@ -132,6 +143,7 @@ class VIEW3D_HT_header(Header):
# ********** Menu **********
+
# ********** Utilities **********
@@ -167,8 +179,9 @@ class VIEW3D_MT_transform_base(Menu):
layout.operator("transform.tosphere", text="To Sphere")
layout.operator("transform.shear", text="Shear")
- layout.operator("transform.warp", text="Warp")
+ layout.operator("transform.bend", text="Bend")
layout.operator("transform.push_pull", text="Push/Pull")
+ layout.operator("object.vertex_warp", text="Warp")
# Generic transform menu - geometry types
@@ -528,7 +541,7 @@ class VIEW3D_MT_select_pose(Menu):
layout.operator("pose.select_all").action = 'TOGGLE'
layout.operator("pose.select_all", text="Inverse").action = 'INVERT'
- layout.operator("pose.select_flip_active", text="Flip Active")
+ layout.operator("pose.select_mirror", text="Flip Active")
layout.operator("pose.select_constraint_target", text="Constraint Target")
layout.operator("pose.select_linked", text="Linked")
@@ -716,6 +729,10 @@ class VIEW3D_MT_select_edit_metaball(Menu):
layout.operator("mball.select_random_metaelems")
+ layout.separator()
+
+ layout.operator_menu_enum("mball.select_similar", "type", text="Similar")
+
class VIEW3D_MT_select_edit_lattice(Menu):
bl_label = "Select"
@@ -750,6 +767,7 @@ class VIEW3D_MT_select_edit_armature(Menu):
layout.operator("armature.select_all").action = 'TOGGLE'
layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("armature.select_mirror", text="Mirror").extend = False
layout.separator()
@@ -812,6 +830,145 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu):
layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
+# ********** Add menu **********
+
+# XXX: INFO_MT_ names used to keep backwards compatibility (Addons etc that hook into the menu)
+
+
+class INFO_MT_mesh_add(Menu):
+ bl_idname = "INFO_MT_mesh_add"
+ bl_label = "Mesh"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
+ layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
+ layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
+ layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
+ layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
+ layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder")
+ layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
+ layout.separator()
+ layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
+ layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
+ layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus")
+
+
+class INFO_MT_curve_add(Menu):
+ bl_idname = "INFO_MT_curve_add"
+ bl_label = "Curve"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
+ layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
+ layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
+ layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
+ layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
+
+
+class INFO_MT_surface_add(Menu):
+ bl_idname = "INFO_MT_surface_add"
+ bl_label = "Surface"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
+ layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
+ layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
+ layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
+ layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
+ layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
+
+
+class INFO_MT_metaball_add(Menu):
+ bl_idname = "INFO_MT_metaball_add"
+ bl_label = "Metaball"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator_enum("object.metaball_add", "type")
+
+
+class INFO_MT_edit_curve_add(Menu):
+ bl_idname = "INFO_MT_edit_curve_add"
+ bl_label = "Add"
+
+ def draw(self, context):
+ is_surf = context.active_object.type == 'SURFACE'
+
+ layout = self.layout
+ layout.operator_context = 'EXEC_REGION_WIN'
+
+ if is_surf:
+ INFO_MT_surface_add.draw(self, context)
+ else:
+ INFO_MT_curve_add.draw(self, context)
+
+
+class INFO_MT_armature_add(Menu):
+ bl_idname = "INFO_MT_armature_add"
+ bl_label = "Armature"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'EXEC_REGION_WIN'
+ layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
+
+
+class INFO_MT_add(Menu):
+ bl_label = "Add"
+
+ def draw(self, context):
+ layout = self.layout
+
+ # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context.
+
+ # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
+ # "align_view" to work on first call (see [#32719]).
+ layout.operator_context = 'EXEC_REGION_WIN'
+
+ #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
+ layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
+
+ #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
+ layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
+ #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
+ layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
+ layout.menu("INFO_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META')
+ layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
+ layout.separator()
+
+ layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
+ layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
+ layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
+ layout.separator()
+
+ layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
+ layout.separator()
+
+ layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
+ layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
+ layout.separator()
+
+ layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
+ layout.separator()
+
+ if len(bpy.data.groups) > 10:
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
+ else:
+ layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
+
# ********** Object menu **********
@@ -1364,6 +1521,7 @@ class VIEW3D_MT_paint_weight(Menu):
layout.operator("object.vertex_group_mirror", text="Mirror")
layout.operator("object.vertex_group_invert", text="Invert")
layout.operator("object.vertex_group_clean", text="Clean")
+ layout.operator("object.vertex_group_quantize", text="Quantize")
layout.operator("object.vertex_group_levels", text="Levels")
layout.operator("object.vertex_group_blend", text="Blend")
layout.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
@@ -1442,6 +1600,9 @@ class VIEW3D_MT_hide_mask(Menu):
props.mode = 'VALUE'
props.value = 0
+ props = layout.operator("view3d.select_border", text="Box Mask")
+ props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
+
# ********** Particle menu **********
@@ -1909,10 +2070,16 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
bl_label = "Extrude"
_extrude_funcs = {
- 'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
- 'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
- 'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
- 'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
+ 'VERT': lambda layout:
+ layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
+ 'EDGE': lambda layout:
+ layout.operator("mesh.extrude_edges_move", text="Edges Only"),
+ 'FACE': lambda layout:
+ layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
+ 'REGION': lambda layout:
+ layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
+ 'REGION_VERT_NORMAL': lambda layout:
+ layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Region (Vertex Normals)"),
}
@staticmethod
@@ -1922,7 +2089,7 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
menu = []
if mesh.total_face_sel:
- menu += ['REGION', 'FACE']
+ menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE']
if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
menu += ['EDGE']
if mesh.total_vert_sel and select_mode[0]:
@@ -2379,6 +2546,7 @@ class VIEW3D_MT_edit_armature(Menu):
layout.operator("armature.merge")
layout.operator("armature.fill")
layout.operator("armature.delete")
+ layout.operator("armature.split")
layout.operator("armature.separate")
layout.separator()
@@ -2634,10 +2802,14 @@ class VIEW3D_PT_view3d_shading(Panel):
if not scene.render.use_shading_nodes:
col.prop(gs, "material_mode", text="")
col.prop(view, "show_textured_solid")
+
if view.viewport_shade == 'SOLID':
col.prop(view, "use_matcap")
if view.use_matcap:
col.template_icon_view(view, "matcap_icon")
+ elif view.viewport_shade == 'TEXTURED':
+ col.prop(view, "show_textured_shadeless")
+
col.prop(view, "show_backface_culling")
if obj and obj.mode == 'EDIT' and view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}:
col.prop(view, "show_occlude_wire")
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 0bb31f51c1b..cd3c238fe86 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -135,6 +135,7 @@ class VIEW3D_PT_tools_rigidbody(View3DPanel, Panel):
col.operator("rigidbody.shape_change", text="Change Shape")
col.operator("rigidbody.mass_calculate", text="Calculate Mass")
col.operator("rigidbody.object_settings_copy", text="Copy from Active")
+ col.operator("object.visual_transform_apply", text="Apply Transformation")
col.operator("rigidbody.bake_to_keyframes", text="Bake To Keyframes")
col.label(text="Constraints:")
col.operator("rigidbody.connect", text="Connect")
@@ -739,6 +740,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
col.prop(brush, "vertex_tool", text="Blend")
+
class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
bl_label = "Overlay"
bl_options = {'DEFAULT_CLOSED'}
@@ -752,8 +754,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
context.vertex_paint_object or
context.weight_paint_object or
context.image_paint_object))
-
-
+
def draw(self, context):
layout = self.layout
@@ -763,7 +764,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
tex_slot_mask = brush.mask_texture_slot
col = layout.column()
-
+
col.label(text="Curve:")
row = col.row(align=True)
@@ -777,7 +778,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
col.active = brush.brush_capabilities.has_overlay
-
+
if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
col.label(text="Texture:")
row = col.row(align=True)
@@ -1114,6 +1115,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
col.operator("object.vertex_group_mirror", text="Mirror")
col.operator("object.vertex_group_invert", text="Invert")
col.operator("object.vertex_group_clean", text="Clean")
+ col.operator("object.vertex_group_quantize", text="Quantize")
col.operator("object.vertex_group_levels", text="Levels")
col.operator("object.vertex_group_blend", text="Blend")
col.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 71ff547f6da..fdda753372f 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -141,6 +141,8 @@ shader_node_categories = [
NodeItem("ShaderNodeSqueeze"),
NodeItem("ShaderNodeSeparateRGB"),
NodeItem("ShaderNodeCombineRGB"),
+ NodeItem("ShaderNodeSeparateHSV"),
+ NodeItem("ShaderNodeCombineHSV"),
]),
ShaderOldNodeCategory("SH_GROUP", "Group", items=node_group_items),
ShaderOldNodeCategory("SH_LAYOUT", "Layout", items=[
diff --git a/release/scripts/templates_py/addon_add_object.py b/release/scripts/templates_py/addon_add_object.py
index 66da6a969c7..f0d8bede6d5 100644
--- a/release/scripts/templates_py/addon_add_object.py
+++ b/release/scripts/templates_py/addon_add_object.py
@@ -7,7 +7,6 @@ bl_info = {
"description": "Adds a new Mesh Object",
"warning": "",
"wiki_url": "",
- "tracker_url": "",
"category": "Add Mesh"}
diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py
index 975ae1881f2..bf89c0debad 100644
--- a/release/scripts/templates_py/custom_nodes.py
+++ b/release/scripts/templates_py/custom_nodes.py
@@ -109,6 +109,11 @@ class MyCustomNode(Node, MyCustomTreeNode):
# myStringProperty button will only be visible in the sidebar
layout.prop(self, "myStringProperty")
+ # Optional: custom label
+ # Explicit user label overrides this, but here we can define a label dynamically
+ def draw_label(self):
+ return "I am a custom node"
+
### Node Categories ###
# Node categories are a python system for automatically
diff --git a/release/scripts/templates_py/operator_uv.py b/release/scripts/templates_py/operator_mesh_uv.py
index 96e624bc30d..96e624bc30d 100644
--- a/release/scripts/templates_py/operator_uv.py
+++ b/release/scripts/templates_py/operator_mesh_uv.py
diff --git a/release/scripts/templates_py/operator_modal_timer.py b/release/scripts/templates_py/operator_modal_timer.py
index 3088d59fbcf..4d36860b9e3 100644
--- a/release/scripts/templates_py/operator_modal_timer.py
+++ b/release/scripts/templates_py/operator_modal_timer.py
@@ -9,7 +9,7 @@ class ModalTimerOperator(bpy.types.Operator):
_timer = None
def modal(self, context, event):
- if event.type == 'ESC':
+ if event.type in {'RIGHTMOUSE', 'ESC'}:
return self.cancel(context)
if event.type == 'TIMER':
@@ -21,13 +21,14 @@ class ModalTimerOperator(bpy.types.Operator):
return {'PASS_THROUGH'}
def execute(self, context):
- self._timer = context.window_manager.event_timer_add(0.1, context.window)
- context.window_manager.modal_handler_add(self)
+ wm = context.window_manager
+ self._timer = wm.event_timer_add(0.1, context.window)
+ wm.modal_handler_add(self)
return {'RUNNING_MODAL'}
def cancel(self, context):
- context.window_manager.event_timer_remove(self._timer)
- return {'CANCELLED'}
+ wm = context.window_manager
+ wm.event_timer_remove(self._timer)
def register():
diff --git a/release/text/readme.html b/release/text/readme.html
index b15ea9b3847..7d79c8c3bad 100644
--- a/release/text/readme.html
+++ b/release/text/readme.html
@@ -4,64 +4,72 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
+ <meta name="Generator" content="Cocoa HTML Writer">
+ <meta name="CocoaVersion" content="1265">
<style type="text/css">
- p.title {margin-left: 20%; margin-right: 20%; text-align: center; font: 22.0px Helvetica}
- p.footer {margin-left: 20%; margin-right: 20%; text-align: center; font: 14.0px Helvetica; min-height: 14.0px}
- p.header {margin-left: 20%; margin-right: 20%; font: 16.0px Helvetica}
- p.body {margin-left: 20%; margin-right: 20%; font: 14.0px Helvetica}
+ p.p1 {margin: 0.0px 156.0px 22.0px 156.0px; text-align: center; font: 22.0px Helvetica}
+ p.p2 {margin: 0.0px 0.0px 12.0px 0.0px; font: 12.0px Times; min-height: 14.0px}
+ p.p3 {margin: 0.0px 156.0px 16.0px 156.0px; font: 16.0px Helvetica}
+ p.p4 {margin: 0.0px 156.0px 14.0px 156.0px; font: 14.0px Helvetica}
+ p.p5 {margin: 0.0px 156.0px 14.0px 156.0px; font: 14.0px Helvetica; color: #0000ee}
+ p.p6 {margin: 0.0px 156.0px 14.0px 156.0px; text-align: center; font: 14.0px Helvetica}
+ span.s1 {text-decoration: underline ; color: #0000ee}
+ span.s2 {font: 14.0px 'Lucida Grande'}
+ span.s3 {color: #000000}
+ span.s4 {text-decoration: underline}
</style>
</head>
<body>
-<p class="title"><b>Blender 2.69</b></p>
-<p><br></p>
-<p class="header"><b>About</b></p>
-<p class="body">Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X and Windows and has a large world-wide community.</p>
-<p class="body">Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.</p>
-<p class="body">For more information, visit <a href="http://www.blender.org">blender.org</a>.</p>
-<p><br></p>
-<p class="header"><b>2.69</b></p>
-<p class="body">The Blender Foundation and online developer community is proud to present Blender 2.69. This release is the tenth official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features. <a href="http://www.blender.org/development/release-logs/blender-269/">More information about this release</a>.</p>
-<p><br></p>
-<p class="header"><b>Bugs</b></p>
-<p class="body">Although Blender 2.69 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.</p>
-<p><br></p>
-<p class="header"><b>Package Contents</b></p>
-<p class="body">The downloaded Blender package includes:</p>
-<p class="body"> • The Blender application for the chosen operating system.</p>
-<p class="body"> • Scripts for importing and exporting to other 3d formats.</p>
-<p class="body"> • Readme and copyright files.</p>
-<p><br></p>
-<p class="header"><b>Installation</b></p>
-<p class="body"><b>Windows: </b>The download .zip contains a Blender folder. You may put this anywhere on your hard drive. To launch Blender, double-click on Blender.exe.</p>
-<p class="body"><b>Linux: </b>Unpack the archive, then run the Blender executable.</p>
-<p class="body"><b>Mac OS X: </b>The downloaded package includes blender.app. Optionally copy this to your Applications folder, and add it to the dock by dragging it from there to the dock.</p>
-<p></p>
-<p class="body"><b>Installing Addons (all systems)</b> Addons can be installed from the user preferences addons section, download an addon as a .py or .zip file, then press the "Install Addon" button and select the file to install it.</p>
-<p><br></p>
-<p class="header"><b>Getting Started</b></p>
-<p class="body">When opening Blender, you’ll see large 3D view in the center, a Toolbar on the left, a Properties editor and an Outliner on the right and a Timeline at the bottom.</p>
-<p class="body">Orbit around in the 3D view by holding the middle mouse button and dragging. Alternatively, hold the alt key and drag the left mouse button. Additionally, hold Shift to pan the view and Ctrl to zoom.</p>
-<p class="body">Select objects using the right mouse button. With the object selected, perform actions by clicking any of the tool buttons on the left, or make changes to its properties by altering any of the setting on the right.</p>
-<p class="body">For more information on how to use Blender, <a href="http://www.blender.org/education-help/">watch tutorials</a> or <a href="http://wiki.blender.org/index.php/Doc:2.6/Manual">read the manual</a>.</p>
-<p><br></p>
-<p class="header"><b>Links</b></p>
-<p class="body">Users:</p>
-<p class="body"> General information <a href="http://www.blender.org">www.blender.org</a> <br>
- Full release log <a href="http://www.blender.org/development/release-logs/blender-269/">www.blender.org/development/release-logs/blender-269/</a><br>
- Tutorials <a href="http://www.blender.org/education-help/">www.blender.org/education-help/</a> <br>
- Manual <a href="http://wiki.blender.org/index.php/Doc:2.6/Manual">wiki.blender.org/index.php/Doc:2.6/Manual</a><br>
- User Forum <a href="http://www.blenderartists.org">www.blenderartists.org</a><br>
- IRC <a href="irc://irc.freenode.net/#blenderchat">#blenderchat</a> or <a href="irc://irc.freenode.net/#blender">#blender</a> on irc.freenode.net<br>
-</p>
-<p class="body">Developers:</p>
-<p class="body"> Development <a href="http://www.blender.org/development/">www.blender.org/development/</a><br>
- SVN and Bug Tracker <a href="http://projects.blender.org">projects.blender.org</a><br>
- Get Involved <a href="http://www.blender.org/community/get-involved/">www.blender.org/community/get-involved/</a><br>
- IRC <a href="irc://irc.freenode.net/#blendercoders">#blendercoders on irc.freenode.net</a></p>
-<p><br></p>
-<p><br></p><p class="footer">Blender is open-source and free for all to use.</p>
-<p><br></p>
-<p class="footer">Enjoy.</p>
-<p><br></p>
+<p class="p1"><b>Blender 2.70</b></p>
+<p class="p2"><br></p>
+<p class="p3"><b>About</b></p>
+<p class="p4">Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X and Windows and has a large world-wide community.</p>
+<p class="p4">Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.</p>
+<p class="p4">For more information, visit <a href="http://www.blender.org/"><span class="s1">blender.org</span></a>.</p>
+<p class="p2"><br></p>
+<p class="p3"><b>2.70</b></p>
+<p class="p4">The Blender Foundation and online developer community is proud to present Blender 2.70. This release is the first official stable release of the Blender 2.7 series. <a href="http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70"><span class="s1">More information about this release</span></a>.</p>
+<p class="p2"><br></p>
+<p class="p3"><b>Bugs</b></p>
+<p class="p4">Although Blender 2.70 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help <span class="s2">→</span> Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.</p>
+<p class="p2"><br></p>
+<p class="p3"><b>Package Contents</b></p>
+<p class="p4">The downloaded Blender package includes:</p>
+<p class="p4">• The Blender application for the chosen operating system.</p>
+<p class="p4">• Scripts for importing and exporting to other 3d formats.</p>
+<p class="p4">• Readme and copyright files.</p>
+<p class="p2"><br></p>
+<p class="p3"><b>Installation</b></p>
+<p class="p4"><b>Windows: </b>The download .zip contains a Blender folder. You may put this anywhere on your hard drive. To launch Blender, double-click on Blender.exe.</p>
+<p class="p4"><b>Linux: </b>Unpack the archive, then run the Blender executable.</p>
+<p class="p4"><b>Mac OS X: </b>The downloaded package includes blender.app. Optionally copy this to your Applications folder, and add it to the dock by dragging it from there to the dock.</p>
+<p class="p2"><br></p>
+<p class="p4"><b>Installing Addons (all systems)</b> Addons can be installed from the user preferences addons section, download an addon as a .py or .zip file, then press the "Install Addon" button and select the file to install it.</p>
+<p class="p2"><br></p>
+<p class="p3"><b>Getting Started</b></p>
+<p class="p4">When opening Blender, you’ll see large 3D view in the center, a Toolbar on the left, a Properties editor and an Outliner on the right and a Timeline at the bottom.</p>
+<p class="p4">Orbit around in the 3D view by holding the middle mouse button and dragging. Alternatively, hold the alt key and drag the left mouse button. Additionally, hold Shift to pan the view and Ctrl to zoom.</p>
+<p class="p4">Select objects using the right mouse button. With the object selected, perform actions by clicking any of the tool buttons on the left, or make changes to its properties by altering any of the setting on the right.</p>
+<p class="p4">For more information on how to use Blender, <a href="http://www.blender.org/support/"><span class="s1">check out the support page</span></a>.</p>
+<p class="p2"><br></p>
+<p class="p3"><b>Links</b></p>
+<p class="p4">Users:</p>
+<p class="p5"><span class="s3">General information <a href="http://www.blender.org/"><span class="s4">www.blender.org</span></a> <br>
+Full release log <a href="http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70"><span class="s4">wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70</span></a><br>
+Tutorials <a href="http://www.blender.org/support/tutorials/"><span class="s4">www.blender.org/support/tutorials/</span></a> <br>
+Manual <a href="http://wiki.blender.org/index.php/Doc:2.6/Manual"><span class="s4">wiki.blender.org/index.php/Doc:2.6/Manual</span></a><br>
+User Forum <a href="http://www.blenderartists.org/"><span class="s4">www.blenderartists.org</span></a><br>
+IRC <a href="irc://irc.freenode.net/#blenderchat"><span class="s4">#blenderchat</span></a> or <a href="irc://irc.freenode.net/#blender"><span class="s4">#blender</span></a> on irc.freenode.net</span></p>
+<p class="p4">Developers:</p>
+<p class="p5"><span class="s3">Development <a href="http://www.blender.org/get-involved/developers/"><span class="s4">www.blender.org/get-involved/developers/</span></a><br>
+GIT and Bug Tracker <a href="http://developer.blender.org/"><span class="s4">developer.blender.org/</span></a><br>
+Get Involved <a href="http://www.blender.org/get-involved/"><span class="s4">www.blender.org/get-involved/</span></a><br>
+IRC <a href="irc://irc.freenode.net/#blendercoders"><span class="s4">#blendercoders on irc.freenode.net</span></a></span></p>
+<p class="p2"><br></p>
+<p class="p2"><br></p>
+<p class="p6">Blender is open-source and free for all to use.</p>
+<p class="p2"><br></p>
+<p class="p6">Enjoy.</p>
+<p class="p2"><br></p>
</body>
</html>
diff --git a/scons b/scons
new file mode 160000
+Subproject 2d6ebcb23909058b846aa232ecb2fee497924cf
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index d46df829295..998b415a6af 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -210,6 +210,7 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len)
blf_font_ensure_ascii_table(font);
while ((c = *(str++)) && len--) {
+ BLI_assert(c < 128);
if ((g = glyph_ascii_table[c]) == NULL)
continue;
if (has_kerning)
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 698098d28c3..3ac5c8c9a76 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -132,61 +132,21 @@ struct bActionGroup *BKE_action_group_find_name(struct bAction *act, const char
void action_groups_clear_tempflags(struct bAction *act);
/* Pose API ----------------- */
-
-/**
- * Deallocates a pose channel.
- * Does not free the pose channel itself.
- */
-void BKE_pose_channel_free(struct bPoseChannel *pchan);
-
-/**
- * Removes and deallocates all channels from a pose.
- * Does not free the pose itself.
- */
-void BKE_pose_channels_free(struct bPose *pose);
-/**
- * Removes the hash for quick lookup of channels, must
- * be done when adding/removing channels.
- */
-void BKE_pose_channels_hash_make(struct bPose *pose);
-void BKE_pose_channels_hash_free(struct bPose *pose);
-
-/**
- * Removes and deallocates all data from a pose, and also frees the pose.
- */
-void BKE_pose_free(struct bPose *pose);
+void BKE_pose_channel_free(struct bPoseChannel *pchan);
-/**
- * Allocate a new pose on the heap, and copy the src pose and it's channels
- * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL.
- */
-void BKE_pose_copy_data(struct bPose **dst, struct bPose *src, int copyconstraints);
+void BKE_pose_channels_free(struct bPose *pose);
-/**
- * Copy the internal members of each pose channel including constraints
- * and ID-Props, used when duplicating bones in editmode.
- */
-void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
+void BKE_pose_channels_hash_make(struct bPose *pose);
+void BKE_pose_channels_hash_free(struct bPose *pose);
-/**
- * Return a pointer to the pose channel of the given name
- * from this pose.
- */
+void BKE_pose_free(struct bPose *pose);
+void BKE_pose_copy_data(struct bPose **dst, struct bPose *src, const bool copy_constraints);
+void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name);
-
-/**
- * Return a pointer to the active pose channel from this Object.
- * (Note: Object, not bPose is used here, as we need layer info from Armature)
- */
struct bPoseChannel *BKE_pose_channel_active(struct Object *ob);
-
-/**
- * Looks to see if the channel with the given name
- * already exists in this pose - if not a new one is
- * allocated and initialized.
- */
struct bPoseChannel *BKE_pose_channel_verify(struct bPose *pose, const char *name);
+struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose, const char *name);
#ifndef NDEBUG
bool BKE_pose_channels_is_valid(const struct bPose *pose);
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index f0f6b5a2319..a0ec6c7757f 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -104,6 +104,10 @@ void BKE_keyingsets_free(struct ListBase *list);
/* ************************************* */
/* Path Fixing API */
+/* Fix all the paths for the the given ID + Action */
+void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, const char *prefix, const char *oldName,
+ const char *newName, int oldSubscript, int newSubscript, int verify_paths);
+
/* Fix all the paths for the given ID+AnimData */
void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, struct ID *ref_id, const char *prefix,
const char *oldName, const char *newName, int oldSubscript, int newSubscript,
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 5b32e7229d5..f2d9c0efc13 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 269
-#define BLENDER_SUBVERSION 1
+#define BLENDER_SUBVERSION 2
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index 8d4c9e782db..9e1bca45432 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -116,6 +116,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
#define BVHTREE_FROM_VERTICES 1
#define BVHTREE_FROM_EDGES 2
+#define BVHTREE_FROM_FACES_EDITMESH 3
+
typedef struct LinkNode *BVHCache;
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index ddb36df74ca..560617db474 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -122,6 +122,7 @@ void CDDM_recalc_tessellation_ex(struct DerivedMesh *dm, const int do_face_nor_c
*/
void CDDM_lower_num_verts(struct DerivedMesh *dm, int numVerts);
void CDDM_lower_num_edges(struct DerivedMesh *dm, int numEdges);
+void CDDM_lower_num_loops(struct DerivedMesh *dm, int numLoops);
void CDDM_lower_num_polys(struct DerivedMesh *dm, int numPolys);
void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces);
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 07116979eab..dee27cebf59 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -119,6 +119,7 @@ void BKE_nurbList_flag_set(ListBase *editnurb, short flag);
void BKE_nurb_free(struct Nurb *nu);
struct Nurb *BKE_nurb_duplicate(struct Nurb *nu);
+struct Nurb *BKE_nurb_copy(struct Nurb *src, int pntsu, int pntsv);
void BKE_nurb_test2D(struct Nurb *nu);
void BKE_nurb_minmax(struct Nurb *nu, float min[3], float max[3]);
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 5a283922707..f28d16427cf 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -147,14 +147,14 @@ void *CustomData_add_layer_named(struct CustomData *data, int type, int alloctyp
void *layer, int totelem, const char *name);
/* frees the active or first data layer with the give type.
- * returns 1 on succes, 0 if no layer with the given type is found
+ * returns 1 on success, 0 if no layer with the given type is found
*
* in editmode, use EDBM_data_layer_free instead of this function
*/
bool CustomData_free_layer(struct CustomData *data, int type, int totelem, int index);
/* frees the layer index with the give type.
- * returns 1 on succes, 0 if no layer with the given type is found
+ * returns 1 on success, 0 if no layer with the given type is found
*
* in editmode, use EDBM_data_layer_free instead of this function
*/
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index 435cad17e57..e203549fef5 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -91,6 +91,7 @@ void defvert_normalize_lock_map(struct MDeformVert *dvert,
void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
-void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number);
+void BKE_deform_flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME],
+ const bool strip_number);
#endif /* __BKE_DEFORM_H__ */
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index 738cd87dc39..310807370da 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -71,13 +71,6 @@ typedef struct BMEditMesh {
unsigned char (*derivedFaceColor)[4];
int derivedFaceColorLen;
- /* index tables, to map indices to elements via
- * EDBM_index_arrays_init and associated functions. don't
- * touch this or read it directly.*/
- struct BMVert **vert_index;
- struct BMEdge **edge_index;
- struct BMFace **face_index;
-
/*selection mode*/
short selectmode;
short mat_nr;
diff --git a/source/blender/blenkernel/BKE_editmesh_bvh.h b/source/blender/blenkernel/BKE_editmesh_bvh.h
index 7b4ad4284c6..aeac00b06c1 100644
--- a/source/blender/blenkernel/BKE_editmesh_bvh.h
+++ b/source/blender/blenkernel/BKE_editmesh_bvh.h
@@ -33,15 +33,19 @@
#define __BKE_EDITMESH_BVH_H__
struct BMEditMesh;
+struct BMesh;
struct BMFace;
struct BMVert;
+struct BMLoop;
struct BMBVHTree;
struct BVHTree;
struct Scene;
typedef struct BMBVHTree BMBVHTree;
-BMBVHTree *BKE_bmbvh_new(struct BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free);
+BMBVHTree *BKE_bmbvh_new_from_editmesh(struct BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free);
+BMBVHTree *BKE_bmbvh_new(struct BMesh *bm, struct BMLoop *(*looptris)[3], int looptris_tot, int flag,
+ const float (*cos_cage)[3], const bool cos_cage_free);
void BKE_bmbvh_free(BMBVHTree *tree);
struct BVHTree *BKE_bmbvh_tree_get(BMBVHTree *tree);
struct BMFace *BKE_bmbvh_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], const float radius,
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index 028ff0f93d6..8f5ccf1087e 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -63,8 +63,6 @@ typedef struct EditFont {
wchar_t *textbuf;
struct CharInfo *textbufinfo;
- wchar_t *oldstr;
- struct CharInfo *oldstrinfo;
float textcurs[4][2];
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 9d33af1a0f4..d0341ab8c89 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -192,6 +192,7 @@ enum {
#define G_TRANSFORM_OBJ 1
#define G_TRANSFORM_EDIT 2
#define G_TRANSFORM_SEQ 4
+#define G_TRANSFORM_FCURVES 8
/* G.special1 */
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 71fd163a8ee..bd90960eced 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -94,7 +94,8 @@ void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite) A
int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
struct IDProperty *pnew) ATTR_NONNULL(1 /* group */, 3 /* pnew */);
-void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
+void IDP_RemoveFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
+void IDP_FreeFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 264a7421e91..7b7b69034a9 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -53,7 +53,8 @@ typedef struct Main {
char name[1024]; /* 1024 = FILE_MAX */
short versionfile, subversionfile; /* see BLENDER_VERSION, BLENDER_SUBVERSION */
short minversionfile, minsubversionfile;
- int revision; /* svn revision of binary that saved file */
+ uint64_t build_commit_timestamp; /* commit's timestamp from buildinfo */
+ char build_hash[16]; /* hash from buildinfo */
short recovered; /* indicate the main->name (file) is the recovered one */
struct Library *curlib;
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index 9e73e0662ce..d73249041e8 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -90,7 +90,7 @@ float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoi
/* point */
int BKE_mask_point_has_handle(struct MaskSplinePoint *point);
void BKE_mask_point_handle(struct MaskSplinePoint *point, float handle[2]);
-void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], int keep_direction,
+void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], bool keep_direction,
float orig_handle[2], float orig_vec[3][3]);
void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]);
@@ -123,9 +123,9 @@ void BKE_mask_coord_to_image(struct Image *image, struct ImageUser *iuser, float
void BKE_mask_update_display(struct Mask *mask, float ctime);
-void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe);
-void BKE_mask_evaluate(struct Mask *mask, const float ctime, const int do_newframe);
-void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const int do_newframe);
+void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const bool do_newframe);
+void BKE_mask_evaluate(struct Mask *mask, const float ctime, const bool do_newframe);
+void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const bool do_newframe);
void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene);
void BKE_mask_parent_init(struct MaskParent *parent);
void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
@@ -156,17 +156,18 @@ int BKE_mask_layer_shape_find_frame_range(struct MaskLayer *masklay, const float
struct MaskLayerShape **r_masklay_shape_b);
struct MaskLayerShape *BKE_mask_layer_shape_alloc(struct MaskLayer *masklay, const int frame);
void BKE_mask_layer_shape_free(struct MaskLayerShape *masklay_shape);
-struct MaskLayerShape *BKE_mask_layer_shape_varify_frame(struct MaskLayer *masklay, const int frame);
+struct MaskLayerShape *BKE_mask_layer_shape_verify_frame(struct MaskLayer *masklay, const int frame);
struct MaskLayerShape *BKE_mask_layer_shape_duplicate(struct MaskLayerShape *masklay_shape);
void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
void BKE_mask_layer_shape_sort(struct MaskLayer *masklay);
-int BKE_mask_layer_shape_spline_from_index(struct MaskLayer *masklay, int index,
+bool BKE_mask_layer_shape_spline_from_index(struct MaskLayer *masklay, int index,
struct MaskSpline **r_masklay_shape, int *r_index);
int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline);
+/* TODO(sergey): do_init and do_init_interpolate are always true, so let's wipe them later. */
void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index,
- int do_init, int do_init_interpolate);
+ bool do_init, bool do_init_interpolate);
void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count);
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 6bf42a3e885..65038c7f09c 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -357,6 +357,7 @@ bool modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
bool modifiers_isCorrectableDeformed(struct Scene *scene, struct Object *ob);
void modifier_freeTemporaryData(struct ModifierData *md);
bool modifiers_isPreview(struct Object *ob);
+void modifier_skin_customdata_ensure(struct Object *ob);
typedef struct CDMaskLink {
struct CDMaskLink *next;
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 7cc8c7290f7..b700cbb16db 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -132,7 +132,7 @@ typedef struct bNodeSocketType {
} bNodeSocketType;
typedef void *(*NodeInitExecFunction)(struct bNodeExecContext *context, struct bNode *node, bNodeInstanceKey key);
-typedef void (*NodeFreeExecFunction)(struct bNode *node, void *nodedata);
+typedef void (*NodeFreeExecFunction)(void *nodedata);
typedef void (*NodeExecFunction)(void *data, int thread, struct bNode *, struct bNodeExecData *execdata, struct bNodeStack **in, struct bNodeStack **out);
typedef int (*NodeGPUExecFunction)(struct GPUMaterial *mat, struct bNode *node, struct bNodeExecData *execdata, struct GPUNodeStack *in, struct GPUNodeStack *out);
@@ -175,7 +175,7 @@ typedef struct bNodeType {
void (*draw_backdrop)(struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y);
/// Optional custom label function for the node header.
- const char *(*labelfunc)(struct bNode *);
+ void (*labelfunc)(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
/// Optional custom resize handle polling.
int (*resize_area_func)(struct bNode *node, int x, int y);
/// Optional selection area polling.
@@ -556,7 +556,7 @@ void BKE_node_preview_set_pixel(struct bNodePreview *preview, const f
/* ************** NODE TYPE ACCESS *************** */
-const char *nodeLabel(struct bNode *node);
+void nodeLabel(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
int nodeGroupPoll(struct bNodeTree *nodetree, struct bNodeTree *grouptree);
@@ -571,7 +571,7 @@ void node_type_storage(struct bNodeType *ntype,
const char *storagename,
void (*freefunc)(struct bNode *node),
void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, struct bNode *src_node));
-void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *));
+void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNodeTree *ntree, struct bNode *, char *label, int maxlen));
void node_type_update(struct bNodeType *ntype,
void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id));
@@ -944,6 +944,9 @@ void ntreeCompositOutputFileSetLayer(struct bNode *node, struct bNodeSocket *soc
void ntreeCompositOutputFileUniquePath(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
+void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *ntree, bNode *node);
+void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *ntree, bNode *node);
+
/* ************** TEXTURE NODES *************** */
struct TexResult;
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index e99eb2a64f2..434175624b7 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -48,6 +48,7 @@ struct rctf;
struct MovieClip;
struct Main;
struct RigidBodyWorld;
+struct HookModifierData;
void BKE_object_workob_clear(struct Object *workob);
void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob);
@@ -66,6 +67,8 @@ void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob);
void BKE_object_free(struct Object *ob);
void BKE_object_free_derived_caches(struct Object *ob);
+void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd);
+
bool BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type);
void BKE_object_link_modifiers(struct Object *ob, struct Object *from);
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 9e21831dba0..f8c21a1fa16 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -151,8 +151,9 @@ typedef enum {
void BKE_pbvh_node_mark_update(PBVHNode *node);
void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node);
-void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
+void BKE_pbvh_node_mark_redraw(PBVHNode *node);
void BKE_pbvh_node_mark_topology_update(PBVHNode *node);
+void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 929d9686328..86be3bfe770 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -57,7 +57,7 @@ void BKE_rigidbody_relink_constraint(struct RigidBodyCon *rbc);
/* -------------- */
/* Setup */
-/* create Blender-side settings data - physics objects not initialised yet */
+/* create Blender-side settings data - physics objects not initialized yet */
struct RigidBodyWorld *BKE_rigidbody_create_world(struct Scene *scene);
struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type);
struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type);
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 2a00dee2a3f..e9e351f8f37 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -52,6 +52,7 @@ struct ParticleSettings;
struct PointDensity;
struct Tex;
struct TexMapping;
+struct TexResult;
struct VoxelData;
struct World;
@@ -129,6 +130,8 @@ struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot);
bool BKE_texture_dependsOnTime(const struct Tex *texture);
+void BKE_texture_get_value(struct Scene *scene, struct Tex *texture, float *tex_co, struct TexResult *texres, bool use_color_management);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 51f97180ddb..94e530529ec 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -225,7 +225,7 @@ void BKE_tracking_homography_between_two_quads(/*const*/ float reference_corners
bool 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 MovieReconstructContext *BKE_tracking_reconstruction_context_new(struct MovieClip *clip,
struct MovieTrackingObject *object,
int keyframe1, int keyframe2,
int width, int height);
diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h
index 8a11d48d063..347c8b60532 100644
--- a/source/blender/blenkernel/BKE_writeffmpeg.h
+++ b/source/blender/blenkernel/BKE_writeffmpeg.h
@@ -38,31 +38,34 @@
extern "C" {
#endif
-#define FFMPEG_MPEG1 0
-#define FFMPEG_MPEG2 1
-#define FFMPEG_MPEG4 2
-#define FFMPEG_AVI 3
-#define FFMPEG_MOV 4
-#define FFMPEG_DV 5
-#define FFMPEG_H264 6
-#define FFMPEG_XVID 7
-#define FFMPEG_FLV 8
-#define FFMPEG_MKV 9
-#define FFMPEG_OGG 10
-#define FFMPEG_WAV 11
-#define FFMPEG_MP3 12
+enum {
+ FFMPEG_MPEG1 = 0,
+ FFMPEG_MPEG2 = 1,
+ FFMPEG_MPEG4 = 2,
+ FFMPEG_AVI = 3,
+ FFMPEG_MOV = 4,
+ FFMPEG_DV = 5,
+ FFMPEG_H264 = 6,
+ FFMPEG_XVID = 7,
+ FFMPEG_FLV = 8,
+ FFMPEG_MKV = 9,
+ FFMPEG_OGG = 10,
+ FFMPEG_INVALID = 11,
+};
-#define FFMPEG_PRESET_NONE 0
-#define FFMPEG_PRESET_DVD 1
-#define FFMPEG_PRESET_SVCD 2
-#define FFMPEG_PRESET_VCD 3
-#define FFMPEG_PRESET_DV 4
-#define FFMPEG_PRESET_H264 5
-#define FFMPEG_PRESET_THEORA 6
-#define FFMPEG_PRESET_XVID 7
+enum {
+ FFMPEG_PRESET_NONE = 0,
+ FFMPEG_PRESET_DVD = 1,
+ FFMPEG_PRESET_SVCD = 2,
+ FFMPEG_PRESET_VCD = 3,
+ FFMPEG_PRESET_DV = 4,
+ FFMPEG_PRESET_H264 = 5,
+ FFMPEG_PRESET_THEORA = 6,
+ FFMPEG_PRESET_XVID = 7,
+};
struct IDProperty;
-struct RenderData;
+struct RenderData;
struct ReportList;
struct Scene;
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 368c1e517ef..731196c2480 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1259,7 +1259,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
}
if (dm->type == DM_TYPE_EDITBMESH) {
- /* editmesh draw function checks spesifically for this */
+ /* editmesh draw function checks specifically for this */
}
else {
const int dm_totpoly = dm->getNumPolys(dm);
@@ -2859,14 +2859,19 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
else
layer = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
- if (layer != -1) {
- a = attribs->tottface++;
+ a = attribs->tottface++;
+ if (layer != -1) {
attribs->tface[a].array = tfdata->layers[layer].data;
attribs->tface[a].em_offset = ldata->layers[layer].offset;
- attribs->tface[a].gl_index = gattribs->layer[b].glindex;
- attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
+ else {
+ attribs->tface[a].array = NULL;
+ attribs->tface[a].em_offset = -1;
+ }
+
+ attribs->tface[a].gl_index = gattribs->layer[b].glindex;
+ attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
else {
if (gattribs->layer[b].name[0])
@@ -2875,14 +2880,19 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
else
layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE);
- if (layer != -1) {
- a = attribs->tottface++;
+ a = attribs->tottface++;
+ if (layer != -1) {
attribs->tface[a].array = tfdata->layers[layer].data;
attribs->tface[a].em_offset = tfdata->layers[layer].offset;
- attribs->tface[a].gl_index = gattribs->layer[b].glindex;
- attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
+ else {
+ attribs->tface[a].array = NULL;
+ attribs->tface[a].em_offset = -1;
+ }
+
+ attribs->tface[a].gl_index = gattribs->layer[b].glindex;
+ attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
}
else if (gattribs->layer[b].type == CD_MCOL) {
@@ -2896,14 +2906,19 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
else
layer = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL);
- if (layer != -1) {
- a = attribs->totmcol++;
+ a = attribs->totmcol++;
+ if (layer != -1) {
attribs->mcol[a].array = tfdata->layers[layer].data;
/* odd, store the offset for a different layer type here, but editmode draw code expects it */
attribs->mcol[a].em_offset = ldata->layers[layer].offset;
- attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
+ else {
+ attribs->mcol[a].array = NULL;
+ attribs->mcol[a].em_offset = -1;
+ }
+
+ attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
else {
/* vertex colors */
@@ -2913,40 +2928,54 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
else
layer = CustomData_get_active_layer_index(tfdata, CD_MCOL);
- if (layer != -1) {
- a = attribs->totmcol++;
+ a = attribs->totmcol++;
+ if (layer != -1) {
attribs->mcol[a].array = tfdata->layers[layer].data;
/* odd, store the offset for a different layer type here, but editmode draw code expects it */
attribs->mcol[a].em_offset = tfdata->layers[layer].offset;
- attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
+ else {
+ attribs->mcol[a].array = NULL;
+ attribs->mcol[a].em_offset = -1;
+ }
+
+ attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
}
else if (gattribs->layer[b].type == CD_TANGENT) {
/* tangents */
layer = CustomData_get_layer_index(fdata, CD_TANGENT);
- if (layer != -1) {
- attribs->tottang = 1;
+ attribs->tottang = 1;
+ if (layer != -1) {
attribs->tang.array = fdata->layers[layer].data;
attribs->tang.em_offset = fdata->layers[layer].offset;
- attribs->tang.gl_index = gattribs->layer[b].glindex;
}
+ else {
+ attribs->tang.array = NULL;
+ attribs->tang.em_offset = -1;
+ }
+
+ attribs->tang.gl_index = gattribs->layer[b].glindex;
}
else if (gattribs->layer[b].type == CD_ORCO) {
/* original coordinates */
layer = CustomData_get_layer_index(vdata, CD_ORCO);
+ attribs->totorco = 1;
if (layer != -1) {
- attribs->totorco = 1;
-
attribs->orco.array = vdata->layers[layer].data;
attribs->orco.em_offset = vdata->layers[layer].offset;
- attribs->orco.gl_index = gattribs->layer[b].glindex;
- attribs->orco.gl_texco = gattribs->layer[b].gltexco;
}
+ else {
+ attribs->orco.array = NULL;
+ attribs->orco.em_offset = -1;
+ }
+
+ attribs->orco.gl_index = gattribs->layer[b].glindex;
+ attribs->orco.gl_texco = gattribs->layer[b].gltexco;
}
}
}
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index b0644da4598..c91fae2adbc 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -53,6 +53,7 @@
#include "BKE_anim.h"
#include "BKE_animsys.h"
#include "BKE_constraint.h"
+#include "BKE_deform.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
@@ -440,6 +441,10 @@ void action_groups_clear_tempflags(bAction *act)
/* *************** Pose channels *************** */
+/**
+ * Return a pointer to the pose channel of the given name
+ * from this pose.
+ */
bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
{
if (ELEM(NULL, pose, name) || (name[0] == '\0'))
@@ -451,8 +456,14 @@ bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
return BLI_findstring(&((bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name));
}
-/* Use with care, not on Armature poses but for temporal ones */
-/* (currently used for action constraints and in rebuild_pose) */
+/**
+ * Looks to see if the channel with the given name
+ * already exists in this pose - if not a new one is
+ * allocated and initialized.
+ *
+ * \note Use with care, not on Armature poses but for temporal ones.
+ * \note (currently used for action constraints and in rebuild_pose).
+ */
bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
{
bPoseChannel *chan;
@@ -505,7 +516,12 @@ bool BKE_pose_channels_is_valid(const bPose *pose)
}
#endif
-/* Find the active posechannel for an object (we can't just use pose, as layer info is in armature) */
+
+/**
+ * Find the active posechannel for an object (we can't just use pose, as layer info is in armature)
+ *
+ * \note: Object, not bPose is used here, as we need layer info from Armature)
+ */
bPoseChannel *BKE_pose_channel_active(Object *ob)
{
bArmature *arm = (ob) ? ob->data : NULL;
@@ -524,6 +540,22 @@ bPoseChannel *BKE_pose_channel_active(Object *ob)
return NULL;
}
+/**
+ * \see #ED_armature_bone_get_mirrored (edit-mode, matching function)
+ */
+bPoseChannel *BKE_pose_channel_get_mirrored(const bPose *pose, const char *name)
+{
+ char name_flip[MAXBONENAME];
+
+ BKE_deform_flip_side_name(name_flip, name, false);
+
+ if (!STREQ(name_flip, name)) {
+ return BKE_pose_channel_find_name(pose, name_flip);
+ }
+
+ return NULL;
+}
+
const char *BKE_pose_ikparam_get_name(bPose *pose)
{
if (pose) {
@@ -536,8 +568,14 @@ const char *BKE_pose_ikparam_get_name(bPose *pose)
}
return NULL;
}
-/* dst should be freed already, makes entire duplicate */
-void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon)
+
+/**
+ * Allocate a new pose on the heap, and copy the src pose and it's channels
+ * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL.
+ *
+ * \param dst Should be freed already, makes entire duplicate.
+ */
+void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints)
{
bPose *outPose;
bPoseChannel *pchan;
@@ -551,15 +589,22 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon)
outPose = MEM_callocN(sizeof(bPose), "pose");
BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
-
+ if (outPose->chanbase.first) {
+ bPoseChannel *pchan;
+ for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
+ if (pchan->custom) {
+ id_us_plus(&pchan->custom->id);
+ }
+ }
+ }
+
outPose->iksolver = src->iksolver;
outPose->ikdata = NULL;
outPose->ikparam = MEM_dupallocN(src->ikparam);
outPose->avs = src->avs;
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
- /* TODO: rename this argument... */
- if (copycon) {
+ if (copy_constraints) {
BKE_copy_constraints(&listb, &pchan->constraints, TRUE); // BKE_copy_constraints NULLs listb
pchan->constraints = listb;
pchan->mpath = NULL; /* motion paths should not get copied yet... */
@@ -571,8 +616,9 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon)
}
/* for now, duplicate Bone Groups too when doing this */
- if (copycon)
+ if (copy_constraints) {
BLI_duplicatelist(&outPose->agroups, &src->agroups);
+ }
*dst = outPose;
}
@@ -641,7 +687,10 @@ bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
return pose_channel_in_IK_chain(ob, pchan, 0);
}
-
+/**
+ * Removes the hash for quick lookup of channels, must
+ * be done when adding/removing channels.
+ */
void BKE_pose_channels_hash_make(bPose *pose)
{
if (!pose->chanhash) {
@@ -661,6 +710,10 @@ void BKE_pose_channels_hash_free(bPose *pose)
}
}
+/**
+ * Deallocates a pose channel.
+ * Does not free the pose channel itself.
+ */
void BKE_pose_channel_free(bPoseChannel *pchan)
{
if (pchan->custom) {
@@ -681,6 +734,10 @@ void BKE_pose_channel_free(bPoseChannel *pchan)
}
}
+/**
+ * Removes and deallocates all channels from a pose.
+ * Does not free the pose itself.
+ */
void BKE_pose_channels_free(bPose *pose)
{
bPoseChannel *pchan;
@@ -695,6 +752,9 @@ void BKE_pose_channels_free(bPose *pose)
BKE_pose_channels_hash_free(pose);
}
+/**
+ * Removes and deallocates all data from a pose, and also frees the pose.
+ */
void BKE_pose_free(bPose *pose)
{
if (pose) {
@@ -739,9 +799,13 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
}
}
-/* makes copies of internal data, unlike copy_pose_channel_data which only
- * copies the pose state.
- * hint: use when copying bones in editmode (on returned value from BKE_pose_channel_verify) */
+/**
+ * Copy the internal members of each pose channel including constraints
+ * and ID-Props, used when duplicating bones in editmode.
+ * (unlike copy_pose_channel_data which only).
+ *
+ * \note use when copying bones in editmode (on returned value from #BKE_pose_channel_verify)
+ */
void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_from)
{
/* copy transform locks */
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 225be335c6d..9226538910c 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -285,7 +285,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
/* ........ */
/* Note on evaluation optimizations:
- * Optimisations currently used here play tricks with the depsgraph in order to try and
+ * Optimization's currently used here play tricks with the depsgraph in order to try and
* evaluate as few objects as strictly necessary to get nicer performance under standard
* production conditions. For those people who really need the accurate version,
* disable the ifdef (i.e. 1 -> 0) and comment out the call to motionpaths_calc_optimise_depsgraph()
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 74578266c63..cb628db8cd2 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -711,6 +711,49 @@ static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, const ch
}
}
+/* Fix all RNA_Paths in the given Action, relative to the given ID block
+ *
+ * This is just an external wrapper for the F-Curve fixing function,
+ * with input validity checks on top of the basic method.
+ *
+ * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
+ * i.e. pose.bones["Bone"]
+ */
+void BKE_action_fix_paths_rename(ID *owner_id, bAction *act, const char *prefix, const char *oldName,
+ const char *newName, int oldSubscript, int newSubscript, int verify_paths)
+{
+ char *oldN, *newN;
+
+ /* if no action, no need to proceed */
+ if (ELEM(NULL, owner_id, act))
+ return;
+
+ /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */
+ if ((oldName != NULL) && (newName != NULL)) {
+ /* pad the names with [" "] so that only exact matches are made */
+ const size_t name_old_len = strlen(oldName);
+ const size_t name_new_len = strlen(newName);
+ char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1);
+ char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1);
+
+ BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1);
+ BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1);
+ oldN = BLI_sprintfN("[\"%s\"]", name_old_esc);
+ newN = BLI_sprintfN("[\"%s\"]", name_new_esc);
+ }
+ else {
+ oldN = BLI_sprintfN("[%d]", oldSubscript);
+ newN = BLI_sprintfN("[%d]", newSubscript);
+ }
+
+ /* fix paths in action */
+ fcurves_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &act->curves, verify_paths);
+
+ /* free the temp names */
+ MEM_freeN(oldN);
+ MEM_freeN(newN);
+}
+
/* Fix all RNA-Paths in the AnimData block used by the given ID block
* NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
* i.e. pose.bones["Bone"]
@@ -725,6 +768,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons
if (ELEM(NULL, owner_id, adt))
return;
+ /* Name sanitation logic - shared with BKE_action_fix_paths_rename() */
if ((oldName != NULL) && (newName != NULL)) {
/* pad the names with [" "] so that only exact matches are made */
const size_t name_old_len = strlen(oldName);
@@ -1523,11 +1567,11 @@ static float nlastrip_get_influence(NlaStrip *strip, float cframe)
strip->blendout = fabsf(strip->blendout);
/* result depends on where frame is in respect to blendin/out values */
- if (IS_EQ(strip->blendin, 0) == 0 && (cframe <= (strip->start + strip->blendin))) {
+ if (IS_EQF(strip->blendin, 0.0f) == false && (cframe <= (strip->start + strip->blendin))) {
/* there is some blend-in */
return fabsf(cframe - strip->start) / (strip->blendin);
}
- else if (IS_EQ(strip->blendout, 0) == 0 && (cframe >= (strip->end - strip->blendout))) {
+ else if (IS_EQF(strip->blendout, 0.0f) == false && (cframe >= (strip->end - strip->blendout))) {
/* there is some blend-out */
return fabsf(strip->end - cframe) / (strip->blendout);
}
@@ -1812,7 +1856,7 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, float
inf *= nes->strip_time;
/* optimisation: no need to try applying if there is no influence */
- if (IS_EQ(inf, 0)) return;
+ if (IS_EQF(inf, 0.0f)) return;
/* perform blending */
switch (blendmode) {
@@ -2030,7 +2074,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li
tmp_nes = *nes;
/* evaluate these strips into a temp-buffer (tmp_channels) */
- /* FIXME: modifier evalation here needs some work... */
+ /* FIXME: modifier evaluation here needs some work... */
/* first strip */
tmp_nes.strip_mode = NES_TIME_TRANSITION_START;
tmp_nes.strip = s1;
@@ -2042,7 +2086,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li
nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
- /* assumulate temp-buffer and full-buffer, using the 'real' strip */
+ /* accumulate temp-buffer and full-buffer, using the 'real' strip */
nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes);
/* unlink this strip's modifiers from the parent's modifiers again */
@@ -2080,7 +2124,7 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase
*/
nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, tmp_nes);
- /* assumulate temp-buffer and full-buffer, using the 'real' strip */
+ /* accumulate temp-buffer and full-buffer, using the 'real' strip */
nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes);
/* free temp eval-strip */
@@ -2290,7 +2334,7 @@ static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime)
/* ***************************************** */
/* Overrides System - Public API */
-/* Clear all overides */
+/* Clear all overrides */
/* Add or get existing Override for given setting */
#if 0
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 6b2b782717d..3be80a7e30d 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -285,7 +285,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
*/
if (axis == 2) {
/* z-axis - vertical (top/bottom) */
- if (IS_EQ(head, 0)) {
+ if (IS_EQF(head, 0.0f)) {
if (tail < 0)
strcpy(extension, "Bot");
else if (tail > 0)
@@ -300,7 +300,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
}
else if (axis == 1) {
/* y-axis - depth (front/back) */
- if (IS_EQ(head, 0)) {
+ if (IS_EQF(head, 0.0f)) {
if (tail < 0)
strcpy(extension, "Fr");
else if (tail > 0)
@@ -315,7 +315,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
}
else {
/* x-axis - horizontal (left/right) */
- if (IS_EQ(head, 0)) {
+ if (IS_EQF(head, 0.0f)) {
if (tail < 0)
strcpy(extension, "R");
else if (tail > 0)
@@ -405,7 +405,7 @@ static void equalize_bezier(float *data, int desired)
dist = ((float)a) * ddist;
/* we're looking for location (distance) 'dist' in the array */
- while ((dist >= pdist[nr]) && nr < MAX_BBONE_SUBDIV)
+ while ((nr < MAX_BBONE_SUBDIV) && (dist >= pdist[nr]))
nr++;
fac1 = pdist[nr] - pdist[nr - 1];
diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c
index 2d7249b54f5..732c0c35feb 100644
--- a/source/blender/blenkernel/intern/bmfont.c
+++ b/source/blender/blenkernel/intern/bmfont.c
@@ -204,7 +204,7 @@ void detectBitmapFont(ImBuf *ibuf)
printf("detectBitmapFont :Unsupported version %d\n", (int)version);
}
- /* on succes ibuf->userdata points to the bitmapfont */
+ /* on success ibuf->userdata points to the bitmapfont */
if (ibuf->userdata) {
break;
}
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 790c1f09ff0..33c6f3eb7c0 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -762,7 +762,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
* radius become inconsistent.
* the biggest problem is that it isn't possible to change
* unprojected radius because a view context is not
- * available. my ussual solution to this is to use the
+ * available. my usual solution to this is to use the
* ratio of change of the size to change the unprojected
* radius. Not completely convinced that is correct.
* In any case, a better solution is needed to prevent
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 370dbc62ef8..cce511aedcb 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -557,7 +557,7 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *dm, float e
data->cached = true;
/* a NULL nearest callback works fine
- * remeber the min distance to point is the same as the min distance to BV of point */
+ * remember the min distance to point is the same as the min distance to BV of point */
data->nearest_callback = NULL;
data->raycast_callback = NULL;
@@ -573,8 +573,9 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *dm, float e
/* Builds a bvh tree.. where nodes are the faces of the given dm. */
BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float epsilon, int tree_type, int axis)
{
- BVHTree *tree = bvhcache_find(&dm->bvhCache, BVHTREE_FROM_FACES);
BMEditMesh *em = data->em_evil;
+ const int bvhcache_type = em ? BVHTREE_FROM_FACES_EDITMESH : BVHTREE_FROM_FACES;
+ BVHTree *tree = bvhcache_find(&dm->bvhCache, bvhcache_type);
/* Not in cache */
if (tree == NULL) {
@@ -682,7 +683,7 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float e
/* Save on cache for later use */
// printf("BVHTree built and saved on cache\n");
- bvhcache_insert(&dm->bvhCache, tree, BVHTREE_FROM_FACES);
+ bvhcache_insert(&dm->bvhCache, tree, bvhcache_type);
}
}
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 1bc12cffe7b..d57d9180697 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1063,37 +1063,57 @@ static void cdDM_drawMappedFacesTex(DerivedMesh *dm,
static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal)
{
+ const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
int b;
/* orco texture coordinates */
if (attribs->totorco) {
+ /*const*/ float (*array)[3] = attribs->orco.array;
+ const float *orco = (array) ? array[index] : zero;
+
if (attribs->orco.gl_texco)
- glTexCoord3fv(attribs->orco.array[index]);
+ glTexCoord3fv(orco);
else
- glVertexAttrib3fvARB(attribs->orco.gl_index, attribs->orco.array[index]);
+ glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
}
/* uv texture coordinates */
for (b = 0; b < attribs->tottface; b++) {
- MTFace *tf = &attribs->tface[b].array[a];
+ const float *uv;
+
+ if (attribs->tface[b].array) {
+ MTFace *tf = &attribs->tface[b].array[a];
+ uv = tf->uv[vert];
+ }
+ else {
+ uv = zero;
+ }
if (attribs->tface[b].gl_texco)
- glTexCoord2fv(tf->uv[vert]);
+ glTexCoord2fv(uv);
else
- glVertexAttrib2fvARB(attribs->tface[b].gl_index, tf->uv[vert]);
+ glVertexAttrib2fvARB(attribs->tface[b].gl_index, uv);
}
/* vertex colors */
for (b = 0; b < attribs->totmcol; b++) {
- MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
GLubyte col[4];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+
+ if (attribs->mcol[b].array) {
+ MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ }
+ else {
+ col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0;
+ }
+
glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col);
}
/* tangent for normal mapping */
if (attribs->tottang) {
- float *tang = attribs->tang.array[a * 4 + vert];
+ /*const*/ float (*array)[4] = attribs->tang.array;
+ const float *tang = (array) ? array[a * 4 + vert] : zero;
glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
}
@@ -1264,25 +1284,29 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
if (do_draw) {
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- if (attribs.totorco) {
+ if (attribs.totorco && attribs.orco.array) {
datatypes[numdata].index = attribs.orco.gl_index;
datatypes[numdata].size = 3;
datatypes[numdata].type = GL_FLOAT;
numdata++;
}
for (b = 0; b < attribs.tottface; b++) {
- datatypes[numdata].index = attribs.tface[b].gl_index;
- datatypes[numdata].size = 2;
- datatypes[numdata].type = GL_FLOAT;
- numdata++;
+ if (attribs.tface[b].array) {
+ datatypes[numdata].index = attribs.tface[b].gl_index;
+ datatypes[numdata].size = 2;
+ datatypes[numdata].type = GL_FLOAT;
+ numdata++;
+ }
}
for (b = 0; b < attribs.totmcol; b++) {
- datatypes[numdata].index = attribs.mcol[b].gl_index;
- datatypes[numdata].size = 4;
- datatypes[numdata].type = GL_UNSIGNED_BYTE;
- numdata++;
+ if (attribs.mcol[b].array) {
+ datatypes[numdata].index = attribs.mcol[b].gl_index;
+ datatypes[numdata].size = 4;
+ datatypes[numdata].type = GL_UNSIGNED_BYTE;
+ numdata++;
+ }
}
- if (attribs.tottang) {
+ if (attribs.tottang && attribs.tang.array) {
datatypes[numdata].index = attribs.tang.gl_index;
datatypes[numdata].size = 4;
datatypes[numdata].type = GL_FLOAT;
@@ -1315,34 +1339,38 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
if (do_draw && numdata != 0) {
offset = 0;
- if (attribs.totorco) {
+ if (attribs.totorco && attribs.orco.array) {
copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]);
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]);
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]);
offset += sizeof(float) * 3;
}
for (b = 0; b < attribs.tottface; b++) {
- MTFace *tf = &attribs.tface[b].array[a];
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]);
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]);
+ if (attribs.tface[b].array) {
+ MTFace *tf = &attribs.tface[b].array[a];
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]);
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]);
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]);
- offset += sizeof(float) * 2;
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]);
+ offset += sizeof(float) * 2;
+ }
}
for (b = 0; b < attribs.totmcol; b++) {
- MCol *cp = &attribs.mcol[b].array[a * 4 + 0];
- GLubyte col[4];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
- cp = &attribs.mcol[b].array[a * 4 + 1];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col);
- cp = &attribs.mcol[b].array[a * 4 + 2];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
- offset += sizeof(unsigned char) * 4;
+ if (attribs.mcol[b].array) {
+ MCol *cp = &attribs.mcol[b].array[a * 4 + 0];
+ GLubyte col[4];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
+ cp = &attribs.mcol[b].array[a * 4 + 1];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col);
+ cp = &attribs.mcol[b].array[a * 4 + 2];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
+ offset += sizeof(unsigned char) * 4;
+ }
}
- if (attribs.tottang) {
+ if (attribs.tottang && attribs.tang.array) {
float *tang = attribs.tang.array[a * 4 + 0];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
tang = attribs.tang.array[a * 4 + 1];
@@ -1357,33 +1385,37 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
if (mface->v4) {
if (do_draw && numdata != 0) {
offset = 0;
- if (attribs.totorco) {
+ if (attribs.totorco && attribs.orco.array) {
copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]);
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v4]);
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v1]);
offset += sizeof(float) * 3;
}
for (b = 0; b < attribs.tottface; b++) {
- MTFace *tf = &attribs.tface[b].array[a];
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]);
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]);
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]);
- offset += sizeof(float) * 2;
+ if (attribs.tface[b].array) {
+ MTFace *tf = &attribs.tface[b].array[a];
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]);
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]);
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]);
+ offset += sizeof(float) * 2;
+ }
}
for (b = 0; b < attribs.totmcol; b++) {
- MCol *cp = &attribs.mcol[b].array[a * 4 + 2];
- GLubyte col[4];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
- cp = &attribs.mcol[b].array[a * 4 + 3];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col);
- cp = &attribs.mcol[b].array[a * 4 + 0];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
- offset += sizeof(unsigned char) * 4;
+ if (attribs.mcol[b].array) {
+ MCol *cp = &attribs.mcol[b].array[a * 4 + 2];
+ GLubyte col[4];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
+ cp = &attribs.mcol[b].array[a * 4 + 3];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col);
+ cp = &attribs.mcol[b].array[a * 4 + 0];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
+ offset += sizeof(unsigned char) * 4;
+ }
}
- if (attribs.tottang) {
+ if (attribs.tottang && attribs.tang.array) {
float *tang = attribs.tang.array[a * 4 + 2];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
tang = attribs.tang.array[a * 4 + 3];
@@ -2754,6 +2786,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts)
{
+ BLI_assert(numVerts >= 0);
if (numVerts < dm->numVertData)
CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData - numVerts);
@@ -2762,6 +2795,7 @@ void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts)
void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges)
{
+ BLI_assert(numEdges >= 0);
if (numEdges < dm->numEdgeData)
CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData - numEdges);
@@ -2770,14 +2804,25 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges)
void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces)
{
+ BLI_assert(numTessFaces >= 0);
if (numTessFaces < dm->numTessFaceData)
CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData - numTessFaces);
dm->numTessFaceData = numTessFaces;
}
+void CDDM_lower_num_loops(DerivedMesh *dm, int numLoops)
+{
+ BLI_assert(numLoops >= 0);
+ if (numLoops < dm->numLoopData)
+ CustomData_free_elem(&dm->loopData, numLoops, dm->numLoopData - numLoops);
+
+ dm->numLoopData = numLoops;
+}
+
void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys)
{
+ BLI_assert(numPolys >= 0);
if (numPolys < dm->numPolyData)
CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData - numPolys);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index e4c6f7790d7..cab4adf46bf 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -1114,8 +1114,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if ( numedges==0 )
return 0;
- /* NOTE: handling ownership of sptings and edgehash is quite sloppy
- * currenlty they are never initialized but assert just to be sure */
+ /* NOTE: handling ownership of springs and edgehash is quite sloppy
+ * currently they are never initialized but assert just to be sure */
BLI_assert(cloth->springs == NULL);
BLI_assert(cloth->edgehash == NULL);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 1f892432d80..0dbb739e6f8 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1008,7 +1008,7 @@ static bConstraintTypeInfo CTI_TRACKTO = {
trackto_evaluate /* evaluate */
};
-/* --------- Inverse-Kinemetics --------- */
+/* --------- Inverse-Kinematics --------- */
static void kinematic_new_data(void *cdata)
{
@@ -3075,7 +3075,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
float offset;
/* check to make sure len is not so close to zero that it'll cause errors */
- if (IS_EQ(len, 0) == 0) {
+ if (IS_EQF(len, 0.0f) == false) {
/* find bounding-box range where target is located */
if (ownLoc[clamp_axis] < curveMin[clamp_axis]) {
/* bounding-box range is before */
@@ -3107,7 +3107,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
curvetime = 0.0f;
else if (ownLoc[clamp_axis] >= curveMax[clamp_axis])
curvetime = 1.0f;
- else if (IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0)
+ else if (IS_EQF((curveMax[clamp_axis] - curveMin[clamp_axis]), 0.0f) == false)
curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) / (curveMax[clamp_axis] - curveMin[clamp_axis]);
else
curvetime = 0.0f;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index e255732d3fb..bcf0eafaa65 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -104,10 +104,6 @@ void BKE_curve_editfont_free(Curve *cu)
if (cu->editfont) {
EditFont *ef = cu->editfont;
- if (ef->oldstr)
- MEM_freeN(ef->oldstr);
- if (ef->oldstrinfo)
- MEM_freeN(ef->oldstrinfo);
if (ef->textbuf)
MEM_freeN(ef->textbuf);
if (ef->textbufinfo)
@@ -120,6 +116,8 @@ void BKE_curve_editfont_free(Curve *cu)
MEM_freeN(ef);
cu->editfont = NULL;
}
+
+ MEM_SAFE_FREE(cu->selboxes);
}
void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb)
@@ -230,6 +228,7 @@ Curve *BKE_curve_copy(Curve *cu)
cun->editnurb = NULL;
cun->editfont = NULL;
cun->selboxes = NULL;
+ cun->lastsel = NULL;
#if 0 // XXX old animation system
/* single user ipo too */
@@ -579,6 +578,26 @@ Nurb *BKE_nurb_duplicate(Nurb *nu)
return newnu;
}
+/* copy the nurb but allow for different number of points (to be copied after this) */
+Nurb *BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
+{
+ Nurb *newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "copyNurb");
+ memcpy(newnu, src, sizeof(Nurb));
+
+ if (pntsu == 1) SWAP(int, pntsu, pntsv);
+ newnu->pntsu = pntsu;
+ newnu->pntsv = pntsv;
+
+ if (src->bezt) {
+ newnu->bezt = (BezTriple *)MEM_mallocN(pntsu * pntsv * sizeof(BezTriple), "copyNurb2");
+ }
+ else {
+ newnu->bp = (BPoint *)MEM_mallocN(pntsu * pntsv * sizeof(BPoint), "copyNurb3");
+ }
+
+ return newnu;
+}
+
void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2)
{
Nurb *nu, *nun;
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index a183872552d..8aeacda8100 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -335,9 +335,10 @@ void defvert_normalize_lock_single(MDeformVert *dvert,
}
/* Same as defvert_normalize() if no locked vgroup is a member of the subset */
-void defvert_normalize_lock_map(MDeformVert *dvert,
- const bool *vgroup_subset, const int vgroup_tot,
- const bool *lock_flags, const int defbase_tot)
+void defvert_normalize_lock_map(
+ MDeformVert *dvert,
+ const bool *vgroup_subset, const int vgroup_tot,
+ const bool *lock_flags, const int defbase_tot)
{
if (dvert->totweight == 0) {
/* nothing */
@@ -447,7 +448,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default)
}
else {
bDeformGroup *dg;
- char name[sizeof(dg->name)];
+ char name_flip[sizeof(dg->name)];
int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
for (i = 0; i < defbase_tot; i++) {
@@ -461,9 +462,10 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default)
if (use_default)
map[i] = i;
- flip_side_name(name, dg->name, FALSE);
- if (strcmp(name, dg->name)) {
- flip_num = defgroup_name_index(ob, name);
+ BKE_deform_flip_side_name(name_flip, dg->name, false);
+
+ if (!STREQ(name_flip, dg->name)) {
+ flip_num = defgroup_name_index(ob, name_flip);
if (flip_num >= 0) {
map[i] = flip_num;
map[flip_num] = i; /* save an extra lookup */
@@ -485,7 +487,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_defa
}
else {
bDeformGroup *dg;
- char name[sizeof(dg->name)];
+ char name_flip[sizeof(dg->name)];
int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
for (i = 0; i < defbase_tot; i++) {
@@ -494,9 +496,9 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_defa
dg = BLI_findlink(&ob->defbase, defgroup);
- flip_side_name(name, dg->name, FALSE);
- if (strcmp(name, dg->name)) {
- flip_num = defgroup_name_index(ob, name);
+ BKE_deform_flip_side_name(name_flip, dg->name, false);
+ if (!STREQ(name_flip, dg->name)) {
+ flip_num = defgroup_name_index(ob, name_flip);
if (flip_num != -1) {
map[defgroup] = flip_num;
@@ -514,11 +516,12 @@ int defgroup_flip_index(Object *ob, int index, const bool use_default)
int flip_index = -1;
if (dg) {
- char name[sizeof(dg->name)];
- flip_side_name(name, dg->name, 0);
+ char name_flip[sizeof(dg->name)];
+ BKE_deform_flip_side_name(name_flip, dg->name, false);
- if (strcmp(name, dg->name))
- flip_index = defgroup_name_index(ob, name);
+ if (!STREQ(name_flip, dg->name)) {
+ flip_index = defgroup_name_index(ob, name_flip);
+ }
}
return (flip_index == -1 && use_default) ? index : flip_index;
@@ -602,7 +605,8 @@ void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char pre[MAX_VG
/* finds the best possible flipped name. For renaming; check for unique names afterwards */
/* if strip_number: removes number extensions
* note: don't use sizeof() for 'name' or 'from_name' */
-void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
+void BKE_deform_flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME],
+ const bool strip_number)
{
int len;
char prefix[MAX_VGROUP_NAME] = ""; /* The part before the facing */
@@ -624,7 +628,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
if (isdigit(name[len - 1])) {
index = strrchr(name, '.'); // last occurrence
if (index && isdigit(index[1])) { // doesnt handle case bone.1abc2 correct..., whatever!
- if (strip_number == 0) {
+ if (strip_number == false) {
BLI_strncpy(number, index, sizeof(number));
}
*index = 0;
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index caa5bf90584..c3538b141b5 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -34,7 +34,7 @@
* to three loops per triangle. the derivedmesh stores a cache of tessellations
* for each face. this cache will smartly update as needed (though at first
* it'll simply be more brute force). keeping track of face/edge counts may
- * be a small problbm.
+ * be a small problem.
*
* this won't be the most efficient thing, considering that internal edges and
* faces of tessellations are exposed. looking up an edge by index in particular
@@ -888,23 +888,47 @@ static void emdm_pass_attrib_vertex_glsl(DMVertexAttribs *attribs, BMLoop *loop,
{
BMVert *eve = loop->v;
int i;
+ const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
if (attribs->totorco) {
- const float *orco = attribs->orco.array[BM_elem_index_get(eve)];
- glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
+ int index = BM_elem_index_get(eve);
+ const float *orco = (attribs->orco.array) ? attribs->orco.array[index] : zero;
+
+ if (attribs->orco.gl_texco)
+ glTexCoord3fv(orco);
+ else
+ glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
}
for (i = 0; i < attribs->tottface; i++) {
- const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset);
- glVertexAttrib2fvARB(attribs->tface[i].gl_index, luv->uv);
+ const float *uv;
+
+ if (attribs->tface[i].em_offset != -1) {
+ const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset);
+ uv = luv->uv;
+ }
+ else {
+ uv = zero;
+ }
+
+ if (attribs->tface[i].gl_texco)
+ glTexCoord2fv(uv);
+ else
+ glVertexAttrib2fvARB(attribs->tface[i].gl_index, uv);
}
for (i = 0; i < attribs->totmcol; i++) {
- const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset);
GLubyte col[4];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ if (attribs->mcol[i].em_offset != -1) {
+ const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset);
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ }
+ else {
+ col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0;
+ }
glVertexAttrib4ubvARB(attribs->mcol[i].gl_index, col);
}
if (attribs->tottang) {
- const float *tang = attribs->tang.array[i * 4 + index_in_face];
+ int index = i * 4 + index_in_face;
+ const float *tang = (attribs->tang.array) ? attribs->tang.array[index] : zero;
glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
}
}
@@ -1020,38 +1044,6 @@ static void emDM_drawFacesGLSL(DerivedMesh *dm,
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
}
-/* emdm_pass_attrib_vertex_glsl's note about em_offset use applies here */
-static void emdm_pass_attrib_vertex_mat(DMVertexAttribs *attribs, BMLoop *loop, int index_in_face)
-{
- BMVert *eve = loop->v;
- int i;
-
- if (attribs->totorco) {
- float *orco = attribs->orco.array[BM_elem_index_get(eve)];
- if (attribs->orco.gl_texco)
- glTexCoord3fv(orco);
- else
- glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
- }
- for (i = 0; i < attribs->tottface; i++) {
- const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset);
- if (attribs->tface[i].gl_texco)
- glTexCoord2fv(luv->uv);
- else
- glVertexAttrib2fvARB(attribs->tface[i].gl_index, luv->uv);
- }
- for (i = 0; i < attribs->totmcol; i++) {
- const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset);
- GLubyte col[4];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- glVertexAttrib4ubvARB(attribs->mcol[i].gl_index, col);
- }
- if (attribs->tottang) {
- float *tang = attribs->tang.array[i * 4 + index_in_face];
- glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
- }
-}
-
static void emDM_drawMappedFacesMat(DerivedMesh *dm,
void (*setMaterial)(void *userData, int, void *attribs),
bool (*setFace)(void *userData, int index), void *userData)
@@ -1105,21 +1097,21 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
if (vertexCos) glNormal3fv(polyNos[BM_elem_index_get(efa)]);
else glNormal3fv(efa->no);
- emdm_pass_attrib_vertex_mat(&attribs, ltri[0], 0);
+ emdm_pass_attrib_vertex_glsl(&attribs, ltri[0], 0);
if (vertexCos) glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
else glVertex3fv(ltri[0]->v->co);
- emdm_pass_attrib_vertex_mat(&attribs, ltri[1], 1);
+ emdm_pass_attrib_vertex_glsl(&attribs, ltri[1], 1);
if (vertexCos) glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
else glVertex3fv(ltri[1]->v->co);
- emdm_pass_attrib_vertex_mat(&attribs, ltri[2], 2);
+ emdm_pass_attrib_vertex_glsl(&attribs, ltri[2], 2);
if (vertexCos) glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
else glVertex3fv(ltri[2]->v->co);
}
else {
- emdm_pass_attrib_vertex_mat(&attribs, ltri[0], 0);
+ emdm_pass_attrib_vertex_glsl(&attribs, ltri[0], 0);
if (vertexCos) {
glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
@@ -1129,7 +1121,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
glVertex3fv(ltri[0]->v->co);
}
- emdm_pass_attrib_vertex_mat(&attribs, ltri[1], 1);
+ emdm_pass_attrib_vertex_glsl(&attribs, ltri[1], 1);
if (vertexCos) {
glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
@@ -1139,7 +1131,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
glVertex3fv(ltri[1]->v->co);
}
- emdm_pass_attrib_vertex_mat(&attribs, ltri[2], 2);
+ emdm_pass_attrib_vertex_glsl(&attribs, ltri[2], 2);
if (vertexCos) {
glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
@@ -1241,7 +1233,8 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *r_vert)
return;
}
- ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */
+ BLI_assert((bm->elem_table_dirty & BM_VERT) == 0);
+ ev = bm->vtable[index]; /* should be BM_vert_at_index() */
// ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
bmvert_to_mvert(bm, ev, r_vert);
@@ -1263,7 +1256,10 @@ static void emDM_getVertCo(DerivedMesh *dm, int index, float r_co[3])
copy_v3_v3(r_co, bmdm->vertexCos[index]);
}
else {
- BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */
+ BMVert *ev;
+
+ BLI_assert((bm->elem_table_dirty & BM_VERT) == 0);
+ ev = bm->vtable[index]; /* should be BM_vert_at_index() */
// ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
copy_v3_v3(r_co, ev->co);
}
@@ -1285,7 +1281,10 @@ static void emDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
copy_v3_v3(r_no, bmdm->vertexNos[index]);
}
else {
- BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */
+ BMVert *ev;
+
+ BLI_assert((bm->elem_table_dirty & BM_VERT) == 0);
+ ev = bm->vtable[index]; /* should be BM_vert_at_index() */
// ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
copy_v3_v3(r_no, ev->no);
}
@@ -1306,7 +1305,10 @@ static void emDM_getPolyNo(DerivedMesh *dm, int index, float r_no[3])
copy_v3_v3(r_no, bmdm->polyNos[index]);
}
else {
- BMFace *efa = bmdm->em->face_index[index]; /* should be EDBM_vert_at_index() */
+ BMFace *efa;
+
+ BLI_assert((bm->elem_table_dirty & BM_FACE) == 0);
+ efa = bm->ftable[index]; /* should be BM_vert_at_index() */
// efa = BM_face_at_index(bm, index); /* warning, does list loop, _not_ ideal */
copy_v3_v3(r_no, efa->no);
}
@@ -1324,7 +1326,8 @@ static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *r_edge)
return;
}
- e = bmdm->em->edge_index[index]; /* should be EDBM_edge_at_index() */
+ BLI_assert((bm->elem_table_dirty & BM_EDGE) == 0);
+ e = bm->etable[index]; /* should be BM_edge_at_index() */
// e = BM_edge_at_index(bm, index); /* warning, does list loop, _not_ ideal */
r_edge->flag = BM_edge_flag_to_mflag(e);
@@ -1848,7 +1851,7 @@ static void statvis_calc_thickness(
BM_mesh_elem_index_ensure(bm, BM_VERT);
}
- bmtree = BKE_bmbvh_new(em, 0, vertexCos, false);
+ bmtree = BKE_bmbvh_new_from_editmesh(em, 0, vertexCos, false);
for (i = 0; i < tottri; i++) {
BMFace *f_hit;
@@ -1948,7 +1951,7 @@ static void statvis_calc_intersect(
BM_mesh_elem_index_ensure(bm, BM_VERT);
}
- bmtree = BKE_bmbvh_new(em, 0, vertexCos, false);
+ bmtree = BKE_bmbvh_new_from_editmesh(em, 0, vertexCos, false);
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
BMFace *f_hit;
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index 6a89d16d7bf..88cef0ec031 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -78,10 +78,6 @@ BMEditMesh *BKE_editmesh_copy(BMEditMesh *em)
* used.*/
em_copy->looptris = NULL;
- em_copy->vert_index = NULL;
- em_copy->edge_index = NULL;
- em_copy->face_index = NULL;
-
return em_copy;
}
@@ -106,9 +102,8 @@ BMEditMesh *BKE_editmesh_from_object(Object *ob)
static void editmesh_tessface_calc_intern(BMEditMesh *em)
{
- /* use this to avoid locking pthread for _every_ polygon
- * and calling the fill function */
-#define USE_TESSFACE_SPEEDUP
+ /* allocating space before calculating the tessellation */
+
BMesh *bm = em->bm;
@@ -118,13 +113,6 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em)
const int looptris_tot_prev_alloc = em->looptris ? (MEM_allocN_len(em->looptris) / sizeof(*em->looptris)) : 0;
BMLoop *(*looptris)[3];
- BMIter iter;
- BMFace *efa;
- BMLoop *l;
- int i = 0;
-
- ScanFillContext sf_ctx;
- MemArena *sf_arena = NULL;
#if 0
/* note, we could be clever and re-use this array but would need to ensure
@@ -140,7 +128,7 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em)
/* this means no reallocs for quad dominant models, for */
if ((em->looptris != NULL) &&
- /* (em->tottri >= looptris_tot)) */
+ /* (*em->tottri >= looptris_tot)) */
/* check against alloc'd size incase we over alloc'd a little */
((looptris_tot_prev_alloc >= looptris_tot) && (looptris_tot_prev_alloc <= looptris_tot * 2)))
{
@@ -153,136 +141,10 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em)
#endif
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- /* don't consider two-edged faces */
- if (UNLIKELY(efa->len < 3)) {
- /* do nothing */
- }
-
-#ifdef USE_TESSFACE_SPEEDUP
-
- /* no need to ensure the loop order, we know its ok */
-
- else if (efa->len == 3) {
-#if 0
- int j;
- BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) {
- looptris[i][j] = l;
- }
- i += 1;
-#else
- /* more cryptic but faster */
- BMLoop **l_ptr = looptris[i++];
- l_ptr[0] = l = BM_FACE_FIRST_LOOP(efa);
- l_ptr[1] = l = l->next;
- l_ptr[2] = l->next;
-#endif
- }
- else if (efa->len == 4) {
-#if 0
- BMLoop *ltmp[4];
- int j;
- BLI_array_grow_items(looptris, 2);
- BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) {
- ltmp[j] = l;
- }
-
- looptris[i][0] = ltmp[0];
- looptris[i][1] = ltmp[1];
- looptris[i][2] = ltmp[2];
- i += 1;
-
- looptris[i][0] = ltmp[0];
- looptris[i][1] = ltmp[2];
- looptris[i][2] = ltmp[3];
- i += 1;
-#else
- /* more cryptic but faster */
- BMLoop **l_ptr_a = looptris[i++];
- BMLoop **l_ptr_b = looptris[i++];
- (l_ptr_a[0] = l_ptr_b[0] = l = BM_FACE_FIRST_LOOP(efa));
- (l_ptr_a[1] = l = l->next);
- (l_ptr_a[2] = l_ptr_b[1] = l = l->next);
- ( l_ptr_b[2] = l->next);
-#endif
- }
-
-#endif /* USE_TESSFACE_SPEEDUP */
-
- else {
- int j;
- BMLoop *l_iter;
- BMLoop *l_first;
-
- ScanFillVert *sf_vert, *sf_vert_last = NULL, *sf_vert_first = NULL;
- /* ScanFillEdge *e; */ /* UNUSED */
- ScanFillFace *sf_tri;
- int totfilltri;
-
- if (UNLIKELY(sf_arena == NULL)) {
- sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
- }
-
- BLI_scanfill_begin_arena(&sf_ctx, sf_arena);
-
- /* scanfill time */
- j = 0;
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- sf_vert = BLI_scanfill_vert_add(&sf_ctx, l_iter->v->co);
- sf_vert->tmp.p = l_iter;
-
- if (sf_vert_last) {
- /* e = */ BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
- }
-
- sf_vert_last = sf_vert;
- if (sf_vert_first == NULL) {
- sf_vert_first = sf_vert;
- }
-
- /*mark order */
- BM_elem_index_set(l_iter, j++); /* set_loop */
-
- } while ((l_iter = l_iter->next) != l_first);
-
- /* complete the loop */
- BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert);
-
- totfilltri = BLI_scanfill_calc_ex(&sf_ctx, 0, efa->no);
- BLI_assert(totfilltri <= efa->len - 2);
- (void)totfilltri;
-
- for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) {
- BMLoop **l_ptr = looptris[i++];
- BMLoop *l1 = sf_tri->v1->tmp.p;
- BMLoop *l2 = sf_tri->v2->tmp.p;
- BMLoop *l3 = sf_tri->v3->tmp.p;
-
- if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); }
- if (BM_elem_index_get(l2) > BM_elem_index_get(l3)) { SWAP(BMLoop *, l2, l3); }
- if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); }
-
- l_ptr[0] = l1;
- l_ptr[1] = l2;
- l_ptr[2] = l3;
- }
-
- BLI_scanfill_end_arena(&sf_ctx, sf_arena);
- }
- }
-
- if (sf_arena) {
- BLI_memarena_free(sf_arena);
- sf_arena = NULL;
- }
-
- em->tottri = i;
em->looptris = looptris;
- BLI_assert(em->tottri <= looptris_tot);
-
-#undef USE_TESSFACE_SPEEDUP
+ /* after allocating the em->looptris, we're ready to tessellate */
+ BM_bmesh_calc_tessellation(em->bm, em->looptris, &em->tottri);
}
@@ -345,10 +207,6 @@ void BKE_editmesh_free(BMEditMesh *em)
if (em->looptris) MEM_freeN(em->looptris);
- if (em->vert_index) MEM_freeN(em->vert_index);
- if (em->edge_index) MEM_freeN(em->edge_index);
- if (em->face_index) MEM_freeN(em->face_index);
-
if (em->bm)
BM_mesh_free(em->bm);
}
diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c
index cb65fd80fc4..1c0e508e9e6 100644
--- a/source/blender/blenkernel/intern/editmesh_bvh.c
+++ b/source/blender/blenkernel/intern/editmesh_bvh.c
@@ -44,7 +44,9 @@
struct BMBVHTree {
BVHTree *tree;
- BMEditMesh *em;
+ BMLoop *(*looptris)[3];
+ int looptris_tot;
+
BMesh *bm;
const float (*cos_cage)[3];
@@ -53,33 +55,39 @@ struct BMBVHTree {
int flag;
};
-BMBVHTree *BKE_bmbvh_new(BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free)
+BMBVHTree *BKE_bmbvh_new_from_editmesh(BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free)
+{
+ return BKE_bmbvh_new(em->bm, em->looptris, em->tottri, flag, cos_cage, cos_cage_free);
+}
+
+BMBVHTree *BKE_bmbvh_new(BMesh *bm, BMLoop *(*looptris)[3], int looptris_tot, int flag, const float (*cos_cage)[3],
+const bool cos_cage_free)
{
/* could become argument */
const float epsilon = FLT_EPSILON * 2.0f;
- struct BMLoop *(*looptris)[3] = em->looptris;
BMBVHTree *bmtree = MEM_callocN(sizeof(*bmtree), "BMBVHTree");
float cos[3][3];
int i;
int tottri;
/* BKE_editmesh_tessface_calc() must be called already */
- BLI_assert(em->tottri != 0 || em->bm->totface == 0);
+ BLI_assert(looptris_tot != 0 || bm->totface == 0);
if (cos_cage) {
- BM_mesh_elem_index_ensure(em->bm, BM_VERT);
+ BM_mesh_elem_index_ensure(bm, BM_VERT);
}
- bmtree->em = em;
- bmtree->bm = em->bm;
+ bmtree->looptris = looptris;
+ bmtree->looptris_tot = looptris_tot;
+ bmtree->bm = bm;
bmtree->cos_cage = cos_cage;
bmtree->cos_cage_free = cos_cage_free;
bmtree->flag = flag;
if (flag & (BMBVH_RESPECT_SELECT)) {
tottri = 0;
- for (i = 0; i < em->tottri; i++) {
+ for (i = 0; i < looptris_tot; i++) {
if (BM_elem_flag_test(looptris[i][0]->f, BM_ELEM_SELECT)) {
tottri++;
}
@@ -87,23 +95,23 @@ BMBVHTree *BKE_bmbvh_new(BMEditMesh *em, int flag, const float (*cos_cage)[3], c
}
else if (flag & (BMBVH_RESPECT_HIDDEN)) {
tottri = 0;
- for (i = 0; i < em->tottri; i++) {
+ for (i = 0; i < looptris_tot; i++) {
if (!BM_elem_flag_test(looptris[i][0]->f, BM_ELEM_HIDDEN)) {
tottri++;
}
}
}
else {
- tottri = em->tottri;
+ tottri = looptris_tot;
}
bmtree->tree = BLI_bvhtree_new(tottri, epsilon, 8, 8);
- for (i = 0; i < em->tottri; i++) {
+ for (i = 0; i < looptris_tot; i++) {
if (flag & BMBVH_RESPECT_SELECT) {
/* note, the arrays wont align now! take care */
- if (!BM_elem_flag_test(em->looptris[i][0]->f, BM_ELEM_SELECT)) {
+ if (!BM_elem_flag_test(looptris[i][0]->f, BM_ELEM_SELECT)) {
continue;
}
}
@@ -231,14 +239,14 @@ BMFace *BKE_bmbvh_ray_cast(BMBVHTree *bmtree, const float co[3], const float dir
hit.index = -1;
/* ok to leave 'uv' uninitialized */
- bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->em->looptris;
+ bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->looptris;
bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage;
BLI_bvhtree_ray_cast(bmtree->tree, co, dir, radius, &hit, bmbvh_ray_cast_cb, &bmcb_data);
if (hit.index != -1 && hit.dist != dist) {
if (r_hitout) {
if (bmtree->flag & BMBVH_RETURN_ORIG) {
- BMLoop **ltri = bmtree->em->looptris[hit.index];
+ BMLoop **ltri = bmtree->looptris[hit.index];
interp_v3_v3v3v3_uv(r_hitout, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co, bmcb_data.uv);
}
else {
@@ -254,7 +262,7 @@ BMFace *BKE_bmbvh_ray_cast(BMBVHTree *bmtree, const float co[3], const float dir
*r_dist = hit.dist;
}
- return bmtree->em->looptris[hit.index][0]->f;
+ return bmtree->looptris[hit.index][0]->f;
}
return NULL;
@@ -327,7 +335,7 @@ BMFace *BKE_bmbvh_find_face_segment(BMBVHTree *bmtree, const float co_a[3], cons
hit.index = -1;
/* ok to leave 'uv' uninitialized */
- bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->em->looptris;
+ bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->looptris;
bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage;
bmcb_data.co_a = co_a;
bmcb_data.co_b = co_b;
@@ -337,7 +345,7 @@ BMFace *BKE_bmbvh_find_face_segment(BMBVHTree *bmtree, const float co_a[3], cons
/* duplicate of BKE_bmbvh_ray_cast() */
if (r_hitout) {
if (bmtree->flag & BMBVH_RETURN_ORIG) {
- BMLoop **ltri = bmtree->em->looptris[hit.index];
+ BMLoop **ltri = bmtree->looptris[hit.index];
interp_v3_v3v3v3_uv(r_hitout, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co, bmcb_data.uv);
}
else {
@@ -354,7 +362,7 @@ BMFace *BKE_bmbvh_find_face_segment(BMBVHTree *bmtree, const float co_a[3], cons
*r_fac = hit.dist / dist;
}
- return bmtree->em->looptris[hit.index][0]->f;
+ return bmtree->looptris[hit.index][0]->f;
}
return NULL;
@@ -410,13 +418,13 @@ BMVert *BKE_bmbvh_find_vert_closest(BMBVHTree *bmtree, const float co[3], const
hit.dist = maxdist_sq;
hit.index = -1;
- bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->em->looptris;
+ bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->looptris;
bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage;
bmcb_data.maxdist = maxdist_sq;
BLI_bvhtree_find_nearest(bmtree->tree, co, &hit, bmbvh_find_vert_closest_cb, &bmcb_data);
if (hit.index != -1) {
- BMLoop **ltri = bmtree->em->looptris[hit.index];
+ BMLoop **ltri = bmtree->looptris[hit.index];
return ltri[bmcb_data.index_tri]->v;
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index dbdf30ea63d..a40d7401566 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -2139,11 +2139,39 @@ float evaluate_fcurve(FCurve *fcu, float evaltime)
/* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime"
* since drivers essentially act as alternative input (i.e. in place of 'time') for F-Curves
- * - this value will also be returned as the value of the 'curve', if there are no keyframes
*/
if (fcu->driver) {
/* evaltime now serves as input for the curve */
- evaltime = cvalue = evaluate_driver(fcu->driver, evaltime);
+ evaltime = evaluate_driver(fcu->driver, evaltime);
+
+ /* only do a default 1-1 mapping if it's unlikely that anything else will set a value... */
+ if (fcu->totvert == 0) {
+ FModifier *fcm;
+ bool do_linear = true;
+
+ /* out-of-range F-Modifiers will block, as will those which just plain overwrite the values
+ * XXX: additive is a bit more dicey; it really depends then if things are in range or not...
+ */
+ for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
+ /* if there are range-restrictions, we must definitely block [#36950] */
+ if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
+ ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
+ {
+ /* within range: here it probably doesn't matter, though we'd want to check on additive... */
+ }
+ else {
+ /* outside range: modifier shouldn't contribute to the curve here, though it does in other areas,
+ * so neither should the driver!
+ */
+ do_linear = false;
+ }
+ }
+
+ /* only copy over results if none of the modifiers disagreed with this */
+ if (do_linear) {
+ cvalue = evaltime;
+ }
+ }
}
/* evaluate modifiers which modify time to evaluate the base curve at */
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index f24d84df2e8..f489adc7445 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -315,25 +315,13 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
MEM_freeN(nu2);
return;
}
- nu2->bp = bp;
- nu2->bp[0].vec[0] = x1;
- nu2->bp[0].vec[1] = y1;
- nu2->bp[0].vec[2] = 0;
- nu2->bp[0].vec[3] = 1.0f;
- nu2->bp[1].vec[0] = x2;
- nu2->bp[1].vec[1] = y1;
- nu2->bp[1].vec[2] = 0;
- nu2->bp[1].vec[3] = 1.0f;
- nu2->bp[2].vec[0] = x2;
- nu2->bp[2].vec[1] = y2;
- nu2->bp[2].vec[2] = 0;
- nu2->bp[2].vec[3] = 1.0f;
- nu2->bp[3].vec[0] = x1;
- nu2->bp[3].vec[1] = y2;
- nu2->bp[3].vec[2] = 0;
- nu2->bp[3].vec[3] = 1.0f;
-
+ copy_v4_fl4(bp[0].vec, x1, y1, 0.0f, 1.0f);
+ copy_v4_fl4(bp[1].vec, x2, y1, 0.0f, 1.0f);
+ copy_v4_fl4(bp[2].vec, x2, y2, 0.0f, 1.0f);
+ copy_v4_fl4(bp[3].vec, x1, y2, 0.0f, 1.0f);
+
+ nu2->bp = bp;
BLI_addtail(&(cu->nurb), nu2);
}
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 4d17bd286b4..42e146301a2 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -38,6 +38,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
#include "BLF_translation.h"
@@ -182,7 +183,7 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, int setactive)
BLI_addtail(&gpd->layers, gpl);
/* set basic settings */
- gpl->color[3] = 0.9f;
+ copy_v4_v4(gpl->color, U.gpencil_new_layer_col);
gpl->thickness = 3;
/* auto-name */
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 6f275e4ec75..594c918b4c2 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -641,7 +641,7 @@ int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew)
* IDP_FreeProperty(prop); //free all subdata
* MEM_freeN(prop); //free property struct itself
*/
-void IDP_RemFromGroup(IDProperty *group, IDProperty *prop)
+void IDP_RemoveFromGroup(IDProperty *group, IDProperty *prop)
{
BLI_assert(group->type == IDP_GROUP);
@@ -649,6 +649,16 @@ void IDP_RemFromGroup(IDProperty *group, IDProperty *prop)
BLI_remlink(&group->data.group, prop);
}
+/**
+ * Removes the property from the group and frees it.
+ */
+void IDP_FreeFromGroup(IDProperty *group, IDProperty *prop)
+{
+ IDP_RemoveFromGroup(group, prop);
+ IDP_FreeProperty(prop);
+ MEM_freeN(prop);
+}
+
IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
{
BLI_assert(prop->type == IDP_GROUP);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 01b41eb22cd..6a411f8c308 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -191,17 +191,21 @@ void BKE_image_de_interlace(Image *ima, int odd)
/* ***************** ALLOC & FREE, DATA MANAGING *************** */
-static void image_free_buffers(Image *ima)
+static void image_free_cahced_frames(Image *image)
{
ImBuf *ibuf;
-
- while ((ibuf = BLI_pophead(&ima->ibufs))) {
+ while ((ibuf = BLI_pophead(&image->ibufs))) {
if (ibuf->userdata) {
MEM_freeN(ibuf->userdata);
ibuf->userdata = NULL;
}
IMB_freeImBuf(ibuf);
}
+}
+
+static void image_free_buffers(Image *ima)
+{
+ image_free_cahced_frames(ima);
if (ima->anim) IMB_free_anim(ima->anim);
ima->anim = NULL;
@@ -2237,7 +2241,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
#else
/* image buffers for non-sequence multilayer will share buffers with RenderResult,
* however sequence multilayer will own buffers. Such logic makes switching from
- * single multilayer file to sequence completely instable
+ * single multilayer file to sequence completely unstable
* since changes in nodes seems this workaround isn't needed anymore, all sockets
* are nicely detecting anyway, but freeing buffers always here makes multilayer
* sequences behave stable
@@ -2505,26 +2509,22 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f
/* check for new RenderResult */
if (ima->rr == NULL || frame != ima->rr->framenr) {
- /* copy to survive not found multilayer image */
- RenderResult *oldrr = ima->rr;
+ if (ima->rr) {
+ /* Cached image buffers shares pointers with render result,
+ * need to ensure there's no image buffers are hanging around
+ * with dead links after freeing the render result.
+ */
+ image_free_cahced_frames(ima);
+ RE_FreeRenderResult(ima->rr);
+ ima->rr = NULL;
+ }
- ima->rr = NULL;
ibuf = image_load_sequence_file(ima, iuser, frame);
if (ibuf) { /* actually an error */
ima->type = IMA_TYPE_IMAGE;
printf("error, multi is normal image\n");
}
- // printf("loaded new result %p\n", ima->rr);
- /* free result if new one found */
- if (ima->rr) {
- // if (oldrr) printf("freed previous result %p\n", oldrr);
- if (oldrr) RE_FreeRenderResult(oldrr);
- }
- else {
- ima->rr = oldrr;
- }
-
}
if (ima->rr) {
RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser);
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index ecc4a03d255..8ef3b7ef23d 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -712,17 +712,6 @@ static const char *world_adrcodes_to_paths(int adrcode, int *array_index)
return "mist.start";
case WO_MISTHI:
return "mist.height";
-
- case WO_STAR_R:
- case WO_STAR_G:
- case WO_STAR_B:
- printf("WARNING: WO_STAR_R/G/B deprecated\n");
- return NULL;
-
- case WO_STARDIST:
- return "stars.min_distance";
- case WO_STARSIZE:
- return "stars.size";
default: /* for now, we assume that the others were MTex channels */
return mtex_adrcodes_to_paths(adrcode, array_index);
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index c856d8cfea4..b20b4294f84 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -462,7 +462,7 @@ void BKE_mask_point_handle(MaskSplinePoint *point, float handle[2])
handle[1] = (point->bezt.vec[1][1] - vec[0]);
}
-void BKE_mask_point_set_handle(MaskSplinePoint *point, float loc[2], int keep_direction,
+void BKE_mask_point_set_handle(MaskSplinePoint *point, float loc[2], bool keep_direction,
float orig_handle[2], float orig_vec[3][3])
{
BezTriple *bezt = &point->bezt;
@@ -1443,7 +1443,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline)
}
}
-void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do_newframe)
+void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool do_newframe)
{
/* animation if available */
if (do_newframe) {
@@ -1521,7 +1521,7 @@ void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do
}
}
-void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe)
+void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)
{
MaskLayer *masklay;
@@ -1562,10 +1562,10 @@ void BKE_mask_update_display(Mask *mask, float ctime)
}
#endif
- BKE_mask_evaluate(mask, ctime, FALSE);
+ BKE_mask_evaluate(mask, ctime, false);
}
-void BKE_mask_evaluate_all_masks(Main *bmain, float ctime, const int do_newframe)
+void BKE_mask_evaluate_all_masks(Main *bmain, float ctime, const bool do_newframe)
{
Mask *mask;
@@ -1772,7 +1772,7 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, const float frame,
}
}
-MaskLayerShape *BKE_mask_layer_shape_varify_frame(MaskLayer *masklay, const int frame)
+MaskLayerShape *BKE_mask_layer_shape_verify_frame(MaskLayer *masklay, const int frame)
{
MaskLayerShape *masklay_shape;
@@ -1835,8 +1835,8 @@ void BKE_mask_layer_shape_sort(MaskLayer *masklay)
BLI_sortlist(&masklay->splines_shapes, mask_layer_shape_sort_cb);
}
-int BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay, int index,
- MaskSpline **r_masklay_shape, int *r_index)
+bool BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay, int index,
+ MaskSpline **r_masklay_shape, int *r_index)
{
MaskSpline *spline;
@@ -1844,12 +1844,12 @@ int BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay, int index,
if (index < spline->tot_point) {
*r_masklay_shape = spline;
*r_index = index;
- return TRUE;
+ return true;
}
index -= spline->tot_point;
}
- return FALSE;
+ return false;
}
int BKE_mask_layer_shape_spline_to_index(MaskLayer *masklay, MaskSpline *spline)
@@ -1891,7 +1891,7 @@ static void interp_weights_uv_v2_apply(const float uv[2], float r_pt[2], const f
/* when a new points added - resize all shapekey array */
void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, int index,
- int do_init, int do_init_interpolate)
+ bool do_init, bool do_init_interpolate)
{
MaskLayerShape *masklay_shape;
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index a4b59153e2b..83c257dbd56 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -1637,22 +1637,6 @@ static void polygonize(PROCESS *process, MetaBall *mb)
}
}
-/* could move to math api */
-BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z)
-{
- v[0] = x;
- v[1] = y;
- v[2] = z;
-}
-
-/* TODO(sergey): Perhaps it could be general utility function in mathutils. */
-static bool has_zero_axis_m4(float matrix[4][4])
-{
- return len_squared_v3(matrix[0]) < FLT_EPSILON ||
- len_squared_v3(matrix[1]) < FLT_EPSILON ||
- len_squared_v3(matrix[2]) < FLT_EPSILON;
-}
-
static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return totsize */
{
Scene *sce_iter = scene;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index a77f768835a..e6fca21f2af 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -708,26 +708,32 @@ bool BKE_mesh_uv_cdlayer_rename(Mesh *me, const char *old_name, const char *new_
return false;
}
else {
- lidx = lidx_start + (fidx - fidx_start);
+ lidx = fidx;
}
}
- pidx = pidx_start + (lidx - lidx_start);
+ pidx = lidx;
}
else {
if (lidx == -1) {
- lidx = lidx_start + (pidx - pidx_start);
+ lidx = pidx;
}
if (fidx == -1 && do_tessface) {
- fidx = fidx_start + (pidx - pidx_start);
+ fidx = pidx;
}
}
#if 0
/* For now, we do not consider mismatch in indices (i.e. same name leading to (relative) different indices). */
- else if ((pidx - pidx_start) != (lidx - lidx_start)) {
- lidx = lidx_start + (pidx - pidx_start);
+ else if (pidx != lidx) {
+ lidx = pidx;
}
#endif
+ /* Go back to absolute indices! */
+ pidx += pidx_start;
+ lidx += lidx_start;
+ if (fidx != -1)
+ fidx += fidx_start;
+
return BKE_mesh_uv_cdlayer_rename_index(me, pidx, lidx, fidx, new_name, do_tessface);
}
}
@@ -1345,6 +1351,8 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu;
/* cyclic correction */
+ if ((i == 1 || i == 2) && mloopuv->uv[0] == 0.0f)
+ mloopuv->uv[0] = 1.0f;
if ((i == 0 || i == 1) && mloopuv->uv[1] == 0.0f)
mloopuv->uv[1] = 1.0f;
}
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 47b8e053bf7..1e74ce23c2c 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -379,7 +379,8 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdg
if ((e2l[0] | e2l[1]) == 0) {
/* 'Empty' edge until now, set e2l[0] (and e2l[1] to INDEX_UNSET to tag it as unset). */
e2l[0] = ml_curr_index;
- e2l[1] = INDEX_UNSET;
+ /* We have to check this here too, else we might miss some flat faces!!! */
+ e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID;
}
else if (e2l[1] == INDEX_UNSET) {
/* Second loop using this edge, time to test its sharpness.
@@ -945,7 +946,7 @@ bool BKE_mesh_center_centroid(Mesh *me, float cent[3])
* \{ */
-/* ngon version wip, based on EDBM_uv_vert_map_create */
+/* ngon version wip, based on BM_uv_vert_map_create */
/* this replaces the non bmesh function (in trunk) which takes MTFace's, if we ever need it back we could
* but for now this replaces it because its unused. */
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 1c9576d74d0..a4f5529ee43 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -922,7 +922,7 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata,
{
bool is_valid = true;
bool is_change_v, is_change_e, is_change_l, is_change_p;
- int tot_texpoly, tot_uvloop;
+ int tot_texpoly, tot_uvloop, tot_vcolloop;
CustomDataMask mask = check_meshmask ? CD_MASK_MESH : 0;
is_valid &= mesh_validate_customdata(vdata, mask, do_verbose, do_fixes, &is_change_v);
@@ -932,10 +932,23 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata,
tot_texpoly = CustomData_number_of_layers(pdata, CD_MTEXPOLY);
tot_uvloop = CustomData_number_of_layers(ldata, CD_MLOOPUV);
+ tot_vcolloop = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
if (tot_texpoly != tot_uvloop) {
PRINT_ERR("\tCustomDataLayer mismatch, tot_texpoly(%d), tot_uvloop(%d)\n",
tot_texpoly, tot_uvloop);
}
+ if (tot_texpoly > MAX_MTFACE) {
+ PRINT_ERR("\tMore UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n",
+ MAX_MTFACE, tot_texpoly - MAX_MTFACE);
+ }
+ if (tot_uvloop > MAX_MTFACE) {
+ PRINT_ERR("\tMore UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n",
+ MAX_MTFACE, tot_uvloop - MAX_MTFACE);
+ }
+ if (tot_vcolloop > MAX_MCOL) {
+ PRINT_ERR("\tMore VCol layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n",
+ MAX_MCOL, tot_vcolloop - MAX_MCOL);
+ }
*r_change = (is_change_v || is_change_e || is_change_l || is_change_p);
@@ -989,10 +1002,25 @@ void BKE_mesh_cd_validate(Mesh *me)
{
int totlayer_mtex = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
int totlayer_uv = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
+ int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
int mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY);
int uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV);
int i;
+ /* XXX For now, do not delete those, just warn they are not really usable. */
+ if (UNLIKELY(totlayer_mtex > MAX_MTFACE)) {
+ printf("WARNING! More UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n",
+ MAX_MTFACE, totlayer_mtex - MAX_MTFACE);
+ }
+ if (UNLIKELY(totlayer_uv > MAX_MTFACE)) {
+ printf("WARNING! More UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n",
+ MAX_MTFACE, totlayer_uv - MAX_MTFACE);
+ }
+ if (UNLIKELY(totlayer_mcol > MAX_MCOL)) {
+ printf("WARNING! More VCol layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n",
+ MAX_MCOL, totlayer_mcol - MAX_MCOL);
+ }
+
if (LIKELY(totlayer_mtex == totlayer_uv)) {
/* pass */
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index c0df306a3fa..869dbe032c9 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -959,9 +959,6 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
{
bNodeLink *link, *link_next;
- if (node->internal_links.first == NULL)
- return;
-
/* store link pointers in output sockets, for efficient lookup */
for (link = node->internal_links.first; link; link = link->next)
link->tosock->link = link;
@@ -1675,8 +1672,8 @@ static void free_localized_node_groups(bNodeTree *ntree)
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP && node->id) {
bNodeTree *ngroup = (bNodeTree *)node->id;
- if (BLI_findindex(&G.main->nodetree, ngroup) == -1) {
- /* ntree is not in library, i.e. localized node group: free it */
+ if (ngroup->flag & NTREE_IS_LOCALIZED) {
+ /* ntree is a localized copy: free it */
ntreeFreeTree_ex(ngroup, false);
MEM_freeN(ngroup);
}
@@ -1963,6 +1960,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
* Note: previews are not copied here.
*/
ltree = ntreeCopyTree_internal(ntree, NULL, FALSE, FALSE, FALSE);
+ ltree->flag |= NTREE_IS_LOCALIZED;
for (node = ltree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP && node->id) {
@@ -3091,14 +3089,14 @@ void nodeSynchronizeID(bNode *node, bool copy_to_id)
/* ************* node type access ********** */
-const char *nodeLabel(bNode *node)
+void nodeLabel(bNodeTree *ntree, bNode *node, char *label, int maxlen)
{
if (node->label[0] != '\0')
- return node->label;
+ BLI_strncpy(label, node->label, maxlen);
else if (node->typeinfo->labelfunc)
- return node->typeinfo->labelfunc(node);
+ node->typeinfo->labelfunc(ntree, node, label, maxlen);
else
- return IFACE_(node->typeinfo->ui_name);
+ BLI_strncpy(label, IFACE_(node->typeinfo->ui_name), maxlen);
}
static void node_type_base_defaults(bNodeType *ntype)
@@ -3269,7 +3267,7 @@ void node_type_storage(bNodeType *ntype,
ntype->freefunc = freefunc;
}
-void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *))
+void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen))
{
ntype->labelfunc = labelfunc;
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8c2475369de..45d9d144f55 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <math.h>
-#include <stdio.h>
+#include <stdio.h>
#include "MEM_guardedalloc.h"
@@ -194,6 +194,28 @@ void BKE_object_free_modifiers(Object *ob)
BKE_object_free_softbody(ob);
}
+void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd)
+{
+ /* reset functionality */
+ if (hmd->object) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget);
+
+ if (hmd->subtarget[0] && pchan) {
+ float imat[4][4], mat[4][4];
+
+ /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
+ mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
+
+ invert_m4_m4(imat, mat);
+ mul_m4_m4m4(hmd->parentinv, imat, ob->obmat);
+ }
+ else {
+ invert_m4_m4(hmd->object->imat, hmd->object->obmat);
+ mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat);
+ }
+ }
+}
+
bool BKE_object_support_modifier_type_check(Object *ob, int modifier_type)
{
ModifierTypeInfo *mti;
@@ -234,6 +256,11 @@ void BKE_object_link_modifiers(struct Object *ob_dst, struct Object *ob_src)
if (!BKE_object_support_modifier_type_check(ob_dst, md->type))
continue;
+
+ if (md->type == eModifierType_Skin) {
+ /* ensure skin-node customdata exists */
+ modifier_skin_customdata_ensure(ob_dst);
+ }
nmd = modifier_new(md->type);
BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
@@ -568,6 +595,9 @@ void BKE_object_unlink(Object *ob)
}
}
}
+
+ if (tpsys->parent == ob)
+ tpsys->parent = NULL;
}
if (ob->pd)
DAG_id_tag_update(&obt->id, OB_RECALC_DATA);
@@ -1277,6 +1307,11 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches)
obn->mode = 0;
obn->sculpt = NULL;
+ /* Proxies are not to be copied. */
+ obn->proxy_from = NULL;
+ obn->proxy_group = NULL;
+ obn->proxy = NULL;
+
/* increase user numbers */
id_us_plus((ID *)obn->data);
id_us_plus((ID *)obn->gpd);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 526d54a97fa..41217110cd8 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2006,6 +2006,12 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->lifetime = 100.0f;
}
else {
+ /* initialize the lifetime, in case the texture coordinates
+ * are from Particles/Strands, which would cause undefined values
+ */
+ pa->lifetime = part->lifetime * (1.0f - part->randlife * PSYS_FRAND(p + 21));
+ pa->dietime = pa->time + pa->lifetime;
+
/* get possible textural influence */
psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra);
@@ -2844,10 +2850,10 @@ static void sphclassical_force_cb(void *sphdata_v, ParticleKey *state, float *fo
continue;
}
- /* Find vector to neighbour. Exclude particles that are more than 2h
+ /* Find vector to neighbor. Exclude particles that are more than 2h
* away. Can't use current state here because it may have changed on
* another thread - so do own mini integration. Unlike basic_integrate,
- * SPH integration depends on neighbouring particles. - z0r */
+ * SPH integration depends on neighboring particles. - z0r */
madd_v3_v3v3fl(co, npa->prev_state.co, npa->prev_state.vel, state->time);
sub_v3_v3v3(vec, co, state->co);
rij = normalize_v3(vec);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 45a29f6cc90..c9822600fe7 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1283,6 +1283,11 @@ void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node)
node->flag |= PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw;
}
+void BKE_pbvh_node_mark_redraw(PBVHNode *node)
+{
+ node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw;
+}
+
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden)
{
BLI_assert(node->flag & PBVH_Leaf);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 334ef9b2d3d..381237f713c 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1426,7 +1426,7 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
}
}
-/* Used when cancelling transforms - return rigidbody and object to initial states */
+/* Used when canceling transforms - return rigidbody and object to initial states */
void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle)
{
RigidBodyOb *rbo = ob->rigidbody_object;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 41e43c00457..985eae18570 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -157,6 +157,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
lb = scen->r.layers;
scen->r = sce->r;
scen->r.layers = lb;
+ scen->r.actlay = 0;
scen->unit = sce->unit;
scen->physics_settings = sce->physics_settings;
scen->gm = sce->gm;
@@ -443,7 +444,6 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
sce->r.blurfac = 0.5;
sce->r.frs_sec = 24;
sce->r.frs_sec_base = 1;
- sce->r.edgeint = 10;
sce->r.ocres = 128;
/* OCIO_TODO: for forwards compatibility only, so if no tonecurve are used,
@@ -503,6 +503,8 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
sce->toolsettings->normalsize = 0.1;
sce->toolsettings->autokey_mode = U.autokey_mode;
+ sce->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
+
sce->toolsettings->skgen_resolution = 100;
sce->toolsettings->skgen_threshold_internal = 0.01f;
sce->toolsettings->skgen_threshold_external = 0.01f;
@@ -874,18 +876,35 @@ Object *BKE_scene_camera_switch_find(Scene *scene)
TimeMarker *m;
int cfra = scene->r.cfra;
int frame = -(MAXFRAME + 1);
+ int min_frame = MAXFRAME + 1;
Object *camera = NULL;
+ Object *first_camera = NULL;
for (m = scene->markers.first; m; m = m->next) {
- if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0 && (m->frame <= cfra) && (m->frame > frame)) {
- camera = m->camera;
- frame = m->frame;
+ if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0) {
+ if ((m->frame <= cfra) && (m->frame > frame)) {
+ camera = m->camera;
+ frame = m->frame;
- if (frame == cfra)
- break;
+ if (frame == cfra)
+ break;
+ }
+ if (m->frame < min_frame) {
+ first_camera = m->camera;
+ min_frame = m->frame;
+ }
}
}
+
+ if (camera == NULL) {
+ /* If there's no marker to the left of current frame,
+ * use camera from left-most marker to solve all sort
+ * of Schrodinger uncertainties.
+ */
+ return first_camera;
+ }
+
return camera;
}
#endif
@@ -1285,7 +1304,7 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
* so don't call within 'scene_update_tagged_recursive' */
DAG_scene_update_flags(bmain, sce, lay, TRUE); // only stuff that moves or needs display still
- BKE_mask_evaluate_all_masks(bmain, ctime, TRUE);
+ BKE_mask_evaluate_all_masks(bmain, ctime, true);
/* All 'standard' (i.e. without any dependencies) animation is handled here,
* with an 'local' to 'macro' order of evaluation. This should ensure that
@@ -1484,16 +1503,6 @@ void BKE_scene_disable_color_management(Scene *scene)
int BKE_scene_check_color_management_enabled(const Scene *scene)
{
- /* TODO(sergey): shouldn't be needed. but we're currently far to close to the release,
- * so better be extra-safe than sorry.
- *
- * Will remove the check after the release.
- */
- if (!scene) {
- BLI_assert(!"Shouldn't happen!");
- return TRUE;
- }
-
return strcmp(scene->display_settings.display_device, "None") != 0;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index dd7e847feaf..49b237fc3ea 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -463,6 +463,7 @@ void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_
if (!STREQ(float_colorspace, to_colorspace)) {
IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
from_colorspace, to_colorspace, true);
+ sequencer_imbuf_assign_spaces(scene, ibuf);
}
}
}
@@ -1854,7 +1855,6 @@ void BKE_sequencer_color_balance_apply(StripColorBalance *cb, ImBuf *ibuf, float
init_data.cb = cb;
init_data.ibuf = ibuf;
init_data.mul = mul;
- init_data.mask = NULL;
init_data.make_float = make_float;
init_data.mask = mask_input;
@@ -2342,7 +2342,7 @@ static ImBuf *seq_render_mask(SeqRenderData context, Mask *mask, float nr, short
mask_temp = BKE_mask_copy_nolib(mask);
- BKE_mask_evaluate(mask_temp, mask->sfra + nr, TRUE);
+ BKE_mask_evaluate(mask_temp, mask->sfra + nr, true);
maskbuf = MEM_mallocN(sizeof(float) * context.rectx * context.recty, __func__);
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 5c9c564998e..3a6912157fd 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -136,7 +136,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
nearest.index = -1;
nearest.dist = FLT_MAX;
#ifndef __APPLE__
-#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static)
+#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData, calc) schedule(static)
#endif
for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
@@ -331,7 +331,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
{
#ifndef __APPLE__
-#pragma omp parallel for private(i,hit) schedule(static)
+#pragma omp parallel for private(i, hit) schedule(static)
#endif
for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
@@ -441,7 +441,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
/* Find the nearest vertex */
#ifndef __APPLE__
-#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static)
+#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc, treeData) schedule(static)
#endif
for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index fb0e22abf2a..23f7dd6ccfb 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -84,6 +84,7 @@
#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_smoke.h"
+#include "BKE_texture.h"
#include "RE_shader_ext.h"
@@ -275,21 +276,21 @@ static void smoke_set_domain_from_derivedmesh(SmokeDomainSettings *sds, Object *
/* define grid resolutions from longest domain side */
if (size[0] >= MAX2(size[1], size[2])) {
scale = res / size[0];
- sds->scale = size[0] / fabs(ob->size[0]);
+ sds->scale = size[0] / fabsf(ob->size[0]);
sds->base_res[0] = res;
sds->base_res[1] = (int)(size[1] * scale + 0.5f);
sds->base_res[2] = (int)(size[2] * scale + 0.5f);
}
else if (size[1] >= MAX2(size[0], size[2])) {
scale = res / size[1];
- sds->scale = size[1] / fabs(ob->size[1]);
+ sds->scale = size[1] / fabsf(ob->size[1]);
sds->base_res[0] = (int)(size[0] * scale + 0.5f);
sds->base_res[1] = res;
sds->base_res[2] = (int)(size[2] * scale + 0.5f);
}
else {
scale = res / size[2];
- sds->scale = size[2] / fabs(ob->size[2]);
+ sds->scale = size[2] / fabsf(ob->size[2]);
sds->base_res[0] = (int)(size[0] * scale + 0.5f);
sds->base_res[1] = (int)(size[1] * scale + 0.5f);
sds->base_res[2] = res;
@@ -1108,7 +1109,7 @@ static void em_freeData(EmissionMap *em)
static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int hires_multiplier, int additive, float sample_size)
{
- int i, x,y,z;
+ int i, x, y, z;
/* copyfill input 1 struct and clear output for new allocation */
EmissionMap em1;
@@ -1226,7 +1227,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
float solid = sfs->particle_size * 0.5f;
float smooth = 0.5f; /* add 0.5 cells of linear falloff to reduce aliasing */
int hires_multiplier = 1;
- int i,z;
+ int i, z;
KDTree *tree;
sim.scene = scene;
@@ -1337,7 +1338,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
float hr = 1.0f / ((float)hires_multiplier);
/* slightly adjust high res antialias smoothness based on number of divisions
* to allow smaller details but yet not differing too much from the low res size */
- float hr_smooth = smooth * pow(hr, 1.0f/3.0f);
+ const float hr_smooth = smooth * powf(hr, 1.0f / 3.0f);
/* setup loop bounds */
for (i = 0; i < 3; i++) {
@@ -1418,27 +1419,6 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
}
}
-/* TODO(sergey): de-duplicate with get_texture_value from modifier utils */
-/* NOTE: Skips color management, because result is only used for value now, not for color. */
-static void get_texture_value(Tex *texture, float tex_co[3], TexResult *texres)
-{
- int result_type;
-
- /* no node textures for now */
- result_type = multitex_ext_safe(texture, tex_co, texres, NULL, false);
-
- /* if the texture gave an RGB value, we assume it didn't give a valid
- * intensity, since this is in the context of modifiers don't use perceptual color conversion.
- * if the texture didn't give an RGB value, copy the intensity across
- */
- if (result_type & TEX_RGB) {
- texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
- }
- else {
- copy_v3_fl(&texres->tr, texres->tin);
- }
-}
-
static void sample_derivedmesh(SmokeFlowSettings *sfs, MVert *mvert, MTFace *tface, MFace *mface, float *influence_map, float *velocity_map, int index, int base_res[3], float flow_center[3], BVHTreeFromMesh *treeData, float ray_start[3],
float *vert_vel, int has_velocity, int defgrp_index, MDeformVert *dvert, float x, float y, float z)
{
@@ -1550,7 +1530,7 @@ static void sample_derivedmesh(SmokeFlowSettings *sfs, MVert *mvert, MTFace *tfa
tex_co[2] = sfs->texture_offset;
}
texres.nor = NULL;
- get_texture_value(sfs->noise_texture, tex_co, &texres);
+ BKE_texture_get_value(NULL, sfs->noise_texture, tex_co, &texres, false);
sample_str *= texres.tin;
}
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 9a38a5f87b8..900d92d1637 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1817,6 +1817,64 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
}
}
+static void ccgdm_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
+{
+ const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ int b;
+
+ /* orco texture coordinates */
+ if (attribs->totorco) {
+ /*const*/ float (*array)[3] = attribs->orco.array;
+ const float *orco = (array) ? array[index] : zero;
+
+ if (attribs->orco.gl_texco)
+ glTexCoord3fv(orco);
+ else
+ glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
+ }
+
+ /* uv texture coordinates */
+ for (b = 0; b < attribs->tottface; b++) {
+ const float *uv;
+
+ if (attribs->tface[b].array) {
+ MTFace *tf = &attribs->tface[b].array[a];
+ uv = tf->uv[vert];
+ }
+ else {
+ uv = zero;
+ }
+
+ if (attribs->tface[b].gl_texco)
+ glTexCoord2fv(uv);
+ else
+ glVertexAttrib2fvARB(attribs->tface[b].gl_index, uv);
+ }
+
+ /* vertex colors */
+ for (b = 0; b < attribs->totmcol; b++) {
+ GLubyte col[4];
+
+ if (attribs->mcol[b].array) {
+ MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ }
+ else {
+ col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0;
+ }
+
+ glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col);
+ }
+
+ /* tangent for normal mapping */
+ if (attribs->tottang) {
+ /*const*/ float (*array)[4] = attribs->tang.array;
+ const float *tang = (array) ? array[a * 4 + vert] : zero;
+
+ glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
+ }
+}
+
/* Only used by non-editmesh types */
static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
DMSetMaterial setMaterial,
@@ -1833,7 +1891,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
int gridFaces = gridSize - 1;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
DMFlagMat *faceFlags = ccgdm->faceFlags;
- int a, b, i, do_draw, numVerts, matnr, new_matnr, totface;
+ int a, i, do_draw, numVerts, matnr, new_matnr, totface;
CCG_key_top_level(&key, ss);
ccgdm_pbvh_update(ccgdm);
@@ -1842,25 +1900,11 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
matnr = -1;
#define PASSATTRIB(dx, dy, vert) { \
- if (attribs.totorco) { \
+ if (attribs.totorco) \
index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
- glVertexAttrib3fvARB(attribs.orco.gl_index, \
- attribs.orco.array[index]); \
- } \
- for (b = 0; b < attribs.tottface; b++) { \
- MTFace *tf = &attribs.tface[b].array[a]; \
- glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \
- } \
- for (b = 0; b < attribs.totmcol; b++) { \
- MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \
- GLubyte col[4]; \
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \
- glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \
- } \
- if (attribs.tottang) { \
- float *tang = attribs.tang.array[a * 4 + vert]; \
- glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \
- } \
+ else \
+ index = 0; \
+ ccgdm_draw_attrib_vertex(&attribs, a, index, vert); \
} (void)0
totface = ccgSubSurf_getNumFaces(ss);
@@ -1984,7 +2028,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
int gridFaces = gridSize - 1;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
DMFlagMat *faceFlags = ccgdm->faceFlags;
- int a, b, i, numVerts, matnr, new_matnr, totface;
+ int a, i, numVerts, matnr, new_matnr, totface;
CCG_key_top_level(&key, ss);
ccgdm_pbvh_update(ccgdm);
@@ -1992,31 +2036,11 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
matnr = -1;
#define PASSATTRIB(dx, dy, vert) { \
- if (attribs.totorco) { \
+ if (attribs.totorco) \
index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
- if (attribs.orco.gl_texco) \
- glTexCoord3fv(attribs.orco.array[index]); \
- else \
- glVertexAttrib3fvARB(attribs.orco.gl_index, \
- attribs.orco.array[index]); \
- } \
- for (b = 0; b < attribs.tottface; b++) { \
- MTFace *tf = &attribs.tface[b].array[a]; \
- if (attribs.tface[b].gl_texco) \
- glTexCoord2fv(tf->uv[vert]); \
- else \
- glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \
- } \
- for (b = 0; b < attribs.totmcol; b++) { \
- MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \
- GLubyte col[4]; \
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \
- glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \
- } \
- if (attribs.tottang) { \
- float *tang = attribs.tang.array[a * 4 + vert]; \
- glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \
- } \
+ else \
+ index = 0; \
+ ccgdm_draw_attrib_vertex(&attribs, a, index, vert); \
} (void)0
totface = ccgSubSurf_getNumFaces(ss);
@@ -3183,9 +3207,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
/* reuse of ccgDM_getNumTessFaces is intentional here: subsurf polys are just created from tessfaces */
ccgdm->dm.getNumPolys = ccgDM_getNumTessFaces;
- ccgdm->dm.getNumGrids = ccgDM_getNumGrids;
- ccgdm->dm.getPBVH = ccgDM_getPBVH;
-
ccgdm->dm.getVert = ccgDM_getFinalVert;
ccgdm->dm.getEdge = ccgDM_getFinalEdge;
ccgdm->dm.getTessFace = ccgDM_getFinalFace;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 22b0fe7bc24..ccbccac85cf 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -68,6 +68,9 @@
#include "BKE_node.h"
#include "BKE_animsys.h"
#include "BKE_colortools.h"
+#include "BKE_scene.h"
+
+#include "RE_shader_ext.h"
/* ****************** Mapping ******************* */
@@ -1436,3 +1439,27 @@ bool BKE_texture_dependsOnTime(const struct Tex *texture)
}
/* ------------------------------------------------------------------------- */
+
+void BKE_texture_get_value(Scene *scene, Tex *texture, float *tex_co, TexResult *texres, bool use_color_management)
+{
+ int result_type;
+ bool do_color_manage = false;
+
+ if (scene && use_color_management) {
+ do_color_manage = BKE_scene_check_color_management_enabled(scene);
+ }
+
+ /* no node textures for now */
+ result_type = multitex_ext_safe(texture, tex_co, texres, NULL, do_color_manage);
+
+ /* if the texture gave an RGB value, we assume it didn't give a valid
+ * intensity, since this is in the context of modifiers don't use perceptual color conversion.
+ * if the texture didn't give an RGB value, copy the intensity across
+ */
+ if (result_type & TEX_RGB) {
+ texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
+ }
+ else {
+ copy_v3_fl(&texres->tr, texres->tin);
+ }
+}
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index b8711f6e5f6..d519b93f963 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -36,6 +36,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_camera_types.h"
#include "DNA_movieclip_types.h"
@@ -53,6 +54,7 @@
#include "BLF_translation.h"
+#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_tracking.h"
#include "BKE_movieclip.h"
@@ -62,6 +64,8 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "RNA_access.h"
+
#include "raskter.h"
#include "libmv-capi.h"
@@ -212,7 +216,6 @@ void BKE_tracking_settings_init(MovieTracking *tracking)
tracking->settings.default_algorithm_flag |= TRACK_ALGORITHM_FLAG_USE_BRUTE;
tracking->settings.dist = 1;
tracking->settings.object_distance = 1;
- tracking->settings.reconstruction_success_threshold = 1e-3f;
tracking->stabilization.scaleinf = 1.0f;
tracking->stabilization.locinf = 1.0f;
@@ -591,6 +594,7 @@ MovieTrackingTrack *BKE_tracking_track_add(MovieTracking *tracking, ListBase *tr
track->frames_limit = settings->default_frames_limit;
track->flag = settings->default_flag;
track->algorithm_flag = settings->default_algorithm_flag;
+ track->weight = 1.0f;
memset(&marker, 0, sizeof(marker));
marker.pos[0] = x;
@@ -3264,23 +3268,6 @@ static int point_markers_correspondences_on_both_image(MovieTrackingPlaneTrack *
return correspondence_index;
}
-/* TODO(sergey): Make it generic function available for everyone. */
-BLI_INLINE void mat3f_from_mat3d(float mat_float[3][3], double mat_double[3][3])
-{
- /* Keep it stupid simple for better data flow in CPU. */
- mat_float[0][0] = mat_double[0][0];
- mat_float[0][1] = mat_double[0][1];
- mat_float[0][2] = mat_double[0][2];
-
- mat_float[1][0] = mat_double[1][0];
- mat_float[1][1] = mat_double[1][1];
- mat_float[1][2] = mat_double[1][2];
-
- mat_float[2][0] = mat_double[2][0];
- mat_float[2][1] = mat_double[2][1];
- mat_float[2][2] = mat_double[2][2];
-}
-
/* NOTE: frame number should be in clip space, not scene space */
static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_track, int start_frame,
int direction, bool retrack)
@@ -3342,7 +3329,7 @@ static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_trac
libmv_homography2DFromCorrespondencesEuc(x1, x2, num_correspondences, H_double);
- mat3f_from_mat3d(H, H_double);
+ copy_m3_m3d(H, H_double);
for (i = 0; i < 4; i++) {
float vec[3] = {0.0f, 0.0f, 1.0f}, vec2[3];
@@ -3446,7 +3433,7 @@ void BKE_tracking_homography_between_two_quads(/*const*/ float reference_corners
libmv_homography2DFromCorrespondencesEuc(x1, x2, 4, H_double);
- mat3f_from_mat3d(H, H_double);
+ copy_m3_m3d(H, H_double);
}
/*********************** Camera solving *************************/
@@ -3473,9 +3460,6 @@ typedef struct MovieReconstructContext {
TracksMap *tracks_map;
- float success_threshold;
- bool use_fallback_reconstruction;
-
int sfra, efra;
} MovieReconstructContext;
@@ -3488,7 +3472,7 @@ typedef struct ReconstructProgressData {
} ReconstructProgressData;
/* Create new libmv Tracks structure from blender's tracks list. */
-static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, int height)
+static struct libmv_Tracks *libmv_tracks_new(MovieClip *clip, ListBase *tracksbase, int width, int height)
{
int tracknr = 0;
MovieTrackingTrack *track;
@@ -3496,15 +3480,28 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in
track = tracksbase->first;
while (track) {
+ FCurve *weight_fcurve;
int a = 0;
+ weight_fcurve = id_data_find_fcurve(&clip->id, track, &RNA_MovieTrackingTrack,
+ "weight", 0, NULL);
+
for (a = 0; a < track->markersnr; a++) {
MovieTrackingMarker *marker = &track->markers[a];
if ((marker->flag & MARKER_DISABLED) == 0) {
+ float weight = track->weight;
+
+ if (weight_fcurve) {
+ int scene_framenr =
+ BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
+ weight = evaluate_fcurve(weight_fcurve, scene_framenr);
+ }
+
libmv_tracksInsert(tracks, marker->framenr, tracknr,
(marker->pos[0] + track->offset[0]) * width,
- (marker->pos[1] + track->offset[1]) * height);
+ (marker->pos[1] + track->offset[1]) * height,
+ weight);
}
}
@@ -3751,9 +3748,10 @@ bool BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObj
* clip datablock, so editing this clip is safe during
* reconstruction job is in progress.
*/
-MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *tracking, MovieTrackingObject *object,
+MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip, MovieTrackingObject *object,
int keyframe1, int keyframe2, int width, int height)
{
+ MovieTracking *tracking = &clip->tracking;
MovieReconstructContext *context = MEM_callocN(sizeof(MovieReconstructContext), "MovieReconstructContext data");
MovieTrackingCamera *camera = &tracking->camera;
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
@@ -3780,9 +3778,6 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
context->k2 = camera->k2;
context->k3 = camera->k3;
- context->success_threshold = tracking->settings.reconstruction_success_threshold;
- context->use_fallback_reconstruction = tracking->settings.reconstruction_flag & TRACKING_USE_FALLBACK_RECONSTRUCTION;
-
context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
track = tracksbase->first;
@@ -3817,7 +3812,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
context->sfra = sfra;
context->efra = efra;
- context->tracks = libmv_tracks_new(tracksbase, width, height * aspy);
+ context->tracks = libmv_tracks_new(clip, tracksbase, width, height * aspy);
context->keyframe1 = keyframe1;
context->keyframe2 = keyframe2;
context->refine_flags = reconstruct_refine_intrinsics_get_flags(tracking, object);
@@ -3877,9 +3872,6 @@ static void reconstructionOptionsFromContext(libmv_ReconstructionOptions *recons
reconstruction_options->keyframe2 = context->keyframe2;
reconstruction_options->refine_intrinsics = context->refine_flags;
-
- reconstruction_options->success_threshold = context->success_threshold;
- reconstruction_options->use_fallback_reconstruction = context->use_fallback_reconstruction;
}
/* Solve camera/object motion and reconstruct 3D markers position
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index a69df62f505..64470542844 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -95,11 +95,6 @@ typedef struct bUnitDef {
#define B_UNIT_DEF_SUPPRESS 1 /* Use for units that are not used enough to be translated into for common use */
#define B_UNIT_DEF_TENTH 2 /* Display a unit even if its value is 0.1, eg 0.1mm instead of 100um */
-/* workaround encoding issue with "µm", bug [#36090] */
-#define B_UNIT_CHAR_MICRO "\xb5"
-#define UM B_UNIT_CHAR_MICRO"m"
-#define US B_UNIT_CHAR_MICRO"s"
-
/* define a single unit */
typedef struct bUnitCollection {
struct bUnitDef *units;
@@ -121,7 +116,7 @@ static struct bUnitDef buMetricLenDef[] = {
{"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
- {"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too?
+ {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
/* These get displayed because of float precision problems in the transform header,
* could work around, but for now probably people wont use these */
@@ -154,7 +149,7 @@ static struct bUnitDef buMetricAreaDef[] = {
{"square decimeter", "square decimetees", "dm²", "dm2", "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
- {"square micrometer", "square micrometers", UM"²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
+ {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buMetricAreaCollection = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)};
@@ -180,7 +175,7 @@ static struct bUnitDef buMetricVolDef[] = {
{"cubic decimeter", "cubic decimeters", "dm³", "dm3", "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM * UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM * UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
- {"cubic micrometer", "cubic micrometers", UM"³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
+ {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buMetricVolCollection = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)};
@@ -258,7 +253,7 @@ static struct bUnitDef buNaturalTimeDef[] = {
{"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE},
{"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */
{"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE},
- {"microsecond", "microseconds", US, "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE},
+ {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)};
@@ -278,7 +273,7 @@ static struct bUnitDef buCameraLenDef[] = {
{"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS},
{"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS},
{"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_M, 0.0, B_UNIT_DEF_NONE},
- {"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, // micron too?
+ {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buCameraLenCollection = {buCameraLenDef, 3, 0, sizeof(buCameraLenDef) / sizeof(bUnitDef)};
@@ -614,9 +609,10 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
int i;
char *ch = str;
- for (i = 0; (i >= len_max || *ch == '\0'); i++, ch++)
+ for (i = 0; (i < len_max) && (*ch != '\0'); i++, ch++) {
if ((*ch >= 'A') && (*ch <= 'Z'))
*ch += ('a' - 'A');
+ }
}
for (unit = usys->units; unit->name; unit++) {
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 206f829eaa8..c5a932e4173 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -92,8 +92,6 @@ World *add_world(Main *bmain, const char *name)
wrld->zeng = 0.01f;
wrld->zenb = 0.01f;
wrld->skytype = 0;
- wrld->stardist = 15.0f;
- wrld->starsize = 2.0f;
wrld->exp = 0.0f;
wrld->exposure = wrld->range = 1.0f;
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 538c98cc899..bcf5e712eff 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -295,17 +295,7 @@ static const char **get_file_extensions(int format)
}
case FFMPEG_OGG:
{
- static const char *rv[] = { ".ogg", ".ogv", NULL };
- return rv;
- }
- case FFMPEG_MP3:
- {
- static const char *rv[] = { ".mp3", NULL };
- return rv;
- }
- case FFMPEG_WAV:
- {
- static const char *rv[] = { ".wav", NULL };
+ static const char *rv[] = { ".ogv", ".ogg", NULL };
return rv;
}
default:
@@ -875,12 +865,6 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
case FFMPEG_FLV:
fmt->video_codec = CODEC_ID_FLV1;
break;
- case FFMPEG_MP3:
- fmt->audio_codec = CODEC_ID_MP3;
- /* fall-through */
- case FFMPEG_WAV:
- fmt->video_codec = CODEC_ID_NONE;
- break;
case FFMPEG_MPEG4:
default:
fmt->video_codec = CODEC_ID_MPEG4;
@@ -1254,9 +1238,7 @@ void BKE_ffmpeg_property_del(RenderData *rd, void *type, void *prop_)
group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type);
if (group && prop) {
- IDP_RemFromGroup(group, prop);
- IDP_FreeProperty(prop);
- MEM_freeN(prop);
+ IDP_FreeFromGroup(group, prop);
}
}
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index b04af44156f..c83494790a8 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -60,6 +60,9 @@ void copy_m4_m4(float R[4][4], float A[4][4]);
void copy_m3_m4(float R[3][3], float A[4][4]);
void copy_m4_m3(float R[4][4], float A[3][3]);
+/* double->float */
+void copy_m3_m3d(float R[3][3], double A[3][3]);
+
void swap_m3m3(float A[3][3], float B[3][3]);
void swap_m4m4(float A[4][4], float B[4][4]);
@@ -160,6 +163,8 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A[4][4]);
void pseudoinverse_m4_m4(float Ainv[4][4], float A[4][4], float epsilon);
void pseudoinverse_m3_m3(float Ainv[3][3], float A[3][3], float epsilon);
+bool has_zero_axis_m4(float matrix[4][4]);
+
/****************************** Transformations ******************************/
void scale_m3_fl(float R[3][3], float scale);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 675ba88fc72..3ff81e478c9 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -82,6 +82,9 @@ MINLINE void copy_v4fl_v4db(float r[4], const double a[4]);
MINLINE void copy_v2db_v2fl(double r[2], const float a[2]);
MINLINE void copy_v3db_v3fl(double r[3], const float a[3]);
MINLINE void copy_v4db_v4fl(double r[4], const float a[4]);
+/* float args -> vec */
+MINLINE void copy_v3_fl3(float v[3], float x, float y, float z);
+MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w);
/********************************* Arithmetic ********************************/
@@ -117,6 +120,9 @@ MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]) ATTR_WA
MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT;
MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT;
MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE float dot_m4_v3_row_x(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE float dot_m4_v3_row_y(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE float dot_m4_v3_row_z(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
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]);
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index f8b9088fe3d..0fee9264191 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -74,6 +74,8 @@ bool BLI_rctf_isect_pt(const struct rctf *rect, const float x, const float y);
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]);
bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]);
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]);
+bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], const float radius);
+bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], const float radius);
bool BLI_rcti_inside_rcti(rcti *rct_a, const rcti *rct_b);
bool BLI_rctf_inside_rctf(rctf *rct_a, const rctf *rct_b);
void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2);
diff --git a/source/blender/blenlib/BLI_sys_types.h b/source/blender/blenlib/BLI_sys_types.h
index e544006fd69..0b7f07e3d36 100644
--- a/source/blender/blenlib/BLI_sys_types.h
+++ b/source/blender/blenlib/BLI_sys_types.h
@@ -116,7 +116,7 @@ typedef uint64_t u_int64_t;
* use (bool, true / false) instead */
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
-#else
+#elif !defined(__bool_true_false_are_defined) && !defined(__BOOL_DEFINED)
# ifndef HAVE__BOOL
# ifdef __cplusplus
typedef bool _BLI_Bool;
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index f57d42858c7..c9cbaf997fb 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -88,8 +88,8 @@ void BLI_task_pool_cancel(TaskPool *pool);
/* stop all worker threads */
void BLI_task_pool_stop(TaskPool *pool);
-/* for worker threads, test if cancelled */
-bool BLI_task_pool_cancelled(TaskPool *pool);
+/* for worker threads, test if canceled */
+bool BLI_task_pool_canceled(TaskPool *pool);
/* optional userdata pointer to pass along to run function */
void *BLI_task_pool_userdata(TaskPool *pool);
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index c3a3c035ed3..9bf720c03ea 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -240,8 +240,13 @@
#define CLAMPIS(a, b, c) ((a) < (b) ? (b) : (a) > (c) ? (c) : (a))
-#define IS_EQ(a, b) ((fabs((double)(a) - (b)) >= (double) FLT_EPSILON) ? 0 : 1)
-#define IS_EQF(a, b) ((fabsf((float)(a) - (b)) >= (float) FLT_EPSILON) ? 0 : 1)
+#define IS_EQ(a, b) ( \
+ CHECK_TYPE_INLINE(a, double), CHECK_TYPE_INLINE(b, double), \
+ ((fabs((double)(a) - (b)) >= (double) FLT_EPSILON) ? false : true))
+
+#define IS_EQF(a, b) ( \
+ CHECK_TYPE_INLINE(a, float), CHECK_TYPE_INLINE(b, float), \
+ ((fabsf((float)(a) - (b)) >= (float) FLT_EPSILON) ? false : true))
#define IS_EQT(a, b, c) ((a > b) ? (((a - b) <= c) ? 1 : 0) : ((((b - a) <= c) ? 1 : 0)))
#define IN_RANGE(a, b, c) ((b < c) ? ((b < a && a < c) ? 1 : 0) : ((c < a && a < b) ? 1 : 0))
diff --git a/source/blender/blenlib/BLI_voronoi.h b/source/blender/blenlib/BLI_voronoi.h
index 68d7398d89b..9d32061bf97 100644
--- a/source/blender/blenlib/BLI_voronoi.h
+++ b/source/blender/blenlib/BLI_voronoi.h
@@ -52,7 +52,7 @@ typedef struct VoronoiEdge {
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;
+ struct VoronoiEdge *neighbor;
} VoronoiEdge;
typedef struct VoronoiTriangulationPoint {
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index fcca6cd59ba..f3ebddddc8c 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -136,7 +136,7 @@ BLI_INLINE void ghash_resize_buckets(GHash *gh, const unsigned int nbuckets)
}
/**
- * Increase initial bucket size to match a reserved ammount.
+ * Increase initial bucket size to match a reserved amount.
*/
BLI_INLINE void ghash_buckets_reserve(GHash *gh, const unsigned int nentries_reserve)
{
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 261e53f0f55..28539d9ca34 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -584,7 +584,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve)
/* free all after pool->maxchunks */
- for (mpchunk = BLI_findlink(&pool->chunks, (int)maxchunks); mpchunk; mpchunk = mpchunk_next) {
+ for (mpchunk = BLI_findlink(&pool->chunks, (int)maxchunks); mpchunk; mpchunk = mpchunk_next) {
mpchunk_next = mpchunk->next;
BLI_remlink(&pool->chunks, mpchunk);
mempool_chunk_free(mpchunk, pool->flag);
diff --git a/source/blender/blenlib/intern/convexhull2d.c b/source/blender/blenlib/intern/convexhull2d.c
index 5669a302bd8..2c29ef042a1 100644
--- a/source/blender/blenlib/intern/convexhull2d.c
+++ b/source/blender/blenlib/intern/convexhull2d.c
@@ -191,6 +191,8 @@ static int pointref_cmp_y(const void *a_, const void *b_)
* \param points An array of 2D points.
* \param n The number of points in points.
* \param r_points An array of the convex hull vertex indices (max is n).
+ * _must_ be allocated as ``n * 2`` becauise of how its used internally,
+ * even though the final result will be no more then \a n in size.
* \returns the number of points in r_points.
*/
int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[])
@@ -310,7 +312,7 @@ float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], unsigned int n
float angle;
- index_map = MEM_mallocN(sizeof(*index_map) * n, __func__);
+ index_map = MEM_mallocN(sizeof(*index_map) * n * 2, __func__);
tot = BLI_convexhull_2d((const float (*)[2])points, (int)n, index_map);
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index b26e007b3e6..50dcd01207d 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -137,7 +137,7 @@ BLI_INLINE void edgehash_resize_buckets(EdgeHash *eh, const unsigned int nbucket
}
/**
- * Increase initial bucket size to match a reserved ammount.
+ * Increase initial bucket size to match a reserved amount.
*/
BLI_INLINE void edgehash_buckets_reserve(EdgeHash *eh, const unsigned int nentries_reserve)
{
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index d24200fc0b7..1f52caac8e9 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -112,6 +112,22 @@ void copy_m4_m3(float m1[4][4], float m2[3][3]) /* no clear */
}
+void copy_m3_m3d(float R[3][3], double A[3][3])
+{
+ /* Keep it stupid simple for better data flow in CPU. */
+ R[0][0] = A[0][0];
+ R[0][1] = A[0][1];
+ R[0][2] = A[0][2];
+
+ R[1][0] = A[1][0];
+ R[1][1] = A[1][1];
+ R[1][2] = A[1][2];
+
+ R[2][0] = A[2][0];
+ R[2][1] = A[2][1];
+ R[2][2] = A[2][2];
+}
+
void swap_m3m3(float m1[3][3], float m2[3][3])
{
float t;
@@ -2070,3 +2086,9 @@ void pseudoinverse_m3_m3(float Ainv[3][3], float A[3][3], float epsilon)
}
}
+bool has_zero_axis_m4(float matrix[4][4])
+{
+ return len_squared_v3(matrix[0]) < FLT_EPSILON ||
+ len_squared_v3(matrix[1]) < FLT_EPSILON ||
+ len_squared_v3(matrix[2]) < FLT_EPSILON;
+}
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 2eebe10dd58..41535cf32b6 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1712,7 +1712,7 @@ float fov_to_focallength(float hfov, float sensor)
return (sensor / 2.0f) / tanf(hfov * 0.5f);
}
-/* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */
+/* 'mod_inline(-3, 4)= 1', 'fmod(-3, 4)= -3' */
static float mod_inline(float a, float b)
{
return a - (b * floorf(a / b));
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index ce5d9657c7f..ace8e6b48c1 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -235,6 +235,22 @@ MINLINE void swap_v4_v4(float a[4], float b[4])
SWAP(float, a[3], b[3]);
}
+/* float args -> vec */
+MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
+{
+ v[0] = x;
+ v[1] = y;
+ v[2] = z;
+}
+
+MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
+{
+ v[0] = x;
+ v[1] = y;
+ v[2] = z;
+ v[3] = w;
+}
+
/********************************* Arithmetic ********************************/
MINLINE void add_v2_fl(float r[2], float f)
@@ -434,6 +450,22 @@ MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3])
return M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
}
+/**
+ * Almost like mul_m4_v3(), misses adding translation.
+ */
+MINLINE float dot_m4_v3_row_x(float M[4][4], const float a[3])
+{
+ return M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
+}
+MINLINE float dot_m4_v3_row_y(float M[4][4], const float a[3])
+{
+ return M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
+}
+MINLINE float dot_m4_v3_row_z(float M[4][4], const float a[3])
+{
+ return M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
+}
+
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
{
r[0] += a[0] * f;
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 02525e25dda..d36cd3cb394 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -216,6 +216,32 @@ bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[
}
}
+bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
+{
+ float dx, dy;
+
+ if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0;
+ else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
+
+ if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0;
+ else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
+
+ return dx * dx + dy * dy <= radius * radius;
+}
+
+bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius)
+{
+ float dx, dy;
+
+ if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0;
+ else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
+
+ if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0;
+ else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
+
+ return dx * dx + dy * dy <= radius * radius;
+}
+
void BLI_rctf_union(rctf *rct1, const rctf *rct2)
{
if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index 7fa108b906f..4ae60abb2c8 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -402,7 +402,7 @@ void BLI_task_pool_stop(TaskPool *pool)
BLI_assert(pool->num == 0);
}
-bool BLI_task_pool_cancelled(TaskPool *pool)
+bool BLI_task_pool_canceled(TaskPool *pool)
{
return pool->do_cancel;
}
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 64682965649..0b8f5dfdde5 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -166,7 +166,7 @@ TaskScheduler *BLI_task_scheduler_get(void)
if (task_scheduler == NULL) {
int tot_thread = BLI_system_thread_count();
- /* Do a lazy initialization, so it happes after
+ /* Do a lazy initialization, so it happens after
* command line arguments parsing
*/
task_scheduler = BLI_task_scheduler_create(tot_thread);
@@ -624,7 +624,7 @@ struct ThreadQueue {
pthread_cond_t push_cond;
pthread_cond_t finish_cond;
volatile int nowait;
- volatile int cancelled;
+ volatile int canceled;
};
ThreadQueue *BLI_thread_queue_init(void)
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c
index 3f6adff1eda..731536ff0df 100644
--- a/source/blender/blenlib/intern/voronoi.c
+++ b/source/blender/blenlib/intern/voronoi.c
@@ -99,7 +99,7 @@ static VoronoiEdge *voronoiEdge_new(float start[2], float left[2], float right[2
copy_v2_v2(edge->left, left);
copy_v2_v2(edge->right, right);
- edge->neighbour = NULL;
+ edge->neighbor = NULL;
edge->end[0] = 0;
edge->end[1] = 0;
@@ -395,7 +395,7 @@ static void voronoi_addParabola(VoronoiProcess *process, float site[2])
el = voronoiEdge_new(start, par->site, site);
er = voronoiEdge_new(start, site, par->site);
- el->neighbour = er;
+ el->neighbor = er;
BLI_addtail(&process->edges, el);
par->edge = er;
@@ -682,9 +682,9 @@ void BLI_voronoi_compute(const VoronoiSite *sites, int sites_total, int width, i
edge = process.edges.first;
while (edge) {
- if (edge->neighbour) {
- copy_v2_v2(edge->start, edge->neighbour->end);
- MEM_freeN(edge->neighbour);
+ if (edge->neighbor) {
+ copy_v2_v2(edge->start, edge->neighbor->end);
+ MEM_freeN(edge->neighbor);
}
edge = edge->next;
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index f865962bac9..24b8df78258 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -66,4 +66,8 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+if(WITH_CODEC_FFMPEG)
+ add_definitions(-DWITH_FFMPEG)
+endif()
+
blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript
index 3882cc1029a..bd002e59fa4 100644
--- a/source/blender/blenloader/SConscript
+++ b/source/blender/blenloader/SConscript
@@ -51,6 +51,9 @@ defs = []
if env['WITH_BF_INTERNATIONAL']:
defs.append('WITH_INTERNATIONAL')
+if env['WITH_BF_FFMPEG']:
+ defs.append('WITH_FFMPEG')
+
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
env.BlenderLib('bf_blenloader', sources, incs, defs, libtype=['core', 'player'], priority = [167, 30]) #, cc_compileflags=['/WX'])
else:
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 40d442f4e0b..2ad2ff1d7b0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -40,6 +40,7 @@
#include <string.h> // for strrchr strncmp strstr
#include <math.h> // for fabs
#include <stdarg.h> /* for va_start/end */
+#include <time.h> /* for gmtime */
#include "BLI_utildefines.h"
#ifndef WIN32
@@ -153,6 +154,7 @@
#include "BKE_tracking.h"
#include "BKE_treehash.h"
#include "BKE_sound.h"
+#include "BKE_writeffmpeg.h"
#include "IMB_imbuf.h" // for proxy / timecode versioning stuff
@@ -3359,6 +3361,8 @@ static void lib_link_curve(FileData *fd, Main *main)
cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system
cu->key = newlibadr_us(fd, cu->id.lib, cu->key);
+
+ cu->selboxes = NULL; /* runtime, clear */
cu->id.flag -= LIB_NEED_LINK;
}
@@ -3700,7 +3704,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
/* if we have indexes, let's use them */
for (dw = part->dupliweights.first; dw; dw = dw->next) {
GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index);
- dw->ob = go ? newlibadr(fd, part->id.lib, dw->ob) : NULL;
+ dw->ob = go ? go->ob : NULL;
}
}
else {
@@ -3806,7 +3810,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
for (; pt; pt=pt->next)
pt->ob=newlibadr(fd, id->lib, pt->ob);
- psys->parent = newlibadr_us(fd, id->lib, psys->parent);
+ psys->parent = newlibadr(fd, id->lib, psys->parent);
psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
if (psys->clmd) {
@@ -3815,6 +3819,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
psys->clmd->point_cache = psys->pointcache;
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last= NULL;
psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
+ psys->clmd->modifier.error = NULL;
}
}
else {
@@ -5937,6 +5942,14 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
/* not very nice, but could help */
if ((v3d->layact & v3d->lay) == 0) v3d->layact = v3d->lay;
+ /* its possible the current transform orientation has been removed */
+ if (v3d->twmode >= V3D_MANIP_CUSTOM) {
+ const int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
+ if (!BLI_findlink(&sc->scene->transform_spaces, selected_index)) {
+ v3d->twmode = V3D_MANIP_GLOBAL;
+ }
+ }
+
/* free render engines for now */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
RegionView3D *rv3d= ar->regiondata;
@@ -7297,7 +7310,8 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
bfd->main->subversionfile = fg->subversion;
bfd->main->minversionfile = fg->minversion;
bfd->main->minsubversionfile = fg->minsubversion;
- bfd->main->revision = fg->revision;
+ bfd->main->build_commit_timestamp = fg->build_commit_timestamp;
+ BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash));
bfd->winpos = fg->winpos;
bfd->fileflags = fg->fileflags;
@@ -7931,8 +7945,21 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
- if (G.debug & G_DEBUG)
- printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision);
+ if (G.debug & G_DEBUG) {
+ char build_commit_datetime[32];
+ time_t temp_time = main->build_commit_timestamp;
+ struct tm *tm = gmtime(&temp_time);
+ if (LIKELY(tm)) {
+ strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm);
+ }
+ else {
+ BLI_strncpy(build_commit_datetime, "date-unknown", sizeof(build_commit_datetime));
+ }
+
+ printf("read file %s\n Version %d sub %d date %s hash %s\n",
+ fd->relabase, main->versionfile, main->subversionfile,
+ build_commit_datetime, main->build_hash);
+ }
blo_do_versions_pre250(fd, lib, main);
blo_do_versions_250(fd, lib, main);
@@ -9095,17 +9122,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
-
- /* fallbck resection method settings */
- {
- MovieClip *clip;
-
- for (clip = main->movieclip.first; clip; clip = clip->id.next) {
- if (clip->tracking.settings.reconstruction_success_threshold == 0.0f) {
- clip->tracking.settings.reconstruction_success_threshold = 1e-3f;
- }
- }
- }
}
if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
@@ -9713,7 +9729,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
-
+
if (!MAIN_VERSION_ATLEAST(main, 269, 1)) {
/* Removal of Cycles SSS Compatible falloff */
FOREACH_NODETREE(main, ntree, id) {
@@ -9730,6 +9746,120 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
} FOREACH_NODETREE_END
}
+ if (!MAIN_VERSION_ATLEAST(main, 269, 2)) {
+ /* Initialize CDL settings for Color Balance nodes */
+ FOREACH_NODETREE(main, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_COLORBALANCE) {
+ NodeColorBalance *n = node->storage;
+ if (node->custom1 == 0) {
+ /* LGG mode stays the same, just init CDL settings */
+ ntreeCompositColorBalanceSyncFromLGG(ntree, node);
+ }
+ else if (node->custom1 == 1) {
+ /* CDL previously used same variables as LGG, copy them over
+ * and then sync LGG for comparable results in both modes.
+ */
+ copy_v3_v3(n->offset, n->lift);
+ copy_v3_v3(n->power, n->gamma);
+ copy_v3_v3(n->slope, n->gain);
+ ntreeCompositColorBalanceSyncFromCDL(ntree, node);
+ }
+ }
+ }
+ }
+ } FOREACH_NODETREE_END
+ }
+
+ {
+ bScreen *sc;
+ ScrArea *sa;
+ SpaceLink *sl;
+ Scene *scene;
+
+ /* Update files using invalid (outdated) outlinevis Outliner values. */
+ for (sc = main->screen.first; sc; sc = sc->id.next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOops *so = (SpaceOops *)sl;
+
+ if (!ELEM11(so->outlinevis, SO_ALL_SCENES, SO_CUR_SCENE, SO_VISIBLE, SO_SELECTED, SO_ACTIVE,
+ SO_SAME_TYPE, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_DATABLOCKS,
+ SO_USERDEF))
+ {
+ so->outlinevis = SO_ALL_SCENES;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) {
+ MovieClip *clip;
+ for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object;
+ for (tracking_object = tracking->objects.first;
+ tracking_object;
+ tracking_object = tracking_object->next)
+ {
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
+ MovieTrackingTrack *track;
+ for (track = tracksbase->first;
+ track;
+ track = track->next)
+ {
+ track->weight = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) {
+ Object *ob;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Triangulate) {
+ TriangulateModifierData *tmd = (TriangulateModifierData *)md;
+ if ((tmd->flag & MOD_TRIANGULATE_BEAUTY)) {
+ tmd->quad_method = MOD_TRIANGULATE_QUAD_BEAUTY;
+ tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY;
+ }
+ else {
+ tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
+ tmd->ngon_method = MOD_TRIANGULATE_NGON_SCANFILL;
+ }
+ }
+ }
+ }
+ }
+
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ if (scene->gm.matmode == GAME_MAT_TEXFACE) {
+ scene->gm.matmode = GAME_MAT_MULTITEX;
+ }
+ }
+
+ /* 'Increment' mode disabled for nodes, use true grid snapping instead */
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT)
+ scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
+ }
+
+ /* Update for removed "sound-only" option in FFMPEG export settings. */
+#ifdef WITH_FFMPEG
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ if (scene->r.ffcodecdata.type >= FFMPEG_INVALID) {
+ scene->r.ffcodecdata.type = FFMPEG_AVI;
+ }
+ }
+#endif
+ }
+
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 80e34f0fce4..62e3955ca60 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -2323,7 +2323,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
KeyBlock *kb;
for (kb = key->block.first; kb; kb = kb->next) {
- if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0))
+ if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f))
kb->slidermax = kb->slidermin + 1.0f;
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 44dc98fe537..dad8a60289e 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2904,9 +2904,6 @@ static void write_brushes(WriteData *wd, ListBase *idbase)
writestruct(wd, ID_BR, "Brush", 1, brush);
if (brush->id.properties) IDP_WriteProperty(brush->id.properties, wd);
- writestruct(wd, DATA, "MTex", 1, &brush->mtex);
- writestruct(wd, DATA, "MTex", 1, &brush->mask_mtex);
-
if (brush->curve)
write_curvemapping(wd, brush->curve);
}
@@ -3265,7 +3262,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
char subvstr[8];
/* prevent mem checkers from complaining */
- fg.pads= fg.pad= 0;
+ fg.pads= 0;
memset(fg.filename, 0, sizeof(fg.filename));
current_screen_compat(mainvar, &screen);
@@ -3289,11 +3286,15 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
fg.minsubversion= BLENDER_MINSUBVERSION;
#ifdef WITH_BUILDINFO
{
- extern char build_rev[];
- fg.revision= atoi(build_rev);
+ extern unsigned long build_commit_timestamp;
+ extern char build_hash[];
+ /* TODO(sergey): Add branch name to file as well? */
+ fg.build_commit_timestamp = build_commit_timestamp;
+ BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash));
}
#else
- fg.revision= 0;
+ fg.build_commit_timestamp = 0;
+ BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash));
#endif
writestruct(wd, GLOB, "FileGlobal", 1, &fg);
}
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 67f95cca6aa..b80a10b43fe 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -119,6 +119,8 @@ set(SRC
intern/bmesh_operator_api.h
intern/bmesh_error.h
+ tools/bmesh_beautify.c
+ tools/bmesh_beautify.h
tools/bmesh_bevel.c
tools/bmesh_bevel.h
tools/bmesh_bisect_plane.c
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 90105b0dd81..9c43e5a2ee4 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -183,9 +183,28 @@ typedef struct BMesh {
* BM_LOOP isn't handled so far. */
char elem_index_dirty;
+ /* flag array table as being dirty so we know when its safe to use it,
+ * or when it needs to be re-created */
+ char elem_table_dirty;
+
+
/* element pools */
struct BLI_mempool *vpool, *epool, *lpool, *fpool;
+ /* mempool lookup tables (optional)
+ * index tables, to map indices to elements via
+ * BM_mesh_elem_table_ensure and associated functions. don't
+ * touch this or read it directly.\
+ * Use BM_mesh_elem_table_ensure(), BM_vert/edge/face_at_index() */
+ BMVert **vtable;
+ BMEdge **etable;
+ BMFace **ftable;
+
+ /* size of allocated tables */
+ int vtable_tot;
+ int etable_tot;
+ int ftable_tot;
+
/* operator api stuff (must be all NULL or all alloc'd) */
struct BLI_mempool *vtoolflagpool, *etoolflagpool, *ftoolflagpool;
diff --git a/source/blender/bmesh/bmesh_tools.h b/source/blender/bmesh/bmesh_tools.h
index b2dac810bce..baffeb774b6 100644
--- a/source/blender/bmesh/bmesh_tools.h
+++ b/source/blender/bmesh/bmesh_tools.h
@@ -34,6 +34,7 @@
extern "C" {
#endif
+#include "tools/bmesh_beautify.h"
#include "tools/bmesh_bevel.h"
#include "tools/bmesh_bisect_plane.h"
#include "tools/bmesh_decimate.h"
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 8441a6ec75f..0726af4b641 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -70,7 +70,9 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3],
/* disallow this flag for verts - its meaningless */
BLI_assert((create_flag & BM_CREATE_NO_DOUBLE) == 0);
- bm->elem_index_dirty |= BM_VERT; /* may add to middle of the pool */
+ /* may add to middle of the pool */
+ bm->elem_index_dirty |= BM_VERT;
+ bm->elem_table_dirty |= BM_VERT;
bm->totvert++;
@@ -130,7 +132,9 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2,
BM_elem_index_set(e, -1); /* set_ok_invalid */
#endif
- bm->elem_index_dirty |= BM_EDGE; /* may add to middle of the pool */
+ /* may add to middle of the pool */
+ bm->elem_index_dirty |= BM_EDGE;
+ bm->elem_table_dirty |= BM_EDGE;
bm->totedge++;
@@ -292,7 +296,9 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm, const eBMCreateFlag creat
BM_elem_index_set(f, -1); /* set_ok_invalid */
#endif
- bm->elem_index_dirty |= BM_FACE; /* may add to middle of the pool */
+ /* may add to middle of the pool */
+ bm->elem_index_dirty |= BM_FACE;
+ bm->elem_table_dirty |= BM_FACE;
bm->totface++;
@@ -562,6 +568,7 @@ static void bm_kill_only_vert(BMesh *bm, BMVert *v)
{
bm->totvert--;
bm->elem_index_dirty |= BM_VERT;
+ bm->elem_table_dirty |= BM_VERT;
BM_select_history_remove(bm, v);
@@ -582,6 +589,7 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e)
{
bm->totedge--;
bm->elem_index_dirty |= BM_EDGE;
+ bm->elem_table_dirty |= BM_EDGE;
BM_select_history_remove(bm, (BMElem *)e);
@@ -605,6 +613,7 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f)
bm->totface--;
bm->elem_index_dirty |= BM_FACE;
+ bm->elem_table_dirty |= BM_FACE;
BM_select_history_remove(bm, (BMElem *)f);
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index cc2324ba34a..701fdf07710 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -213,6 +213,10 @@ void BM_mesh_data_free(BMesh *bm)
BLI_mempool_destroy(bm->lpool);
BLI_mempool_destroy(bm->fpool);
+ if (bm->vtable) MEM_freeN(bm->vtable);
+ if (bm->etable) MEM_freeN(bm->etable);
+ if (bm->ftable) MEM_freeN(bm->ftable);
+
/* destroy flag pool */
BM_mesh_elem_toolflags_clear(bm);
@@ -623,6 +627,179 @@ void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *fu
}
+/* debug check only - no need to optimize */
+#ifndef NDEBUG
+bool BM_mesh_elem_table_check(BMesh *bm)
+{
+ BMIter iter;
+ BMElem *ele;
+ int i;
+
+ if (bm->vtable && ((bm->elem_table_dirty & BM_VERT) == 0)) {
+ BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if (ele != (BMElem *)bm->vtable[i]) {
+ return false;
+ }
+ }
+ }
+
+ if (bm->etable && ((bm->elem_table_dirty & BM_EDGE) == 0)) {
+ BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
+ if (ele != (BMElem *)bm->etable[i]) {
+ return false;
+ }
+ }
+ }
+
+ if (bm->ftable && ((bm->elem_table_dirty & BM_FACE) == 0)) {
+ BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
+ if (ele != (BMElem *)bm->ftable[i]) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+#endif
+
+
+
+void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
+{
+ /* assume if the array is non-null then its valid and no need to recalc */
+ const char htype_needed = (((bm->vtable && ((bm->elem_table_dirty & BM_VERT) == 0)) ? 0 : BM_VERT) |
+ ((bm->etable && ((bm->elem_table_dirty & BM_EDGE) == 0)) ? 0 : BM_EDGE) |
+ ((bm->ftable && ((bm->elem_table_dirty & BM_FACE) == 0)) ? 0 : BM_FACE)) & htype;
+
+ BLI_assert((htype & ~BM_ALL_NOLOOP) == 0);
+
+ /* in debug mode double check we didn't need to recalculate */
+ BLI_assert(BM_mesh_elem_table_check(bm) == true);
+
+ if (htype_needed & BM_VERT) {
+ if (bm->vtable && bm->totvert <= bm->vtable_tot && bm->totvert * 2 >= bm->vtable_tot) {
+ /* pass (re-use the array) */
+ }
+ else {
+ if (bm->vtable)
+ MEM_freeN(bm->vtable);
+ bm->vtable = MEM_mallocN(sizeof(void **) * bm->totvert, "bm->vtable");
+ bm->vtable_tot = bm->totvert;
+ }
+ bm->elem_table_dirty &= ~BM_VERT;
+ }
+ if (htype_needed & BM_EDGE) {
+ if (bm->etable && bm->totedge <= bm->etable_tot && bm->totedge * 2 >= bm->etable_tot) {
+ /* pass (re-use the array) */
+ }
+ else {
+ if (bm->etable)
+ MEM_freeN(bm->etable);
+ bm->etable = MEM_mallocN(sizeof(void **) * bm->totedge, "bm->etable");
+ bm->etable_tot = bm->totedge;
+ }
+ bm->elem_table_dirty &= ~BM_EDGE;
+ }
+ if (htype_needed & BM_FACE) {
+ if (bm->ftable && bm->totface <= bm->ftable_tot && bm->totface * 2 >= bm->ftable_tot) {
+ /* pass (re-use the array) */
+ }
+ else {
+ if (bm->ftable)
+ MEM_freeN(bm->ftable);
+ bm->ftable = MEM_mallocN(sizeof(void **) * bm->totface, "bm->ftable");
+ bm->ftable_tot = bm->totface;
+ }
+ bm->elem_table_dirty &= ~BM_FACE;
+ }
+
+#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT)
+ {
+#pragma omp section
+ {
+ if (htype_needed & BM_VERT) {
+ BM_iter_as_array(bm, BM_VERTS_OF_MESH, NULL, (void **)bm->vtable, bm->totvert);
+ }
+ }
+#pragma omp section
+ {
+ if (htype_needed & BM_EDGE) {
+ BM_iter_as_array(bm, BM_EDGES_OF_MESH, NULL, (void **)bm->etable, bm->totedge);
+ }
+ }
+#pragma omp section
+ {
+ if (htype_needed & BM_FACE) {
+ BM_iter_as_array(bm, BM_FACES_OF_MESH, NULL, (void **)bm->ftable, bm->totface);
+ }
+ }
+ }
+}
+
+/* use BM_mesh_elem_table_ensure where possible to avoid full rebuild */
+void BM_mesh_elem_table_init(BMesh *bm, const char htype)
+{
+ BLI_assert((htype & ~BM_ALL_NOLOOP) == 0);
+
+ /* force recalc */
+ BM_mesh_elem_table_free(bm, BM_ALL_NOLOOP);
+ BM_mesh_elem_table_ensure(bm, htype);
+}
+
+void BM_mesh_elem_table_free(BMesh *bm, const char htype)
+{
+ if (htype & BM_VERT) {
+ MEM_SAFE_FREE(bm->vtable);
+ }
+
+ if (htype & BM_EDGE) {
+ MEM_SAFE_FREE(bm->etable);
+ }
+
+ if (htype & BM_FACE) {
+ MEM_SAFE_FREE(bm->ftable);
+ }
+}
+
+BMVert *BM_vert_at_index(BMesh *bm, const int index)
+{
+ BLI_assert((index >= 0) && (index < bm->totvert));
+ BLI_assert((bm->elem_table_dirty & BM_VERT) == 0);
+ return bm->vtable[index];
+}
+
+BMEdge *BM_edge_at_index(BMesh *bm, const int index)
+{
+ BLI_assert((index >= 0) && (index < bm->totedge));
+ BLI_assert((bm->elem_table_dirty & BM_EDGE) == 0);
+ return bm->etable[index];
+}
+
+BMFace *BM_face_at_index(BMesh *bm, const int index)
+{
+ BLI_assert((index >= 0) && (index < bm->totface));
+ BLI_assert((bm->elem_table_dirty & BM_FACE) == 0);
+ return bm->ftable[index];
+}
+
+
+BMVert *BM_vert_at_index_find(BMesh *bm, const int index)
+{
+ return BLI_mempool_findelem(bm->vpool, index);
+}
+
+BMEdge *BM_edge_at_index_find(BMesh *bm, const int index)
+{
+ return BLI_mempool_findelem(bm->epool, index);
+}
+
+BMFace *BM_face_at_index_find(BMesh *bm, const int index)
+{
+ return BLI_mempool_findelem(bm->fpool, index);
+}
+
+
/**
* Return the amount of element of type 'type' in a given bmesh.
*/
@@ -828,18 +1005,3 @@ void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx)
if (fptr_map)
BLI_ghash_free(fptr_map, NULL, NULL);
}
-
-BMVert *BM_vert_at_index(BMesh *bm, const int index)
-{
- return BLI_mempool_findelem(bm->vpool, index);
-}
-
-BMEdge *BM_edge_at_index(BMesh *bm, const int index)
-{
- return BLI_mempool_findelem(bm->epool, index);
-}
-
-BMFace *BM_face_at_index(BMesh *bm, const int index)
-{
- return BLI_mempool_findelem(bm->fpool, index);
-}
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index 583b1589290..33431714660 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -45,14 +45,29 @@ void bmesh_edit_end(BMesh *bm, const BMOpTypeFlag type_flag);
void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag);
void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func,
const char *msg_a, const char *msg_b);
-int BM_mesh_elem_count(BMesh *bm, const char htype);
-void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx);
+#ifndef NDEBUG
+bool BM_mesh_elem_table_check(BMesh *em);
+#endif
+
+void BM_mesh_elem_table_ensure(BMesh *bm, const char htype);
+void BM_mesh_elem_table_init(BMesh *bm, const char htype);
+void BM_mesh_elem_table_free(BMesh *bm, const char htype);
BMVert *BM_vert_at_index(BMesh *bm, const int index);
BMEdge *BM_edge_at_index(BMesh *bm, const int index);
BMFace *BM_face_at_index(BMesh *bm, const int index);
+BMVert *BM_vert_at_index_find(BMesh *bm, const int index);
+BMEdge *BM_edge_at_index_find(BMesh *bm, const int index);
+BMFace *BM_face_at_index_find(BMesh *bm, const int index);
+
+// XXX
+
+int BM_mesh_elem_count(BMesh *bm, const char htype);
+
+void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx);
+
typedef struct BMAllocTemplate {
int totvert, totedge, totloop, totface;
} BMAllocTemplate;
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 3ffdd0f86a6..4dc155e68c2 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -231,49 +231,24 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v)
* to be reconsidered.
*
* If the windings do not match the winding of the new face will follow
- * \a f1's winding (i.e. \a f2 will be reversed before the join).
+ * \a f_a's winding (i.e. \a f_b will be reversed before the join).
*
* \return pointer to the combined face
*/
-BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, const bool do_del)
+BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f_a, BMFace *f_b, BMEdge *e, const bool do_del)
{
- BMLoop *l1, *l2;
- BMEdge *jed = NULL;
- BMFace *faces[2] = {f1, f2};
-
- jed = e;
- if (!jed) {
- BMLoop *l_first;
- /* search for an edge that has both these faces in its radial cycle */
- l1 = l_first = BM_FACE_FIRST_LOOP(f1);
- do {
- if (l1->radial_next->f == f2) {
- jed = l1->e;
- break;
- }
- } while ((l1 = l1->next) != l_first);
- }
+ BMFace *faces[2] = {f_a, f_b};
- if (UNLIKELY(!jed)) {
- BMESH_ASSERT(0);
- return NULL;
- }
-
- l1 = jed->l;
-
- if (UNLIKELY(!l1)) {
- BMESH_ASSERT(0);
- return NULL;
- }
-
- l2 = l1->radial_next;
- if (l1->v == l2->v) {
- bmesh_loop_reverse(bm, f2);
- }
+ BMLoop *l_a = BM_face_edge_share_loop(f_a, e);
+ BMLoop *l_b = BM_face_edge_share_loop(f_b, e);
- f1 = BM_faces_join(bm, faces, 2, do_del);
+ BLI_assert(l_a && l_b);
+
+ if (l_a->v == l_b->v) {
+ bmesh_loop_reverse(bm, f_b);
+ }
- return f1;
+ return BM_faces_join(bm, faces, 2, do_del);
}
/**
@@ -849,7 +824,7 @@ void BM_edge_calc_rotate(BMEdge *e, const bool ccw,
/* we could swap the verts _or_ the faces, swapping faces
* gives more predictable results since that way the next vert
* just stitches from face fa / fb */
- if (ccw) {
+ if (!ccw) {
SWAP(BMFace *, fa, fb);
}
@@ -1074,7 +1049,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f
f_hflag_prev_2 = l2->f->head.hflag;
/* don't delete the edge, manually remove the edge after so we can copy its attributes */
- f = BM_faces_join_pair(bm, l1->f, l2->f, NULL, true);
+ f = BM_faces_join_pair(bm, l1->f, l2->f, e, true);
if (f == NULL) {
return NULL;
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 775cb24b8c9..ef43d73d485 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1028,7 +1028,8 @@ static BMOpDefine bmo_triangulate_def = {
"triangulate",
/* slots_in */
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
- {"use_beauty", BMO_OP_SLOT_BOOL},
+ {"quad_method", BMO_OP_SLOT_INT},
+ {"ngon_method", BMO_OP_SLOT_INT},
{{'\0'}},
},
/* slots_out */
@@ -1556,6 +1557,7 @@ static BMOpDefine bmo_bevel_def = {
/* slots_in */
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input edges and vertices */
{"offset", BMO_OP_SLOT_FLT}, /* amount to offset beveled edge */
+ {"offset_type", BMO_OP_SLOT_INT}, /* how to measure offset (enum) */
{"segments", BMO_OP_SLOT_INT}, /* number of segments in bevel */
{"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */
{{'\0'}},
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 56d63694d88..b3d97947cab 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -117,6 +117,14 @@ enum {
BMOP_POKE_BOUNDS
};
+/* Bevel offset_type slot values */
+enum {
+ BEVEL_AMT_OFFSET,
+ BEVEL_AMT_WIDTH,
+ BEVEL_AMT_DEPTH,
+ BEVEL_AMT_PERCENT
+};
+
extern const BMOpDefine *bmo_opdefines[];
extern const int bmo_opdefines_total;
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index e4c1180d433..3db6ba0e7c9 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -29,6 +29,9 @@
*/
#include "DNA_listBase.h"
+#include "DNA_modifier_types.h"
+
+#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_math.h"
@@ -37,6 +40,7 @@
#include "BLI_listbase.h"
#include "bmesh.h"
+#include "bmesh_tools.h"
#include "intern/bmesh_private.h"
@@ -803,33 +807,98 @@ bool BM_face_point_inside_test(BMFace *f, const float co[3])
/**
* \brief BMESH TRIANGULATE FACE
*
- * Currently repeatedly find the best triangle (i.e. the most "open" one), provided it does not
- * produces a "remaining" face with too much wide/narrow angles
- * (using cos (i.e. dot product of normalized vectors) of angles).
+ * Breaks all quads and ngons down to triangles.
+ * It uses scanfill for the ngons splitting, and
+ * the beautify operator when use_beauty is true.
*
* \param r_faces_new if non-null, must be an array of BMFace pointers,
- * with a length equal to (f->len - 2). It will be filled with the new
- * triangles.
+ * with a length equal to (f->len - 3). It will be filled with the new
+ * triangles (not including the original triangle).
*
* \note use_tag tags new flags and edges.
*/
-#define SF_EDGE_IS_BOUNDARY 0xff
void BM_face_triangulate(BMesh *bm, BMFace *f,
BMFace **r_faces_new,
MemArena *sf_arena,
- const bool UNUSED(use_beauty), const bool use_tag)
+ const int quad_method,
+ const int ngon_method,
+ const bool use_tag)
{
- int nf_i = 0;
BMLoop *l_iter, *l_first, *l_new;
BMFace *f_new;
+ int orig_f_len = f->len;
+ int nf_i = 0;
+ BMEdge **edge_array;
+ int edge_array_len;
+ bool use_beauty = (ngon_method == MOD_TRIANGULATE_NGON_BEAUTY);
+
+#define SF_EDGE_IS_BOUNDARY 0xff
BLI_assert(BM_face_is_normal_valid(f));
if (f->len == 4) {
+ BMVert *v1, *v2;
l_first = BM_FACE_FIRST_LOOP(f);
- f_new = BM_face_split(bm, f, l_first->v, l_first->next->next->v, &l_new, NULL, false);
+ switch (quad_method) {
+ case MOD_TRIANGULATE_QUAD_FIXED:
+ {
+ v1 = l_first->v;
+ v2 = l_first->next->next->v;
+ break;
+ }
+ case MOD_TRIANGULATE_QUAD_ALTERNATE:
+ {
+ v1 = l_first->next->v;
+ v2 = l_first->prev->v;
+ break;
+ }
+ case MOD_TRIANGULATE_QUAD_SHORTEDGE:
+ {
+ BMVert *v3, *v4;
+ float d1, d2;
+
+ v1 = l_first->v;
+ v2 = l_first->next->next->v;
+ v3 = l_first->next->v;
+ v4 = l_first->prev->v;
+
+ d1 = len_squared_v3v3(v1->co, v2->co);
+ d2 = len_squared_v3v3(v3->co, v4->co);
+
+ if (d2 < d1) {
+ v1 = v3;
+ v2 = v4;
+ }
+ break;
+ }
+ case MOD_TRIANGULATE_QUAD_BEAUTY:
+ default:
+ {
+ BMVert *v3, *v4;
+ float cost;
+
+ v1 = l_first->next->v;
+ v2 = l_first->next->next->v;
+ v3 = l_first->prev->v;
+ v4 = l_first->v;
+
+ cost = BM_verts_calc_rotate_beauty(v1, v2, v3, v4, 0, 0);
+
+ if (cost < 0.0f) {
+ v1 = v4;
+ //v2 = v2;
+ }
+ else {
+ //v1 = v1;
+ v2 = v3;
+ }
+ break;
+ }
+ }
+
+ f_new = BM_face_split(bm, f, v1, v2, &l_new, NULL, false);
copy_v3_v3(f_new->no, f->no);
if (use_tag) {
@@ -904,35 +973,115 @@ void BM_face_triangulate(BMesh *bm, BMFace *f,
if (use_tag) {
BM_elem_flag_enable(f_new, BM_ELEM_TAG);
}
- if (r_faces_new && sf_tri->next) {
+ if (r_faces_new) {
r_faces_new[nf_i++] = f_new;
}
}
}
- if (use_tag) {
+ if (use_beauty || use_tag) {
ScanFillEdge *sf_edge;
+ edge_array = BLI_array_alloca(edge_array, orig_f_len - 3);
+ edge_array_len = 0;
+
for (sf_edge = sf_ctx.filledgebase.first; sf_edge; sf_edge = sf_edge->next) {
+ BMLoop *l1 = sf_edge->v1->tmp.p;
+ BMLoop *l2 = sf_edge->v2->tmp.p;
+
+ BMEdge *e = BM_edge_exists(l1->v, l2->v);
if (sf_edge->tmp.c != SF_EDGE_IS_BOUNDARY) {
- BMLoop *l1 = sf_edge->v1->tmp.p;
- BMLoop *l2 = sf_edge->v2->tmp.p;
- BMEdge *e = BM_edge_exists(l1->v, l2->v);
- BM_elem_flag_enable(e, BM_ELEM_TAG);
+ if (use_beauty) {
+ BM_elem_index_set(e, edge_array_len); /* set_dirty */
+ edge_array[edge_array_len] = e;
+ edge_array_len++;
+ }
+
+ if (use_tag) {
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
+ }
+ }
+ else if (use_tag) {
+ BM_elem_flag_disable(e, BM_ELEM_TAG);
}
}
+
}
- if (sf_ctx.fillfacebase.first) {
+ if ((!use_beauty) || (!r_faces_new)) {
/* we can't delete the real face, because some of the callers expect it to remain valid.
* so swap data and delete the last created tri */
bmesh_face_swap_data(bm, f, f_new);
BM_face_kill(bm, f_new);
}
+ if (use_beauty) {
+ bm->elem_index_dirty |= BM_EDGE;
+ BM_mesh_beautify_fill(bm, edge_array, edge_array_len, 0, 0, 0, 0);
+
+ if (r_faces_new) {
+ /* beautify deletes and creates new faces
+ * we need to re-populate the r_faces_new array
+ * with the new faces
+ */
+ int i;
+
+
+#define FACE_USED_TEST(f) (BM_elem_index_get(f) == -2)
+#define FACE_USED_SET(f) BM_elem_index_set(f, -2)
+
+ nf_i = 0;
+ for (i = 0; i < edge_array_len; i++) {
+ BMFace *f_a, *f_b;
+ BMEdge *e = edge_array[i];
+ const bool ok = BM_edge_face_pair(e, &f_a, &f_b);
+
+ BLI_assert(ok);
+
+ if (FACE_USED_TEST(f_a) == false) {
+ FACE_USED_SET(f_a);
+
+ if (nf_i < edge_array_len) {
+ r_faces_new[nf_i++] = f_a;
+ }
+ else {
+ f_new = f_a;
+ break;
+ }
+ }
+
+ if (FACE_USED_TEST(f_b) == false) {
+ FACE_USED_SET(f_b);
+
+ if (nf_i < edge_array_len) {
+ r_faces_new[nf_i++] = f_b;
+ }
+ else {
+ f_new = f_b;
+ break;
+ }
+ }
+ }
+
+#undef FACE_USED_TEST
+#undef FACE_USED_SET
+
+ /* nf_i doesn't include the last face */
+ BLI_assert(nf_i == orig_f_len - 3);
+
+ /* we can't delete the real face, because some of the callers expect it to remain valid.
+ * so swap data and delete the last created tri */
+ bmesh_face_swap_data(bm, f, f_new);
+ BM_face_kill(bm, f_new);
+ }
+ }
+
/* garbage collection */
BLI_scanfill_end_arena(&sf_ctx, sf_arena);
}
+
+#undef SF_EDGE_IS_BOUNDARY
+
}
/**
@@ -1121,3 +1270,160 @@ void BM_face_as_array_loop_quad(BMFace *f, BMLoop *r_loops[4])
r_loops[2] = l; l = l->next;
r_loops[3] = l;
}
+
+
+/**
+ * \brief BM_bmesh_calc_tessellation get the looptris and its number from a certain bmesh
+ * \param looptris
+ *
+ * \note \a looptris Must be pre-allocated to at least the size of given by: poly_to_tri_count
+ */
+void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot)
+{
+ /* use this to avoid locking pthread for _every_ polygon
+ * and calling the fill function */
+#define USE_TESSFACE_SPEEDUP
+
+ /* this assumes all faces can be scan-filled, which isn't always true,
+ * worst case we over alloc a little which is acceptable */
+ const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
+
+ BMIter iter;
+ BMFace *efa;
+ BMLoop *l;
+ int i = 0;
+
+ ScanFillContext sf_ctx;
+ MemArena *sf_arena = NULL;
+
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ /* don't consider two-edged faces */
+ if (UNLIKELY(efa->len < 3)) {
+ /* do nothing */
+ }
+
+#ifdef USE_TESSFACE_SPEEDUP
+
+ /* no need to ensure the loop order, we know its ok */
+
+ else if (efa->len == 3) {
+#if 0
+ int j;
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) {
+ looptris[i][j] = l;
+ }
+ i += 1;
+#else
+ /* more cryptic but faster */
+ BMLoop **l_ptr = looptris[i++];
+ l_ptr[0] = l = BM_FACE_FIRST_LOOP(efa);
+ l_ptr[1] = l = l->next;
+ l_ptr[2] = l->next;
+#endif
+ }
+ else if (efa->len == 4) {
+#if 0
+ BMLoop *ltmp[4];
+ int j;
+ BLI_array_grow_items(looptris, 2);
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) {
+ ltmp[j] = l;
+ }
+
+ looptris[i][0] = ltmp[0];
+ looptris[i][1] = ltmp[1];
+ looptris[i][2] = ltmp[2];
+ i += 1;
+
+ looptris[i][0] = ltmp[0];
+ looptris[i][1] = ltmp[2];
+ looptris[i][2] = ltmp[3];
+ i += 1;
+#else
+ /* more cryptic but faster */
+ BMLoop **l_ptr_a = looptris[i++];
+ BMLoop **l_ptr_b = looptris[i++];
+ (l_ptr_a[0] = l_ptr_b[0] = l = BM_FACE_FIRST_LOOP(efa));
+ (l_ptr_a[1] = l = l->next);
+ (l_ptr_a[2] = l_ptr_b[1] = l = l->next);
+ ( l_ptr_b[2] = l->next);
+#endif
+ }
+
+#endif /* USE_TESSFACE_SPEEDUP */
+
+ else {
+ int j;
+ BMLoop *l_iter;
+ BMLoop *l_first;
+
+ ScanFillVert *sf_vert, *sf_vert_last = NULL, *sf_vert_first = NULL;
+ /* ScanFillEdge *e; */ /* UNUSED */
+ ScanFillFace *sf_tri;
+ int totfilltri;
+
+ if (UNLIKELY(sf_arena == NULL)) {
+ sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
+ }
+
+ BLI_scanfill_begin_arena(&sf_ctx, sf_arena);
+
+ /* scanfill time */
+ j = 0;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ sf_vert = BLI_scanfill_vert_add(&sf_ctx, l_iter->v->co);
+ sf_vert->tmp.p = l_iter;
+
+ if (sf_vert_last) {
+ /* e = */ BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
+ }
+
+ sf_vert_last = sf_vert;
+ if (sf_vert_first == NULL) {
+ sf_vert_first = sf_vert;
+ }
+
+ /*mark order */
+ BM_elem_index_set(l_iter, j++); /* set_loop */
+
+ } while ((l_iter = l_iter->next) != l_first);
+
+ /* complete the loop */
+ BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert);
+
+ totfilltri = BLI_scanfill_calc_ex(&sf_ctx, 0, efa->no);
+ BLI_assert(totfilltri <= efa->len - 2);
+ (void)totfilltri;
+
+ for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) {
+ BMLoop **l_ptr = looptris[i++];
+ BMLoop *l1 = sf_tri->v1->tmp.p;
+ BMLoop *l2 = sf_tri->v2->tmp.p;
+ BMLoop *l3 = sf_tri->v3->tmp.p;
+
+ if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); }
+ if (BM_elem_index_get(l2) > BM_elem_index_get(l3)) { SWAP(BMLoop *, l2, l3); }
+ if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); }
+
+ l_ptr[0] = l1;
+ l_ptr[1] = l2;
+ l_ptr[2] = l3;
+ }
+
+ BLI_scanfill_end_arena(&sf_ctx, sf_arena);
+ }
+ }
+
+ if (sf_arena) {
+ BLI_memarena_free(sf_arena);
+ sf_arena = NULL;
+ }
+
+ *r_looptris_tot = looptris_tot;
+
+ BLI_assert(i <= looptris_tot);
+
+#undef USE_TESSFACE_SPEEDUP
+
+}
diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h
index b7117621273..4b3b7f4b837 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.h
+++ b/source/blender/bmesh/intern/bmesh_polygon.h
@@ -29,6 +29,8 @@
#include "BLI_compiler_attrs.h"
+void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot);
+
int BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, int (*r_index)[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BM_face_calc_normal(const BMFace *f, float r_no[3]) ATTR_NONNULL();
void BM_face_calc_normal_vcos(BMesh *bm, BMFace *f, float r_no[3],
@@ -54,7 +56,8 @@ bool BM_face_point_inside_test(BMFace *f, const float co[3]) ATTR_WARN_UNUSED_R
void BM_face_triangulate(BMesh *bm, BMFace *f, BMFace **newfaces,
struct MemArena *sf_arena,
- const bool use_beauty, const bool use_tag) ATTR_NONNULL(1, 2);
+ const int quad_method, const int ngon_method,
+ const bool use_tag) ATTR_NONNULL(1, 2);
void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len) ATTR_NONNULL();
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index 238b7b4aaaa..aca2f96dc18 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -37,7 +37,7 @@
#include "intern/bmesh_walkers_private.h"
/* pop into stack memory (common operation) */
-#define BMW_state_remove_r(walker, owalk) { \
+#define BMW_state_remove_r(walker, owalk) { \
memcpy(owalk, BMW_current_state(walker), sizeof(*(owalk))); \
BMW_state_remove(walker); \
} (void)0
diff --git a/source/blender/bmesh/operators/bmo_beautify.c b/source/blender/bmesh/operators/bmo_beautify.c
index bd20e384234..d9ab30bfcfa 100644
--- a/source/blender/bmesh/operators/bmo_beautify.c
+++ b/source/blender/bmesh/operators/bmo_beautify.c
@@ -25,426 +25,19 @@
*
* Beautify the mesh by rotating edges between triangles
* to more attractive positions until no more rotations can be made.
- *
- * In principle this is very simple however there is the possibility of
- * going into an eternal loop where edges keep rotating.
- * To avoid this - each edge stores a set of it previous
- * states so as not to rotate back.
- *
- * TODO
- * - Take face normals into account.
*/
#include "BLI_math.h"
-#include "BLI_heap.h"
#include "MEM_guardedalloc.h"
#include "bmesh.h"
+#include "bmesh_tools.h"
#include "intern/bmesh_operators_private.h"
-#include "BLI_strict_flags.h"
-
-// #define DEBUG_TIME
-
-#ifdef DEBUG_TIME
-# include "PIL_time.h"
-# include "PIL_time_utildefines.h"
-#endif
-
-enum {
- VERT_RESTRICT_TAG = (1 << 0),
-};
-
-/* -------------------------------------------------------------------- */
-/* GSet for edge rotation */
-
-typedef struct EdRotState {
- int v1, v2; /* edge vert, small -> large */
- int f1, f2; /* face vert, small -> large */
-} EdRotState;
-
-static unsigned int erot_gsetutil_hash(const void *ptr)
-{
- const EdRotState *e_state = (const EdRotState *)ptr;
- unsigned int
- hash = BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v1));
- hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v2));
- hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f1));
- hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f2));
- return hash;
-}
-static int erot_gsetutil_cmp(const void *a, const void *b)
-{
- const EdRotState *e_state_a = (const EdRotState *)a;
- const EdRotState *e_state_b = (const EdRotState *)b;
- if (e_state_a->v1 < e_state_b->v1) return -1;
- else if (e_state_a->v1 > e_state_b->v1) return 1;
- else if (e_state_a->v2 < e_state_b->v2) return -1;
- else if (e_state_a->v2 > e_state_b->v2) return 1;
- else if (e_state_a->f1 < e_state_b->f1) return -1;
- else if (e_state_a->f1 > e_state_b->f1) return 1;
- else if (e_state_a->f2 < e_state_b->f2) return -1;
- else if (e_state_a->f2 > e_state_b->f2) return 1;
- else return 0;
-}
-
-static GSet *erot_gset_new(void)
-{
- return BLI_gset_new(erot_gsetutil_hash, erot_gsetutil_cmp, __func__);
-}
-
-/* ensure v0 is smaller */
-#define EDGE_ORD(v0, v1) \
- if (v0 > v1) { \
- v0 ^= v1; \
- v1 ^= v0; \
- v0 ^= v1; \
- } (void)0
-
-static void erot_state_ex(const BMEdge *e, int v_index[2], int f_index[2])
-{
- BLI_assert(BM_edge_is_manifold((BMEdge *)e));
- BLI_assert(BM_vert_in_edge(e, e->l->prev->v) == false);
- BLI_assert(BM_vert_in_edge(e, e->l->radial_next->prev->v) == false);
-
- /* verts of the edge */
- v_index[0] = BM_elem_index_get(e->v1);
- v_index[1] = BM_elem_index_get(e->v2);
- EDGE_ORD(v_index[0], v_index[1]);
-
- /* verts of each of the 2 faces attached to this edge
- * (that are not apart of this edge) */
- f_index[0] = BM_elem_index_get(e->l->prev->v);
- f_index[1] = BM_elem_index_get(e->l->radial_next->prev->v);
- EDGE_ORD(f_index[0], f_index[1]);
-}
-
-static void erot_state_current(const BMEdge *e, EdRotState *e_state)
-{
- erot_state_ex(e, &e_state->v1, &e_state->f1);
-}
-
-static void erot_state_alternate(const BMEdge *e, EdRotState *e_state)
-{
- erot_state_ex(e, &e_state->f1, &e_state->v1);
-}
-
-/* -------------------------------------------------------------------- */
-/* Calculate the improvement of rotating the edge */
-
-/**
- * \return a negative value means the edge can be rotated.
- */
-static float bm_edge_calc_rotate_beauty__area(
- const float v1[3], const float v2[3], const float v3[3], const float v4[3])
-{
- /* not a loop (only to be able to break out) */
- do {
- float v1_xy[2], v2_xy[2], v3_xy[2], v4_xy[2];
-
- /* first get the 2d values */
- {
- bool is_zero_a, is_zero_b;
- float no[3];
- float axis_mat[3][3];
-
- // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f);
- BLI_assert((ELEM3(v1, v2, v3, v4) == false) &&
- (ELEM3(v2, v1, v3, v4) == false) &&
- (ELEM3(v3, v1, v2, v4) == false) &&
- (ELEM3(v4, v1, v2, v3) == false));
-
- is_zero_a = area_tri_v3(v2, v3, v4) <= FLT_EPSILON;
- is_zero_b = area_tri_v3(v2, v4, v1) <= FLT_EPSILON;
-
- if (LIKELY(is_zero_a == false && is_zero_b == false)) {
- float no_a[3], no_b[3];
- normal_tri_v3(no_a, v2, v3, v4); /* a */
- normal_tri_v3(no_b, v2, v4, v1); /* b */
- add_v3_v3v3(no, no_a, no_b);
- if (UNLIKELY(normalize_v3(no) <= FLT_EPSILON)) {
- break;
- }
- }
- else if (is_zero_a == false) {
- normal_tri_v3(no, v2, v3, v4); /* a */
- }
- else if (is_zero_b == false) {
- normal_tri_v3(no, v2, v4, v1); /* b */
- }
- else {
- /* both zero area, no useful normal can be calculated */
- break;
- }
-
- // { float a = angle_normalized_v3v3(no_a, no_b); printf("~ %.7f\n", a); fflush(stdout);}
-
- axis_dominant_v3_to_m3(axis_mat, no);
- mul_v2_m3v3(v1_xy, axis_mat, v1);
- mul_v2_m3v3(v2_xy, axis_mat, v2);
- mul_v2_m3v3(v3_xy, axis_mat, v3);
- mul_v2_m3v3(v4_xy, axis_mat, v4);
- }
-
- // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f);
-
- if (is_quad_convex_v2(v1_xy, v2_xy, v3_xy, v4_xy)) {
- /* testing rule: the area divided by the perimeter,
- * check if (1-3) beats the existing (2-4) edge rotation */
- float area_a, area_b;
- float prim_a, prim_b;
- float fac_24, fac_13;
-
- float len_12, len_23, len_34, len_41, len_24, len_13;
-
- /* edges around the quad */
- len_12 = len_v2v2(v1_xy, v2_xy);
- len_23 = len_v2v2(v2_xy, v3_xy);
- len_34 = len_v2v2(v3_xy, v4_xy);
- len_41 = len_v2v2(v4_xy, v1_xy);
- /* edges crossing the quad interior */
- len_13 = len_v2v2(v1_xy, v3_xy);
- len_24 = len_v2v2(v2_xy, v4_xy);
-
- /* edge (2-4), current state */
- area_a = area_tri_v2(v2_xy, v3_xy, v4_xy);
- area_b = area_tri_v2(v2_xy, v4_xy, v1_xy);
- prim_a = len_23 + len_34 + len_24;
- prim_b = len_24 + len_41 + len_12;
- fac_24 = (area_a / prim_a) + (area_b / prim_b);
-
- /* edge (1-3), new state */
- area_a = area_tri_v2(v1_xy, v2_xy, v3_xy);
- area_b = area_tri_v2(v1_xy, v3_xy, v4_xy);
- prim_a = len_12 + len_23 + len_13;
- prim_b = len_34 + len_41 + len_13;
- fac_13 = (area_a / prim_a) + (area_b / prim_b);
-
- /* negative number if (1-3) is an improved state */
- return fac_24 - fac_13;
- }
- } while (false);
-
- return FLT_MAX;
-}
-
-static float bm_edge_calc_rotate_beauty__angle(
- const float v1[3], const float v2[3], const float v3[3], const float v4[3])
-{
- /* not a loop (only to be able to break out) */
- do {
- float no_a[3], no_b[3];
- float angle_24, angle_13;
-
- /* edge (2-4), current state */
- normal_tri_v3(no_a, v2, v3, v4);
- normal_tri_v3(no_b, v2, v4, v1);
- angle_24 = angle_normalized_v3v3(no_a, no_b);
-
- /* edge (1-3), new state */
- /* only check new state for degenerate outcome */
- if ((normal_tri_v3(no_a, v1, v2, v3) == 0.0f) ||
- (normal_tri_v3(no_b, v1, v3, v4) == 0.0f))
- {
- break;
- }
- angle_13 = angle_normalized_v3v3(no_a, no_b);
-
- return angle_13 - angle_24;
- } while (false);
-
- return FLT_MAX;
-}
-
-static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const short method)
-{
- /* not a loop (only to be able to break out) */
- do {
- const float *v1, *v2, *v3, *v4;
-
- v1 = e->l->prev->v->co; /* first face co */
- v2 = e->l->v->co; /* e->v1 or e->v2*/
- v3 = e->l->radial_next->prev->v->co; /* second face co */
- v4 = e->l->next->v->co; /* e->v1 or e->v2*/
-
- if (flag & VERT_RESTRICT_TAG) {
- BMVert *v_a = e->l->prev->v, *v_b = e->l->radial_next->prev->v;
- if (BM_elem_flag_test(v_a, BM_ELEM_TAG) == BM_elem_flag_test(v_b, BM_ELEM_TAG)) {
- break;
- }
- }
-
- if (UNLIKELY(v1 == v3)) {
- // printf("This should never happen, but does sometimes!\n");
- break;
- }
-
- switch (method) {
- case 0:
- return bm_edge_calc_rotate_beauty__area(v1, v2, v3, v4);
- default:
- return bm_edge_calc_rotate_beauty__angle(v1, v2, v3, v4);
- }
- } while (false);
-
- return FLT_MAX;
-}
-
-/* -------------------------------------------------------------------- */
-/* Update the edge cost of rotation in the heap */
-
-/* recalc an edge in the heap (surrounding geometry has changed) */
-static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr,
- const short flag, const short method)
-{
- if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
- const int i = BM_elem_index_get(e);
- GSet *e_state_set = edge_state_arr[i];
-
- if (eheap_table[i]) {
- BLI_heap_remove(eheap, eheap_table[i]);
- eheap_table[i] = NULL;
- }
-
- /* check if we can add it back */
- BLI_assert(BM_edge_is_manifold(e) == true);
- //BLI_assert(BMO_elem_flag_test(bm, e->l->f, FACE_MARK) &&
- // BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK));
-
- /* check we're not moving back into a state we have been in before */
- if (e_state_set != NULL) {
- EdRotState e_state_alt;
- erot_state_alternate(e, &e_state_alt);
- if (BLI_gset_haskey(e_state_set, (void *)&e_state_alt)) {
- // printf(" skipping, we already have this state\n");
- return;
- }
- }
-
- {
- /* recalculate edge */
- const float cost = bm_edge_calc_rotate_beauty(e, flag, method);
- if (cost < 0.0f) {
- eheap_table[i] = BLI_heap_insert(eheap, cost, e);
- }
- else {
- eheap_table[i] = NULL;
- }
- }
- }
-}
-
-/* we have rotated an edge, tag other edges and clear this one */
-static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr,
- const short flag, const short method)
-{
- BMLoop *l;
- BLI_assert(e->l->f->len == 3 &&
- e->l->radial_next->f->len == 3);
-
- l = e->l;
- bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method);
- bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method);
- l = l->radial_next;
- bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method);
- bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method);
-}
-
-/* -------------------------------------------------------------------- */
-/* Beautify Fill */
-
#define ELE_NEW 1
#define FACE_MARK 2
-/**
- * \note All edges in \a edge_array must be tagged and
- * have their index values set according to their position in the array.
- */
-static void bm_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len,
- const short flag, const short method)
-{
- Heap *eheap; /* edge heap */
- HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */
-
- GSet **edge_state_arr = MEM_callocN((size_t)edge_array_len * sizeof(GSet *), __func__);
- BLI_mempool *edge_state_pool = BLI_mempool_create(sizeof(EdRotState), 512, 512, BLI_MEMPOOL_SYSMALLOC);
- int i;
-
-#ifdef DEBUG_TIME
- TIMEIT_START(beautify_fill);
-#endif
-
- eheap = BLI_heap_new_ex((unsigned int)edge_array_len);
- eheap_table = MEM_mallocN(sizeof(HeapNode *) * (size_t)edge_array_len, __func__);
-
- /* build heap */
- for (i = 0; i < edge_array_len; i++) {
- BMEdge *e = edge_array[i];
- const float cost = bm_edge_calc_rotate_beauty(e, flag, method);
- if (cost < 0.0f) {
- eheap_table[i] = BLI_heap_insert(eheap, cost, e);
- }
- else {
- eheap_table[i] = NULL;
- }
- }
-
- while (BLI_heap_is_empty(eheap) == false) {
- BMEdge *e = BLI_heap_popmin(eheap);
- i = BM_elem_index_get(e);
- eheap_table[i] = NULL;
-
- e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS);
- if (LIKELY(e)) {
- GSet *e_state_set = edge_state_arr[i];
-
- /* add the new state into the set so we don't move into this state again
- * note: we could add the previous state too but this isn't essential)
- * for avoiding eternal loops */
- EdRotState *e_state = BLI_mempool_alloc(edge_state_pool);
- erot_state_current(e, e_state);
- if (UNLIKELY(e_state_set == NULL)) {
- edge_state_arr[i] = e_state_set = erot_gset_new(); /* store previous state */
- }
- BLI_assert(BLI_gset_haskey(e_state_set, (void *)e_state) == false);
- BLI_gset_insert(e_state_set, e_state);
-
-
- // printf(" %d -> %d, %d\n", i, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2));
-
- /* maintain the index array */
- edge_array[i] = e;
- BM_elem_index_set(e, i);
-
- /* recalculate faces connected on the heap */
- bm_edge_update_beauty_cost(e, eheap, eheap_table, edge_state_arr, flag, method);
-
- /* update flags */
- BMO_elem_flag_enable(bm, e, ELE_NEW);
- BMO_elem_flag_enable(bm, e->l->f, FACE_MARK | ELE_NEW);
- BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK | ELE_NEW);
- }
- }
-
- BLI_heap_free(eheap, NULL);
- MEM_freeN(eheap_table);
-
- for (i = 0; i < edge_array_len; i++) {
- if (edge_state_arr[i]) {
- BLI_gset_free(edge_state_arr[i], NULL);
- }
- }
-
- MEM_freeN(edge_state_arr);
- BLI_mempool_destroy(edge_state_pool);
-
-#ifdef DEBUG_TIME
- TIMEIT_END(beautify_fill);
-#endif
-}
-
-
void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
{
BMIter iter;
@@ -486,9 +79,10 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
}
bm->elem_index_dirty |= BM_EDGE;
- bm_mesh_beautify_fill(bm, edge_array, edge_array_len, flag, method);
+ BM_mesh_beautify_fill(bm, edge_array, edge_array_len, flag, method, ELE_NEW, FACE_MARK | ELE_NEW);
MEM_freeN(edge_array);
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW);
}
+
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index eef470e0d85..4eec15d4d7e 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -35,9 +35,10 @@
void bmo_bevel_exec(BMesh *bm, BMOperator *op)
{
- const float offset = BMO_slot_float_get(op->slots_in, "offset");
- const int seg = BMO_slot_int_get(op->slots_in, "segments");
- const bool vonly = BMO_slot_bool_get(op->slots_in, "vertex_only");
+ const float offset = BMO_slot_float_get(op->slots_in, "offset");
+ const int offset_type = BMO_slot_int_get(op->slots_in, "offset_type");
+ const int seg = BMO_slot_int_get(op->slots_in, "segments");
+ const bool vonly = BMO_slot_bool_get(op->slots_in, "vertex_only");
if (offset > 0) {
BMOIter siter;
@@ -58,7 +59,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
}
}
- BM_mesh_bevel(bm, offset, seg, vonly, false, false, NULL, -1);
+ BM_mesh_bevel(bm, offset, offset_type, seg, vonly, false, false, NULL, -1);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
}
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index cf36e88ea98..ae645b97874 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -440,13 +440,18 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op)
BMO_error_raise(bm, op, BMERR_DISSOLVEVERTS_FAILED, msg);
}
- /* clean up any remainin */
- BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) {
+ /* clean up any remaining */
+ /* note: don't use BM_ITER_MESH_MUTABLE here, even though vertices are removed (T37559) */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
if (!BM_vert_dissolve(bm, v)) {
BMO_error_raise(bm, op, BMERR_DISSOLVEVERTS_FAILED, NULL);
return;
}
+#ifdef DEBUG
+ /* workaround debug assert */
+ iter.count = bm->totvert;
+#endif
}
}
diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c
index a4b1237bc5d..50d25202f7e 100644
--- a/source/blender/bmesh/operators/bmo_fill_grid.c
+++ b/source/blender/bmesh/operators/bmo_fill_grid.c
@@ -142,11 +142,11 @@ static void bm_loop_pair_from_verts(BMVert *v_a, BMVert *v_b,
static void bm_loop_pair_test_copy(BMLoop *l_pair_a[2], BMLoop *l_pair_b[2])
{
/* if the first one is set, we know the second is too */
- if (l_pair_a[0] && l_pair_b[0] == NULL) {
+ if (l_pair_a[0] && l_pair_b[0] == NULL) {
l_pair_b[0] = l_pair_a[1];
l_pair_b[1] = l_pair_a[0];
}
- else if (l_pair_b[0] && l_pair_a[0] == NULL) {
+ else if (l_pair_b[0] && l_pair_a[0] == NULL) {
l_pair_a[0] = l_pair_b[1];
l_pair_a[1] = l_pair_b[0];
}
@@ -633,7 +633,12 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
goto cleanup;
}
- BM_mesh_edgeloops_find_path(bm, &eloops_rail, bm_edge_test_rail_cb, (void *)bm, v_a_first, v_b_last);
+ /* We may find a first path, but not a second one! See geometry attached to bug [#37388]. */
+ if (BM_mesh_edgeloops_find_path(bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_first, v_b_last) == false) {
+ BMO_error_raise(bm, op, BMERR_INVALID_SELECTION,
+ "Loops are not connected by wire/boundary edges");
+ goto cleanup;
+ }
/* Check flipping by comparing path length */
estore_rail_a = eloops_rail.first;
@@ -656,7 +661,7 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
BM_edgeloop_free(estore_rail_a);
estore_rail_a = estore_rail_b;
- /* reverse so these so both are sorted the same way */
+ /* reverse so both are sorted the same way */
BM_edgeloop_flip(bm, estore_b);
SWAP(BMVert *, v_b_first, v_b_last);
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index ca45289520b..a1de265bc56 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -42,13 +42,15 @@
void bmo_triangulate_exec(BMesh *bm, BMOperator *op)
{
- const bool use_beauty = BMO_slot_bool_get(op->slots_in, "use_beauty");
+ const int quad_method = BMO_slot_int_get(op->slots_in, "quad_method");
+ const int ngon_method = BMO_slot_int_get(op->slots_in, "ngon_method");
+
BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "face_map.out");
BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false);
BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, false);
- BM_mesh_triangulate(bm, use_beauty, true, op, slot_facemap_out);
+ BM_mesh_triangulate(bm, quad_method, ngon_method, true, op, slot_facemap_out);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index c89fee71cbc..600386893dd 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -145,19 +145,23 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_test(bm, fb, FACE_TAINT) == false)
{
+ /* don't touch again (faces will be freed so run before rotating the edge) */
+ BMO_elem_flag_enable(bm, fa, FACE_TAINT);
+ BMO_elem_flag_enable(bm, fb, FACE_TAINT);
+
if (!(e2 = BM_edge_rotate(bm, e, use_ccw, check_flag))) {
+
+ BMO_elem_flag_disable(bm, fa, FACE_TAINT);
+ BMO_elem_flag_disable(bm, fb, FACE_TAINT);
#if 0
BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Could not rotate edge");
return;
#endif
+
continue;
}
BMO_elem_flag_enable(bm, e2, EDGE_OUT);
-
- /* don't touch again */
- BMO_elem_flag_enable(bm, fa, FACE_TAINT);
- BMO_elem_flag_enable(bm, fb, FACE_TAINT);
}
}
}
diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c
index 2e5db5210c4..94b35426e2b 100644
--- a/source/blender/bmesh/operators/bmo_wireframe.c
+++ b/source/blender/bmesh/operators/bmo_wireframe.c
@@ -172,9 +172,9 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
BMIter itersub;
/* filled only with boundary verts */
- BMVert **verts_src = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__);
- BMVert **verts_neg = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__);
- BMVert **verts_pos = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__);
+ BMVert **verts_src = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
+ BMVert **verts_neg = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
+ BMVert **verts_pos = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
/* will over-alloc, but makes for easy lookups by index to keep aligned */
BMVert **verts_boundary = use_boundary ?
@@ -210,7 +210,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
}
/* setup tags, all faces and verts will be tagged which will be duplicated */
- BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, false);
+ BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false);
BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) {
verts_loop_tot += f_src->len;
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
new file mode 100644
index 00000000000..cad5e1beeff
--- /dev/null
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -0,0 +1,445 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Joseph Eagar.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/tools/bmesh_beautify.c
+ * \ingroup bmesh
+ *
+ * Beautify the mesh by rotating edges between triangles
+ * to more attractive positions until no more rotations can be made.
+ *
+ * In principle this is very simple however there is the possibility of
+ * going into an eternal loop where edges keep rotating.
+ * To avoid this - each edge stores a set of it previous
+ * states so as not to rotate back.
+ *
+ * TODO
+ * - Take face normals into account.
+ */
+
+#include "BLI_math.h"
+#include "BLI_heap.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "bmesh.h"
+#include "bmesh_beautify.h" /* own include */
+
+
+// #define DEBUG_TIME
+
+#ifdef DEBUG_TIME
+# include "PIL_time.h"
+# include "PIL_time_utildefines.h"
+#endif
+
+/* -------------------------------------------------------------------- */
+/* GSet for edge rotation */
+
+typedef struct EdRotState {
+ int v1, v2; /* edge vert, small -> large */
+ int f1, f2; /* face vert, small -> large */
+} EdRotState;
+
+static unsigned int erot_gsetutil_hash(const void *ptr)
+{
+ const EdRotState *e_state = (const EdRotState *)ptr;
+ unsigned int
+ hash = BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v1));
+ hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v2));
+ hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f1));
+ hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f2));
+ return hash;
+}
+static int erot_gsetutil_cmp(const void *a, const void *b)
+{
+ const EdRotState *e_state_a = (const EdRotState *)a;
+ const EdRotState *e_state_b = (const EdRotState *)b;
+ if (e_state_a->v1 < e_state_b->v1) return -1;
+ else if (e_state_a->v1 > e_state_b->v1) return 1;
+ else if (e_state_a->v2 < e_state_b->v2) return -1;
+ else if (e_state_a->v2 > e_state_b->v2) return 1;
+ else if (e_state_a->f1 < e_state_b->f1) return -1;
+ else if (e_state_a->f1 > e_state_b->f1) return 1;
+ else if (e_state_a->f2 < e_state_b->f2) return -1;
+ else if (e_state_a->f2 > e_state_b->f2) return 1;
+ else return 0;
+}
+
+static GSet *erot_gset_new(void)
+{
+ return BLI_gset_new(erot_gsetutil_hash, erot_gsetutil_cmp, __func__);
+}
+
+/* ensure v0 is smaller */
+#define EDGE_ORD(v0, v1) \
+ if (v0 > v1) { \
+ v0 ^= v1; \
+ v1 ^= v0; \
+ v0 ^= v1; \
+ } (void)0
+
+static void erot_state_ex(const BMEdge *e, int v_index[2], int f_index[2])
+{
+ BLI_assert(BM_edge_is_manifold((BMEdge *)e));
+ BLI_assert(BM_vert_in_edge(e, e->l->prev->v) == false);
+ BLI_assert(BM_vert_in_edge(e, e->l->radial_next->prev->v) == false);
+
+ /* verts of the edge */
+ v_index[0] = BM_elem_index_get(e->v1);
+ v_index[1] = BM_elem_index_get(e->v2);
+ EDGE_ORD(v_index[0], v_index[1]);
+
+ /* verts of each of the 2 faces attached to this edge
+ * (that are not apart of this edge) */
+ f_index[0] = BM_elem_index_get(e->l->prev->v);
+ f_index[1] = BM_elem_index_get(e->l->radial_next->prev->v);
+ EDGE_ORD(f_index[0], f_index[1]);
+}
+
+static void erot_state_current(const BMEdge *e, EdRotState *e_state)
+{
+ erot_state_ex(e, &e_state->v1, &e_state->f1);
+}
+
+static void erot_state_alternate(const BMEdge *e, EdRotState *e_state)
+{
+ erot_state_ex(e, &e_state->f1, &e_state->v1);
+}
+
+/* -------------------------------------------------------------------- */
+/* Calculate the improvement of rotating the edge */
+
+/**
+ * \return a negative value means the edge can be rotated.
+ */
+static float bm_edge_calc_rotate_beauty__area(
+ const float v1[3], const float v2[3], const float v3[3], const float v4[3])
+{
+ /* not a loop (only to be able to break out) */
+ do {
+ float v1_xy[2], v2_xy[2], v3_xy[2], v4_xy[2];
+
+ /* first get the 2d values */
+ {
+ bool is_zero_a, is_zero_b;
+ float no[3];
+ float axis_mat[3][3];
+
+ // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f);
+ BLI_assert((ELEM3(v1, v2, v3, v4) == false) &&
+ (ELEM3(v2, v1, v3, v4) == false) &&
+ (ELEM3(v3, v1, v2, v4) == false) &&
+ (ELEM3(v4, v1, v2, v3) == false));
+
+ is_zero_a = area_tri_v3(v2, v3, v4) <= FLT_EPSILON;
+ is_zero_b = area_tri_v3(v2, v4, v1) <= FLT_EPSILON;
+
+ if (LIKELY(is_zero_a == false && is_zero_b == false)) {
+ float no_a[3], no_b[3];
+ normal_tri_v3(no_a, v2, v3, v4); /* a */
+ normal_tri_v3(no_b, v2, v4, v1); /* b */
+ add_v3_v3v3(no, no_a, no_b);
+ if (UNLIKELY(normalize_v3(no) <= FLT_EPSILON)) {
+ break;
+ }
+ }
+ else if (is_zero_a == false) {
+ normal_tri_v3(no, v2, v3, v4); /* a */
+ }
+ else if (is_zero_b == false) {
+ normal_tri_v3(no, v2, v4, v1); /* b */
+ }
+ else {
+ /* both zero area, no useful normal can be calculated */
+ break;
+ }
+
+ // { float a = angle_normalized_v3v3(no_a, no_b); printf("~ %.7f\n", a); fflush(stdout);}
+
+ axis_dominant_v3_to_m3(axis_mat, no);
+ mul_v2_m3v3(v1_xy, axis_mat, v1);
+ mul_v2_m3v3(v2_xy, axis_mat, v2);
+ mul_v2_m3v3(v3_xy, axis_mat, v3);
+ mul_v2_m3v3(v4_xy, axis_mat, v4);
+ }
+
+ // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f);
+
+ if (is_quad_convex_v2(v1_xy, v2_xy, v3_xy, v4_xy)) {
+ /* testing rule: the area divided by the perimeter,
+ * check if (1-3) beats the existing (2-4) edge rotation */
+ float area_a, area_b;
+ float prim_a, prim_b;
+ float fac_24, fac_13;
+
+ float len_12, len_23, len_34, len_41, len_24, len_13;
+
+ /* edges around the quad */
+ len_12 = len_v2v2(v1_xy, v2_xy);
+ len_23 = len_v2v2(v2_xy, v3_xy);
+ len_34 = len_v2v2(v3_xy, v4_xy);
+ len_41 = len_v2v2(v4_xy, v1_xy);
+ /* edges crossing the quad interior */
+ len_13 = len_v2v2(v1_xy, v3_xy);
+ len_24 = len_v2v2(v2_xy, v4_xy);
+
+ /* edge (2-4), current state */
+ area_a = area_tri_v2(v2_xy, v3_xy, v4_xy);
+ area_b = area_tri_v2(v2_xy, v4_xy, v1_xy);
+ prim_a = len_23 + len_34 + len_24;
+ prim_b = len_24 + len_41 + len_12;
+ fac_24 = (area_a / prim_a) + (area_b / prim_b);
+
+ /* edge (1-3), new state */
+ area_a = area_tri_v2(v1_xy, v2_xy, v3_xy);
+ area_b = area_tri_v2(v1_xy, v3_xy, v4_xy);
+ prim_a = len_12 + len_23 + len_13;
+ prim_b = len_34 + len_41 + len_13;
+ fac_13 = (area_a / prim_a) + (area_b / prim_b);
+
+ /* negative number if (1-3) is an improved state */
+ return fac_24 - fac_13;
+ }
+ } while (false);
+
+ return FLT_MAX;
+}
+
+static float bm_edge_calc_rotate_beauty__angle(
+ const float v1[3], const float v2[3], const float v3[3], const float v4[3])
+{
+ /* not a loop (only to be able to break out) */
+ do {
+ float no_a[3], no_b[3];
+ float angle_24, angle_13;
+
+ /* edge (2-4), current state */
+ normal_tri_v3(no_a, v2, v3, v4);
+ normal_tri_v3(no_b, v2, v4, v1);
+ angle_24 = angle_normalized_v3v3(no_a, no_b);
+
+ /* edge (1-3), new state */
+ /* only check new state for degenerate outcome */
+ if ((normal_tri_v3(no_a, v1, v2, v3) == 0.0f) ||
+ (normal_tri_v3(no_b, v1, v3, v4) == 0.0f))
+ {
+ break;
+ }
+ angle_13 = angle_normalized_v3v3(no_a, no_b);
+
+ return angle_13 - angle_24;
+ } while (false);
+
+ return FLT_MAX;
+}
+
+float BM_verts_calc_rotate_beauty(
+const BMVert *v1, const BMVert *v2, const BMVert *v3, const BMVert *v4, const short flag, const short method)
+{
+ /* not a loop (only to be able to break out) */
+ do {
+ if (flag & VERT_RESTRICT_TAG) {
+ const BMVert *v_a = v1, *v_b = v3;
+ if (BM_elem_flag_test(v_a, BM_ELEM_TAG) == BM_elem_flag_test(v_b, BM_ELEM_TAG)) {
+ break;
+ }
+ }
+
+ if (UNLIKELY(v1 == v3)) {
+ // printf("This should never happen, but does sometimes!\n");
+ break;
+ }
+
+ switch (method) {
+ case 0:
+ return bm_edge_calc_rotate_beauty__area(v1->co, v2->co, v3->co, v4->co);
+ default:
+ return bm_edge_calc_rotate_beauty__angle(v1->co, v2->co, v3->co, v4->co);
+ }
+ } while (false);
+
+ return FLT_MAX;
+}
+
+static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const short method)
+{
+ const BMVert *v1, *v2, *v3, *v4;
+ v1 = e->l->prev->v; /* first vert co */
+ v2 = e->l->v; /* e->v1 or e->v2*/
+ v3 = e->l->radial_next->prev->v; /* second vert co */
+ v4 = e->l->next->v; /* e->v1 or e->v2*/
+
+ return BM_verts_calc_rotate_beauty(v1, v2, v3, v4, flag, method);
+}
+
+/* -------------------------------------------------------------------- */
+/* Update the edge cost of rotation in the heap */
+
+/* recalc an edge in the heap (surrounding geometry has changed) */
+static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr,
+ const short flag, const short method)
+{
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ const int i = BM_elem_index_get(e);
+ GSet *e_state_set = edge_state_arr[i];
+
+ if (eheap_table[i]) {
+ BLI_heap_remove(eheap, eheap_table[i]);
+ eheap_table[i] = NULL;
+ }
+
+ /* check if we can add it back */
+ BLI_assert(BM_edge_is_manifold(e) == true);
+
+ /* check we're not moving back into a state we have been in before */
+ if (e_state_set != NULL) {
+ EdRotState e_state_alt;
+ erot_state_alternate(e, &e_state_alt);
+ if (BLI_gset_haskey(e_state_set, (void *)&e_state_alt)) {
+ // printf(" skipping, we already have this state\n");
+ return;
+ }
+ }
+
+ {
+ /* recalculate edge */
+ const float cost = bm_edge_calc_rotate_beauty(e, flag, method);
+ if (cost < 0.0f) {
+ eheap_table[i] = BLI_heap_insert(eheap, cost, e);
+ }
+ else {
+ eheap_table[i] = NULL;
+ }
+ }
+ }
+}
+
+/* we have rotated an edge, tag other edges and clear this one */
+static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr,
+ const short flag, const short method)
+{
+ BMLoop *l;
+ BLI_assert(e->l->f->len == 3 &&
+ e->l->radial_next->f->len == 3);
+
+ l = e->l;
+ bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method);
+ bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method);
+ l = l->radial_next;
+ bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method);
+ bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method);
+}
+
+/* -------------------------------------------------------------------- */
+/* Beautify Fill */
+
+/**
+ * \note All edges in \a edge_array must be tagged and
+ * have their index values set according to their position in the array.
+ */
+void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len,
+ const short flag, const short method,
+ const short oflag_edge, const short oflag_face)
+{
+ Heap *eheap; /* edge heap */
+ HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */
+
+ GSet **edge_state_arr = MEM_callocN((size_t)edge_array_len * sizeof(GSet *), __func__);
+ BLI_mempool *edge_state_pool = BLI_mempool_create(sizeof(EdRotState), 512, 512, BLI_MEMPOOL_SYSMALLOC);
+ int i;
+
+#ifdef DEBUG_TIME
+ TIMEIT_START(beautify_fill);
+#endif
+
+ eheap = BLI_heap_new_ex((unsigned int)edge_array_len);
+ eheap_table = MEM_mallocN(sizeof(HeapNode *) * (size_t)edge_array_len, __func__);
+
+ /* build heap */
+ for (i = 0; i < edge_array_len; i++) {
+ BMEdge *e = edge_array[i];
+ const float cost = bm_edge_calc_rotate_beauty(e, flag, method);
+ if (cost < 0.0f) {
+ eheap_table[i] = BLI_heap_insert(eheap, cost, e);
+ }
+ else {
+ eheap_table[i] = NULL;
+ }
+ }
+
+ while (BLI_heap_is_empty(eheap) == false) {
+ BMEdge *e = BLI_heap_popmin(eheap);
+ i = BM_elem_index_get(e);
+ eheap_table[i] = NULL;
+
+ e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS);
+ if (LIKELY(e)) {
+ GSet *e_state_set = edge_state_arr[i];
+
+ /* add the new state into the set so we don't move into this state again
+ * note: we could add the previous state too but this isn't essential)
+ * for avoiding eternal loops */
+ EdRotState *e_state = BLI_mempool_alloc(edge_state_pool);
+ erot_state_current(e, e_state);
+ if (UNLIKELY(e_state_set == NULL)) {
+ edge_state_arr[i] = e_state_set = erot_gset_new(); /* store previous state */
+ }
+ BLI_assert(BLI_gset_haskey(e_state_set, (void *)e_state) == false);
+ BLI_gset_insert(e_state_set, e_state);
+
+
+ // printf(" %d -> %d, %d\n", i, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2));
+
+ /* maintain the index array */
+ edge_array[i] = e;
+ BM_elem_index_set(e, i);
+
+ /* recalculate faces connected on the heap */
+ bm_edge_update_beauty_cost(e, eheap, eheap_table, edge_state_arr, flag, method);
+
+ /* update flags */
+ if (oflag_edge)
+ BMO_elem_flag_enable(bm, e, oflag_edge);
+ if (oflag_face) {
+ BMO_elem_flag_enable(bm, e->l->f, oflag_face);
+ BMO_elem_flag_enable(bm, e->l->radial_next->f, oflag_face);
+ }
+ }
+ }
+
+ BLI_heap_free(eheap, NULL);
+ MEM_freeN(eheap_table);
+
+ for (i = 0; i < edge_array_len; i++) {
+ if (edge_state_arr[i]) {
+ BLI_gset_free(edge_state_arr[i], NULL);
+ }
+ }
+
+ MEM_freeN(edge_state_arr);
+ BLI_mempool_destroy(edge_state_pool);
+
+#ifdef DEBUG_TIME
+ TIMEIT_END(beautify_fill);
+#endif
+}
+
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.cpp b/source/blender/bmesh/tools/bmesh_beautify.h
index f0e57ceac02..7cc17008b50 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.cpp
+++ b/source/blender/bmesh/tools/bmesh_beautify.h
@@ -15,35 +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.
*
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
+ * Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file gameengine/Ketsji/KX_IPhysicsController.cpp
- * \ingroup ketsji
- */
+#ifndef __BMESH_BEAUTIFY_H__
+#define __BMESH_BEAUTIFY_H__
-#include "KX_IPhysicsController.h"
+/** \file blender/bmesh/tools/bmesh_beautify.h
+ * \ingroup bmesh
+ */
-#include "PHY_DynamicTypes.h"
+enum {
+ VERT_RESTRICT_TAG = (1 << 0),
+};
-KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool sensor, bool character, bool compound, void* userdata)
+void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len,
+ const short flag, const short method,
+ const short oflag_edge, const short oflag_face);
-: m_bDyna(dyna),
- m_bSensor(sensor),
- m_bCharacter(character),
- m_bCompound(compound),
- m_suspendDynamics(false),
- m_userdata(userdata)
-{
-}
+float BM_verts_calc_rotate_beauty(const BMVert *v1, const BMVert *v2,
+ const BMVert *v3, const BMVert *v4,
+ const short flag, const short method);
-KX_IPhysicsController::~KX_IPhysicsController()
-{
-}
+#endif /* __BMESH_BEAUTIFY_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index bb3fe129e0b..5e68e468fb8 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -73,7 +73,8 @@ typedef struct EdgeHalf {
struct BoundVert *leftv; /* left boundary vert (looking along edge to end) */
struct BoundVert *rightv; /* right boundary vert, if beveled */
int seg; /* how many segments for the bevel */
- float offset; /* offset for this edge */
+ float offset_l; /* offset for this edge, on left side */
+ float offset_r; /* offset for this edge, on right side */
bool is_bev; /* is this edge beveled? */
bool is_rev; /* is e->v2 the vertex at this end? */
bool is_seam; /* is e a seam for custom loopdata (e.g., UVs)? */
@@ -128,9 +129,11 @@ typedef struct BevelParams {
MemArena *mem_arena; /* use for all allocs while bevel runs, if we need to free we can switch to mempool */
float offset; /* blender units to offset each side of a beveled edge */
+ int offset_type; /* how offset is measured; enum defined in bmesh_operators.h */
int seg; /* number of segments in beveled edge profile */
bool vertex_only; /* bevel vertices only */
bool use_weights; /* bevel amount affected by weights on edges or verts */
+ bool preserve_widths; /* should bevel prefer widths over angles, if forced to choose? */
const struct MDeformVert *dvert; /* vertex group array, maybe set if vertex_only */
int vertex_group; /* vertex group index, maybe set if vertex_only */
} BevelParams;
@@ -206,6 +209,28 @@ static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
return NULL;
}
+/* find the BevVert corresponding to BMVert bmv */
+static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv)
+{
+ return BLI_ghash_lookup(bp->vert_hash, bmv);
+}
+
+/* Find the EdgeHalf representing the other end of e->e.
+ * That may not have been constructed yet, in which case return NULL. */
+static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e)
+{
+ BevVert *bvother;
+ EdgeHalf *eother;
+
+ bvother = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2);
+ if (bvother) {
+ eother = find_edge_half(bvother, e->e);
+ BLI_assert(eother != NULL);
+ return eother;
+ }
+ return NULL;
+}
+
/* Return the next EdgeHalf after from_e that is beveled.
* If from_e is NULL, find the first beveled edge. */
static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
@@ -223,12 +248,6 @@ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
return NULL;
}
-/* find the BevVert corresponding to BMVert bmv */
-static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv)
-{
- return BLI_ghash_lookup(bp->vert_hash, bmv);
-}
-
/* Return a good representative face (for materials, etc.) for faces
* created around/near BoundVert v */
static BMFace *boundvert_rep_face(BoundVert *v)
@@ -449,14 +468,12 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
* Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco.
* e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of
* the bevel vertex, e1 precedes e2 in CCW order.
- * If on_right is true, offset edge is on right of both edges, where e1 enters v and
- * e2 leave it. If on_right is false, then the offset edge is on the left.
+ * Offset edge is on right of both edges, where e1 enters v and e2 leave it.
* When offsets are equal, the new point is on the edge bisector, with length offset/sin(angle/2),
* but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
* lead to different offsets) then meeting point can be found be intersecting offset lines.
*/
-static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
- int on_right, float meetco[3])
+static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, float meetco[3])
{
float dir1[3], dir2[3], norm_v[3], norm_perp1[3], norm_perp2[3],
off1a[3], off1b[3], off2a[3], off2b[3], isect2[3], ang;
@@ -469,7 +486,7 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
if (ang < 100.0f * BEVEL_EPSILON) {
/* special case: e1 and e2 are parallel; put offset point perp to both, from v.
* need to find a suitable plane.
- * if offsets are different, we're out of luck: just use e1->offset */
+ * if offsets are different, we're out of luck: just use e1->offset_r */
if (f)
copy_v3_v3(norm_v, f->no);
else
@@ -477,26 +494,25 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
cross_v3_v3v3(norm_perp1, dir1, norm_v);
normalize_v3(norm_perp1);
copy_v3_v3(off1a, v->co);
- madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
copy_v3_v3(meetco, off1a);
}
else if (fabsf(ang - (float)M_PI) < 100.0f * BEVEL_EPSILON) {
/* special case e1 and e2 are antiparallel, so bevel is into
* a zero-area face. Just make the offset point on the
* common line, at offset distance from v. */
- slide_dist(e2, v, e2->offset, meetco);
+ slide_dist(e2, v, e2->offset_l, meetco);
}
else {
- /* get normal to plane where meet point should be */
+ /* Get normal to plane where meet point should be,
+ * using cross product instead of f->no in case f is non-planar.
+ * If e1-v-e2 is a reflex angle (viewed from vertex normal side), need to flip*/
cross_v3_v3v3(norm_v, dir2, dir1);
normalize_v3(norm_v);
- if (!on_right)
+ if (dot_v3v3(norm_v, v->no) < 0.0f)
negate_v3(norm_v);
/* get vectors perp to each edge, perp to norm_v, and pointing into face */
- if (f) {
- copy_v3_v3(norm_v, f->no);
- }
cross_v3_v3v3(norm_perp1, dir1, norm_v);
cross_v3_v3v3(norm_perp2, dir2, norm_v);
normalize_v3(norm_perp1);
@@ -504,10 +520,10 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
/* get points that are offset distances from each line, then another point on each line */
copy_v3_v3(off1a, v->co);
- madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
add_v3_v3v3(off1b, off1a, dir1);
copy_v3_v3(off2a, v->co);
- madd_v3_v3fl(off2a, norm_perp2, e2->offset);
+ madd_v3_v3fl(off2a, norm_perp2, e2->offset_l);
add_v3_v3v3(off2b, off2a, dir2);
/* intersect the lines; by construction they should be on the same plane and not parallel */
@@ -520,19 +536,40 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
}
}
+/* Like offset_in_two planes, but for the case where we prefer to solve the problem
+ * of not meeting at the same point by choosing to change the bevel offset on one
+ * of the appropriate side of either e1 or e2, in order that the lines can meet on emid. */
+static void offset_on_edge_between(BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid,
+ BMVert *v, float meetco[3])
+{
+ BLI_assert(e1->is_bev && e2->is_bev && !emid->is_bev);
+
+ /* If have to change offset of e1 or e2, which one?
+ * Prefer the one whose other end hasn't been constructed yet.
+ * Following will choose to change e2 if both have already been constructed. */
+ if (find_other_end_edge_half(bp, e1)) {
+ offset_meet(e1, emid, v, e1->fnext, meetco);
+ /* now e2's left offset is probably different */
+ e2->offset_l = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e2->e, v)->co);
+ }
+ else {
+ offset_meet(emid, e2, v, emid->fnext, meetco);
+ /* now e1's right offset is probably different */
+ e1->offset_r = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e1->e, v)->co);
+ }
+}
+
/* Like offset_meet, but with a mid edge between them that is used
* to calculate the planes in which to run the offset lines.
- * They may not meet exactly: the offsets for the edges may be different
- * or both the planes and the lines may be angled so that they can't meet.
+ * They may not meet exactly: the lines may be angled so that they can't meet,
+ * probably because one or both faces is non-planar.
* In that case, pick a close point on emid, which should be the dividing
- * edge between the two planes.
- * TODO: should have a global 'offset consistency' prepass to adjust offset
- * widths so that all edges have the same offset at both ends. */
-static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid,
+ * edge between the two planes. */
+static void offset_in_two_planes(BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid,
BMVert *v, float meetco[3])
{
float dir1[3], dir2[3], dirmid[3], norm_perp1[3], norm_perp2[3],
- off1a[3], off1b[3], off2a[3], off2b[3], isect2[3], co[3],
+ off1a[3], off1b[3], off2a[3], off2b[3], isect2[3],
f1no[3], f2no[3], ang;
int iret;
@@ -545,6 +582,14 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid,
/* calculate face normals at corner in case faces are nonplanar */
cross_v3_v3v3(f1no, dirmid, dir1);
cross_v3_v3v3(f2no, dirmid, dir2);
+
+ /* if e1-v-emid or emid-v-e2 are reflex angles, need to flip corner normals */
+ if (dot_v3v3(f1no, v->no) < 0.0f)
+ negate_v3(f1no);
+ if (dot_v3v3(f2no, v->no) < 0.0f)
+ negate_v3(f2no);
+
+ /* get vectors perpendicular to e1 and e2, pointing into the proper faces */
cross_v3_v3v3(norm_perp1, dir1, f1no);
normalize_v3(norm_perp1);
cross_v3_v3v3(norm_perp2, dir2, f2no);
@@ -552,19 +597,19 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid,
/* get points that are offset distances from each line, then another point on each line */
copy_v3_v3(off1a, v->co);
- madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
sub_v3_v3v3(off1b, off1a, dir1);
copy_v3_v3(off2a, v->co);
- madd_v3_v3fl(off2a, norm_perp2, e2->offset);
+ madd_v3_v3fl(off2a, norm_perp2, e2->offset_l);
add_v3_v3v3(off2b, off2a, dir2);
ang = angle_v3v3(dir1, dir2);
if (ang < 100.0f * BEVEL_EPSILON) {
- /* lines are parallel; off1a is a good meet point */
- copy_v3_v3(meetco, off1a);
+ /* lines are parallel; put intersection on emid */
+ offset_on_edge_between(bp, e1, e2, emid, v, meetco);
}
else if (fabsf(ang - (float)M_PI) < 100.0f * BEVEL_EPSILON) {
- slide_dist(e2, v, e2->offset, meetco);
+ slide_dist(e2, v, e2->offset_l, meetco);
}
else {
iret = isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2);
@@ -573,11 +618,10 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid,
copy_v3_v3(meetco, off1a);
}
else if (iret == 2) {
- /* lines are not coplanar; meetco and isect2 are nearest to first and second lines */
+ /* lines are not coplanar and don't meet; meetco and isect2 are nearest to first and second lines */
if (len_v3v3(meetco, isect2) > 100.0f * BEVEL_EPSILON) {
- /* offset lines don't meet: project average onto emid; this is not ideal (see TODO above) */
- mid_v3_v3v3(co, meetco, isect2);
- closest_to_line_v3(meetco, co, v->co, BM_edge_other_vert(emid->e, v)->co);
+ /* offset lines don't meet so can't preserve widths; fallback on sliding along edge between */
+ offset_on_edge_between(bp, e1, e2, emid, v, meetco);
}
}
/* else iret == 1 and the lines are coplanar so meetco has the intersection */
@@ -612,7 +656,7 @@ static void offset_in_plane(EdgeHalf *e, const float plane_no[3], int left, floa
cross_v3_v3v3(fdir, no, dir);
normalize_v3(fdir);
copy_v3_v3(r, v->co);
- madd_v3_v3fl(r, fdir, e->offset);
+ madd_v3_v3fl(r, fdir, left? e->offset_l : e->offset_r);
}
/* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */
@@ -818,7 +862,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv)
v->efirst = v->elast = e;
e->rightv = v;
/* make artifical extra point along unbeveled edge, and form triangle */
- slide_dist(e->next, bv->v, e->offset, co);
+ slide_dist(e->next, bv->v, e->offset_l, co);
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = e->next;
e->next->leftv = e->next->rightv = v;
@@ -828,14 +872,14 @@ static void build_boundary(BevelParams *bp, BevVert *bv)
return;
}
- lastd = bp->vertex_only ? bv->offset : e->offset;
+ lastd = bp->vertex_only ? bv->offset : e->offset_l;
vm->boundstart = NULL;
do {
if (e->is_bev) {
/* handle only left side of beveled edge e here: next iteration should do right side */
if (e->prev->is_bev) {
BLI_assert(e->prev != e); /* see: wire edge special case */
- offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ offset_meet(e->prev, e, bv->v, e->fprev, co);
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev;
v->elast = v->ebev = e;
@@ -847,7 +891,10 @@ static void build_boundary(BevelParams *bp, BevVert *bv)
if (e->prev->prev->is_bev) {
BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */
/* find meet point between e->prev->prev and e and attach e->prev there */
- offset_in_two_planes(e->prev->prev, e, e->prev, bv->v, co);
+ if (bp->preserve_widths)
+ offset_in_two_planes(bp, e->prev->prev, e, e->prev, bv->v, co);
+ else
+ offset_on_edge_between(bp, e->prev->prev, e, e->prev, bv->v, co);
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev->prev;
v->elast = v->ebev = e;
@@ -857,7 +904,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv)
}
else {
/* neither e->prev nor e->prev->prev are beveled: make on-edge on e->prev */
- offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ offset_meet(e->prev, e, bv->v, e->fprev, co);
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev;
v->elast = v->ebev = e;
@@ -875,7 +922,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv)
}
else if (e->prev->is_bev) {
/* on-edge meet between e->prev and e */
- offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ offset_meet(e->prev, e, bv->v, e->fprev, co);
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev;
v->elast = e;
@@ -1921,6 +1968,19 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
}
}
+/* Return the angle between the two faces adjacent to e.
+ * If there are not two, return 0. */
+static float edge_face_angle(EdgeHalf *e)
+{
+ if (e->fprev && e->fnext) {
+ /* angle between faces is supplement of angle between face normals */
+ return (float)M_PI - angle_normalized_v3v3(e->fprev->no, e->fnext->no);
+ }
+ else {
+ return 0.0f;
+ }
+}
+
/* take care, this flag isn't cleared before use, it just so happens that its not set */
#define BM_BEVEL_EDGE_TAG_ENABLE(bme) BM_ELEM_API_FLAG_ENABLE( (bme), _FLAG_OVERLAP)
#define BM_BEVEL_EDGE_TAG_DISABLE(bme) BM_ELEM_API_FLAG_DISABLE( (bme), _FLAG_OVERLAP)
@@ -1936,8 +1996,8 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
BMEdge *bme2, *unflagged_bme, *first_bme;
BMFace *f;
BMIter iter, iter2;
- EdgeHalf *e;
- float weight;
+ EdgeHalf *e, *eother;
+ float weight, z;
int i, found_shared_face, ccw_test_sum;
int nsel = 0;
int ntot = 0;
@@ -2053,16 +2113,6 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
e->seg = 0;
}
e->is_rev = (bme->v2 == v);
- if (e->is_bev) {
- e->offset = bp->offset;
- if (bp->use_weights) {
- weight = BM_elem_float_data_get(&bm->edata, bme, CD_BWEIGHT);
- e->offset *= weight;
- }
- }
- else {
- e->offset = 0.0f;
- }
}
/* find wrap-around shared face */
BM_ITER_ELEM (f, &iter2, bme, BM_FACES_OF_EDGE) {
@@ -2098,6 +2148,63 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
for (i = 0, e = bv->edges; i < ntot; i++, e++) {
e->next = &bv->edges[(i + 1) % ntot];
e->prev = &bv->edges[(i + ntot - 1) % ntot];
+
+ /* set offsets */
+ if (e->is_bev) {
+ /* Convert distance as specified by user into offsets along
+ * faces on left side and right side of this edgehalf.
+ * Except for percent method, offset will be same on each side.
+ *
+ * First check to see if other end has had construction made,
+ * because offset may have been forced to another number
+ * (but for percent method all 4 widths can be different). */
+
+ eother = find_other_end_edge_half(bp, e);
+ if (eother && bp->offset_type != BEVEL_AMT_PERCENT) {
+ e->offset_l = eother->offset_r;
+ e->offset_r = eother->offset_l;
+ }
+ else {
+ switch (bp->offset_type) {
+ case BEVEL_AMT_OFFSET:
+ e->offset_l = bp->offset;
+ break;
+ case BEVEL_AMT_WIDTH:
+ z = fabsf(2.0f * sinf(edge_face_angle(e) / 2.0f));
+ if (z < BEVEL_EPSILON)
+ e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */
+ else
+ e->offset_l = bp->offset / z;
+ break;
+ case BEVEL_AMT_DEPTH:
+ z = fabsf(cosf(edge_face_angle(e) / 2.0f));
+ if (z < BEVEL_EPSILON)
+ e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */
+ else
+ e->offset_l = bp->offset / z;
+ break;
+ case BEVEL_AMT_PERCENT:
+ e->offset_l = BM_edge_calc_length(e->prev->e) * bp->offset / 100.0f;
+ e->offset_r = BM_edge_calc_length(e->next->e) * bp->offset / 100.0f;
+ break;
+ default:
+ BLI_assert(!"bad bevel offset kind");
+ e->offset_l = bp->offset;
+ break;
+ }
+ if (bp->offset_type != BEVEL_AMT_PERCENT)
+ e->offset_r = e->offset_l;
+ if (bp->use_weights) {
+ weight = BM_elem_float_data_get(&bm->edata, e->e, CD_BWEIGHT);
+ e->offset_l *= weight;
+ e->offset_r *= weight;
+ }
+ }
+ }
+ else {
+ e->offset_l = e->offset_r = 0.0f;
+ }
+
BM_BEVEL_EDGE_TAG_DISABLE(e->e);
if (e->fprev && e->fnext)
e->is_seam = !contig_ldata_across_edge(bm, e->e, e->fprev, e->fnext);
@@ -2370,7 +2477,7 @@ static float bevel_limit_offset(BMesh *bm, BevelParams *bp)
*
* \warning all tagged edges _must_ be manifold.
*/
-void BM_mesh_bevel(BMesh *bm, const float offset, const float segments,
+void BM_mesh_bevel(BMesh *bm, const float offset, const int offset_type, const float segments,
const bool vertex_only, const bool use_weights, const bool limit_offset,
const struct MDeformVert *dvert, const int vertex_group)
{
@@ -2380,9 +2487,11 @@ void BM_mesh_bevel(BMesh *bm, const float offset, const float segments,
BevelParams bp = {NULL};
bp.offset = offset;
+ bp.offset_type = offset_type;
bp.seg = segments;
bp.vertex_only = vertex_only;
bp.use_weights = use_weights;
+ bp.preserve_widths = false;
bp.dvert = dvert;
bp.vertex_group = vertex_group;
diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h
index bee26357aca..9897b6b070c 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.h
+++ b/source/blender/bmesh/tools/bmesh_bevel.h
@@ -29,7 +29,7 @@
struct MDeformVert;
-void BM_mesh_bevel(BMesh *bm, const float offset, const float segments,
+void BM_mesh_bevel(BMesh *bm, const float offset, const int offset_type, const float segments,
const bool vertex_only, const bool use_weights, const bool limit_offset,
const struct MDeformVert *dvert, const int vertex_group);
diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c
index 9cfe17d6413..6aeb26435ac 100644
--- a/source/blender/bmesh/tools/bmesh_bisect_plane.c
+++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c
@@ -300,31 +300,26 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4],
BMIter iter;
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- vert_is_center_disable(v);
-
- BM_VERT_DIR(v) = plane_point_test_v3(plane, v->co, eps, &(BM_VERT_DIST(v)));
- if (BM_VERT_DIR(v) == 0) {
- if (oflag_center) {
- BMO_elem_flag_enable(bm, v, oflag_center);
- }
- if (use_snap_center) {
- closest_to_plane_v3(v->co, plane, v->co);
- }
- }
- }
-
if (use_tag) {
/* build tagged edge array */
BMEdge *e;
einput_len = 0;
+
+ /* flush edge tags to verts */
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
+
/* keep face tags as is */
BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
if (edge_is_cut_test(e)) {
edges_arr[einput_len++] = e;
+
+ /* flush edge tags to verts */
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
}
}
+ /* face tags are set by caller */
}
else {
BMEdge *e;
@@ -339,6 +334,32 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4],
}
}
+
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+
+ if (use_tag && !BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ vert_is_center_disable(v);
+
+ /* these should never be accessed */
+ BM_VERT_DIR(v) = 0;
+ BM_VERT_DIST(v) = 0.0f;
+
+ continue;
+ }
+
+ vert_is_center_disable(v);
+ BM_VERT_DIR(v) = plane_point_test_v3(plane, v->co, eps, &(BM_VERT_DIST(v)));
+
+ if (BM_VERT_DIR(v) == 0) {
+ if (oflag_center) {
+ BMO_elem_flag_enable(bm, v, oflag_center);
+ }
+ if (use_snap_center) {
+ closest_to_plane_v3(v->co, plane, v->co);
+ }
+ }
+ }
+
/* store a stack of faces to be evaluated for splitting */
BLI_LINKSTACK_INIT(face_stack);
@@ -372,7 +393,7 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4],
BM_VERT_DIR(v_new) = 0;
BM_VERT_DIST(v_new) = 0.0f;
}
- else {
+ else if (side[0] == 0 || side[1] == 0) {
/* check if either edge verts are aligned,
* if so - tag and push all faces that use it into the stack */
unsigned int j;
@@ -394,6 +415,13 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4],
}
}
}
+
+ /* if both verts are on the center - tag it */
+ if (oflag_center) {
+ if (side[0] == 0 && side[1] == 0) {
+ BMO_elem_flag_enable(bm, e, oflag_center);
+ }
+ }
}
}
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 4b6835a81fe..99d46559ca5 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -390,10 +390,10 @@ static void bm_decim_triangulate_end(BMesh *bm)
{
/* decimation finished, now re-join */
BMIter iter;
- BMEdge *e;
+ BMEdge *e, *e_next;
/* boundary edges */
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) {
BMLoop *l_a, *l_b;
if (BM_edge_loop_pair(e, &l_a, &l_b)) {
const int l_a_index = BM_elem_index_get(l_a);
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c
index 34ff493a026..59c2aa4331d 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.c
+++ b/source/blender/bmesh/tools/bmesh_triangulate.c
@@ -42,14 +42,16 @@
/**
* a version of #BM_face_triangulate that maps to #BMOpSlot
*/
-static void bm_face_triangulate_mapping(BMesh *bm, BMFace *face, MemArena *sf_arena, const bool use_beauty, const bool use_tag,
+static void bm_face_triangulate_mapping(BMesh *bm, BMFace *face, MemArena *sf_arena,
+ const int quad_method, const int ngon_method,
+ const bool use_tag,
BMOperator *op, BMOpSlot *slot_facemap_out)
{
const int faces_array_tot = face->len - 3;
BMFace **faces_array = BLI_array_alloca(faces_array, faces_array_tot);
BLI_assert(face->len > 3);
- BM_face_triangulate(bm, face, faces_array, sf_arena, use_beauty, use_tag);
+ BM_face_triangulate(bm, face, faces_array, sf_arena, quad_method, ngon_method, use_tag);
if (faces_array) {
int i;
@@ -61,7 +63,7 @@ static void bm_face_triangulate_mapping(BMesh *bm, BMFace *face, MemArena *sf_ar
}
-void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only,
+void BM_mesh_triangulate(BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only,
BMOperator *op, BMOpSlot *slot_facemap_out)
{
BMIter iter;
@@ -75,7 +77,7 @@ void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only,
BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
if (face->len > 3) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
- bm_face_triangulate_mapping(bm, face, sf_arena, use_beauty, tag_only,
+ bm_face_triangulate_mapping(bm, face, sf_arena, quad_method, ngon_method, tag_only,
op, slot_facemap_out);
}
}
@@ -85,7 +87,7 @@ void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only,
BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
if (face->len > 3) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
- BM_face_triangulate(bm, face, NULL, sf_arena, use_beauty, tag_only);
+ BM_face_triangulate(bm, face, NULL, sf_arena, quad_method, ngon_method, tag_only);
}
}
}
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.h b/source/blender/bmesh/tools/bmesh_triangulate.h
index 141aa2f82b4..550109ffef9 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.h
+++ b/source/blender/bmesh/tools/bmesh_triangulate.h
@@ -30,7 +30,7 @@
#ifndef __BMESH_TRIANGULATE_H__
#define __BMESH_TRIANGULATE_H__
-void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only,
+void BM_mesh_triangulate(BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only,
BMOperator *op, BMOpSlot *slot_facemap_out);
#endif /* __BMESH_TRIANGULATE_H__ */
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index ea5fd203bea..60224151308 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -53,10 +53,6 @@ extern "C"
#include "BIK_api.h"
#include "BKE_global.h"
#include "ED_object.h"
-
-#ifdef NAN_BUILDINFO
-extern char build_rev[];
-#endif
}
#include "MEM_guardedalloc.h"
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 5d47ce155c8..74db2082a00 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -701,7 +701,7 @@ void ArmatureImporter::make_shape_keys()
//insert other shape keys
for (int i = 0 ; i < morphTargetIds.getCount() ; i++ ) {
- //better to have a seperate map of morph objects,
+ //better to have a separate map of morph objects,
//This'll do for now since only mesh morphing is imported
Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]);
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index c03316e1fe5..ee0326d5804 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -101,7 +101,9 @@ extern "C"
#include "ED_keyframing.h"
#ifdef WITH_BUILDINFO
-extern char build_rev[];
+extern char build_commit_date[];
+extern char build_commit_time[];
+extern char build_hash[];
#endif
#include "MEM_guardedalloc.h"
@@ -226,9 +228,12 @@ 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);
+ BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d commit date:%s, hash:",
+ BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION,
+ build_commit_date, build_commit_time, build_hash);
#else
- sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
+ BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d",
+ BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
#endif
asset.getContributor().mAuthoringTool = version_buf;
asset.add();
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 146aff5ca5b..2e805ce18f1 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -354,12 +354,14 @@ void bc_match_scale(std::vector<Object *> *objects_done,
void bc_triangulate_mesh(Mesh *me)
{
- bool use_beauty = false;
- bool tag_only = false;
+ bool use_beauty = false;
+ bool tag_only = false;
+ int quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE; /* XXX: The triangulation method selection could be offered in the UI */
BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default);
BM_mesh_bm_from_me(bm, me, true, false, 0);
- BM_mesh_triangulate(bm, use_beauty, tag_only, NULL, NULL);
+ BM_mesh_triangulate(bm, quad_method, use_beauty, tag_only, NULL, NULL);
+
BM_mesh_bm_to_me(bm, me, FALSE);
BM_mesh_free(bm);
}
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index e6a3c33ea5d..11add975db5 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -30,7 +30,6 @@ set(INC
operations
../blenkernel
../blenlib
- ../blenlib
../imbuf
../makesdna
../makesrna
@@ -230,8 +229,6 @@ set(SRC
nodes/COM_SetAlphaNode.h
nodes/COM_ConvertAlphaNode.cpp
nodes/COM_ConvertAlphaNode.h
- nodes/COM_AlphaOverNode.cpp
- nodes/COM_AlphaOverNode.h
nodes/COM_HueSaturationValueNode.cpp
nodes/COM_HueSaturationValueNode.h
nodes/COM_HueSaturationValueCorrectNode.cpp
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
index 9516deee7e3..7def96d426e 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
@@ -45,7 +45,10 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star
vector<Node *>& nodes = system.getNodes();
vector<SocketConnection *>& links = system.getConnections();
- bool is_active_group = (parent_key.value == system.getContext().getbNodeTree()->active_viewer_key.value);
+ const bNodeTree *basetree = system.getContext().getbNodeTree();
+ /* update viewers in the active edittree as well the base tree (for backdrop) */
+ bool is_active_group = ((parent_key.value == basetree->active_viewer_key.value) ||
+ (tree == basetree));
/* add all nodes of the tree to the node list */
bNode *node = (bNode *)tree->nodes.first;
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index b7aae8b92f0..2168611d0c0 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -63,7 +63,7 @@ protected:
* @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 output[4], float x, float y, PixelSampler sampler) {}
+ virtual void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) {}
/**
* @brief calculate a single pixel
@@ -75,7 +75,7 @@ protected:
* @param chunkData chunk specific data a during execution time.
*/
virtual void executePixel(float output[4], int x, int y, void *chunkData) {
- executePixel(output, x, y, COM_PS_NEAREST);
+ executePixelSampled(output, x, y, COM_PS_NEAREST);
}
/**
@@ -88,25 +88,25 @@ protected:
* @param dy
* @param inputBuffers chunks that can be read by their ReadBufferOperation.
*/
- virtual void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {}
+ virtual void executePixelFiltered(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {}
public:
- inline void read(float result[4], float x, float y, PixelSampler sampler) {
- executePixel(result, x, y, sampler);
+ inline void readSampled(float result[4], float x, float y, PixelSampler sampler) {
+ executePixelSampled(result, x, y, sampler);
}
inline void read(float result[4], int x, int y, void *chunkData) {
executePixel(result, x, y, chunkData);
}
- inline void read(float result[4], float x, float y, float dx, float dy, PixelSampler sampler) {
- executePixel(result, x, y, dx, dy, sampler);
+ inline void readFiltered(float result[4], float x, float y, float dx, float dy, PixelSampler sampler) {
+ executePixelFiltered(result, x, y, dx, dy, sampler);
}
virtual void *initializeTileData(rcti *rect) { return 0; }
- virtual void deinitializeTileData(rcti *rect, void *data) {
- }
-
- virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; }
+ virtual void deinitializeTileData(rcti *rect, void *data) {}
+ virtual ~SocketReader() {}
+
+ virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; }
inline const unsigned int getWidth() const { return this->m_width; }
inline const unsigned int getHeight() const { return this->m_height; }
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index 330e61e7fea..57e996fe3b2 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -77,9 +77,9 @@ static bool g_openclInitialized = false;
#define MAX_HIGHLIGHT 8
static bool g_highlightInitialized = false;
extern "C" {
-int g_highlightIndex;
-void **g_highlightedNodes;
-void **g_highlightedNodesRead;
+static int g_highlightIndex;
+static void **g_highlightedNodes;
+static void **g_highlightedNodesRead;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
#define HIGHLIGHT(wp) \
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index b59a92710bc..a8de2aed526 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -53,6 +53,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
if (data->filtertype == R_FILTER_FAST_GAUSS) {
FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
operationfgb->setData(data);
+ operationfgb->setChunksize(context->getChunksize());
operationfgb->setbNode(editorNode);
this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph);
graph->addOperation(operationfgb);
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
index 5578fdae54e..2b396fb9861 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
@@ -43,25 +43,23 @@ void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorCon
NodeOperation *operation;
if (node->custom1 == 0) {
ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation();
- {
- 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;
- }
+
+ float lift_lgg[3], gamma_inv[3];
+ for (int c = 0; c < 3; c++) {
+ lift_lgg[c] = 2.0f - n->lift[c];
+ gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
}
-
+
operationLGG->setGain(n->gain);
- operationLGG->setLift(n->lift_lgg);
- operationLGG->setGammaInv(n->gamma_inv);
+ operationLGG->setLift(lift_lgg);
+ operationLGG->setGammaInv(gamma_inv);
operation = operationLGG;
}
else {
ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation();
- operationCDL->setGain(n->gain);
- operationCDL->setLift(n->lift);
- operationCDL->setGamma(n->gamma);
+ operationCDL->setOffset(n->offset);
+ operationCDL->setPower(n->power);
+ operationCDL->setSlope(n->slope);
operation = operationCDL;
}
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index c2bd8997525..b6dd0e526ae 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -85,7 +85,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
BokehImageOperation *bokeh = new BokehImageOperation();
NodeBokehImage *bokehdata = new NodeBokehImage();
- bokehdata->angle = data->rotation;
+ bokehdata->angle = RAD2DEGF(data->rotation);
bokehdata->rounding = 0.0f;
bokehdata->flaps = data->bktype;
if (data->bktype < 3) {
diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
index a97714c870e..9894dc7b9ac 100644
--- a/source/blender/compositor/nodes/COM_DespeckleNode.cpp
+++ b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
@@ -39,7 +39,7 @@ void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContex
operation->setbNode(editorNode);
operation->setThreshold(editorNode->custom3);
- operation->setThresholdNeighbour(editorNode->custom4);
+ operation->setThresholdNeighbor(editorNode->custom4);
inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index 6e4bff460d1..d595afe6a78 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -142,7 +142,17 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
/* without this, multilayer that fail to load will crash blender [#32490] */
if (is_multilayer_ok == false) {
- convertToOperations_invalid(graph, context);
+ int index;
+ vector<OutputSocket *> &outputsockets = this->getOutputSockets();
+ for (index = 0; index < outputsockets.size(); index++) {
+ const float warning_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(warning_color);
+
+ /* link the operation */
+ this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+ }
}
}
else {
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
index 6cc9aae4553..d4103a61685 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
@@ -27,15 +27,15 @@ AlphaOverKeyOperation::AlphaOverKeyOperation() : MixBaseOperation()
/* pass */
}
-void AlphaOverKeyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void AlphaOverKeyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputOverColor[4];
float value[4];
- this->m_inputValueOperation->read(value, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputOverColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
if (inputOverColor[3] <= 0.0f) {
copy_v4_v4(output, inputColor1);
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
index 31b0422918a..eceee43e600 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
@@ -39,6 +39,6 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
index 111dc899e1d..1dba542e142 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
@@ -27,15 +27,15 @@ AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation()
this->m_x = 0.0f;
}
-void AlphaOverMixedOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void AlphaOverMixedOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputOverColor[4];
float value[4];
- this->m_inputValueOperation->read(value, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputOverColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
if (inputOverColor[3] <= 0.0f) {
copy_v4_v4(output, inputColor1);
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
index 14e7325ec1d..ff6d1a978b8 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
@@ -41,7 +41,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void setX(float x) { this->m_x = x; }
};
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
index ac7906f2f98..60a2fd6a442 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
@@ -27,15 +27,15 @@ AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation() : MixBaseOperatio
/* pass */
}
-void AlphaOverPremultiplyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void AlphaOverPremultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputOverColor[4];
float value[4];
- this->m_inputValueOperation->read(value, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputOverColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
/* Zero alpha values should still permit an add of RGB data */
if (inputOverColor[3] < 0.0f) {
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
index 16bd2aeaeed..db68583baa6 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
@@ -39,7 +39,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index cc91210a385..dfff2bfeafb 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -152,7 +152,7 @@ void BlurBaseOperation::updateSize()
{
if (!this->m_sizeavailable) {
float result[4];
- this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST);
+ this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
this->m_size = result[0];
this->m_sizeavailable = true;
}
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index 1c91af2a7a3..7f17db1d31b 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -80,7 +80,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
float tempBoundingBox[4];
float bokeh[4];
- this->m_inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST);
+ this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST);
if (tempBoundingBox[0] > 0.0f) {
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
@@ -93,7 +93,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
zero_v4(color_accum);
if (pixelSize < 2) {
- this->m_inputProgram->read(color_accum, x, y, COM_PS_NEAREST);
+ this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST);
multiplier_accum[0] = 1.0f;
multiplier_accum[1] = 1.0f;
multiplier_accum[2] = 1.0f;
@@ -118,7 +118,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
for (int nx = minx; nx < maxx; nx += step) {
float u = this->m_bokehMidX - (nx - x) * m;
float v = this->m_bokehMidY - (ny - y) * m;
- this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST);
+ this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST);
madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
add_v4_v4(multiplier_accum, bokeh);
bufferindex += offsetadd;
@@ -130,7 +130,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
}
else {
- this->m_inputProgram->read(output, x, y, COM_PS_NEAREST);
+ this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST);
}
}
@@ -220,7 +220,7 @@ void BokehBlurOperation::updateSize()
{
if (!this->m_sizeavailable) {
float result[4];
- this->getInputSocketReader(3)->read(result, 0, 0, COM_PS_NEAREST);
+ this->getInputSocketReader(3)->readSampled(result, 0, 0, COM_PS_NEAREST);
this->m_size = result[0];
CLAMP(this->m_size, 0.0f, 10.0f);
this->m_sizeavailable = true;
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index b87be33eca1..82de750de72 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -85,7 +85,7 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y)
}
return insideBokeh;
}
-void BokehImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void BokehImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float shift = this->m_data->lensshift;
float shift2 = shift / 2.0f;
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index 44c4c0cfe27..f1f0f1ed11c 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -111,7 +111,7 @@ public:
/**
* @brief the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* @brief Initialize the execution
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index 52f84462761..4dd92aec4c8 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -44,7 +44,7 @@ void BoxMaskOperation::initExecution()
this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
}
-void BoxMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputMask[4];
float inputValue[4];
@@ -57,8 +57,8 @@ void BoxMaskOperation::executePixel(float output[4], float x, float y, PixelSamp
rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
- this->m_inputMask->read(inputMask, x, y, sampler);
- this->m_inputValue->read(inputValue, x, y, sampler);
+ this->m_inputMask->readSampled(inputMask, x, y, sampler);
+ this->m_inputValue->readSampled(inputValue, x, y, sampler);
float halfHeight = this->m_data->height / 2.0f;
float halfWidth = this->m_data->width / 2.0f;
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h
index f39d74829d4..04dc8a90fd7 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.h
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h
@@ -45,7 +45,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
index 0613540250c..33e35c3fe3b 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
@@ -37,15 +37,15 @@ void BrightnessOperation::initExecution()
this->m_inputContrastProgram = this->getInputSocketReader(2);
}
-void BrightnessOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void BrightnessOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float a, b;
float inputBrightness[4];
float inputContrast[4];
- this->m_inputProgram->read(inputValue, x, y, sampler);
- this->m_inputBrightnessProgram->read(inputBrightness, x, y, sampler);
- this->m_inputContrastProgram->read(inputContrast, x, y, sampler);
+ this->m_inputProgram->readSampled(inputValue, x, y, sampler);
+ this->m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler);
+ this->m_inputContrastProgram->readSampled(inputContrast, x, y, sampler);
float brightness = inputBrightness[0];
float contrast = inputContrast[0];
brightness /= 100.0f;
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h
index 1c8eda63e94..22086ae11e8 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.h
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.h
@@ -40,7 +40,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
index e6e93774685..964f1d64667 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -39,11 +39,11 @@ void ChangeHSVOperation::deinitExecution()
this->m_inputOperation = NULL;
}
-void ChangeHSVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ChangeHSVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
- this->m_inputOperation->read(inputColor1, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor1, x, y, sampler);
output[0] = inputColor1[0] + (this->m_hue - 0.5f);
if (output[0] > 1.0f) output[0] -= 1.0f;
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
index 01852084e41..76025e86b7a 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
@@ -49,7 +49,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void setHue(float hue) { this->m_hue = hue; }
void setSaturation(float saturation) { this->m_saturation = saturation; }
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
index 84cc8aad950..14494841c49 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
@@ -88,7 +88,7 @@ void ChannelMatteOperation::deinitExecution()
this->m_inputImageProgram = NULL;
}
-void ChannelMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ChannelMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inColor[4];
float alpha;
@@ -97,7 +97,7 @@ void ChannelMatteOperation::executePixel(float output[4], float x, float y, Pixe
const float limit_min = this->m_limit_min;
const float limit_range = this->m_limit_range;
- this->m_inputImageProgram->read(inColor, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
/* matte operation */
alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]);
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
index efb4f7427ca..58b467e7892 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
@@ -59,7 +59,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
index c2406abaa65..3329093882d 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
@@ -44,7 +44,7 @@ void ChromaMatteOperation::deinitExecution()
this->m_inputKeyProgram = NULL;
}
-void ChromaMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ChromaMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inKey[4];
float inImage[4];
@@ -57,8 +57,8 @@ void ChromaMatteOperation::executePixel(float output[4], float x, float y, Pixel
float theta, beta;
float kfg;
- this->m_inputKeyProgram->read(inKey, x, y, sampler);
- this->m_inputImageProgram->read(inImage, x, y, sampler);
+ this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
/* store matte(alpha) value in [0] to go with
* COM_SetAlphaOperation and the Value output
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
index 9557faec855..a68790838c0 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
@@ -42,7 +42,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
index aa4d0932c92..2846642570c 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -49,21 +49,21 @@ void ColorBalanceASCCDLOperation::initExecution()
this->m_inputColorOperation = this->getInputSocketReader(1);
}
-void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ColorBalanceASCCDLOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
float value[4];
- this->m_inputValueOperation->read(value, x, y, sampler);
- this->m_inputColorOperation->read(inputColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
float fac = value[0];
fac = min(1.0f, fac);
const float mfac = 1.0f - fac;
- output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]);
- output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]);
- output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]);
+ output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_offset[0], this->m_power[0], this->m_slope[0]);
+ output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_offset[1], this->m_power[1], this->m_slope[1]);
+ output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_offset[2], this->m_power[2], this->m_slope[2]);
output[3] = inputColor[3];
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
index 17fb5f67be9..bf3495869b0 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
@@ -36,9 +36,9 @@ protected:
SocketReader *m_inputValueOperation;
SocketReader *m_inputColorOperation;
- float m_gain[3];
- float m_lift[3];
- float m_gamma[3];
+ float m_offset[3];
+ float m_power[3];
+ float m_slope[3];
public:
/**
@@ -49,7 +49,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
@@ -61,8 +61,8 @@ public:
*/
void deinitExecution();
- void setGain(float gain[3]) { copy_v3_v3(this->m_gain, gain); }
- void setLift(float lift[3]) { copy_v3_v3(this->m_lift, lift); }
- void setGamma(float gamma[3]) { copy_v3_v3(this->m_gamma, gamma); }
+ void setOffset(float offset[3]) { copy_v3_v3(this->m_offset, offset); }
+ void setPower(float power[3]) { copy_v3_v3(this->m_power, power); }
+ void setSlope(float slope[3]) { copy_v3_v3(this->m_slope, slope); }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index 7e9c10df0a9..9588687372e 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -54,13 +54,13 @@ void ColorBalanceLGGOperation::initExecution()
this->m_inputColorOperation = this->getInputSocketReader(1);
}
-void ColorBalanceLGGOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ColorBalanceLGGOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
float value[4];
- this->m_inputValueOperation->read(value, x, y, sampler);
- this->m_inputColorOperation->read(inputColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
float fac = value[0];
fac = min(1.0f, fac);
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
index edc824475c2..da3a141e3c2 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
@@ -50,7 +50,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index b7a3f43237a..19209951005 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -40,12 +40,12 @@ void ColorCorrectionOperation::initExecution()
this->m_inputMask = this->getInputSocketReader(1);
}
-void ColorCorrectionOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ColorCorrectionOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputImageColor[4];
float inputMask[4];
- this->m_inputImage->read(inputImageColor, x, y, sampler);
- this->m_inputMask->read(inputMask, x, y, sampler);
+ this->m_inputImage->readSampled(inputImageColor, x, y, sampler);
+ this->m_inputMask->readSampled(inputMask, x, y, sampler);
float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f;
float contrast = this->m_data->master.contrast;
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
index 018e67b7ada..2b47d6a8034 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
@@ -44,7 +44,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
index 2f13a90c072..1115b2ab239 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
@@ -58,7 +58,7 @@ void ColorCurveOperation::initExecution()
}
-void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ColorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
CurveMapping *cumap = this->m_curveMapping;
@@ -70,15 +70,15 @@ void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelS
float white[4];
float bwmul[3];
- this->m_inputBlackProgram->read(black, x, y, sampler);
- this->m_inputWhiteProgram->read(white, x, y, sampler);
+ this->m_inputBlackProgram->readSampled(black, x, y, sampler);
+ this->m_inputWhiteProgram->readSampled(white, x, y, sampler);
/* get our own local bwmul value,
* since we can't be threadsafe and use cumap->bwmul & friends */
curvemapping_set_black_white_ex(black, white, bwmul);
- this->m_inputFacProgram->read(fac, x, y, sampler);
- this->m_inputImageProgram->read(image, x, y, sampler);
+ this->m_inputFacProgram->readSampled(fac, x, y, sampler);
+ this->m_inputImageProgram->readSampled(image, x, y, sampler);
if (*fac >= 1.0f) {
curvemapping_evaluate_premulRGBF_ex(cumap, output, image,
@@ -130,13 +130,13 @@ void ConstantLevelColorCurveOperation::initExecution()
curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white);
}
-void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConstantLevelColorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float fac[4];
float image[4];
- this->m_inputFacProgram->read(fac, x, y, sampler);
- this->m_inputImageProgram->read(image, x, y, sampler);
+ this->m_inputFacProgram->readSampled(fac, x, y, sampler);
+ this->m_inputImageProgram->readSampled(image, x, y, sampler);
if (*fac >= 1.0f) {
curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image);
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h
index 7dc1913b85a..1eb77553953 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h
@@ -41,7 +41,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
@@ -70,7 +70,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
index d73196e42f5..b928141f41d 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
@@ -44,7 +44,7 @@ void ColorMatteOperation::deinitExecution()
this->m_inputKeyProgram = NULL;
}
-void ColorMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ColorMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inColor[4];
float inKey[4];
@@ -55,8 +55,8 @@ void ColorMatteOperation::executePixel(float output[4], float x, float y, PixelS
float h_wrap;
- this->m_inputImageProgram->read(inColor, x, y, sampler);
- this->m_inputKeyProgram->read(inKey, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
+ this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
/* store matte(alpha) value in [0] to go with
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h
index f065a5f7e89..53bbe8f6466 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h
@@ -42,7 +42,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
index 1618c83aece..fd3380d594e 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
@@ -43,11 +43,11 @@ void ColorRampOperation::initExecution()
this->m_inputProgram = this->getInputSocketReader(0);
}
-void ColorRampOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ColorRampOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float values[4];
- this->m_inputProgram->read(values, x, y, sampler);
+ this->m_inputProgram->readSampled(values, x, y, sampler);
do_colorband(this->m_colorBand, values[0], output);
}
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h
index 96d9a525e1e..333e6c36d97 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.h
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.h
@@ -38,7 +38,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
index a8e8cb98564..873ec72d9e9 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -84,12 +84,12 @@ void ColorSpillOperation::deinitExecution()
this->m_inputFacReader = NULL;
}
-void ColorSpillOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ColorSpillOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float fac[4];
float input[4];
- this->m_inputFacReader->read(fac, x, y, sampler);
- this->m_inputImageReader->read(input, x, y, sampler);
+ this->m_inputFacReader->readSampled(fac, x, y, sampler);
+ this->m_inputImageReader->readSampled(input, x, y, sampler);
float rfac = min(1.0f, fac[0]);
float map = calculateMapValue(rfac, input);
if (map > 0.0f) {
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h
index 94ff78c37b2..f9dc9ef7e25 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.h
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h
@@ -46,7 +46,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 383682b1474..3d4b771fecc 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -188,20 +188,20 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber)
for (x = x1; x < x2 && (!breaked); x++) {
int input_x = x + dx, input_y = y + dy;
- this->m_imageInput->read(color, input_x, input_y, COM_PS_NEAREST);
+ this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
if (this->m_ignoreAlpha) {
color[3] = 1.0f;
}
else {
if (this->m_alphaInput != NULL) {
- this->m_alphaInput->read(&(color[3]), input_x, input_y, COM_PS_NEAREST);
+ this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
}
}
copy_v4_v4(buffer + offset4, color);
if (this->m_depthInput != NULL) {
- this->m_depthInput->read(color, input_x, input_y, COM_PS_NEAREST);
+ this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
zbuffer[offset] = color[0];
}
offset4 += COM_NUMBER_OF_CHANNELS;
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
index 79ce149e790..cb269b16bf4 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
@@ -38,10 +38,10 @@ void ConvertColorProfileOperation::initExecution()
this->m_inputOperation = this->getInputSocketReader(0);
}
-void ConvertColorProfileOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorProfileOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float color[4];
- this->m_inputOperation->read(color, x, y, sampler);
+ this->m_inputOperation->readSampled(color, x, y, sampler);
IMB_buffer_float_from_float(output, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0);
}
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
index a8cbc613fb8..e68a9bdf7c1 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
@@ -59,7 +59,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index f39a28b87a8..ea1443598a9 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -72,12 +72,12 @@ void ConvertDepthToRadiusOperation::initExecution()
}
}
-void ConvertDepthToRadiusOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float z;
float radius;
- this->m_inputOperation->read(inputValue, x, y, sampler);
+ this->m_inputOperation->readSampled(inputValue, x, y, sampler);
z = inputValue[0];
if (z != 0.f) {
float iZ = (1.f / z);
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
index d5a1fd72cbf..b92eb65d01e 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
@@ -54,7 +54,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp
index d72aabb078e..6b3e4067b18 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp
@@ -47,10 +47,10 @@ ConvertValueToColorOperation::ConvertValueToColorOperation() : ConvertBaseOperat
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertValueToColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertValueToColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
- this->m_inputOperation->read(inputValue, x, y, sampler);
+ this->m_inputOperation->readSampled(inputValue, x, y, sampler);
output[0] = output[1] = output[2] = inputValue[0];
output[3] = 1.0f;
}
@@ -64,10 +64,10 @@ ConvertColorToValueOperation::ConvertColorToValueOperation() : ConvertBaseOperat
this->addOutputSocket(COM_DT_VALUE);
}
-void ConvertColorToValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorToValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
}
@@ -80,10 +80,10 @@ ConvertColorToBWOperation::ConvertColorToBWOperation() : ConvertBaseOperation()
this->addOutputSocket(COM_DT_VALUE);
}
-void ConvertColorToBWOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorToBWOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
output[0] = rgb_to_bw(inputColor);
}
@@ -96,9 +96,9 @@ ConvertColorToVectorOperation::ConvertColorToVectorOperation() : ConvertBaseOper
this->addOutputSocket(COM_DT_VECTOR);
}
-void ConvertColorToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorToVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- this->m_inputOperation->read(output, x, y, sampler);
+ this->m_inputOperation->readSampled(output, x, y, sampler);
}
@@ -110,10 +110,10 @@ ConvertValueToVectorOperation::ConvertValueToVectorOperation() : ConvertBaseOper
this->addOutputSocket(COM_DT_VECTOR);
}
-void ConvertValueToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertValueToVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
- this->m_inputOperation->read(input, x, y, sampler);
+ this->m_inputOperation->readSampled(input, x, y, sampler);
output[0] = input[0];
output[1] = input[0];
output[2] = input[0];
@@ -129,9 +129,9 @@ ConvertVectorToColorOperation::ConvertVectorToColorOperation() : ConvertBaseOper
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertVectorToColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertVectorToColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- this->m_inputOperation->read(output, x, y, sampler);
+ this->m_inputOperation->readSampled(output, x, y, sampler);
output[3] = 1.0f;
}
@@ -144,10 +144,10 @@ ConvertVectorToValueOperation::ConvertVectorToValueOperation() : ConvertBaseOper
this->addOutputSocket(COM_DT_VALUE);
}
-void ConvertVectorToValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertVectorToValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
- this->m_inputOperation->read(input, x, y, sampler);
+ this->m_inputOperation->readSampled(input, x, y, sampler);
output[0] = (input[0] + input[1] + input[2]) / 3.0f;
}
@@ -176,12 +176,12 @@ void ConvertRGBToYCCOperation::setMode(int mode)
}
}
-void ConvertRGBToYCCOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertRGBToYCCOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
float color[3];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode);
/* divided by 255 to normalize for viewing in */
@@ -214,10 +214,10 @@ void ConvertYCCToRGBOperation::setMode(int mode)
}
}
-void ConvertYCCToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertYCCToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
/* need to un-normalize the data */
/* R,G,B --> Y,Cb,Cr */
@@ -236,10 +236,10 @@ ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : ConvertBaseOperation()
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertRGBToYUVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertRGBToYUVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
output[3] = inputColor[3];
}
@@ -253,10 +253,10 @@ ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : ConvertBaseOperation()
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertYUVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertYUVToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
output[3] = inputColor[3];
}
@@ -270,10 +270,10 @@ ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : ConvertBaseOperation()
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertRGBToHSVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertRGBToHSVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
rgb_to_hsv_v(inputColor, output);
output[3] = inputColor[3];
}
@@ -287,10 +287,10 @@ ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : ConvertBaseOperation()
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertHSVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertHSVToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputOperation->read(inputColor, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
hsv_to_rgb_v(inputColor, output);
output[3] = inputColor[3];
}
@@ -304,12 +304,12 @@ ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : ConvertBa
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertPremulToStraightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertPremulToStraightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float alpha;
- this->m_inputOperation->read(inputValue, x, y, sampler);
+ this->m_inputOperation->readSampled(inputValue, x, y, sampler);
alpha = inputValue[3];
if (fabsf(alpha) < 1e-5f) {
@@ -332,12 +332,12 @@ ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : ConvertBa
this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertStraightToPremulOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ConvertStraightToPremulOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float alpha;
- this->m_inputOperation->read(inputValue, x, y, sampler);
+ this->m_inputOperation->readSampled(inputValue, x, y, sampler);
alpha = inputValue[3];
mul_v3_v3fl(output, inputValue, alpha);
@@ -366,10 +366,10 @@ void SeparateChannelOperation::deinitExecution()
}
-void SeparateChannelOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SeparateChannelOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
- this->m_inputOperation->read(input, x, y, sampler);
+ this->m_inputOperation->readSampled(input, x, y, sampler);
output[0] = input[this->m_channel];
}
@@ -407,23 +407,23 @@ void CombineChannelsOperation::deinitExecution()
}
-void CombineChannelsOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void CombineChannelsOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
if (this->m_inputChannel1Operation) {
- this->m_inputChannel1Operation->read(input, x, y, sampler);
+ this->m_inputChannel1Operation->readSampled(input, x, y, sampler);
output[0] = input[0];
}
if (this->m_inputChannel2Operation) {
- this->m_inputChannel2Operation->read(input, x, y, sampler);
+ this->m_inputChannel2Operation->readSampled(input, x, y, sampler);
output[1] = input[0];
}
if (this->m_inputChannel3Operation) {
- this->m_inputChannel3Operation->read(input, x, y, sampler);
+ this->m_inputChannel3Operation->readSampled(input, x, y, sampler);
output[2] = input[0];
}
if (this->m_inputChannel4Operation) {
- this->m_inputChannel4Operation->read(input, x, y, sampler);
+ this->m_inputChannel4Operation->readSampled(input, x, y, sampler);
output[3] = input[0];
}
}
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.h b/source/blender/compositor/operations/COM_ConvertOperation.h
index 06aeb2e52d7..957df812a2e 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertOperation.h
@@ -42,7 +42,7 @@ class ConvertValueToColorOperation : public ConvertBaseOperation {
public:
ConvertValueToColorOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -50,7 +50,7 @@ class ConvertColorToValueOperation : public ConvertBaseOperation {
public:
ConvertColorToValueOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -58,7 +58,7 @@ class ConvertColorToBWOperation : public ConvertBaseOperation {
public:
ConvertColorToBWOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -66,7 +66,7 @@ class ConvertColorToVectorOperation : public ConvertBaseOperation {
public:
ConvertColorToVectorOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -74,7 +74,7 @@ class ConvertValueToVectorOperation : public ConvertBaseOperation {
public:
ConvertValueToVectorOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -82,7 +82,7 @@ class ConvertVectorToColorOperation : public ConvertBaseOperation {
public:
ConvertVectorToColorOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -90,7 +90,7 @@ class ConvertVectorToValueOperation : public ConvertBaseOperation {
public:
ConvertVectorToValueOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -101,7 +101,7 @@ private:
public:
ConvertRGBToYCCOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/** Set the YCC mode */
void setMode(int mode);
@@ -115,7 +115,7 @@ private:
public:
ConvertYCCToRGBOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/** Set the YCC mode */
void setMode(int mode);
@@ -126,7 +126,7 @@ class ConvertRGBToYUVOperation : public ConvertBaseOperation {
public:
ConvertRGBToYUVOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -134,7 +134,7 @@ class ConvertYUVToRGBOperation : public ConvertBaseOperation {
public:
ConvertYUVToRGBOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -142,7 +142,7 @@ class ConvertRGBToHSVOperation : public ConvertBaseOperation {
public:
ConvertRGBToHSVOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -150,7 +150,7 @@ class ConvertHSVToRGBOperation : public ConvertBaseOperation {
public:
ConvertHSVToRGBOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -158,7 +158,7 @@ class ConvertPremulToStraightOperation : public ConvertBaseOperation {
public:
ConvertPremulToStraightOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -166,7 +166,7 @@ class ConvertStraightToPremulOperation : public ConvertBaseOperation {
public:
ConvertStraightToPremulOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
@@ -176,7 +176,7 @@ private:
int m_channel;
public:
SeparateChannelOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
@@ -193,7 +193,7 @@ private:
SocketReader *m_inputChannel4Operation;
public:
CombineChannelsOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index 844d23db2ac..c514b576dcf 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -82,10 +82,10 @@ CropOperation::CropOperation() : CropBaseOperation()
/* pass */
}
-void CropOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void CropOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if ((x < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) {
- this->m_inputOperation->read(output, x, y, sampler);
+ this->m_inputOperation->readSampled(output, x, y, sampler);
}
else {
zero_v4(output);
@@ -117,10 +117,10 @@ void CropImageOperation::determineResolution(unsigned int resolution[2], unsigne
resolution[1] = this->m_ymax - this->m_ymin;
}
-void CropImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void CropImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
- this->m_inputOperation->read(output, (x + this->m_xmin), (y + this->m_ymin), sampler);
+ this->m_inputOperation->readSampled(output, (x + this->m_xmin), (y + this->m_ymin), sampler);
}
else {
zero_v4(output);
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
index d2f2b15aa36..4890ede18a9 100644
--- a/source/blender/compositor/operations/COM_CropOperation.h
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -48,7 +48,7 @@ class CropOperation : public CropBaseOperation {
private:
public:
CropOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class CropImageOperation : public CropBaseOperation {
@@ -57,7 +57,7 @@ public:
CropImageOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void determineResolution(unsigned int resolution[2], unsigned int preferedResolution[2]);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
index 599f54720f2..186c17845f3 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
@@ -114,7 +114,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void *data)
//mul_v4_fl(color_mid, 1.0f / w);
if ((w != 0.0f) &&
- ((w / WTOT) > (this->m_threshold_neighbour)) &&
+ ((w / WTOT) > (this->m_threshold_neighbor)) &&
color_diff(color_mid, color_org, this->m_threshold))
{
mul_v4_fl(color_mid_ok, 1.0f / w);
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.h b/source/blender/compositor/operations/COM_DespeckleOperation.h
index 99635e61544..00c5463c17a 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.h
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.h
@@ -25,7 +25,7 @@
class DespeckleOperation : public NodeOperation {
private:
float m_threshold;
- float m_threshold_neighbour;
+ float m_threshold_neighbor;
// int m_filterWidth;
// int m_filterHeight;
@@ -40,7 +40,7 @@ public:
void executePixel(float output[4], int x, int y, void *data);
void setThreshold(float threshold) { this->m_threshold = threshold; }
- void setThresholdNeighbour(float threshold) { this->m_threshold_neighbour = threshold; }
+ void setThresholdNeighbor(float threshold) { this->m_threshold_neighbor = threshold; }
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
index e23eb26f527..325ef83a529 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
@@ -44,7 +44,7 @@ void DifferenceMatteOperation::deinitExecution()
this->m_inputImage2Program = NULL;
}
-void DifferenceMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void DifferenceMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inColor1[4];
float inColor2[4];
@@ -54,8 +54,8 @@ void DifferenceMatteOperation::executePixel(float output[4], float x, float y, P
float difference;
float alpha;
- this->m_inputImage1Program->read(inColor1, x, y, sampler);
- this->m_inputImage2Program->read(inColor2, x, y, sampler);
+ this->m_inputImage1Program->readSampled(inColor1, x, y, sampler);
+ this->m_inputImage2Program->readSampled(inColor2, x, y, sampler);
difference = (fabsf(inColor2[0] - inColor1[0]) +
fabsf(inColor2[1] - inColor1[1]) +
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
index e0a38f703ed..a3647e1e5db 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
@@ -43,7 +43,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index 23289429bfd..d6c25574d01 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -71,7 +71,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void
const int iterations = pow(2.0f, this->m_data->iter);
float col[4] = {0, 0, 0, 0};
float col2[4] = {0, 0, 0, 0};
- this->m_inputProgram->read(col2, x, y, COM_PS_NEAREST);
+ this->m_inputProgram->readSampled(col2, x, y, COM_PS_NEAREST);
float ltx = this->m_tx;
float lty = this->m_ty;
float lsc = this->m_sc;
@@ -84,7 +84,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void
const float v = isc * (y - this->m_center_y_pix) + lty;
const float u = isc * (x - this->m_center_x_pix) + ltx;
- this->m_inputProgram->read(col,
+ this->m_inputProgram->readSampled(col,
cs * u + ss * v + this->m_center_x_pix,
cs * v - ss * u + this->m_center_y_pix,
COM_PS_NEAREST);
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
index 1723da11f21..17692bd18ef 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
@@ -64,9 +64,9 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data)
float dxt, dyt;
float u, v;
- this->m_inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST);
+ this->m_inputScaleXProgram->readSampled(inScale, x, y, COM_PS_NEAREST);
float xs = inScale[0];
- this->m_inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST);
+ this->m_inputScaleYProgram->readSampled(inScale, x, y, COM_PS_NEAREST);
float ys = inScale[0];
/* clamp x and y displacement to triple image resolution -
@@ -74,7 +74,7 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data)
CLAMP(xs, -this->m_width_x4, this->m_width_x4);
CLAMP(ys, -this->m_height_x4, this->m_height_x4);
- this->m_inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST);
+ this->m_inputVectorProgram->readSampled(inVector, x, y, COM_PS_NEAREST);
p_dx = inVector[0] * xs;
p_dy = inVector[1] * ys;
@@ -83,9 +83,9 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data)
v = y - p_dy + 0.5f;
/* calc derivatives */
- this->m_inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST);
+ this->m_inputVectorProgram->readSampled(inVector, x + 1, y, COM_PS_NEAREST);
d_dx = inVector[0] * xs;
- this->m_inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST);
+ this->m_inputVectorProgram->readSampled(inVector, x, y + 1, COM_PS_NEAREST);
d_dy = inVector[1] * ys;
/* clamp derivatives to minimum displacement distance in UV space */
@@ -96,7 +96,7 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data)
dyt = signf(dyt) * max_ff(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight();
/* EWA filtering (without nearest it gets blurry with NO distortion) */
- this->m_inputColorProgram->read(output, u, v, dxt, dyt, COM_PS_NEAREST);
+ this->m_inputColorProgram->readFiltered(output, u, v, dxt, dyt, COM_PS_NEAREST);
}
void DisplaceOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
index c8ebb845bb6..48160d5db2c 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
@@ -53,7 +53,7 @@ void DisplaceSimpleOperation::initExecution()
* in order to take effect */
// #define DISPLACE_EPSILON 0.01f
-void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void DisplaceSimpleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inVector[4];
float inScale[4];
@@ -61,9 +61,9 @@ void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, Pi
float p_dx, p_dy; /* main displacement in pixel space */
float u, v;
- this->m_inputScaleXProgram->read(inScale, x, y, sampler);
+ this->m_inputScaleXProgram->readSampled(inScale, x, y, sampler);
float xs = inScale[0];
- this->m_inputScaleYProgram->read(inScale, x, y, sampler);
+ this->m_inputScaleYProgram->readSampled(inScale, x, y, sampler);
float ys = inScale[0];
/* clamp x and y displacement to triple image resolution -
@@ -71,7 +71,7 @@ void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, Pi
CLAMP(xs, -this->m_width_x4, this->m_width_x4);
CLAMP(ys, -this->m_height_x4, this->m_height_x4);
- this->m_inputVectorProgram->read(inVector, x, y, sampler);
+ this->m_inputVectorProgram->readSampled(inVector, x, y, sampler);
p_dx = inVector[0] * xs;
p_dy = inVector[1] * ys;
@@ -82,7 +82,7 @@ void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, Pi
CLAMP(u, 0.f, this->getWidth() - 1.f);
CLAMP(v, 0.f, this->getHeight() - 1.f);
- this->m_inputColorProgram->read(output, u, v, sampler);
+ this->m_inputColorProgram->readSampled(output, u, v, sampler);
}
void DisplaceSimpleOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
index 989cf8a1f67..6e52dfe86e9 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
@@ -48,7 +48,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
index d3309e0c978..072ca1022e7 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
@@ -49,7 +49,7 @@ float DistanceRGBMatteOperation::calculateDistance(float key[4], float image[4])
return len_v3v3(key, image);
}
-void DistanceRGBMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void DistanceRGBMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inKey[4];
float inImage[4];
@@ -60,8 +60,8 @@ void DistanceRGBMatteOperation::executePixel(float output[4], float x, float y,
float distance;
float alpha;
- this->m_inputKeyProgram->read(inKey, x, y, sampler);
- this->m_inputImageProgram->read(inImage, x, y, sampler);
+ this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
distance = this->calculateDistance(inKey, inImage);
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
index 43299486f60..a815caa5ef5 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
@@ -45,7 +45,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp
index 1439dfa404a..368db185adc 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.cpp
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp
@@ -45,11 +45,11 @@ void DotproductOperation::deinitExecution()
/** @todo: current implementation is the inverse of a dotproduct. not 'logically' correct
*/
-void DotproductOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void DotproductOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float input1[4];
float input2[4];
- this->m_input1Operation->read(input1, x, y, sampler);
- this->m_input2Operation->read(input2, x, y, sampler);
+ this->m_input1Operation->readSampled(input1, x, y, sampler);
+ this->m_input2Operation->readSampled(input2, x, y, sampler);
output[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 31588207504..4378e280d17 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.h
+++ b/source/blender/compositor/operations/COM_DotproductOperation.h
@@ -31,7 +31,7 @@ private:
SocketReader *m_input2Operation;
public:
DotproductOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
index 9ab21e2d5bd..d7cc2ec9272 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -44,7 +44,7 @@ void EllipseMaskOperation::initExecution()
this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
}
-void EllipseMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void EllipseMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputMask[4];
float inputValue[4];
@@ -57,8 +57,8 @@ void EllipseMaskOperation::executePixel(float output[4], float x, float y, Pixel
rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
- this->m_inputMask->read(inputMask, x, y, sampler);
- this->m_inputValue->read(inputValue, x, y, sampler);
+ this->m_inputMask->readSampled(inputMask, x, y, sampler);
+ this->m_inputValue->readSampled(inputValue, x, y, sampler);
const float halfHeight = (this->m_data->height) / 2.0f;
const float halfWidth = this->m_data->width / 2.0f;
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
index ed74e6b43db..753615df370 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
@@ -45,7 +45,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 9231261986d..a6be9254f6f 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -29,6 +29,7 @@
FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
this->m_iirgaus = NULL;
+ this->m_chunksize = 256;
}
void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void *data)
@@ -37,22 +38,56 @@ void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void
newData->read(output, x, y);
}
+// Calculate the depending area of interest. This depends on the
+// size of the blur operation; if the blur is large it is faster
+// to just calculate the whole image at once.
+// Returns true if the area is just a tile and false if it is
+// the whole image.
+bool FastGaussianBlurOperation::getDAI(rcti *rect, rcti *output)
+{
+ // m_data->sizex * m_size should be enough? For some reason there
+ // seem to be errors in the boundary between tiles.
+ int sx = this->m_data->sizex * this->m_size * 2;
+ if (sx < 1)
+ sx = 1;
+ int sy = this->m_data->sizey * this->m_size * 2;
+ if (sy < 1)
+ sy = 1;
+
+ if (sx >= this->m_chunksize || sy >= this->m_chunksize) {
+ output->xmin = 0;
+ output->xmax = this->getWidth();
+ output->ymin = 0;
+ output->ymax = this->getHeight();
+ return false;
+ }
+ else {
+ output->xmin = rect->xmin - sx - 1;
+ output->xmax = rect->xmax + sx + 1;
+ output->ymin = rect->ymin - sy - 1;
+ output->ymax = rect->ymax + sy + 1;
+ return true;
+ }
+}
+
bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
+ if (!this->m_sizeavailable) {
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
}
- else {
- if (this->m_iirgaus) {
- return false;
+ {
+ if (this->m_sizeavailable) {
+ getDAI(input, &newInput);
}
else {
newInput.xmin = 0;
@@ -81,6 +116,7 @@ void FastGaussianBlurOperation::deinitExecution()
void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
{
+#if 0
lockMutex();
if (!this->m_iirgaus) {
MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
@@ -109,8 +145,68 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
}
unlockMutex();
return this->m_iirgaus;
+#else
+
+ lockMutex();
+ if (this->m_iirgaus) {
+ // if this->m_iirgaus is set, we don't do tile rendering, so
+ // we can return the already calculated cache
+ unlockMutex();
+ return this->m_iirgaus;
+ }
+ updateSize();
+ rcti dai;
+ bool use_tiles = getDAI(rect, &dai);
+ if (use_tiles) {
+ unlockMutex();
+ }
+
+ MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
+ rcti *buf_rect = buffer->getRect();
+
+ dai.xmin = max(dai.xmin, buf_rect->xmin);
+ dai.xmax = min(dai.xmax, buf_rect->xmax);
+ dai.ymin = max(dai.ymin, buf_rect->ymin);
+ dai.ymax = min(dai.ymax, buf_rect->ymax);
+
+ MemoryBuffer *tile = new MemoryBuffer(NULL, &dai);
+ tile->copyContentFrom(buffer);
+
+ int c;
+ float sx = this->m_data->sizex * this->m_size / 2.0f;
+ float sy = this->m_data->sizey * this->m_size / 2.0f;
+
+ if ((sx == sy) && (sx > 0.f)) {
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
+ IIR_gauss(tile, sx, c, 3);
+ }
+ else {
+ if (sx > 0.0f) {
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
+ IIR_gauss(tile, sx, c, 1);
+ }
+ if (sy > 0.0f) {
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
+ IIR_gauss(tile, sy, c, 2);
+ }
+ }
+ if (!use_tiles) {
+ this->m_iirgaus = tile;
+ unlockMutex();
+ }
+ return tile;
+#endif
}
+void FastGaussianBlurOperation::deinitializeTileData(rcti *rect, void *data)
+{
+ if (!this->m_iirgaus && data) {
+ MemoryBuffer *tile = (MemoryBuffer *)data;
+ delete tile;
+ }
+}
+
+
void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy)
{
double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3];
@@ -195,22 +291,38 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign
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
+ int offset;
for (y = 0; y < src_height; ++y) {
const int yx = y * src_width;
- for (x = 0; x < src_width; ++x)
- X[x] = buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan];
+ offset = yx * COM_NUMBER_OF_CHANNELS + chan;
+ for (x = 0; x < src_width; ++x) {
+ X[x] = buffer[offset];
+ offset += COM_NUMBER_OF_CHANNELS;
+ }
YVV(src_width);
- for (x = 0; x < src_width; ++x)
- buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan] = Y[x];
+ offset = yx * COM_NUMBER_OF_CHANNELS + chan;
+ for (x = 0; x < src_width; ++x) {
+ buffer[offset] = Y[x];
+ offset += COM_NUMBER_OF_CHANNELS;
+ }
}
}
if (xy & 2) { // V
+ int offset;
+ const int add = src_width * COM_NUMBER_OF_CHANNELS;
+
for (x = 0; x < src_width; ++x) {
- for (y = 0; y < src_height; ++y)
- X[y] = buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan];
+ offset = x * COM_NUMBER_OF_CHANNELS + chan;
+ for (y = 0; y < src_height; ++y) {
+ X[y] = buffer[offset];
+ offset += add;
+ }
YVV(src_height);
- for (y = 0; y < src_height; ++y)
- buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan] = Y[y];
+ offset = x * COM_NUMBER_OF_CHANNELS + chan;
+ for (y = 0; y < src_height; ++y) {
+ buffer[offset] = Y[y];
+ offset += add;
+ }
}
}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
index 58bf1d4f596..e12d437b43e 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -28,16 +28,19 @@
class FastGaussianBlurOperation : public BlurBaseOperation {
private:
- float m_sx;
- float m_sy;
MemoryBuffer *m_iirgaus;
+ int m_chunksize;
+
public:
FastGaussianBlurOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void executePixel(float output[4], int x, int y, void *data);
+ void setChunksize(int size) { this->m_chunksize = size; }
static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy);
+ bool getDAI(rcti *rect, rcti *output);
void *initializeTileData(rcti *rect);
+ void deinitializeTileData(rcti *rect, void *data);
void deinitExecution();
void initExecution();
};
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp
index 526eba34d86..3de2ae9dabc 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.cpp
+++ b/source/blender/compositor/operations/COM_FlipOperation.cpp
@@ -42,12 +42,12 @@ void FlipOperation::deinitExecution()
}
-void FlipOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void FlipOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float nx = this->m_flipX ? this->getWidth() - 1 - x : x;
float ny = this->m_flipY ? this->getHeight() - 1 - y : y;
- this->m_inputOperation->read(output, nx, ny, sampler);
+ this->m_inputOperation->readSampled(output, nx, ny, sampler);
}
bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h
index 018617cea8a..a1fcde19876 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.h
+++ b/source/blender/compositor/operations/COM_FlipOperation.h
@@ -33,7 +33,7 @@ private:
public:
FlipOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
index 8f92dc02a57..357677d6832 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -34,10 +34,10 @@ void GammaCorrectOperation::initExecution()
this->m_inputProgram = this->getInputSocketReader(0);
}
-void GammaCorrectOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void GammaCorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputProgram->read(inputColor, x, y, sampler);
+ this->m_inputProgram->readSampled(inputColor, x, y, sampler);
if (inputColor[3] > 0.0f) {
inputColor[0] /= inputColor[3];
inputColor[1] /= inputColor[3];
@@ -73,10 +73,10 @@ void GammaUncorrectOperation::initExecution()
this->m_inputProgram = this->getInputSocketReader(0);
}
-void GammaUncorrectOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void GammaUncorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
- this->m_inputProgram->read(inputColor, x, y, sampler);
+ this->m_inputProgram->readSampled(inputColor, x, y, sampler);
if (inputColor[3] > 0.0f) {
inputColor[0] /= inputColor[3];
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
index 514855b4f56..68eaab83c99 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
@@ -38,7 +38,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
@@ -64,7 +64,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp
index 326031c5984..d98f2c4663f 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaOperation.cpp
@@ -37,13 +37,13 @@ void GammaOperation::initExecution()
this->m_inputGammaProgram = this->getInputSocketReader(1);
}
-void GammaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void GammaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float inputGamma[4];
- this->m_inputProgram->read(inputValue, x, y, sampler);
- this->m_inputGammaProgram->read(inputGamma, x, y, sampler);
+ this->m_inputProgram->readSampled(inputValue, x, y, sampler);
+ this->m_inputGammaProgram->readSampled(inputGamma, x, y, sampler);
const float gamma = inputGamma[0];
/* check for negative to avoid nan's */
output[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0];
diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h
index 4482f7be34a..d8e08457812 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.h
+++ b/source/blender/compositor/operations/COM_GammaOperation.h
@@ -39,7 +39,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
index 1c7d2659c39..78e1e80cafc 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
@@ -42,11 +42,11 @@ void GlareThresholdOperation::initExecution()
this->m_inputProgram = this->getInputSocketReader(0);
}
-void GlareThresholdOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void GlareThresholdOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
const float threshold = this->m_settings->threshold;
- this->m_inputProgram->read(output, x, y, sampler);
+ this->m_inputProgram->readSampled(output, x, y, sampler);
if (rgb_to_luma_y(output) >= threshold) {
output[0] -= threshold, output[1] -= threshold, output[2] -= threshold;
output[0] = max(output[0], 0.0f);
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
index 44f9db6a483..7760a19251b 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
@@ -42,7 +42,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
index 8f58942fbe2..6bbaac8e303 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
@@ -45,11 +45,11 @@ void HueSaturationValueCorrectOperation::initExecution()
this->m_inputProgram = this->getInputSocketReader(0);
}
-void HueSaturationValueCorrectOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void HueSaturationValueCorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float hsv[4], f;
- this->m_inputProgram->read(hsv, x, y, sampler);
+ this->m_inputProgram->readSampled(hsv, x, y, sampler);
/* adjust hue, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]);
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
index 5e57d09a51e..0a0e82bf168 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
@@ -37,7 +37,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
index 4b9bcb118e7..a021f07d2a7 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
@@ -33,11 +33,11 @@ void IDMaskOperation::initExecution()
this->m_inputProgram = this->getInputSocketReader(0);
}
-void IDMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void IDMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
- this->m_inputProgram->read(inputValue, x, y, sampler);
+ this->m_inputProgram->readSampled(inputValue, x, y, sampler);
const float a = (inputValue[0] == this->m_objectIndex) ? 1.0f : 0.0f;
output[0] = a;
}
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
index 68c5cf4c1dc..dfddc489ca4 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.h
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -39,7 +39,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index cface29fdca..adc325de377 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -146,7 +146,7 @@ static void sampleImageAtLocation(ImBuf *ibuf, float x, float y, PixelSampler sa
}
}
-void ImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if ((this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
zero_v4(output);
@@ -156,7 +156,7 @@ void ImageOperation::executePixel(float output[4], float x, float y, PixelSample
}
}
-void ImageAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ImageAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float tempcolor[4];
@@ -170,7 +170,7 @@ void ImageAlphaOperation::executePixel(float output[4], float x, float y, PixelS
}
}
-void ImageDepthOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ImageDepthOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if (this->m_depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
output[0] = 0.0f;
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index b51f11edd04..a9e2ed9ff64 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -73,7 +73,7 @@ public:
* Constructor
*/
ImageOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ImageAlphaOperation : public BaseImageOperation {
public:
@@ -81,7 +81,7 @@ public:
* Constructor
*/
ImageAlphaOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ImageDepthOperation : public BaseImageOperation {
public:
@@ -89,6 +89,6 @@ public:
* Constructor
*/
ImageDepthOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index edcd1563e03..b64c98be0c7 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -48,7 +48,6 @@ void InpaintSimpleOperation::initExecution()
{
this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_cached_buffer = NULL;
this->m_pixelorder = NULL;
this->m_manhatten_distance = NULL;
this->m_cached_buffer = NULL;
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
index 9c2dd825709..dc5a2653129 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -39,12 +39,12 @@ void InvertOperation::initExecution()
this->m_inputColorProgram = this->getInputSocketReader(1);
}
-void InvertOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void InvertOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float inputColor[4];
- this->m_inputValueProgram->read(inputValue, x, y, sampler);
- this->m_inputColorProgram->read(inputColor, x, y, sampler);
+ this->m_inputValueProgram->readSampled(inputValue, x, y, sampler);
+ this->m_inputColorProgram->readSampled(inputColor, x, y, sampler);
const float value = inputValue[0];
const float invertedValue = 1.0f - value;
diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h
index 7fded7bb1e4..be1e933f1e9 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.h
+++ b/source/blender/compositor/operations/COM_InvertOperation.h
@@ -42,7 +42,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
index 01f5c032730..c4b821f998f 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
@@ -53,13 +53,13 @@ void KeyingDespillOperation::deinitExecution()
this->m_screenReader = NULL;
}
-void KeyingDespillOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void KeyingDespillOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float pixelColor[4];
float screenColor[4];
- this->m_pixelReader->read(pixelColor, x, y, sampler);
- this->m_screenReader->read(screenColor, x, y, sampler);
+ this->m_pixelReader->readSampled(pixelColor, x, y, sampler);
+ this->m_screenReader->readSampled(screenColor, x, y, sampler);
const int screen_primary_channel = max_axis_v3(screenColor);
const int other_1 = (screen_primary_channel + 1) % 3;
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
index 18e771b14f1..da9924d5b4b 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
@@ -45,7 +45,7 @@ public:
void setDespillFactor(float value) {this->m_despillFactor = value;}
void setColorBalance(float value) {this->m_colorBalance = value;}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp
index baeacb56744..e2566d2f4f0 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp
@@ -65,13 +65,13 @@ void KeyingOperation::deinitExecution()
this->m_screenReader = NULL;
}
-void KeyingOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float pixelColor[4];
float screenColor[4];
- this->m_pixelReader->read(pixelColor, x, y, sampler);
- this->m_screenReader->read(screenColor, x, y, sampler);
+ this->m_pixelReader->readSampled(pixelColor, x, y, sampler);
+ this->m_screenReader->readSampled(screenColor, x, y, sampler);
const int primary_channel = max_axis_v3(screenColor);
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h
index fcff9243dfc..e4542e2c6dd 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingOperation.h
@@ -49,7 +49,7 @@ public:
void setScreenBalance(float value) {this->m_screenBalance = value;}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
index 4c65113ee70..0e48d5963c6 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
@@ -40,7 +40,7 @@ void LuminanceMatteOperation::deinitExecution()
this->m_inputImageProgram = NULL;
}
-void LuminanceMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void LuminanceMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inColor[4];
@@ -49,7 +49,7 @@ void LuminanceMatteOperation::executePixel(float output[4], float x, float y, Pi
float alpha;
- this->m_inputImageProgram->read(inColor, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
/* one line thread-friend algorithm:
* output[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low))))
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
index cb8cc01efea..93051f52228 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
@@ -41,7 +41,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index 1fe74ade0fc..2e80d4f1ba3 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -46,18 +46,18 @@ void MapRangeOperation::initExecution()
/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
#define BLENDER_ZMAX 10000.0f
-void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MapRangeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputs[8]; /* includes the 5 inputs + 3 pads */
float value;
float source_min, source_max;
float dest_min, dest_max;
- this->m_inputOperation->read(inputs, x, y, sampler);
- this->m_sourceMinOperation->read(inputs + 1, x, y, sampler);
- this->m_sourceMaxOperation->read(inputs + 2, x, y, sampler);
- this->m_destMinOperation->read(inputs + 3, x, y, sampler);
- this->m_destMaxOperation->read(inputs + 4, x, y, sampler);
+ this->m_inputOperation->readSampled(inputs, x, y, sampler);
+ this->m_sourceMinOperation->readSampled(inputs + 1, x, y, sampler);
+ this->m_sourceMaxOperation->readSampled(inputs + 2, x, y, sampler);
+ this->m_destMinOperation->readSampled(inputs + 3, x, y, sampler);
+ this->m_destMaxOperation->readSampled(inputs + 4, x, y, sampler);
value = inputs[0];
source_min = inputs[1];
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.h b/source/blender/compositor/operations/COM_MapRangeOperation.h
index 00dfc68168c..a232f89ea9d 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.h
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.h
@@ -50,7 +50,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index a9b6ad3edc1..289b447dec7 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -40,7 +40,7 @@ void MapUVOperation::initExecution()
this->m_inputUVProgram = this->getInputSocketReader(1);
}
-void MapUVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MapUVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputUV[4];
float uv_a[4], uv_b[4];
@@ -50,22 +50,22 @@ void MapUVOperation::executePixel(float output[4], float x, float y, PixelSample
float uv_l, uv_r;
float uv_u, uv_d;
- this->m_inputUVProgram->read(inputUV, x, y, sampler);
+ this->m_inputUVProgram->readSampled(inputUV, x, y, sampler);
if (inputUV[2] == 0.f) {
zero_v4(output);
return;
}
/* adaptive sampling, red (U) channel */
- this->m_inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST);
- this->m_inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST);
+ this->m_inputUVProgram->readSampled(uv_a, x - 1, y, COM_PS_NEAREST);
+ this->m_inputUVProgram->readSampled(uv_b, x + 1, y, COM_PS_NEAREST);
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->m_inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST);
- this->m_inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST);
+ this->m_inputUVProgram->readSampled(uv_a, x, y - 1, COM_PS_NEAREST);
+ this->m_inputUVProgram->readSampled(uv_b, x, y + 1, COM_PS_NEAREST);
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;
@@ -81,7 +81,7 @@ void MapUVOperation::executePixel(float output[4], float x, float y, PixelSample
u = inputUV[0] * this->m_inputColorProgram->getWidth();
v = inputUV[1] * this->m_inputColorProgram->getHeight();
- this->m_inputColorProgram->read(output, u, v, dx, dy, COM_PS_NEAREST);
+ this->m_inputColorProgram->readFiltered(output, u, v, dx, dy, COM_PS_NEAREST);
/* "premul" */
if (alpha < 1.0f) {
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h
index c8356c1a7ad..fe8bfd2a9ac 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.h
+++ b/source/blender/compositor/operations/COM_MapUVOperation.h
@@ -45,7 +45,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
index 7acc431f7b5..d6aaf560fce 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -34,10 +34,10 @@ void MapValueOperation::initExecution()
this->m_inputOperation = this->getInputSocketReader(0);
}
-void MapValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MapValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float src[4];
- this->m_inputOperation->read(src, x, y, sampler);
+ this->m_inputOperation->readSampled(src, x, y, sampler);
TexMapping *texmap = this->m_settings;
float value = (src[0] + texmap->loc[0]) * texmap->size[0];
if (texmap->flag & TEXMAP_CLIP_MIN)
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h
index 418d6d9bf4d..a9a59d6633a 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.h
+++ b/source/blender/compositor/operations/COM_MapValueOperation.h
@@ -45,7 +45,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index ba1059c4eb5..a5b1987d4b3 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -75,7 +75,7 @@ void MaskOperation::initExecution()
masklay;
masklay = masklay->next)
{
- masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_frame_number);
+ masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, this->m_frame_number);
BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
}
}
@@ -84,7 +84,7 @@ void MaskOperation::initExecution()
this->m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new();
/* re-eval frame info */
- BKE_mask_evaluate(mask_temp, frame_iter, TRUE);
+ BKE_mask_evaluate(mask_temp, frame_iter, true);
BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[i], mask_temp,
this->m_maskWidth, this->m_maskHeight,
@@ -127,7 +127,7 @@ void MaskOperation::determineResolution(unsigned int resolution[2], unsigned int
}
}
-void MaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
const float xy[2] = {x * this->m_maskWidthInv,
y * this->m_maskHeightInv};
diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h
index 2de71afcfa7..18d7e594104 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.h
+++ b/source/blender/compositor/operations/COM_MaskOperation.h
@@ -83,7 +83,7 @@ public:
void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = min(max(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX); }
void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; }
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index fa0c480eb70..cc7511bb9fc 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -72,52 +72,52 @@ void MathBaseOperation::clampIfNeeded(float *color)
}
}
-void MathAddOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathAddOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = inputValue1[0] + inputValue2[0];
clampIfNeeded(output);
}
-void MathSubtractOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathSubtractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = inputValue1[0] - inputValue2[0];
clampIfNeeded(output);
}
-void MathMultiplyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathMultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = inputValue1[0] * inputValue2[0];
clampIfNeeded(output);
}
-void MathDivideOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue2[0] == 0) /* We don't want to divide by zero. */
output[0] = 0.0;
@@ -127,52 +127,52 @@ void MathDivideOperation::executePixel(float output[4], float x, float y, PixelS
clampIfNeeded(output);
}
-void MathSineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathSineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = sin(inputValue1[0]);
clampIfNeeded(output);
}
-void MathCosineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathCosineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = cos(inputValue1[0]);
clampIfNeeded(output);
}
-void MathTangentOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathTangentOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = tan(inputValue1[0]);
clampIfNeeded(output);
}
-void MathArcSineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathArcSineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
output[0] = asin(inputValue1[0]);
@@ -182,13 +182,13 @@ void MathArcSineOperation::executePixel(float output[4], float x, float y, Pixel
clampIfNeeded(output);
}
-void MathArcCosineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathArcCosineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
output[0] = acos(inputValue1[0]);
@@ -198,26 +198,26 @@ void MathArcCosineOperation::executePixel(float output[4], float x, float y, Pix
clampIfNeeded(output);
}
-void MathArcTangentOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathArcTangentOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = atan(inputValue1[0]);
clampIfNeeded(output);
}
-void MathPowerOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathPowerOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue1[0] >= 0) {
output[0] = pow(inputValue1[0], inputValue2[0]);
@@ -236,13 +236,13 @@ void MathPowerOperation::executePixel(float output[4], float x, float y, PixelSa
clampIfNeeded(output);
}
-void MathLogarithmOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathLogarithmOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue1[0] > 0 && inputValue2[0] > 0)
output[0] = log(inputValue1[0]) / log(inputValue2[0]);
@@ -252,78 +252,78 @@ void MathLogarithmOperation::executePixel(float output[4], float x, float y, Pix
clampIfNeeded(output);
}
-void MathMinimumOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathMinimumOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = min(inputValue1[0], inputValue2[0]);
clampIfNeeded(output);
}
-void MathMaximumOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathMaximumOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = max(inputValue1[0], inputValue2[0]);
clampIfNeeded(output);
}
-void MathRoundOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathRoundOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = round(inputValue1[0]);
clampIfNeeded(output);
}
-void MathLessThanOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathLessThanOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f;
clampIfNeeded(output);
}
-void MathGreaterThanOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathGreaterThanOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
clampIfNeeded(output);
}
-void MathModuloOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MathModuloOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue1[4];
float inputValue2[4];
- this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue2[0] == 0)
output[0] = 0.0;
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index 649a9688037..4ea7c43a67d 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -50,7 +50,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler) = 0;
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) = 0;
/**
* Initialize the execution
@@ -73,94 +73,94 @@ public:
class MathAddOperation : public MathBaseOperation {
public:
MathAddOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathSubtractOperation : public MathBaseOperation {
public:
MathSubtractOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathMultiplyOperation : public MathBaseOperation {
public:
MathMultiplyOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathDivideOperation : public MathBaseOperation {
public:
MathDivideOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathSineOperation : public MathBaseOperation {
public:
MathSineOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathCosineOperation : public MathBaseOperation {
public:
MathCosineOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathTangentOperation : public MathBaseOperation {
public:
MathTangentOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathArcSineOperation : public MathBaseOperation {
public:
MathArcSineOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathArcCosineOperation : public MathBaseOperation {
public:
MathArcCosineOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathArcTangentOperation : public MathBaseOperation {
public:
MathArcTangentOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathPowerOperation : public MathBaseOperation {
public:
MathPowerOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathLogarithmOperation : public MathBaseOperation {
public:
MathLogarithmOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathMinimumOperation : public MathBaseOperation {
public:
MathMinimumOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathMaximumOperation : public MathBaseOperation {
public:
MathMaximumOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathRoundOperation : public MathBaseOperation {
public:
MathRoundOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathLessThanOperation : public MathBaseOperation {
public:
MathLessThanOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathGreaterThanOperation : public MathBaseOperation {
public:
MathGreaterThanOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathModuloOperation : public MathBaseOperation {
public:
MathModuloOperation() : MathBaseOperation() {}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp
index f094e93f147..9781cb4e162 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOperation.cpp
@@ -48,15 +48,15 @@ void MixBaseOperation::initExecution()
this->m_inputColor2Operation = this->getInputSocketReader(2);
}
-void MixBaseOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -107,15 +107,15 @@ MixAddOperation::MixAddOperation() : MixBaseOperation()
/* pass */
}
-void MixAddOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixAddOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -136,16 +136,16 @@ MixBlendOperation::MixBlendOperation() : MixBaseOperation()
/* pass */
}
-void MixBlendOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixBlendOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
float value;
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -167,16 +167,16 @@ MixBurnOperation::MixBurnOperation() : MixBaseOperation()
/* pass */
}
-void MixBurnOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixBurnOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
float tmp;
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -235,15 +235,15 @@ MixColorOperation::MixColorOperation() : MixBaseOperation()
/* pass */
}
-void MixColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -277,15 +277,15 @@ MixDarkenOperation::MixDarkenOperation() : MixBaseOperation()
/* pass */
}
-void MixDarkenOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixDarkenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -315,15 +315,15 @@ MixDifferenceOperation::MixDifferenceOperation() : MixBaseOperation()
/* pass */
}
-void MixDifferenceOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixDifferenceOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -345,15 +345,15 @@ MixDivideOperation::MixDivideOperation() : MixBaseOperation()
/* pass */
}
-void MixDivideOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -386,16 +386,16 @@ MixDodgeOperation::MixDodgeOperation() : MixBaseOperation()
/* pass */
}
-void MixDodgeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixDodgeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
float tmp;
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -459,16 +459,16 @@ MixGlareOperation::MixGlareOperation() : MixBaseOperation()
/* pass */
}
-void MixGlareOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixGlareOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
float value;
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
value = inputValue[0];
float mf = 2.f - 2.f * fabsf(value - 0.5f);
@@ -491,15 +491,15 @@ MixHueOperation::MixHueOperation() : MixBaseOperation()
/* pass */
}
-void MixHueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixHueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -533,15 +533,15 @@ MixLightenOperation::MixLightenOperation() : MixBaseOperation()
/* pass */
}
-void MixLightenOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixLightenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -569,15 +569,15 @@ MixLinearLightOperation::MixLinearLightOperation() : MixBaseOperation()
/* pass */
}
-void MixLinearLightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixLinearLightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -608,15 +608,15 @@ MixMultiplyOperation::MixMultiplyOperation() : MixBaseOperation()
/* pass */
}
-void MixMultiplyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixMultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -638,15 +638,15 @@ MixOverlayOperation::MixOverlayOperation() : MixBaseOperation()
/* pass */
}
-void MixOverlayOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixOverlayOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -685,15 +685,15 @@ MixSaturationOperation::MixSaturationOperation() : MixBaseOperation()
/* pass */
}
-void MixSaturationOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixSaturationOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -724,15 +724,15 @@ MixScreenOperation::MixScreenOperation() : MixBaseOperation()
/* pass */
}
-void MixScreenOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixScreenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -755,15 +755,15 @@ MixSoftLightOperation::MixSoftLightOperation() : MixBaseOperation()
/* pass */
}
-void MixSoftLightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) \
+void MixSoftLightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) \
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -792,15 +792,15 @@ MixSubtractOperation::MixSubtractOperation() : MixBaseOperation()
/* pass */
}
-void MixSubtractOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixSubtractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
@@ -821,15 +821,15 @@ MixValueOperation::MixValueOperation() : MixBaseOperation()
/* pass */
}
-void MixValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MixValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
- this->m_inputValueOperation->read(inputValue, x, y, sampler);
- this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
diff --git a/source/blender/compositor/operations/COM_MixOperation.h b/source/blender/compositor/operations/COM_MixOperation.h
index 93dbe6f36a6..479ce161eea 100644
--- a/source/blender/compositor/operations/COM_MixOperation.h
+++ b/source/blender/compositor/operations/COM_MixOperation.h
@@ -60,7 +60,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
@@ -83,115 +83,115 @@ public:
class MixAddOperation : public MixBaseOperation {
public:
MixAddOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixBlendOperation : public MixBaseOperation {
public:
MixBlendOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixBurnOperation : public MixBaseOperation {
public:
MixBurnOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixColorOperation : public MixBaseOperation {
public:
MixColorOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDarkenOperation : public MixBaseOperation {
public:
MixDarkenOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDifferenceOperation : public MixBaseOperation {
public:
MixDifferenceOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDivideOperation : public MixBaseOperation {
public:
MixDivideOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDodgeOperation : public MixBaseOperation {
public:
MixDodgeOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixGlareOperation : public MixBaseOperation {
public:
MixGlareOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixHueOperation : public MixBaseOperation {
public:
MixHueOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixLightenOperation : public MixBaseOperation {
public:
MixLightenOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixLinearLightOperation : public MixBaseOperation {
public:
MixLinearLightOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixMultiplyOperation : public MixBaseOperation {
public:
MixMultiplyOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixOverlayOperation : public MixBaseOperation {
public:
MixOverlayOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixSaturationOperation : public MixBaseOperation {
public:
MixSaturationOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixScreenOperation : public MixBaseOperation {
public:
MixScreenOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixSoftLightOperation : public MixBaseOperation {
public:
MixSoftLightOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixSubtractOperation : public MixBaseOperation {
public:
MixSubtractOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixValueOperation : public MixBaseOperation {
public:
MixValueOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
index 0d2de47bc4f..fbbfa8fd65e 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
@@ -33,7 +33,7 @@ MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation()
this->m_attribute = MCA_X;
}
-void MovieClipAttributeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MovieClipAttributeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if (!this->m_valueSet) {
float loc[2], scale, angle;
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
index f894626d534..49c86c7fafc 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -51,7 +51,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
void setMovieClip(MovieClip *clip) { this->m_clip = clip; }
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index 76dc093035c..5b75113e7f3 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -86,7 +86,7 @@ void MovieClipBaseOperation::determineResolution(unsigned int resolution[2], uns
}
}
-void MovieClipBaseOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MovieClipBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
ImBuf *ibuf = this->m_movieClipBuffer;
@@ -122,9 +122,9 @@ MovieClipAlphaOperation::MovieClipAlphaOperation() : MovieClipBaseOperation()
this->addOutputSocket(COM_DT_VALUE);
}
-void MovieClipAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MovieClipAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- MovieClipBaseOperation::executePixel(output, x, y, sampler);
+ MovieClipBaseOperation::executePixelSampled(output, x, y, sampler);
output[0] = output[3];
output[1] = 0.0f;
output[2] = 0.0f;
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h
index a368dca423c..c16262cbd02 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.h
@@ -57,7 +57,7 @@ public:
void setCacheFrame(bool value) { this->m_cacheFrame = value; }
void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MovieClipOperation : public MovieClipBaseOperation {
@@ -68,7 +68,7 @@ public:
class MovieClipAlphaOperation : public MovieClipBaseOperation {
public:
MovieClipAlphaOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
index 863a404ba67..bc792244dcb 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;
+static vector<DistortionCache *> s_cache;
void deintializeDistortionCache(void)
{
@@ -122,16 +122,16 @@ void MovieDistortionOperation::deinitExecution()
}
-void MovieDistortionOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MovieDistortionOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if (this->m_cache != NULL) {
float u, v;
this->m_cache->getUV(&this->m_movieClip->tracking, x, y, &u, &v);
- this->m_inputOperation->read(output, u, v, COM_PS_BILINEAR);
+ this->m_inputOperation->readSampled(output, u, v, COM_PS_BILINEAR);
}
else {
- this->m_inputOperation->read(output, x, y, COM_PS_BILINEAR);
+ this->m_inputOperation->readSampled(output, x, y, COM_PS_BILINEAR);
}
}
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
index c9629451992..42c4a84f9b2 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -156,7 +156,7 @@ protected:
public:
MovieDistortionOperation(bool distortion);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index e2a95b2e33b..84c1fdfb6f5 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -42,7 +42,7 @@ ImBuf *MultilayerBaseOperation::getImBuf()
return NULL;
}
-void MultilayerColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MultilayerColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
int yi = y;
int xi = x;
@@ -70,7 +70,7 @@ void MultilayerColorOperation::executePixel(float output[4], float x, float y, P
}
}
-void MultilayerValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MultilayerValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
int yi = y;
int xi = x;
@@ -83,7 +83,7 @@ void MultilayerValueOperation::executePixel(float output[4], float x, float y, P
}
}
-void MultilayerVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void MultilayerVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
int yi = y;
int xi = x;
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
index 065bcc7da1e..37bee1b6a8c 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -46,7 +46,7 @@ public:
MultilayerColorOperation(int passindex) : MultilayerBaseOperation(passindex) {
this->addOutputSocket(COM_DT_COLOR);
}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MultilayerValueOperation : public MultilayerBaseOperation {
@@ -54,7 +54,7 @@ public:
MultilayerValueOperation(int passindex) : MultilayerBaseOperation(passindex) {
this->addOutputSocket(COM_DT_VALUE);
}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MultilayerVectorOperation : public MultilayerBaseOperation {
@@ -62,7 +62,7 @@ public:
MultilayerVectorOperation(int passindex) : MultilayerBaseOperation(passindex) {
this->addOutputSocket(COM_DT_VECTOR);
}
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index a5be993f241..c94387337c3 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -79,7 +79,7 @@ static void write_buffer_rect(rcti *rect, const bNodeTree *tree,
for (y = y1; y < y2 && (!breaked); y++) {
for (x = x1; x < x2 && (!breaked); x++) {
- reader->read(color, x, y, COM_PS_NEAREST);
+ reader->readSampled(color, x, y, COM_PS_NEAREST);
for (i = 0; i < size; ++i)
buffer[offset + i] = color[i];
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cpp b/source/blender/compositor/operations/COM_PixelateOperation.cpp
index 89e7f0093a1..eed6d1d01b9 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.cpp
+++ b/source/blender/compositor/operations/COM_PixelateOperation.cpp
@@ -40,10 +40,10 @@ void PixelateOperation::deinitExecution()
this->m_inputOperation = NULL;
}
-void PixelateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void PixelateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float nx = round(x);
float ny = round(y);
- this->m_inputOperation->read(output, nx, ny, sampler);
+ this->m_inputOperation->readSampled(output, nx, ny, sampler);
}
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.h b/source/blender/compositor/operations/COM_PixelateOperation.h
index 83603a59331..8e60baf7f05 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.h
+++ b/source/blender/compositor/operations/COM_PixelateOperation.h
@@ -62,7 +62,7 @@ public:
* @param y y-coordinate
* @param sampler sampler
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp
index 8aa1324d8e2..58fa4bd08dc 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp
@@ -50,7 +50,7 @@ void PlaneTrackMaskOperation::initExecution()
BLI_jitter_init(this->m_jitter[0], this->m_osa);
}
-void PlaneTrackMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void PlaneTrackMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float point[2];
diff --git a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h
index db32f9830e0..7f763954079 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h
@@ -43,7 +43,7 @@ public:
void initExecution();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp
index df487a766f3..dba3a6f3505 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp
@@ -47,23 +47,17 @@ BLI_INLINE bool isPointInsideQuad(const float x, const float y, const float corn
isect_point_tri_v2(point, corners[0], corners[2], corners[3]);
}
-BLI_INLINE bool resolveUV(const float x, const float y, const float corners[4][2], float uv[2])
+BLI_INLINE void warpCoord(float x, float y, float matrix[3][3], float uv[2])
{
- float point[2];
- bool inside;
-
- inside = isPointInsideQuad(x, y, corners);
-
- point[0] = x;
- point[1] = y;
-
- /* Use reverse bilinear to get UV coordinates within original frame */
- resolve_quad_uv(uv, point, corners[0], corners[1], corners[2], corners[3]);
+ float vec[3] = {x, y, 1.0f};
+ mul_m3_v3(matrix, vec);
+ vec[0] /= vec[2];
+ vec[1] /= vec[2];
- return inside;
+ copy_v2_v2(uv, vec);
}
-BLI_INLINE void resolveUVAndDxDy(const float x, const float y, const float corners[4][2],
+BLI_INLINE void resolveUVAndDxDy(const float x, const float y, float matrix[3][3],
float *u_r, float *v_r, float *dx_r, float *dy_r)
{
float inputUV[2];
@@ -73,23 +67,21 @@ BLI_INLINE void resolveUVAndDxDy(const float x, const float y, const float corne
float uv_l, uv_r;
float uv_u, uv_d;
- bool ok1, ok2;
-
- resolveUV(x, y, corners, inputUV);
+ warpCoord(x, y, matrix, inputUV);
/* adaptive sampling, red (U) channel */
- ok1 = resolveUV(x - 1, y, corners, uv_a);
- ok2 = resolveUV(x + 1, y, corners, uv_b);
- uv_l = ok1 ? fabsf(inputUV[0] - uv_a[0]) : 0.0f;
- uv_r = ok2 ? fabsf(inputUV[0] - uv_b[0]) : 0.0f;
+ warpCoord(x - 1, y, matrix, uv_a);
+ warpCoord(x + 1, y, matrix, uv_b);
+ uv_l = fabsf(inputUV[0] - uv_a[0]);
+ uv_r = fabsf(inputUV[0] - uv_b[0]);
dx = 0.5f * (uv_l + uv_r);
/* adaptive sampling, green (V) channel */
- ok1 = resolveUV(x, y - 1, corners, uv_a);
- ok2 = resolveUV(x, y + 1, corners, uv_b);
- uv_u = ok1 ? fabsf(inputUV[1] - uv_a[1]) : 0.f;
- uv_d = ok2 ? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+ warpCoord(x, y - 1, matrix, uv_a);
+ warpCoord(x, y + 1, matrix, uv_b);
+ uv_u = fabsf(inputUV[1] - uv_a[1]);
+ uv_d = fabsf(inputUV[1] - uv_b[1]);
dy = 0.5f * (uv_u + uv_d);
@@ -118,6 +110,16 @@ void PlaneTrackWarpImageOperation::initExecution()
this->m_pixelReader = this->getInputSocketReader(0);
BLI_jitter_init(this->m_jitter[0], this->m_osa);
+
+ const int width = this->m_pixelReader->getWidth();
+ const int height = this->m_pixelReader->getHeight();
+ float frame_corners[4][2] = {{0.0f, 0.0f},
+ {(float) width, 0.0f},
+ {(float) width, (float) height},
+ {0.0f, (float) height}};
+ BKE_tracking_homography_between_two_quads(this->m_frameSpaceCorners,
+ frame_corners,
+ this->m_perspectiveMatrix);
}
void PlaneTrackWarpImageOperation::deinitExecution()
@@ -125,24 +127,25 @@ void PlaneTrackWarpImageOperation::deinitExecution()
this->m_pixelReader = NULL;
}
-void PlaneTrackWarpImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void PlaneTrackWarpImageOperation::executePixelSampled(float output[4], float x_, float y_, PixelSampler sampler)
{
float color_accum[4];
zero_v4(color_accum);
for (int sample = 0; sample < this->m_osa; sample++) {
- float current_x = x + this->m_jitter[sample][0],
- current_y = y + this->m_jitter[sample][1];
+ float current_x = x_ + this->m_jitter[sample][0],
+ current_y = y_ + this->m_jitter[sample][1];
if (isPointInsideQuad(current_x, current_y, this->m_frameSpaceCorners)) {
float current_color[4];
float u, v, dx, dy;
- resolveUVAndDxDy(current_x, current_y, this->m_frameSpaceCorners, &u, &v, &dx, &dy);
+ resolveUVAndDxDy(current_x, current_y, m_perspectiveMatrix, &u, &v, &dx, &dy);
- u *= this->m_pixelReader->getWidth();
- v *= this->m_pixelReader->getHeight();
+ /* derivatives are to be in normalized space.. */
+ dx /= this->m_pixelReader->getWidth();
+ dy /= this->m_pixelReader->getHeight();
- this->m_pixelReader->read(current_color, u, v, dx, dy, COM_PS_NEAREST);
+ this->m_pixelReader->readFiltered(current_color, u, v, dx, dy, COM_PS_NEAREST);
add_v4_v4(color_accum, current_color);
}
}
@@ -152,20 +155,13 @@ void PlaneTrackWarpImageOperation::executePixel(float output[4], float x, float
bool PlaneTrackWarpImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- float frame_space_corners[4][2];
-
- for (int i = 0; i < 4; i++) {
- frame_space_corners[i][0] = this->m_corners[i][0] * this->getWidth();
- frame_space_corners[i][1] = this->m_corners[i][1] * this->getHeight();
- }
-
float UVs[4][2];
/* TODO(sergey): figure out proper way to do this. */
- resolveUV(input->xmin - 2, input->ymin - 2, frame_space_corners, UVs[0]);
- resolveUV(input->xmax + 2, input->ymin - 2, frame_space_corners, UVs[1]);
- resolveUV(input->xmax + 2, input->ymax + 2, frame_space_corners, UVs[2]);
- resolveUV(input->xmin - 2, input->ymax + 2, frame_space_corners, UVs[3]);
+ warpCoord(input->xmin - 2, input->ymin - 2, this->m_perspectiveMatrix, UVs[0]);
+ warpCoord(input->xmax + 2, input->ymin - 2, this->m_perspectiveMatrix, UVs[1]);
+ warpCoord(input->xmax + 2, input->ymax + 2, this->m_perspectiveMatrix, UVs[2]);
+ warpCoord(input->xmin - 2, input->ymax + 2, this->m_perspectiveMatrix, UVs[3]);
float min[2], max[2];
INIT_MINMAX2(min, max);
@@ -175,10 +171,10 @@ bool PlaneTrackWarpImageOperation::determineDependingAreaOfInterest(rcti *input,
rcti newInput;
- newInput.xmin = min[0] * readOperation->getWidth() - 1;
- newInput.ymin = min[1] * readOperation->getHeight() - 1;
- newInput.xmax = max[0] * readOperation->getWidth() + 1;
- newInput.ymax = max[1] * readOperation->getHeight() + 1;
+ newInput.xmin = min[0] - 1;
+ newInput.ymin = min[1] - 1;
+ newInput.xmax = max[0] + 1;
+ newInput.ymax = max[1] + 1;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h
index a92ff3f9ddf..ed9cc2fe5aa 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h
@@ -38,6 +38,7 @@ protected:
SocketReader *m_pixelReader;
int m_osa;
float m_jitter[32][2];
+ float m_perspectiveMatrix[3][3];
public:
PlaneTrackWarpImageOperation();
@@ -45,7 +46,7 @@ public:
void initExecution();
void deinitExecution();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
};
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index ba158fb2509..add9e8b959e 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -104,7 +104,7 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber)
color[1] = 0.0f;
color[2] = 0.0f;
color[3] = 1.0f;
- this->m_input->read(color, rx, ry, COM_PS_NEAREST);
+ this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST);
IMB_colormanagement_processor_apply_v4(cm_processor, color);
F4TOCHAR4(color, this->m_outputBuffer + offset);
offset += 4;
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index e8b900b9a85..7f6079c55aa 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -102,7 +102,7 @@ void ProjectorLensDistortionOperation::updateDispersion()
this->lockMutex();
if (!this->m_dispersionAvailable) {
float result[4];
- this->getInputSocketReader(1)->read(result, 1, 1, COM_PS_NEAREST);
+ this->getInputSocketReader(1)->readSampled(result, 1, 1, COM_PS_NEAREST);
this->m_dispersion = result[0];
this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f);
this->m_kr2 = this->m_kr * 20;
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
index 3aeef6bf409..b93e338ad6c 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
@@ -52,7 +52,7 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[2], unsign
m_single_value = operation->isSingleValue();
}
}
-void ReadBufferOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ReadBufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if (m_single_value) {
/* write buffer has a single value stored at (0,0) */
@@ -81,7 +81,7 @@ void ReadBufferOperation::executePixelExtend(float output[4], float x, float y,
}
}
-void ReadBufferOperation::executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler)
+void ReadBufferOperation::executePixelFiltered(float output[4], float x, float y, float dx, float dy, PixelSampler sampler)
{
if (m_single_value) {
/* write buffer has a single value stored at (0,0) */
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
index 7a67056eda6..cdc6e50f6d4 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.h
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -40,10 +40,10 @@ public:
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
void *initializeTileData(rcti *rect);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void executePixelExtend(float output[4], float x, float y, PixelSampler sampler,
MemoryBufferExtend extend_x, MemoryBufferExtend extend_y);
- void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler);
+ void executePixelFiltered(float output[4], float x, float y, float dx, float dy, PixelSampler sampler);
const bool isReadBufferOperation() const { return true; }
void setOffset(unsigned int offset) { this->m_offset = offset; }
unsigned int getOffset() const { return this->m_offset; }
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index ea6ad86d92c..2c2a4c6f180 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -60,7 +60,7 @@ void RenderLayersBaseProg::initExecution()
if (rl && rl->rectf) {
this->m_inputBuffer = RE_RenderLayerGetPass(rl, this->m_renderpass);
- if (this->m_inputBuffer == NULL || this->m_renderpass == SCE_PASS_COMBINED) {
+ if (this->m_inputBuffer == NULL && this->m_renderpass == SCE_PASS_COMBINED) {
this->m_inputBuffer = rl->rectf;
}
}
@@ -112,7 +112,7 @@ void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, Pi
}
}
-void RenderLayersBaseProg::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void RenderLayersBaseProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
#if 0
const RenderData *rd = this->m_rd;
@@ -192,7 +192,7 @@ RenderLayersAlphaProg::RenderLayersAlphaProg() : RenderLayersBaseProg(SCE_PASS_C
this->addOutputSocket(COM_DT_VALUE);
}
-void RenderLayersAlphaProg::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void RenderLayersAlphaProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
int ix = x;
int iy = y;
@@ -234,7 +234,7 @@ RenderLayersDepthProg::RenderLayersDepthProg() : RenderLayersBaseProg(SCE_PASS_Z
this->addOutputSocket(COM_DT_VALUE);
}
-void RenderLayersDepthProg::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void RenderLayersDepthProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
int ix = x;
int iy = y;
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index 04861174387..b76a8621b19 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -99,7 +99,7 @@ public:
short getLayerId() { return this->m_layerId; }
void initExecution();
void deinitExecution();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class RenderLayersAOOperation : public RenderLayersBaseProg {
@@ -110,7 +110,7 @@ public:
class RenderLayersAlphaProg : public RenderLayersBaseProg {
public:
RenderLayersAlphaProg();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class RenderLayersColorOperation : public RenderLayersBaseProg {
@@ -126,7 +126,7 @@ public:
class RenderLayersDepthProg : public RenderLayersBaseProg {
public:
RenderLayersDepthProg();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class RenderLayersDiffuseOperation : public RenderLayersBaseProg {
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
index 422c5b93484..c6ad87bbf97 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cpp
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -52,7 +52,7 @@ inline void RotateOperation::ensureDegree()
{
if (!this->m_isDegreeSet) {
float degree[4];
- this->m_degreeSocket->read(degree, 0, 0, COM_PS_NEAREST);
+ this->m_degreeSocket->readSampled(degree, 0, 0, COM_PS_NEAREST);
double rad;
if (this->m_doDegree2RadConversion) {
rad = DEG2RAD((double)degree[0]);
@@ -68,14 +68,14 @@ inline void RotateOperation::ensureDegree()
}
-void RotateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void RotateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
ensureDegree();
const float dy = y - this->m_centerY;
const float dx = x - this->m_centerX;
const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy);
const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy);
- this->m_imageSocket->read(output, nx, ny, sampler);
+ this->m_imageSocket->readSampled(output, nx, ny, sampler);
}
bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h
index 292f0743a44..40acad1abe6 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.h
+++ b/source/blender/compositor/operations/COM_RotateOperation.h
@@ -38,7 +38,7 @@ private:
public:
RotateOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
void setDoDegree2RadConversion(bool abool) { this->m_doDegree2RadConversion = abool; }
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 9e8f5af0ef0..452765a5ab7 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -66,22 +66,22 @@ void ScaleOperation::deinitExecution()
}
-void ScaleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ScaleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
PixelSampler effective_sampler = getEffectiveSampler(sampler);
float scaleX[4];
float scaleY[4];
- this->m_inputXOperation->read(scaleX, x, y, effective_sampler);
- this->m_inputYOperation->read(scaleY, x, y, effective_sampler);
+ this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
+ this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
const float scx = scaleX[0];
const float scy = scaleY[0];
float nx = this->m_centerX + (x - this->m_centerX) / scx;
float ny = this->m_centerY + (y - this->m_centerY) / scy;
- this->m_inputOperation->read(output, nx, ny, effective_sampler);
+ this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
}
bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -90,8 +90,8 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe
float scaleX[4];
float scaleY[4];
- this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST);
- this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST);
+ this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
+ this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
const float scx = scaleX[0];
const float scy = scaleY[0];
@@ -134,15 +134,15 @@ void ScaleAbsoluteOperation::deinitExecution()
}
-void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ScaleAbsoluteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
PixelSampler effective_sampler = getEffectiveSampler(sampler);
float scaleX[4];
float scaleY[4];
- this->m_inputXOperation->read(scaleX, x, y, effective_sampler);
- this->m_inputYOperation->read(scaleY, x, y, effective_sampler);
+ this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
+ this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
const float scx = scaleX[0]; // target absolute scale
const float scy = scaleY[0]; // target absolute scale
@@ -156,7 +156,7 @@ void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, Pix
float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale;
float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale;
- this->m_inputOperation->read(output, nx, ny, effective_sampler);
+ this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
}
bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -165,8 +165,8 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB
float scaleX[4];
float scaleY[4];
- this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST);
- this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST);
+ this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
+ this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
const float scx = scaleX[0];
const float scy = scaleY[0];
@@ -253,17 +253,17 @@ void ScaleFixedSizeOperation::deinitExecution()
}
-void ScaleFixedSizeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ScaleFixedSizeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
PixelSampler effective_sampler = getEffectiveSampler(sampler);
if (this->m_is_offset) {
float nx = ((x - this->m_offsetX) * this->m_relX);
float ny = ((y - this->m_offsetY) * this->m_relY);
- this->m_inputOperation->read(output, nx, ny, effective_sampler);
+ this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
}
else {
- this->m_inputOperation->read(output, x * this->m_relX, y * this->m_relY, effective_sampler);
+ this->m_inputOperation->readSampled(output, x * this->m_relX, y * this->m_relY, effective_sampler);
}
}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index f42cdbd78ed..706a5898027 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -47,7 +47,7 @@ private:
public:
ScaleOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
@@ -63,7 +63,7 @@ class ScaleAbsoluteOperation : public BaseScaleOperation {
public:
ScaleAbsoluteOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
@@ -88,7 +88,7 @@ public:
ScaleFixedSizeOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index d1060224444..5d2977d361b 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -291,9 +291,9 @@ void ScreenLensDistortionOperation::updateDispersionAndDistortion()
this->lockMutex();
if (!this->m_valuesAvailable) {
float result[4];
- this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST);
+ this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
this->m_distortion = result[0];
- this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST);
+ this->getInputSocketReader(2)->readSampled(result, 0, 0, COM_PS_NEAREST);
this->m_dispersion = result[0];
updateVariables(this->m_distortion, this->m_dispersion);
this->m_valuesAvailable = true;
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
index fc6cfa455f3..efdc844704a 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
@@ -38,12 +38,12 @@ void SetAlphaOperation::initExecution()
this->m_inputAlpha = getInputSocketReader(1);
}
-void SetAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SetAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float alphaInput[4];
- this->m_inputColor->read(output, x, y, sampler);
- this->m_inputAlpha->read(alphaInput, x, y, sampler);
+ this->m_inputColor->readSampled(output, x, y, sampler);
+ this->m_inputAlpha->readSampled(alphaInput, x, y, sampler);
output[3] = alphaInput[0];
}
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h
index 1ec4a7aeacf..a0869ec90b2 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.h
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h
@@ -43,7 +43,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp
index 44c29b3befd..94a863e628b 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp
@@ -27,7 +27,7 @@ SetColorOperation::SetColorOperation() : NodeOperation()
this->addOutputSocket(COM_DT_COLOR);
}
-void SetColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SetColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
copy_v4_v4(output, this->m_color);
}
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h
index 8377decdd7b..7dfed6b570b 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.h
+++ b/source/blender/compositor/operations/COM_SetColorOperation.h
@@ -55,7 +55,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
bool isSetOperation() const { return true; }
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
index 343b5973f7e..be72ffd0336 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
@@ -37,7 +37,7 @@ void SetSamplerOperation::deinitExecution()
this->m_reader = NULL;
}
-void SetSamplerOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SetSamplerOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- this->m_reader->read(output, x, y, this->m_sampler);
+ this->m_reader->readSampled(output, x, y, this->m_sampler);
}
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h
index c94e174fc81..145d82bd407 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.h
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h
@@ -44,7 +44,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
};
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp
index c5ce3e4c09c..51e09a63051 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp
@@ -27,7 +27,7 @@ SetValueOperation::SetValueOperation() : NodeOperation()
this->addOutputSocket(COM_DT_VALUE);
}
-void SetValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SetValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
output[0] = this->m_value;
}
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h
index b88b85d66f2..7cb914ffa48 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.h
+++ b/source/blender/compositor/operations/COM_SetValueOperation.h
@@ -46,7 +46,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
bool isSetOperation() const { return true; }
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
index d5c665e81f5..17212d78e15 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
@@ -28,7 +28,7 @@ SetVectorOperation::SetVectorOperation() : NodeOperation()
this->addOutputSocket(COM_DT_VECTOR);
}
-void SetVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SetVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
output[0] = this->m_x;
output[1] = this->m_y;
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
index d15da58e58e..6fd1b9768fc 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.h
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -54,7 +54,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
bool isSetOperation() const { return true; }
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
index ac2cee8eb44..d047198ac93 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -39,9 +39,9 @@ void SocketProxyOperation::deinitExecution()
this->m_inputOperation = NULL;
}
-void SocketProxyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SocketProxyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
if (this->m_inputOperation) {
- this->m_inputOperation->read(output, x, y, sampler);
+ this->m_inputOperation->readSampled(output, x, y, sampler);
}
}
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index a37384455ca..6a6a0b351b0 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.h
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -30,7 +30,7 @@ private:
SocketReader *m_inputOperation;
public:
SocketProxyOperation(DataType type);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_SplitOperation.cpp b/source/blender/compositor/operations/COM_SplitOperation.cpp
index a7dbccfc2f7..210095f3bf1 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitOperation.cpp
@@ -57,15 +57,15 @@ void SplitOperation::deinitExecution()
this->m_image2Input = NULL;
}
-void SplitOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void SplitOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f;
bool image1 = this->m_xSplit ? x > perc : y > perc;
if (image1) {
- this->m_image1Input->read(output, x, y, COM_PS_NEAREST);
+ this->m_image1Input->readSampled(output, x, y, COM_PS_NEAREST);
}
else {
- this->m_image2Input->read(output, x, y, COM_PS_NEAREST);
+ this->m_image2Input->readSampled(output, x, y, COM_PS_NEAREST);
}
}
diff --git a/source/blender/compositor/operations/COM_SplitOperation.h b/source/blender/compositor/operations/COM_SplitOperation.h
index 5a042b789d8..2853c845d03 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.h
+++ b/source/blender/compositor/operations/COM_SplitOperation.h
@@ -35,7 +35,7 @@ public:
SplitOperation();
void initExecution();
void deinitExecution();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; }
void setXSplit(bool xsplit) { this->m_xSplit = xsplit; }
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index bbb7c8b5289..96aea56050f 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -75,16 +75,16 @@ void TextureBaseOperation::determineResolution(unsigned int resolution[2], unsig
}
}
-void TextureAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void TextureAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- TextureBaseOperation::executePixel(output, x, y, sampler);
+ TextureBaseOperation::executePixelSampled(output, x, y, sampler);
output[0] = output[3];
output[1] = 0.0f;
output[2] = 0.0f;
output[3] = 0.0f;
}
-void TextureBaseOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void TextureBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
float textureSize[4];
@@ -96,8 +96,8 @@ void TextureBaseOperation::executePixel(float output[4], float x, float y, Pixel
const float u = (x - cx) / this->getWidth() * 2;
const float v = (y - cy) / this->getHeight() * 2;
- this->m_inputSize->read(textureSize, x, y, sampler);
- this->m_inputOffset->read(textureOffset, x, y, sampler);
+ this->m_inputSize->readSampled(textureSize, x, y, sampler);
+ this->m_inputOffset->readSampled(textureOffset, x, y, sampler);
vec[0] = textureSize[0] * (u + textureOffset[0]);
vec[1] = textureSize[1] * (v + textureOffset[1]);
@@ -136,7 +136,7 @@ MemoryBuffer *TextureBaseOperation::createMemoryBuffer(rcti *rect2)
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++, data += 4) {
- this->executePixel(data, x, y, COM_PS_NEAREST);
+ this->executePixelSampled(data, x, y, COM_PS_NEAREST);
}
}
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index b776f6f2493..064e63c025a 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -62,7 +62,7 @@ protected:
MemoryBuffer *createMemoryBuffer(rcti *rect2);
public:
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void setTexture(Tex *texture) { this->m_texture = texture; }
void initExecution();
@@ -79,7 +79,7 @@ public:
class TextureAlphaOperation : public TextureBaseOperation {
public:
TextureAlphaOperation();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
index 4f00358633a..721b17bcff0 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
@@ -102,7 +102,7 @@ void TrackPositionOperation::initExecution()
}
}
-void TrackPositionOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void TrackPositionOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
output[0] = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis];
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.h b/source/blender/compositor/operations/COM_TrackPositionOperation.h
index 7a4ce9f9213..10dbaf96646 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.h
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.h
@@ -70,7 +70,7 @@ public:
void initExecution();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
bool isSetOperation() const { return true; }
};
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp
index e2582c3b67b..64da954a2e1 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.cpp
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp
@@ -52,14 +52,14 @@ void TranslateOperation::deinitExecution()
}
-void TranslateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void TranslateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
ensureDelta();
float originalXPos = x - this->getDeltaX();
float originalYPos = y - this->getDeltaY();
- this->m_inputOperation->read(output, originalXPos, originalYPos, sampler);
+ this->m_inputOperation->readSampled(output, originalXPos, originalYPos, sampler);
}
bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h
index a638ae7ce69..f2ae976e2ef 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.h
+++ b/source/blender/compositor/operations/COM_TranslateOperation.h
@@ -38,7 +38,7 @@ private:
public:
TranslateOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
@@ -49,9 +49,9 @@ public:
inline void ensureDelta() {
if (!this->m_isDeltaSet) {
float tempDelta[4];
- this->m_inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST);
+ this->m_inputXOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
this->m_deltaX = tempDelta[0];
- this->m_inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST);
+ this->m_inputYOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
this->m_deltaY = tempDelta[0];
this->m_isDeltaSet = true;
}
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 03031e0f764..8bdaa0f486e 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -338,7 +338,7 @@ voi *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
return data;
}
-void InverseSearchRadiusOperation::executePixel(float output[4], int x, int y, void *data)
+void InverseSearchRadiusOperation::executePixelChunk(float output[4], int x, int y, void *data)
{
MemoryBuffer *buffer = (MemoryBuffer *)data;
buffer->readNoCheck(color, x, y);
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
index 7ba8df16795..cab38698296 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -85,7 +85,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ void executePixelChunk(float output[4], int x, int y, void *data);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
index 6450b0716a3..204b0f2011b 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
@@ -43,12 +43,12 @@ void VectorCurveOperation::initExecution()
this->m_inputProgram = this->getInputSocketReader(0);
}
-void VectorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void VectorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
- this->m_inputProgram->read(input, x, y, sampler);
+ this->m_inputProgram->readSampled(input, x, y, sampler);
curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input);
output[3] = input[3];
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h
index 6a1f916c60b..677af77b05e 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h
@@ -37,7 +37,7 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index 468aec64a56..13b50910b50 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -101,18 +101,18 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
for (y = y1; y < y2 && (!breaked); y++) {
for (x = x1; x < x2; x++) {
- this->m_imageInput->read(&(buffer[offset4]), x, y, COM_PS_NEAREST);
+ this->m_imageInput->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
if (this->m_ignoreAlpha) {
buffer[offset4 + 3] = 1.0f;
}
else {
if (this->m_alphaInput != NULL) {
- this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST);
+ this->m_alphaInput->readSampled(alpha, x, y, COM_PS_NEAREST);
buffer[offset4 + 3] = alpha[0];
}
}
if (m_depthInput) {
- this->m_depthInput->read(depth, x, y, COM_PS_NEAREST);
+ this->m_depthInput->readSampled(depth, x, y, COM_PS_NEAREST);
depthbuffer[offset] = depth[0];
}
@@ -147,8 +147,6 @@ void ViewerOperation::initImage()
ima->ok = IMA_OK_LOADED;
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
-
- BLI_unlock_thread(LOCK_DRAW_IMAGE);
}
if (m_doDepthBuffer) {
diff --git a/source/blender/compositor/operations/COM_WrapOperation.cpp b/source/blender/compositor/operations/COM_WrapOperation.cpp
index ea19952f60c..e6cde05eae2 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.cpp
+++ b/source/blender/compositor/operations/COM_WrapOperation.cpp
@@ -42,7 +42,7 @@ inline float WrapOperation::getWrappedOriginalYPos(float y)
return fmodf(y, this->getHeight());
}
-void WrapOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void WrapOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float nx, ny;
nx = x;
diff --git a/source/blender/compositor/operations/COM_WrapOperation.h b/source/blender/compositor/operations/COM_WrapOperation.h
index ddd5fa8032d..33ea1280564 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.h
+++ b/source/blender/compositor/operations/COM_WrapOperation.h
@@ -31,7 +31,7 @@ private:
public:
WrapOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
void setWrapping(int wrapping_type);
float getWrappedOriginalXPos(float x);
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
index cf462607936..832864b399d 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -40,9 +40,9 @@ WriteBufferOperation::~WriteBufferOperation()
}
}
-void WriteBufferOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void WriteBufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- this->m_input->read(output, x, y, sampler);
+ this->m_input->readSampled(output, x, y, sampler);
}
void WriteBufferOperation::initExecution()
@@ -98,7 +98,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber)
for (y = y1; y < y2 && (!breaked); y++) {
int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS;
for (x = x1; x < x2; x++) {
- this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST);
+ this->m_input->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
offset4 += COM_NUMBER_OF_CHANNELS;
}
if (isBreaked()) {
@@ -157,14 +157,14 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device, rcti *rect,
this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
// STEP 4
- while (clMemToCleanUp->size() > 0) {
+ while (!clMemToCleanUp->empty()) {
cl_mem mem = clMemToCleanUp->front();
error = clReleaseMemObject(mem);
if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
clMemToCleanUp->pop_front();
}
- while (clKernelsToCleanUp->size() > 0) {
+ while (!clKernelsToCleanUp->empty()) {
cl_kernel kernel = clKernelsToCleanUp->front();
error = clReleaseKernel(kernel);
if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
index 157543fcb72..1f1f58b18f1 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.h
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -39,7 +39,7 @@ public:
~WriteBufferOperation();
int isBufferOperation() { return true; }
MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; }
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
const bool isWriteBufferOperation() const { return true; }
bool isSingleValue() const { return m_single_value; }
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 7db91a40fb7..6cb88919b1b 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -46,36 +46,36 @@ void ZCombineOperation::initExecution()
this->m_depth2Reader = this->getInputSocketReader(3);
}
-void ZCombineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float depth1[4];
float depth2[4];
- this->m_depth1Reader->read(depth1, x, y, sampler);
- this->m_depth2Reader->read(depth2, x, y, sampler);
+ this->m_depth1Reader->readSampled(depth1, x, y, sampler);
+ this->m_depth2Reader->readSampled(depth2, x, y, sampler);
if (depth1[0] < depth2[0]) {
- this->m_image1Reader->read(output, x, y, sampler);
+ this->m_image1Reader->readSampled(output, x, y, sampler);
}
else {
- this->m_image2Reader->read(output, x, y, sampler);
+ this->m_image2Reader->readSampled(output, x, y, sampler);
}
}
-void ZCombineAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float depth1[4];
float depth2[4];
float color1[4];
float color2[4];
- this->m_depth1Reader->read(depth1, x, y, sampler);
- this->m_depth2Reader->read(depth2, x, y, sampler);
+ this->m_depth1Reader->readSampled(depth1, x, y, sampler);
+ this->m_depth2Reader->readSampled(depth2, x, y, sampler);
if (depth1[0] <= depth2[0]) {
- this->m_image1Reader->read(color1, x, y, sampler);
- this->m_image2Reader->read(color2, x, y, sampler);
+ this->m_image1Reader->readSampled(color1, x, y, sampler);
+ this->m_image2Reader->readSampled(color2, x, y, sampler);
}
else {
- this->m_image1Reader->read(color2, x, y, sampler);
- this->m_image2Reader->read(color1, x, y, sampler);
+ this->m_image1Reader->readSampled(color2, x, y, sampler);
+ this->m_image2Reader->readSampled(color1, x, y, sampler);
}
float fac = color1[3];
float ifac = 1.0f - fac;
@@ -113,28 +113,28 @@ void ZCombineMaskOperation::initExecution()
this->m_image2Reader = this->getInputSocketReader(2);
}
-void ZCombineMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float mask[4];
float color1[4];
float color2[4];
- this->m_maskReader->read(mask, x, y, sampler);
- this->m_image1Reader->read(color1, x, y, sampler);
- this->m_image2Reader->read(color2, x, y, sampler);
+ this->m_maskReader->readSampled(mask, x, y, sampler);
+ this->m_image1Reader->readSampled(color1, x, y, sampler);
+ this->m_image2Reader->readSampled(color2, x, y, sampler);
interp_v4_v4v4(output, color1, color2, 1.0f - mask[0]);
}
-void ZCombineMaskAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineMaskAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float mask[4];
float color1[4];
float color2[4];
- this->m_maskReader->read(mask, x, y, sampler);
- this->m_image1Reader->read(color1, x, y, sampler);
- this->m_image2Reader->read(color2, x, y, sampler);
+ this->m_maskReader->readSampled(mask, x, y, sampler);
+ this->m_image1Reader->readSampled(color1, x, y, sampler);
+ this->m_image2Reader->readSampled(color2, x, y, sampler);
float fac = (1.0f - mask[0]) * (1.0f - color1[3]) + mask[0] * color2[3];
float mfac = 1.0f - fac;
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h
index eeeb29d330f..199120fa3be 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.h
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.h
@@ -47,11 +47,11 @@ public:
/**
* the inner loop of this program
*/
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ZCombineAlphaOperation : public ZCombineOperation {
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ZCombineMaskOperation : public NodeOperation {
@@ -64,10 +64,10 @@ public:
void initExecution();
void deinitExecution();
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ZCombineMaskAlphaOperation : public ZCombineMaskOperation {
- void executePixel(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 142342997be..75363f4f567 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -63,6 +63,7 @@
#include "BKE_curve.h"
#include "BKE_key.h"
+#include "BKE_nla.h"
#include "BKE_context.h"
#include "UI_interface.h"
@@ -341,7 +342,7 @@ static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
}
/* name property for ID block entries */
-static short acf_generic_idblock_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+static bool acf_generic_idblock_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
RNA_id_pointer_create(ale->id, ptr);
*prop = RNA_struct_name_property(ptr->type);
@@ -351,7 +352,7 @@ static short acf_generic_idblock_nameprop(bAnimListElem *ale, PointerRNA *ptr, P
/* name property for ID block entries which are just subheading "fillers" */
-static short acf_generic_idfill_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+static bool acf_generic_idfill_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
/* actual ID we're representing is stored in ale->data not ale->id, as id gives the owner */
RNA_id_pointer_create(ale->data, ptr);
@@ -364,19 +365,19 @@ static short acf_generic_idfill_nameprop(bAnimListElem *ale, PointerRNA *ptr, Pr
#if 0
/* channel type has no settings */
-static short acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+static bool acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
{
- return 0;
+ return false;
}
#endif
/* check if some setting exists for this object-based data-expander (datablock only) */
-static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
+static bool acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* expand is always supported */
case ACHANNEL_SETTING_EXPAND:
- return 1;
+ return true;
/* mute is only supported for NLA */
case ACHANNEL_SETTING_MUTE:
@@ -384,11 +385,11 @@ static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListEle
/* select is ok for most "ds*" channels (e.g. dsmat) */
case ACHANNEL_SETTING_SELECT:
- return 1;
+ return true;
/* other flags are never supported */
default:
- return 0;
+ return false;
}
}
@@ -437,23 +438,23 @@ static int acf_summary_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static short acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
/* only expanded is supported, as it is used for hiding all stuff which the summary covers */
return (setting == ACHANNEL_SETTING_EXPAND);
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
if (setting == ACHANNEL_SETTING_EXPAND) {
/* expanded */
- *neg = 1;
+ *neg = true;
return ADS_FLAG_SUMMARY_COLLAPSED;
}
else {
/* unsupported */
- *neg = 0;
+ *neg = false;
return 0;
}
}
@@ -508,7 +509,7 @@ static int acf_scene_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
+static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* muted only in NLA */
@@ -522,32 +523,32 @@ static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale
/* only select and expand supported otherwise */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return SCE_DS_SELECTED;
case ACHANNEL_SETTING_EXPAND: /* expanded */
- *neg = 1;
+ *neg = true;
return SCE_DS_COLLAPSED;
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
default: /* unsupported */
@@ -592,7 +593,7 @@ static bAnimChannelType ACF_SCENE =
NULL, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_scene_icon, /* icon */
acf_scene_setting_valid, /* has setting */
@@ -648,7 +649,7 @@ static void acf_object_name(bAnimListElem *ale, char *name)
}
/* check if some setting exists for this channel */
-static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
{
Base *base = (Base *)ale->data;
Object *ob = base->object;
@@ -665,18 +666,18 @@ static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int
/* only select and expand supported otherwise */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -690,7 +691,7 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
default: /* unsupported */
@@ -736,7 +737,7 @@ static bAnimChannelType ACF_OBJECT =
NULL, /* offset */
acf_object_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_object_icon, /* icon */
acf_object_setting_valid, /* has setting */
@@ -802,7 +803,7 @@ static void acf_group_name(bAnimListElem *ale, char *name)
}
/* name property for group entries */
-static short acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+static bool acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
RNA_pointer_create(ale->id, &RNA_ActionGroup, ale->data, ptr);
*prop = RNA_struct_name_property(ptr->type);
@@ -811,23 +812,28 @@ static short acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN
}
/* check if some setting exists for this channel */
-static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
+static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
{
/* for now, all settings are supported, though some are only conditionally */
switch (setting) {
+ /* unsupported */
+ case ACHANNEL_SETTING_SOLO: /* Only available in NLA Editor for tracks */
+ return false;
+
+ /* conditionally supported */
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
return (ac->spacetype == SPACE_IPO);
default: /* always supported */
- return 1;
+ return true;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg)
+static int acf_group_setting_flag(bAnimContext *ac, int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -848,7 +854,6 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg)
return AGRP_MUTED;
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to edtiability
return AGRP_PROTECTED;
case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
@@ -897,7 +902,7 @@ static void acf_fcurve_name(bAnimListElem *ale, char *name)
}
/* "name" property for fcurve entries */
-static short acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
FCurve *fcu = (FCurve *)ale->data;
@@ -918,36 +923,37 @@ static short acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyR
}
/* check if some setting exists for this channel */
-static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
{
FCurve *fcu = (FCurve *)ale->data;
switch (setting) {
/* unsupported */
+ case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */
case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */
- return 0;
+ return false;
/* conditionally available */
case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
if (fcu->bezt)
- return 1;
+ return true;
else
- return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
+ return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
return (ac->spacetype == SPACE_IPO);
/* always available */
default:
- return 1;
+ return true;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -957,7 +963,6 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short
return FCURVE_MUTED;
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to edtiability
return FCURVE_PROTECTED;
case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
@@ -1005,31 +1010,31 @@ static int acf_fillactd_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static short acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* only select and expand supported */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
case ACHANNEL_SETTING_EXPAND: /* expanded */
- *neg = 1;
+ *neg = true;
return ACT_COLLAPSED;
default: /* unsupported */
@@ -1072,7 +1077,7 @@ static bAnimChannelType ACF_FILLACTD =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idfill_name_prop, /* name prop */
acf_fillactd_icon, /* icon */
acf_fillactd_setting_valid, /* has setting */
@@ -1095,27 +1100,27 @@ static void acf_filldrivers_name(bAnimListElem *UNUSED(ale), char *name)
/* check if some setting exists for this channel */
// TODO: this could be made more generic
-static short acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* only expand supported */
case ACHANNEL_SETTING_EXPAND:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
- *neg = 1;
+ *neg = true;
return ADT_DRIVERS_COLLAPSED;
default: /* unsupported */
@@ -1169,10 +1174,10 @@ static int acf_dsmat_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1182,7 +1187,7 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1228,7 +1233,7 @@ static bAnimChannelType ACF_DSMAT =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dsmat_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1245,10 +1250,10 @@ static int acf_dslam_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1258,7 +1263,7 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1304,7 +1309,7 @@ static bAnimChannelType ACF_DSLAM =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dslam_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1328,10 +1333,10 @@ static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1341,7 +1346,7 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1387,7 +1392,7 @@ static bAnimChannelType ACF_DSTEX =
acf_dstex_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idfill_name_prop, /* name prop */
acf_dstex_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1404,10 +1409,10 @@ static int acf_dscam_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1417,7 +1422,7 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1463,7 +1468,7 @@ static bAnimChannelType ACF_DSCAM =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idfill_name_prop, /* name prop */
acf_dscam_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1490,10 +1495,10 @@ static int acf_dscur_icon(bAnimListElem *ale)
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1503,7 +1508,7 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1549,7 +1554,7 @@ static bAnimChannelType ACF_DSCUR =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dscur_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1566,10 +1571,10 @@ static int acf_dsskey_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1579,7 +1584,7 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1625,7 +1630,7 @@ static bAnimChannelType ACF_DSSKEY =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dsskey_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1642,10 +1647,10 @@ static int acf_dswor_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1655,7 +1660,7 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1701,7 +1706,7 @@ static bAnimChannelType ACF_DSWOR =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idfill_name_prop, /* name prop */
acf_dswor_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1718,10 +1723,10 @@ static int acf_dspart_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1731,7 +1736,7 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1777,7 +1782,7 @@ static bAnimChannelType ACF_DSPART =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dspart_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1794,10 +1799,10 @@ static int acf_dsmball_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1807,7 +1812,7 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1853,7 +1858,7 @@ static bAnimChannelType ACF_DSMBALL =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dsmball_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1870,10 +1875,10 @@ static int acf_dsarm_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1883,7 +1888,7 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -1929,7 +1934,7 @@ static bAnimChannelType ACF_DSARM =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dsarm_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -1957,10 +1962,10 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale)
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -1970,7 +1975,7 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2016,7 +2021,7 @@ static bAnimChannelType ACF_DSNTREE =
acf_dsntree_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dsntree_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -2033,10 +2038,10 @@ static int acf_dslinestyle_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -2046,7 +2051,7 @@ static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, s
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2092,7 +2097,7 @@ static bAnimChannelType ACF_DSLINESTYLE =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dslinestyle_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -2109,10 +2114,10 @@ static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -2122,7 +2127,7 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2168,7 +2173,7 @@ static bAnimChannelType ACF_DSMESH =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dsmesh_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -2185,10 +2190,10 @@ static int acf_dslat_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -2198,7 +2203,7 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2244,7 +2249,7 @@ static bAnimChannelType ACF_DSLAT =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dslat_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -2261,10 +2266,10 @@ static int acf_dsspk_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
@@ -2274,7 +2279,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
- *neg = 1;
+ *neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2320,7 +2325,7 @@ static bAnimChannelType ACF_DSSPK =
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idblock_nameprop, /* name prop */
+ acf_generic_idblock_name_prop, /* name prop */
acf_dsspk_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
@@ -2346,7 +2351,7 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name)
}
/* name property for ShapeKey entries */
-static short acf_shapekey_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+static bool acf_shapekey_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
KeyBlock *kb = (KeyBlock *)ale->data;
@@ -2358,29 +2363,29 @@ static short acf_shapekey_nameprop(bAnimListElem *ale, PointerRNA *ptr, Property
return (*prop != NULL);
}
- return 0;
+ return false;
}
/* check if some setting exists for this channel */
-static short acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted */
case ACHANNEL_SETTING_PROTECT: /* protected */
- return 1;
+ return true;
/* nothing else is supported */
default:
- return 0;
+ return false;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_MUTE: /* mute */
@@ -2427,7 +2432,7 @@ static bAnimChannelType ACF_SHAPEKEY =
acf_generic_basic_offset, /* offset */
acf_shapekey_name, /* name */
- acf_shapekey_nameprop, /* name prop */
+ acf_shapekey_name_prop, /* name prop */
NULL, /* icon */
acf_shapekey_setting_valid, /* has setting */
@@ -2451,24 +2456,24 @@ static int acf_gpd_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static short acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* only select and expand supported */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2502,7 +2507,7 @@ static bAnimChannelType ACF_GPD =
acf_generic_group_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idfill_name_prop, /* name prop */
acf_gpd_icon, /* icon */
acf_gpd_setting_valid, /* has setting */
@@ -2522,7 +2527,7 @@ static void acf_gpl_name(bAnimListElem *ale, char *name)
}
/* name property for grease pencil layer entries */
-static short acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+static bool acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
if (ale->data) {
RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, ptr);
@@ -2531,29 +2536,30 @@ static short acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA
return (*prop != NULL);
}
- return 0;
+ return false;
}
/* check if some setting exists for this channel */
-static short acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* unsupported */
case ACHANNEL_SETTING_EXPAND: /* gpencil layers are more like F-Curves than groups */
case ACHANNEL_SETTING_VISIBLE: /* graph editor only */
- return 0;
+ case ACHANNEL_SETTING_SOLO: /* nla editor only */
+ return false;
/* always available */
default:
- return 1;
+ return true;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2563,7 +2569,6 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne
return GP_LAYER_HIDE;
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to editability
return GP_LAYER_LOCKED;
default: /* unsupported */
@@ -2616,24 +2621,24 @@ static int acf_mask_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static short acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* only select and expand supported */
case ACHANNEL_SETTING_SELECT:
case ACHANNEL_SETTING_EXPAND:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2667,7 +2672,7 @@ static bAnimChannelType ACF_MASKDATA =
acf_generic_group_offset, /* offset */
acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idfill_name_prop, /* name prop */
acf_mask_icon, /* icon */
acf_mask_setting_valid, /* has setting */
@@ -2687,7 +2692,7 @@ static void acf_masklay_name(bAnimListElem *ale, char *name)
}
/* name property for grease pencil layer entries */
-static short acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+static bool acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
{
if (ale->data) {
RNA_pointer_create(ale->id, &RNA_MaskLayer, ale->data, ptr);
@@ -2696,39 +2701,36 @@ static short acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, Property
return (*prop != NULL);
}
- return 0;
+ return false;
}
/* check if some setting exists for this channel */
-static short acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
{
switch (setting) {
/* unsupported */
case ACHANNEL_SETTING_EXPAND: /* mask layers are more like F-Curves than groups */
case ACHANNEL_SETTING_VISIBLE: /* graph editor only */
- return 0;
+ case ACHANNEL_SETTING_SOLO: /* nla editor only */
+ return false;
/* always available */
default:
- return 1;
+ return true;
}
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
{
/* clear extra return data first */
- *neg = 0;
+ *neg = false;
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
return MASK_LAYERFLAG_SELECT;
-// case ACHANNEL_SETTING_MUTE: /* muted */
-// return GP_LAYER_HIDE;
-
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to editability
return MASK_LAYERFLAG_LOCKED;
default: /* unsupported */
@@ -2764,6 +2766,146 @@ static bAnimChannelType ACF_MASKLAYER =
acf_masklay_setting_ptr /* pointer for setting */
};
+/* NLA Track ----------------------------------------------- */
+
+/* get backdrop color for nla track channels */
+static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3])
+{
+ NlaTrack *nlt = (NlaTrack *)ale->data;
+ AnimData *adt = ale->adt;
+ bool nonSolo = false;
+
+ /* is track enabled for solo drawing? */
+ if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) {
+ if ((nlt->flag & NLATRACK_SOLO) == 0) {
+ /* tag for special non-solo handling */
+ nonSolo = true;
+ }
+ }
+
+ /* set color for nla track */
+ UI_GetThemeColorShade3fv(TH_HEADER, ((nonSolo == false) ? 20 : -20), r_color);
+}
+
+/* name for nla track entries */
+static void acf_nlatrack_name(bAnimListElem *ale, char *name)
+{
+ NlaTrack *nlt = (NlaTrack *)ale->data;
+
+ if (nlt && name)
+ BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE);
+}
+
+/* name property for nla track entries */
+static bool acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+{
+ if (ale->data) {
+ RNA_pointer_create(ale->id, &RNA_NlaTrack, ale->data, ptr);
+ *prop = RNA_struct_name_property(ptr->type);
+
+ return (*prop != NULL);
+ }
+
+ return false;
+}
+
+/* check if some setting exists for this channel */
+static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, int setting)
+{
+ NlaTrack *nlt = (NlaTrack *)ale->data;
+ AnimData *adt = ale->adt;
+
+ /* visibility of settings depends on various states... */
+ switch (setting) {
+ /* always supported */
+ case ACHANNEL_SETTING_SELECT:
+ case ACHANNEL_SETTING_SOLO:
+ return true;
+
+ /* conditionally supported... */
+ case ACHANNEL_SETTING_PROTECT:
+ case ACHANNEL_SETTING_MUTE:
+ /* if this track is active and we're tweaking it, don't draw these toggles */
+ if (((nlt->flag & NLATRACK_ACTIVE) && (nlt->flag & NLATRACK_DISABLED)) == 0) {
+ /* is track enabled for solo drawing? */
+ if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) {
+ if (nlt->flag & NLATRACK_SOLO) {
+ /* ok - we've got a solo track, and this is it */
+ return true;
+ }
+ else {
+ /* not ok - we've got a solo track, but this isn't it, so make it more obvious */
+ return false;
+ }
+ }
+
+
+ /* ok - no tracks are solo'd, and this isn't being tweaked */
+ return true;
+ }
+ else {
+ /* unsupported - this track is being tweaked */
+ return false;
+ }
+
+ /* unsupported */
+ default:
+ return false;
+ }
+}
+
+/* get the appropriate flag(s) for the setting when it is valid */
+static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+{
+ /* clear extra return data first */
+ *neg = false;
+
+ switch (setting) {
+ case ACHANNEL_SETTING_SELECT: /* selected */
+ return NLATRACK_SELECTED;
+
+ case ACHANNEL_SETTING_MUTE: /* muted */
+ return NLATRACK_MUTED;
+
+ case ACHANNEL_SETTING_PROTECT: /* protected */
+ return NLATRACK_PROTECTED;
+
+ case ACHANNEL_SETTING_SOLO: /* solo */
+ return NLATRACK_SOLO;
+
+ default: /* unsupported */
+ return 0;
+ }
+}
+
+/* get pointer to the setting */
+static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+{
+ NlaTrack *nlt = (NlaTrack *)ale->data;
+ return GET_ACF_FLAG_PTR(nlt->flag, type);
+}
+
+/* nla track type define */
+static bAnimChannelType ACF_NLATRACK =
+{
+ "NLA Track", /* type name */
+
+ acf_nlatrack_color, /* backdrop color */
+ acf_generic_channel_backdrop, /* backdrop */
+ acf_generic_indention_flexible, /* indent level */
+ acf_generic_group_offset, /* offset */ // XXX?
+
+ acf_nlatrack_name, /* name */
+ acf_nlatrack_name_prop, /* name prop */
+ NULL, /* icon */
+
+ acf_nlatrack_setting_valid, /* has setting */
+ acf_nlatrack_setting_flag, /* flag for setting */
+ acf_nlatrack_setting_ptr /* pointer for setting */
+};
+
+
+
/* *********************************************** */
/* Type Registration and General Access */
@@ -2822,9 +2964,9 @@ static void ANIM_init_channel_typeinfo_data(void)
animchannelTypeInfo[type++] = &ACF_MASKDATA; /* Mask Datablock */
animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */
- // TODO: these types still need to be implemented!!!
- // probably need a few extra flags for these special cases...
- animchannelTypeInfo[type++] = NULL; /* NLA Track */
+ animchannelTypeInfo[type++] = &ACF_NLATRACK; /* NLA Track */
+
+ // TODO: this channel type still hasn't been ported over yet, since it requires special attention
animchannelTypeInfo[type++] = NULL; /* NLA Action */
}
}
@@ -2888,7 +3030,8 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting
/* 1) check that the setting exists for the current context */
if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) {
/* 2) get pointer to check for flag in, and the flag to check for */
- short negflag, ptrsize;
+ short ptrsize;
+ bool negflag;
int flag;
void *ptr;
@@ -2963,7 +3106,8 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting,
/* 1) check that the setting exists for the current context */
if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) {
/* 2) get pointer to check for flag in, and the flag to check for */
- short negflag, ptrsize;
+ short ptrsize;
+ bool negflag;
int flag;
void *ptr;
@@ -3225,6 +3369,26 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
BLI_freelistN(&anim_data);
}
+/* callback for wrapping NLA Track "solo" toggle logic */
+static void achannel_nlatrack_solo_widget_cb(bContext *C, void *adt_poin, void *nlt_poin)
+{
+ AnimData *adt = adt_poin;
+ NlaTrack *nlt = nlt_poin;
+
+ /* Toggle 'solo' mode. There are several complications here which need explaining:
+ * - The method call is needed to perform a few additional validation operations
+ * to ensure that the mode is applied properly
+ * - BUT, since the button already toggles the value, we need to un-toggle it
+ * before the API call gets to it, otherwise it will end up clearing the result
+ * again!
+ */
+ nlt->flag ^= NLATRACK_SOLO;
+ BKE_nlatrack_solo_toggle(adt, nlt);
+
+ /* send notifiers */
+ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL);
+}
+
/* callback for rename widgets - clear rename-in-progress */
static void achannel_setting_rename_done_cb(bContext *C, void *ads_poin, void *UNUSED(arg2))
{
@@ -3325,7 +3489,8 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChannelType *acf,
uiBlock *block, int xpos, int ypos, int setting)
{
- short negflag, ptrsize /* , enabled */ /* UNUSED */, butType;
+ short ptrsize, butType;
+ bool negflag;
int flag, icon;
void *ptr;
const char *tooltip;
@@ -3343,7 +3508,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
icon = ICON_VISIBLE_IPO_OFF;
if (ale->type == ANIMTYPE_FCURVE)
- tooltip = TIP_("Channel is visible in Graph Editor for editing");
+ tooltip = TIP_("F-Curve is visible in Graph Editor for editing");
else
tooltip = TIP_("Channels are visible in Graph Editor for editing");
break;
@@ -3355,9 +3520,9 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
break;
case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */
- //icon = ((enabled) ? ICON_LAYER_ACTIVE : ICON_LAYER_USED);
- icon = ICON_LAYER_USED;
- tooltip = TIP_("NLA Track is the only one evaluated for the AnimData block it belongs to");
+ //icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON);
+ icon = ICON_SOLO_OFF;
+ tooltip = TIP_("NLA Track is the only one evaluated in this Animation Data block, with all others muted");
break;
/* --- */
@@ -3366,14 +3531,18 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
// TODO: what about when there's no protect needed?
//icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
- tooltip = TIP_("Editability of keyframes for this channel");
+
+ if (ale->datatype != ALE_NLASTRIP)
+ tooltip = TIP_("Editability of keyframes for this channel");
+ else
+ tooltip = TIP_("Editability of NLA Strips in this track");
break;
case ACHANNEL_SETTING_MUTE: /* muted speaker */
//icon = ((enabled) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
icon = ICON_MUTE_IPO_OFF;
- if (ale->type == ALE_FCURVE)
+ if (ale->type == ANIMTYPE_FCURVE)
tooltip = TIP_("Does F-Curve contribute to result");
else
tooltip = TIP_("Do channels contribute to result");
@@ -3420,6 +3589,11 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
uiButSetNFunc(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting));
break;
+ /* settings needing special attention */
+ case ACHANNEL_SETTING_SOLO: /* NLA Tracks - Solo toggle */
+ uiButSetFunc(but, achannel_nlatrack_solo_widget_cb, ale->adt, ale->data);
+ break;
+
/* no flushing */
case ACHANNEL_SETTING_EXPAND: /* expanding - cannot flush, otherwise all would open/close at once */
default:
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index e04c51b33d8..33ca10420ec 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -58,6 +58,7 @@
#include "UI_view2d.h"
#include "ED_anim_api.h"
+#include "ED_armature.h"
#include "ED_keyframes_edit.h" // XXX move the select modes out of there!
#include "ED_screen.h"
@@ -1106,7 +1107,6 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
break;
case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
-
default: /* some collection of actions */
if (adt->action)
rearrange_action_channels(&ac, adt->action, mode);
@@ -2441,6 +2441,35 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
{
bActionGroup *agrp = (bActionGroup *)ale->data;
+ Object *ob = NULL;
+ bPoseChannel *pchan = NULL;
+
+
+ /* Armatures-Specific Feature:
+ * Since groups are used to collect F-Curves of the same Bone by default
+ * (via Keying Sets) so that they can be managed better, we try to make
+ * things here easier for animators by mapping group selection to bone
+ * selection.
+ *
+ * Only do this if "Only Selected" dopesheet filter is not active, or else it
+ * becomes too unpredictable/tricky to manage
+ */
+ if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL) == 0) {
+ if ((ale->id) && (GS(ale->id->name) == ID_OB)) {
+ ob = (Object *)ale->id;
+
+ if (ob->type == OB_ARMATURE) {
+ /* Assume for now that any group with corresponding name is what we want
+ * (i.e. for an armature whose location is animated, things would break
+ * if the user were to add a bone named "Location").
+ *
+ * TODO: check the first F-Curve or so to be sure...
+ */
+ pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
+ }
+ }
+ }
+
/* select/deselect group */
if (selectmode == SELECT_INVERT) {
/* inverse selection status of this group only */
@@ -2452,6 +2481,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
/* deselect all other channels */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ if (pchan) ED_pose_deselectall(ob, 0);
/* only select channels in group and group itself */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
@@ -2461,14 +2491,20 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
else {
/* select group by itself */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ if (pchan) ED_pose_deselectall(ob, 0);
+
agrp->flag |= AGRP_SELECTED;
}
/* if group is selected now, make group the 'active' one in the visible list */
- if (agrp->flag & AGRP_SELECTED)
+ if (agrp->flag & AGRP_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
- else
+ if (pchan) ED_pose_bone_select(ob, pchan, true);
+ }
+ else {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
+ if (pchan) ED_pose_bone_select(ob, pchan, false);
+ }
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 9e8800fd91e..25fcd76b513 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -33,6 +33,7 @@
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "BLI_math.h"
@@ -359,9 +360,68 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, short restore, sh
/* *************************************************** */
/* UNITS CONVERSION MAPPING (required for drawing and editing keyframes) */
+/* Get flags used for normalization in ANIM_unit_mapping_get_factor. */
+short ANIM_get_normalization_flags(bAnimContext *ac)
+{
+ if (ac->sl->spacetype == SPACE_IPO) {
+ SpaceIpo *sipo = (SpaceIpo *) ac->sl;
+ bool use_normalization = (sipo->flag & SIPO_NORMALIZE) != 0;
+ bool freeze_normalization = (sipo->flag & SIPO_NORMALIZE_FREEZE) != 0;
+ return use_normalization
+ ? (ANIM_UNITCONV_NORMALIZE | (freeze_normalization ? ANIM_UNITCONV_NORMALIZE_FREEZE : 0))
+ : 0;
+ }
+
+ return 0;
+}
+
+static float normalzation_factor_get(FCurve *fcu, short flag)
+{
+ float factor = 1.0f;
+
+ if (flag & ANIM_UNITCONV_RESTORE) {
+ return 1.0f / fcu->prev_norm_factor;
+ }
+
+ if (flag & ANIM_UNITCONV_NORMALIZE_FREEZE) {
+ return fcu->prev_norm_factor;
+ }
+
+ if (G.moving & G_TRANSFORM_FCURVES) {
+ return fcu->prev_norm_factor;
+ }
+
+ fcu->prev_norm_factor = 1.0f;
+ if (fcu->bezt) {
+ BezTriple *bezt;
+ int i;
+ float max_coord = -FLT_MAX;
+
+ if (fcu->totvert < 1) {
+ return 1.0f;
+ }
+
+ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ max_coord = max_ff(max_coord, fabsf(bezt->vec[0][1]));
+ max_coord = max_ff(max_coord, fabsf(bezt->vec[1][1]));
+ max_coord = max_ff(max_coord, fabsf(bezt->vec[2][1]));
+ }
+
+ if (max_coord > FLT_EPSILON) {
+ factor = 1.0f / max_coord;
+ }
+ }
+ fcu->prev_norm_factor = factor;
+ return factor;
+}
+
/* Get unit conversion factor for given ID + F-Curve */
-float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short restore)
+float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag)
{
+ if (flag & ANIM_UNITCONV_NORMALIZE) {
+ return normalzation_factor_get(fcu, flag);
+ }
+
/* sanity checks */
if (id && fcu && fcu->rna_path) {
PointerRNA ptr, id_ptr;
@@ -374,7 +434,7 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest
if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) {
/* if the radians flag is not set, default to using degrees which need conversions */
if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) {
- if (restore)
+ if (flag & ANIM_UNITCONV_RESTORE)
return DEG2RADF(1.0f); /* degrees to radians */
else
return RAD2DEGF(1.0f); /* radians to degrees */
@@ -389,76 +449,4 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest
return 1.0f;
}
-/* ----------------------- */
-
-/* helper function for ANIM_unit_mapping_apply_fcurve -> mapping callback for unit mapping */
-static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt)
-{
- /* mapping factor is stored in f1, flags are stored in i1 */
- const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS) != 0;
- const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS) != 0;
- const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS) != 0;
- float fac = ked->f1;
-
- /* adjust BezTriple handles only if allowed to */
- if (only_keys == false) {
- if ((sel_vs == false) || (bezt->f1 & SELECT))
- bezt->vec[0][1] *= fac;
- if ((sel_vs == false) || (bezt->f3 & SELECT))
- bezt->vec[2][1] *= fac;
- }
-
- if (skip_knot == false) {
- if ((sel_vs == false) || (bezt->f2 & SELECT))
- bezt->vec[1][1] *= fac;
- }
-
- return 0;
-}
-
-/* Apply/Unapply units conversions to keyframes */
-void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short flag)
-{
- KeyframeEditData ked;
- KeyframeEditFunc sel_cb;
- float fac;
-
- /* abort if rendering - we may get some race condition issues... */
- if (G.is_rendering) return;
-
- /* calculate mapping factor, and abort if nothing to change */
- fac = ANIM_unit_mapping_get_factor(scene, id, fcu, (flag & ANIM_UNITCONV_RESTORE));
- if (fac == 1.0f)
- return;
-
- /* init edit data
- * - mapping factor is stored in f1
- * - flags are stored in 'i1'
- */
- memset(&ked, 0, sizeof(KeyframeEditData));
- ked.f1 = (float)fac;
- ked.i1 = (int)flag;
-
- /* only selected? */
- if (flag & ANIM_UNITCONV_ONLYSEL)
- sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
- else
- sel_cb = NULL;
-
- /* apply to F-Curve */
- ANIM_fcurve_keyframes_loop(&ked, fcu, sel_cb, bezt_unit_mapping_apply, NULL);
-
- // FIXME: loop here for samples should be generalised
- // TODO: only sel?
- if (fcu->fpt) {
- FPoint *fpt;
- unsigned int i;
-
- for (i = 0, fpt = fcu->fpt; i < fcu->totvert; i++, fpt++) {
- /* apply unit mapping */
- fpt->vec[1] *= fac;
- }
- }
-}
-
/* *************************************************** */
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 09b6e7d2206..ad745155286 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1503,8 +1503,7 @@ static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int
}
/* NOTE: owner_id is scene, material, or texture block, which is the direct owner of the node tree in question */
-// TODO: how to handle group nodes is still unclear...
-static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode)
+static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode)
{
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
@@ -1538,6 +1537,32 @@ static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data,
return items;
}
+static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode)
+{
+ bNode *node;
+ size_t items = 0;
+ int group_filter_mode = filter_mode & ~ADS_FILTER_ONLYSEL;
+
+ items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, ntree, filter_mode);
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_GROUP) {
+ if (node->id) {
+ int filterflag = ads->filterflag;
+ if ((filter_mode & ADS_FILTER_ONLYSEL) && (node->flag & NODE_SELECT) == 0) {
+ continue;
+ }
+ /* TODO(sergey): A bit creepy, but this flag is not used from threads anyway. */
+ ads->filterflag &= ~ADS_FILTER_ONLYSEL;
+ items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, (bNodeTree *) node->id, group_filter_mode);
+ ads->filterflag = filterflag;
+ }
+ }
+ }
+
+ return items;
+}
+
static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
{
SceneRenderLayer *srl;
@@ -2599,24 +2624,50 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo
/* firstly filter the data */
switch (datatype) {
+ /* Action-Editing Modes */
case ANIMCONT_ACTION: /* 'Action Editor' */
{
Object *obact = ac->obact;
SpaceAction *saction = (SpaceAction *)ac->sl;
bDopeSheet *ads = (saction) ? &saction->ads : NULL;
- /* the check for the DopeSheet summary is included here since the summary works here too */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
- items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact);
+ /* specially check for AnimData filter... [#36687] */
+ if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) {
+ /* all channels here are within the same AnimData block, hence this special case */
+ if (LIKELY(obact->adt)) {
+ ANIMCHANNEL_NEW_CHANNEL(obact->adt, ANIMTYPE_ANIMDATA, (ID *)obact);
+ }
+ }
+ else {
+ /* the check for the DopeSheet summary is included here since the summary works here too */
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact);
+ }
+
break;
}
case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */
{
- /* the check for the DopeSheet summary is included here since the summary works here too */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
- items = animdata_filter_shapekey(ac, anim_data, data, filter_mode);
+ Key *key = (Key *)data;
+
+ /* specially check for AnimData filter... [#36687] */
+ if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) {
+ /* all channels here are within the same AnimData block, hence this special case */
+ if (LIKELY(key->adt)) {
+ ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, (ID *)key);
+ }
+ }
+ else {
+ /* the check for the DopeSheet summary is included here since the summary works here too */
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ items = animdata_filter_shapekey(ac, anim_data, key, filter_mode);
+ }
+
break;
}
+
+
+ /* Modes for Specialty Data Types (i.e. not keyframes) */
case ANIMCONT_GPENCIL:
{
if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
@@ -2629,6 +2680,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo
items = animdata_filter_mask(anim_data, data, filter_mode);
break;
}
+
+
+ /* DopeSheet Based Modes */
case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */
{
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
@@ -2644,6 +2698,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo
items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
break;
}
+
+
+ /* Special/Internal Use */
case ANIMCONT_CHANNEL: /* animation channel */
{
bDopeSheet *ads = ac->ads;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 34246427b7e..cab072675b2 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -197,58 +197,23 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
{
TimeMarker *marker;
float min, max;
- int selcount = 0;
/* sanity check */
//printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
- if (markers == NULL) {
- *first = 0.0f;
- *last = 0.0f;
- return;
- }
-
- if (markers->first && markers->last) {
- TimeMarker *fm = markers->first;
- TimeMarker *lm = markers->last;
-
- min = (float)fm->frame;
- max = (float)lm->frame;
- }
- else {
+ if (ELEM3(NULL, markers, markers->first, markers->last)) {
*first = 0.0f;
*last = 0.0f;
return;
}
-
- /* count how many markers are usable - see later */
- if (sel) {
- for (marker = markers->first; marker; marker = marker->next) {
- if (marker->flag & SELECT)
- selcount++;
- }
- }
- else
- selcount = BLI_countlist(markers);
-
- /* if only selected are to be considered, only consider the selected ones
- * (optimization for not searching list)
- */
- if (selcount > 1) {
- for (marker = markers->first; marker; marker = marker->next) {
- if (sel) {
- if (marker->flag & SELECT) {
- if (marker->frame < min)
- min = (float)marker->frame;
- if (marker->frame > max)
- max = (float)marker->frame;
- }
- }
- else {
- if (marker->frame < min)
- min = (float)marker->frame;
- if (marker->frame > max)
- max = (float)marker->frame;
- }
+
+ min = FLT_MAX;
+ max = -FLT_MAX;
+ for (marker = markers->first; marker; marker = marker->next) {
+ if (!sel || (marker->flag & SELECT)) {
+ if (marker->frame < min)
+ min = (float)marker->frame;
+ if (marker->frame > max)
+ max = (float)marker->frame;
}
}
@@ -746,13 +711,11 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op)
}
/* only for modal */
-static int ed_marker_move_cancel(bContext *C, wmOperator *op)
+static void ed_marker_move_cancel(bContext *C, wmOperator *op)
{
RNA_int_set(op->ptr, "frames", 0);
ed_marker_move_apply(C, op);
ed_marker_move_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
@@ -769,7 +732,6 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
case ESCKEY:
ed_marker_move_cancel(C, op);
return OPERATOR_CANCELLED;
-
case RIGHTMOUSE:
/* press = user manually demands transform to be canceled */
if (event->val == KM_PRESS) {
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 15a75c57758..af9b58736ef 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -118,13 +118,21 @@ static int change_frame_exec(bContext *C, wmOperator *op)
static int frame_from_event(bContext *C, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
float viewx;
+ int frame;
/* convert from region coordinates to View2D 'tot' space */
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &viewx, NULL);
/* round result to nearest int (frames are ints!) */
- return (int)floor(viewx + 0.5f);
+ frame = (int)floor(viewx + 0.5f);
+
+ if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
+ CLAMP(frame, PSFRA, PEFRA);
+ }
+
+ return frame;
}
/* Modal Operator init */
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 826e204d981..bbfa981c0c7 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -76,7 +76,7 @@ void free_anim_drivers_copybuf(void);
*
* - add: 0 - don't add anything if not found,
* 1 - add new Driver FCurve (with keyframes for visual tweaking),
- * 2 - add new Driver FCurve (with generator, for script backwards compatability)
+ * 2 - add new Driver FCurve (with generator, for script backwards compatibility)
* -1 - add new Driver FCurve without driver stuff (for pasting)
*/
FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, short add)
@@ -125,7 +125,7 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
/* F-Modifier or Keyframes? */
// FIXME: replace these magic numbers with defines
if (add == 2) {
- /* Python API Backwards compatability hack:
+ /* Python API Backwards compatibility hack:
* Create FModifier so that old scripts won't break
* for now before 2.7 series -- (September 4, 2013)
*/
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 6b9200afb75..1028fb30ba4 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1100,7 +1100,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(reports, RPT_WARNING,
- "not deleting keyframe for locked F-Curve '%s' for %s '%s'",
+ "Not deleting keyframe for locked F-Curve '%s' for %s '%s'",
fcu->rna_path, BKE_idcode_to_name(GS(id->name)), id->name + 2);
continue;
}
@@ -1225,7 +1225,7 @@ static int modify_key_op_poll(bContext *C)
/* if Outliner, don't allow in some views */
if (so) {
- if (ELEM5(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP)) {
+ if (ELEM4(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF)) {
return 0;
}
}
@@ -1570,7 +1570,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(op->reports, RPT_WARNING,
- "not deleting keyframe for locked F-Curve '%s', object '%s'",
+ "Not deleting keyframe for locked F-Curve '%s', object '%s'",
fcu->rna_path, id->name + 2);
continue;
}
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index d480d41f5d6..b91deab6c8d 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -176,7 +176,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
newbone->flag |= BONE_CONNECTED;
}
- curs = give_cursor(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(newbone->tail, curs);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
@@ -216,7 +216,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv
ar = CTX_wm_region(C);
v3d = CTX_wm_view3d(C);
- fp = give_cursor(scene, v3d);
+ fp = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(oldcurs, fp);
@@ -624,7 +624,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name));
if (flipbone && forked) { // only set if mirror edit
- if (strlen(newbone->name) < 30) {
+ if (strlen(newbone->name) < (MAXBONENAME - 2)) {
if (a == 0) strcat(newbone->name, "_L");
else strcat(newbone->name, "_R");
}
@@ -691,7 +691,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
- copy_v3_v3(curs, give_cursor(CTX_data_scene(C), CTX_wm_view3d(C)));
+ copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C)));
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 90c1a439a19..1bc5bf0fd74 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -252,7 +252,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
float cursor_local[3];
- const float *cursor = give_cursor(scene, v3d);
+ const float *cursor = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(cursor_local, cursor);
@@ -484,7 +484,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* the number of joints determines how we fill:
* 1) between joint and cursor (joint=head, cursor=tail)
- * 2) between the two joints (order is dependent on active-bone/hierachy)
+ * 2) between the two joints (order is dependent on active-bone/hierarchy)
* 3+) error (a smarter method involving finding chains needs to be worked out
*/
count = BLI_countlist(&points);
@@ -502,7 +502,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* Get points - cursor (tail) */
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
+ mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));
/* Create a bone */
/* newbone = */ add_points_bone(obedit, ebp->vec, curs);
@@ -536,7 +536,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* get cursor location */
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
+ mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));
/* get distances */
sub_v3_v3v3(vecA, ebp->vec, curs);
@@ -583,8 +583,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
else
newbone->parent = ebp2->head_owner;
}
-
- newbone->flag |= BONE_CONNECTED;
+
+ /* don't set for bone connecting two head points of bones */
+ if (ebp->tail_owner || ebp2->tail_owner) {
+ newbone->flag |= BONE_CONNECTED;
+ }
}
}
else {
@@ -840,7 +843,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
armature_tag_select_mirrored(arm);
/* clear BONE_TRANSFORM flags
- * - used to prevent duplicate/cancelling operations from occurring [#34123]
+ * - used to prevent duplicate/canceling operations from occurring [#34123]
* - BONE_DONE cannot be used here as that's already used for mirroring
*/
armature_clear_swap_done_flags(arm);
@@ -1063,6 +1066,44 @@ void ARMATURE_OT_align(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/* ********************************* Split ******************************* */
+
+static int armature_split_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *ob = CTX_data_edit_object(C);
+ bArmature *arm = (bArmature *)ob->data;
+ EditBone *bone;
+
+ for (bone = arm->edbo->first; bone; bone = bone->next) {
+ if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)) {
+ bone->parent = NULL;
+ bone->flag &= ~BONE_CONNECTED;
+ }
+ }
+ for (bone = arm->edbo->first; bone; bone = bone->next) {
+ ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0);
+ }
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void ARMATURE_OT_split(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Split";
+ ot->idname = "ARMATURE_OT_split";
+ ot->description = "Split off selected bones from connected unselected bones";
+
+ /* api callbacks */
+ ot->exec = armature_split_exec;
+ ot->poll = ED_operator_editarmature;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/* ********************************* Delete ******************************* */
/* previously delete_armature */
@@ -1086,7 +1127,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
bPoseChannel *pchan, *pchan_next;
for (pchan = obedit->pose->chanbase.first; pchan; pchan = pchan_next) {
pchan_next = pchan->next;
- curBone = editbone_name_exists(arm->edbo, pchan->name);
+ curBone = ED_armature_bone_find_name(arm->edbo, pchan->name);
if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
BKE_pose_channel_free(pchan);
@@ -1105,7 +1146,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == obedit) {
if (ct->subtarget[0]) {
- curBone = editbone_name_exists(arm->edbo, ct->subtarget);
+ curBone = ED_armature_bone_find_name(arm->edbo, ct->subtarget);
if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
con->flag |= CONSTRAINT_DISABLE;
ct->subtarget[0] = 0;
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index e58d8fd2380..f3db9042879 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -62,12 +62,13 @@ void ARMATURE_OT_parent_set(struct wmOperatorType *ot);
void ARMATURE_OT_parent_clear(struct wmOperatorType *ot);
void ARMATURE_OT_select_all(struct wmOperatorType *ot);
-void ARMATURE_OT_select_inverse(struct wmOperatorType *ot);
+void ARMATURE_OT_select_mirror(struct wmOperatorType *ot);
void ARMATURE_OT_select_more(struct wmOperatorType *ot);
void ARMATURE_OT_select_less(struct wmOperatorType *ot);
void ARMATURE_OT_select_hierarchy(struct wmOperatorType *ot);
void ARMATURE_OT_select_linked(struct wmOperatorType *ot);
void ARMATURE_OT_select_similar(struct wmOperatorType *ot);
+void ARMATURE_OT_shortest_path_pick(struct wmOperatorType *ot);
void ARMATURE_OT_delete(struct wmOperatorType *ot);
void ARMATURE_OT_duplicate(struct wmOperatorType *ot);
@@ -78,6 +79,7 @@ void ARMATURE_OT_click_extrude(struct wmOperatorType *ot);
void ARMATURE_OT_fill(struct wmOperatorType *ot);
void ARMATURE_OT_merge(struct wmOperatorType *ot);
void ARMATURE_OT_separate(struct wmOperatorType *ot);
+void ARMATURE_OT_split(struct wmOperatorType *ot);
void ARMATURE_OT_autoside_names(struct wmOperatorType *ot);
void ARMATURE_OT_flip_names(struct wmOperatorType *ot);
@@ -109,7 +111,7 @@ void POSE_OT_select_hierarchy(struct wmOperatorType *ot);
void POSE_OT_select_linked(struct wmOperatorType *ot);
void POSE_OT_select_constraint_target(struct wmOperatorType *ot);
void POSE_OT_select_grouped(struct wmOperatorType *ot);
-void POSE_OT_select_flip_active(struct wmOperatorType *ot);
+void POSE_OT_select_mirror(struct wmOperatorType *ot);
void POSE_OT_group_add(struct wmOperatorType *ot);
void POSE_OT_group_remove(struct wmOperatorType *ot);
@@ -228,9 +230,6 @@ struct EditBone *duplicateEditBoneObjects(struct EditBone *curBone, const char *
/* editbones is the source list */
void updateDuplicateSubtargetObjects(struct EditBone *dupBone, struct ListBase *editbones, struct Object *src_ob, struct Object *dst_ob);
-
-EditBone *editbone_name_exists(struct ListBase *edbo, const char *name);
-
EditBone *add_points_bone(struct Object *obedit, float head[3], float tail[3]);
void bone_free(struct bArmature *arm, struct EditBone *bone);
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 8745d571a28..c574fc6a297 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -67,17 +67,11 @@
/* ************************************************** */
/* EditBone Names */
-/* checks if an EditBone with a matching name already, returning the matching bone if it exists */
-EditBone *editbone_name_exists(ListBase *edbo, const char *name)
-{
- return BLI_findstring(edbo, name, offsetof(EditBone, name));
-}
-
/* note: there's a unique_bone_name() too! */
static bool editbone_unique_check(void *arg, const char *name)
{
struct {ListBase *lb; void *bone; } *data = arg;
- EditBone *dupli = editbone_name_exists(data->lb, name);
+ EditBone *dupli = ED_armature_bone_find_name(data->lb, name);
return dupli && dupli != data->bone;
}
@@ -113,6 +107,7 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon);
ListBase targets = {NULL, NULL};
+ /* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(curcon, &targets);
@@ -126,6 +121,12 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(curcon, &targets, 0);
}
+
+ /* action constraints */
+ if (curcon->type == CONSTRAINT_TYPE_ACTION) {
+ bActionConstraint *actcon = (bActionConstraint *)curcon->data;
+ BKE_action_fix_paths_rename(&ob->id, actcon->act, "pose.bones", oldname, newname, 0, 0, 1);
+ }
}
}
@@ -148,7 +149,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
/* now check if we're in editmode, we need to find the unique name */
if (arm->edbo) {
- EditBone *eBone = editbone_name_exists(arm->edbo, oldname);
+ EditBone *eBone = ED_armature_bone_find_name(arm->edbo, oldname);
if (eBone) {
unique_editbone_name(arm->edbo, newname, NULL);
@@ -282,7 +283,6 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm;
- char newname[MAXBONENAME];
/* paranoia checks */
if (ELEM(NULL, ob, ob->pose))
@@ -292,8 +292,9 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
- flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions
- ED_armature_bone_rename(arm, ebone->name, newname);
+ char name_flip[MAXBONENAME];
+ BKE_deform_flip_side_name(name_flip, ebone->name, true);
+ ED_armature_bone_rename(arm, ebone->name, name_flip);
}
CTX_DATA_END;
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 0090522d1e1..feb9b0f939a 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -58,12 +58,13 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_parent_clear);
WM_operatortype_append(ARMATURE_OT_select_all);
- WM_operatortype_append(ARMATURE_OT_select_inverse);
+ WM_operatortype_append(ARMATURE_OT_select_mirror);
WM_operatortype_append(ARMATURE_OT_select_more);
WM_operatortype_append(ARMATURE_OT_select_less);
WM_operatortype_append(ARMATURE_OT_select_hierarchy);
WM_operatortype_append(ARMATURE_OT_select_linked);
WM_operatortype_append(ARMATURE_OT_select_similar);
+ WM_operatortype_append(ARMATURE_OT_shortest_path_pick);
WM_operatortype_append(ARMATURE_OT_delete);
WM_operatortype_append(ARMATURE_OT_duplicate);
@@ -74,6 +75,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_fill);
WM_operatortype_append(ARMATURE_OT_merge);
WM_operatortype_append(ARMATURE_OT_separate);
+ WM_operatortype_append(ARMATURE_OT_split);
WM_operatortype_append(ARMATURE_OT_autoside_names);
WM_operatortype_append(ARMATURE_OT_flip_names);
@@ -115,7 +117,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_select_linked);
WM_operatortype_append(POSE_OT_select_constraint_target);
WM_operatortype_append(POSE_OT_select_grouped);
- WM_operatortype_append(POSE_OT_select_flip_active);
+ WM_operatortype_append(POSE_OT_select_mirror);
WM_operatortype_append(POSE_OT_group_add);
WM_operatortype_append(POSE_OT_group_remove);
@@ -165,37 +167,31 @@ void ED_operatormacros_armature(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
-
+
ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate",
"Make copies of the selected bones within the same armature and move them",
OPTYPE_UNDO | OPTYPE_REGISTER);
- if (ot) {
- WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
- otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
- }
+ WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude",
"Create new bones from the selected joints and move them",
OPTYPE_UNDO | OPTYPE_REGISTER);
- if (ot) {
- otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
- RNA_boolean_set(otmacro->ptr, "forked", FALSE);
- otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
- }
-
+ otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
+ RNA_boolean_set(otmacro->ptr, "forked", FALSE);
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+
/* XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate?
* that would require fixing a properties bug 19733 */
ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked",
"Create new bones from the selected joints and move them",
OPTYPE_UNDO | OPTYPE_REGISTER);
- if (ot) {
- otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
- RNA_boolean_set(otmacro->ptr, "forked", TRUE);
- otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
- }
+ otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
+ RNA_boolean_set(otmacro->ptr, "forked", TRUE);
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
}
void ED_keymap_armature(wmKeyConfig *keyconf)
@@ -245,6 +241,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
+
+ kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", FALSE);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
@@ -266,6 +265,8 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
+
+ WM_keymap_add_item(keymap, "ARMATURE_OT_shortest_path_pick", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_delete", DELKEY, KM_PRESS, 0, 0);
@@ -275,6 +276,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_click_extrude", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "ARMATURE_OT_split", YKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
@@ -364,7 +366,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "POSE_OT_select_flip_active", FKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "POSE_OT_select_mirror", FKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 79d75c9fcda..cd24e94f9e9 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -230,7 +230,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
/* Copy bones and posechannels from the object to the edit armature */
for (pchan = opose->chanbase.first; pchan; pchan = pchann) {
pchann = pchan->next;
- curbone = editbone_name_exists(curarm->edbo, pchan->name);
+ curbone = ED_armature_bone_find_name(curarm->edbo, pchan->name);
/* Get new name */
unique_editbone_name(arm->edbo, curbone->name, NULL);
@@ -414,7 +414,7 @@ static void separate_armature_bones(Object *ob, short sel)
/* go through pose-channels, checking if a bone should be removed */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) {
pchann = pchan->next;
- curbone = editbone_name_exists(arm->edbo, pchan->name);
+ curbone = ED_armature_bone_find_name(arm->edbo, pchan->name);
/* check if bone needs to be removed */
if ( (sel && (curbone->flag & BONE_SELECTED)) ||
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index fe1d2fa3765..0bc6f1e037c 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -54,6 +54,10 @@
#include "armature_intern.h"
+/* utility macros fro storing a temp int in the bone (selection flag) */
+#define EBONE_PREV_FLAG_GET(ebone) ((void)0, (GET_INT_FROM_POINTER((ebone)->temp)))
+#define EBONE_PREV_FLAG_SET(ebone, val) ((ebone)->temp = SET_INT_IN_POINTER(val))
+
/* **************** PoseMode & EditMode Selection Buffer Queries *************************** */
/* only for opengl selection indices */
@@ -559,39 +563,6 @@ bool mouse_armature(bContext *C, const int mval[2], bool extend, bool deselect,
/* **************** Selections ******************/
-static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
-{
- /* Set the flags */
- CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
- {
- /* ignore bone if selection can't change */
- if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
- /* select bone */
- ebone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- }
- }
- CTX_DATA_END;
-
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-void ARMATURE_OT_select_inverse(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Select Inverse";
- ot->idname = "ARMATURE_OT_select_inverse";
- ot->description = "Flip the selection status of bones (selected -> unselected, unselected -> selected)";
-
- /* api callbacks */
- ot->exec = armature_select_inverse_exec;
- ot->poll = ED_operator_editarmature;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
-}
static int armature_de_select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
@@ -667,9 +638,6 @@ void ARMATURE_OT_select_all(wmOperatorType *ot)
/**************** Select more/less **************/
-#define EBONE_PREV_FLAG_GET(ebone) ((void)0, (GET_INT_FROM_POINTER(ebone->temp)))
-#define EBONE_PREV_FLAG_SET(ebone, val) (ebone->temp = SET_INT_IN_POINTER(val))
-
static void armature_select_more(bArmature *arm, EditBone *ebone)
{
if ((EBONE_PREV_FLAG_GET(ebone) & (BONE_ROOTSEL | BONE_TIPSEL)) != 0) {
@@ -753,9 +721,6 @@ static void armature_select_more_less(Object *ob, bool more)
ED_armature_sync_selection(arm->edbo);
}
-#undef EBONE_PREV_FLAG_GET
-#undef EBONE_PREV_FLAG_SET
-
static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit = CTX_data_edit_object(C);
@@ -1083,3 +1048,195 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
}
+/****************** Mirror Select ****************/
+
+/**
+ * \note clone of #pose_select_mirror_exec keep in sync
+ */
+static int armature_select_mirror_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = obedit->data;
+ EditBone *ebone, *ebone_mirror_act = NULL;
+ const bool active_only = RNA_boolean_get(op->ptr, "only_active");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ const int flag = ED_armature_ebone_selectflag_get(ebone);
+ EBONE_PREV_FLAG_SET(ebone, flag);
+ }
+
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_SELECTABLE(arm, ebone)) {
+ EditBone *ebone_mirror;
+ int flag_new = extend ? EBONE_PREV_FLAG_GET(ebone) : 0;
+
+ if ((ebone_mirror = ED_armature_bone_get_mirrored(arm->edbo, ebone)) &&
+ (EBONE_VISIBLE(arm, ebone_mirror)))
+ {
+ const int flag_mirror = EBONE_PREV_FLAG_GET(ebone_mirror);
+ flag_new |= flag_mirror;
+
+ if (ebone == arm->act_edbone) {
+ ebone_mirror_act = ebone_mirror;
+ }
+
+ /* skip all but the active or its mirror */
+ if (active_only && !ELEM(arm->act_edbone, ebone, ebone_mirror)) {
+ continue;
+ }
+ }
+
+ ED_armature_ebone_selectflag_set(ebone, flag_new);
+ }
+ }
+
+ if (ebone_mirror_act) {
+ arm->act_edbone = ebone_mirror_act;
+ }
+
+ ED_armature_sync_selection(arm->edbo);
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
+}
+
+void ARMATURE_OT_select_mirror(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Flip Active/Selected Bone";
+ ot->idname = "ARMATURE_OT_select_mirror";
+ ot->description = "Mirror the bone selection";
+
+ /* api callbacks */
+ ot->exec = armature_select_mirror_exec;
+ ot->poll = ED_operator_editarmature;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "only_active", false, "Active Only", "Only operate on the active bone");
+ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
+}
+
+
+/****************** Select Path ****************/
+
+static bool armature_shortest_path_select(bArmature *arm, EditBone *ebone_parent, EditBone *ebone_child,
+ bool use_parent, bool is_test)
+{
+ do {
+
+ if (!use_parent && (ebone_child == ebone_parent))
+ break;
+
+ if (is_test) {
+ if (!EBONE_SELECTABLE(arm, ebone_child)) {
+ return false;
+ }
+ }
+ else {
+ ED_armature_ebone_selectflag_set(ebone_child, (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL));
+ }
+
+ if (ebone_child == ebone_parent)
+ break;
+
+ ebone_child = ebone_child->parent;
+ } while (true);
+
+ return true;
+}
+
+static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = obedit->data;
+ EditBone *ebone_src, *ebone_dst;
+ EditBone *ebone_isect_parent = NULL;
+ EditBone *ebone_isect_child[2];
+ bool change;
+
+ view3d_operator_needs_opengl(C);
+
+ ebone_src = arm->act_edbone;
+ ebone_dst = get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
+
+ /* fallback to object selection */
+ if (ELEM(NULL, ebone_src, ebone_dst) || (ebone_src == ebone_dst)) {
+ return OPERATOR_PASS_THROUGH;
+ }
+
+ ebone_isect_child[0] = ebone_src;
+ ebone_isect_child[1] = ebone_dst;
+
+
+ /* ensure 'ebone_src' is the parent of 'ebone_dst', or set 'ebone_isect_parent' */
+ if (ED_armature_ebone_is_child_recursive(ebone_src, ebone_dst)) {
+ /* pass */
+ }
+ else if (ED_armature_ebone_is_child_recursive(ebone_dst, ebone_src)) {
+ SWAP(EditBone *, ebone_src, ebone_dst);
+ }
+ else if ((ebone_isect_parent = ED_armature_bone_find_shared_parent(ebone_isect_child, 2))) {
+ /* pass */
+ }
+ else {
+ /* disconnected bones */
+ return OPERATOR_CANCELLED;
+ }
+
+
+ if (ebone_isect_parent) {
+ if (armature_shortest_path_select(arm, ebone_isect_parent, ebone_src, false, true) &&
+ armature_shortest_path_select(arm, ebone_isect_parent, ebone_dst, false, true))
+ {
+ armature_shortest_path_select(arm, ebone_isect_parent, ebone_src, false, false);
+ armature_shortest_path_select(arm, ebone_isect_parent, ebone_dst, false, false);
+ change = true;
+ }
+ else {
+ /* unselectable */
+ change = false;
+ }
+ }
+ else {
+ if (armature_shortest_path_select(arm, ebone_src, ebone_dst, true, true)) {
+ armature_shortest_path_select(arm, ebone_src, ebone_dst, true, false);
+ change = true;
+ }
+ else {
+ /* unselectable */
+ change = false;
+ }
+ }
+
+ if (change) {
+ arm->act_edbone = ebone_dst;
+ ED_armature_sync_selection(arm->edbo);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BKE_report(op->reports, RPT_WARNING, "Unselectable bone in chain");
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void ARMATURE_OT_shortest_path_pick(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Pick Shortest Path";
+ ot->idname = "ARMATURE_OT_shortest_path_pick";
+ ot->description = "Select shortest path between two bones";
+
+ /* api callbacks */
+ ot->invoke = armature_shortest_path_pick_invoke;
+ ot->poll = ED_operator_editarmature;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 0301db4b4cf..5f15d15d478 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -346,11 +346,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
/* find flipped group */
if (dgroup && mirror) {
- char name[MAXBONENAME];
+ char name_flip[MAXBONENAME];
- // 0 = don't strip off number extensions
- flip_side_name(name, dgroup->name, FALSE);
- dgroupflip[j] = defgroup_find_name(ob, name);
+ BKE_deform_flip_side_name(name_flip, dgroup->name, false);
+ dgroupflip[j] = defgroup_find_name(ob, name_flip);
}
}
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 76cd12f12f8..7d6b3710a38 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -156,6 +156,47 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon
return false;
}
+/**
+ * Finds the first parent shared by \a ebone_child
+ *
+ * \param ebone_child Children bones to search
+ * \param ebone_child_tot Size of the ebone_child array
+ * \return The shared parent or NULL.
+ */
+EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot)
+{
+ unsigned int i;
+ EditBone *ebone_iter;
+
+#define EBONE_TEMP_UINT(ebone) (*((unsigned int *)(&((ebone)->temp))))
+
+ /* clear all */
+ for (i = 0; i < ebone_child_tot; i++) {
+ for (ebone_iter = ebone_child[i]; ebone_iter; ebone_iter = ebone_iter->parent) {
+ EBONE_TEMP_UINT(ebone_iter) = 0;
+ }
+ }
+
+ /* accumulate */
+ for (i = 0; i < ebone_child_tot; i++) {
+ ebone_iter = ebone_child[i];
+ for (ebone_iter = ebone_child[i]->parent; ebone_iter; ebone_iter = ebone_iter->parent) {
+ EBONE_TEMP_UINT(ebone_iter) += 1;
+ }
+ }
+
+ /* only need search the first chain */
+ for (ebone_iter = ebone_child[0]->parent; ebone_iter; ebone_iter = ebone_iter->parent) {
+ if (EBONE_TEMP_UINT(ebone_iter) == ebone_child_tot) {
+ return ebone_iter;
+ }
+ }
+
+#undef EBONE_TEMP_UINT
+
+ return NULL;
+}
+
void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3])
{
float delta[3];
@@ -175,28 +216,35 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4])
copy_v3_v3(mat[3], ebone->head);
}
+/**
+ * Return a pointer to the bone of the given name
+ */
+EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name)
+{
+ return BLI_findstring(edbo, name, offsetof(EditBone, name));
+}
+
+
/* *************************************************************** */
/* Mirroring */
-/* context: editmode armature */
-EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
+/**
+ * \see #BKE_pose_channel_get_mirrored (pose-mode, matching function)
+ */
+EditBone *ED_armature_bone_get_mirrored(const ListBase *edbo, EditBone *ebo)
{
- EditBone *eboflip = NULL;
- char name[MAXBONENAME];
-
+ char name_flip[MAXBONENAME];
+
if (ebo == NULL)
return NULL;
- flip_side_name(name, ebo->name, FALSE);
+ BKE_deform_flip_side_name(name_flip, ebo->name, false);
- for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) {
- if (ebo != eboflip) {
- if (!strcmp(name, eboflip->name))
- break;
- }
+ if (!STREQ(name_flip, ebo->name)) {
+ return ED_armature_bone_find_name(edbo, name_flip);
}
- return eboflip;
+ return NULL;
}
/* ------------------------------------- */
@@ -453,8 +501,9 @@ void ED_armature_from_edit(Object *obedit)
/* armature bones */
BKE_armature_bonelist_free(&arm->bonebase);
+ arm->act_bone = NULL;
- /* remove zero sized bones, this gives instable restposes */
+ /* remove zero sized bones, this gives unstable restposes */
for (eBone = arm->edbo->first; eBone; eBone = neBone) {
float len = len_v3v3(eBone->head, eBone->tail);
neBone = eBone->next;
@@ -586,7 +635,6 @@ void ED_armature_to_edit(Object *ob)
ED_armature_edit_free(ob);
arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone);
- arm->act_bone = NULL;
// BIF_freeTemplates(); /* force template update when entering editmode */
}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 8ae1b9557ee..36999c15665 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -2339,7 +2339,7 @@ static int sketch_convert(bContext *C, wmOperator *UNUSED(op), const wmEvent *UN
return OPERATOR_FINISHED;
}
-static int sketch_cancel(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+static int sketch_cancel_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
SK_Sketch *sketch = contextSketch(C, 0);
if (sketch != NULL) {
@@ -2374,12 +2374,11 @@ static int sketch_select(bContext *C, wmOperator *UNUSED(op), const wmEvent *eve
return OPERATOR_FINISHED;
}
-static int sketch_draw_stroke_cancel(bContext *C, wmOperator *op)
+static void sketch_draw_stroke_cancel(bContext *C, wmOperator *op)
{
SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
sk_cancelStroke(sketch);
MEM_freeN(op->customdata);
- return OPERATOR_CANCELLED;
}
static int sketch_draw_stroke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2400,12 +2399,11 @@ static int sketch_draw_stroke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int sketch_draw_gesture_cancel(bContext *C, wmOperator *op)
+static void sketch_draw_gesture_cancel(bContext *C, wmOperator *op)
{
SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
sk_cancelStroke(sketch);
MEM_freeN(op->customdata);
- return OPERATOR_CANCELLED;
}
static int sketch_draw_gesture(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2622,7 +2620,7 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot)
ot->description = "Cancel the current sketch stroke";
/* api callbacks */
- ot->invoke = sketch_cancel;
+ ot->invoke = sketch_cancel_invoke;
ot->poll = ED_operator_sketch_mode_active_stroke;
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 31ff1e161e8..d1c096e6cf5 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -577,9 +577,9 @@ static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
- char newname[MAXBONENAME];
- flip_side_name(newname, pchan->name, TRUE);
- ED_armature_bone_rename(arm, pchan->name, newname);
+ char name_flip[MAXBONENAME];
+ BKE_deform_flip_side_name(name_flip, pchan->name, true);
+ ED_armature_bone_rename(arm, pchan->name, name_flip);
}
CTX_DATA_END;
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 182f94b3693..69ee794e1d9 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -567,7 +567,7 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
if (fcu->bezt) {
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* check if remove */
- if (IS_EQ(bezt->vec[1][0], marker->frame)) {
+ if (IS_EQF(bezt->vec[1][0], (float)marker->frame)) {
delete_fcurve_key(fcu, i, 1);
break;
}
@@ -1532,10 +1532,9 @@ static int poselib_preview_exit(bContext *C, wmOperator *op)
}
/* Cancel previewing operation (called when exiting Blender) */
-static int poselib_preview_cancel(bContext *C, wmOperator *op)
+static void poselib_preview_cancel(bContext *C, wmOperator *op)
{
poselib_preview_exit(C, op);
- return OPERATOR_CANCELLED;
}
/* main modal status check */
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 9449b5a49bf..765437f3622 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -62,8 +62,51 @@
#include "armature_intern.h"
+/* utility macros fro storing a temp int in the bone (selection flag) */
+#define PBONE_PREV_FLAG_GET(pchan) ((void)0, (GET_INT_FROM_POINTER((pchan)->temp)))
+#define PBONE_PREV_FLAG_SET(pchan, val) ((pchan)->temp = SET_INT_IN_POINTER(val))
+
+
/* ***************** Pose Select Utilities ********************* */
+/* Utility method for changing the selection status of a bone */
+void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
+{
+ bArmature *arm;
+
+ /* sanity checks */
+ // XXX: actually, we can probably still get away with no object - at most we have no updates
+ if (ELEM4(NULL, ob, ob->pose, pchan, pchan->bone))
+ return;
+
+ arm = ob->data;
+
+ /* can only change selection state if bone can be modified */
+ if (PBONE_SELECTABLE(arm, pchan->bone)) {
+ /* change selection state - activate too if selected */
+ if (select) {
+ pchan->bone->flag |= BONE_SELECTED;
+ arm->act_bone = pchan->bone;
+ }
+ else {
+ pchan->bone->flag &= ~BONE_SELECTED;
+ arm->act_bone = NULL;
+ }
+
+ // TODO: select and activate corresponding vgroup?
+
+ /* tag necessary depsgraph updates
+ * (see rna_Bone_select_update() in rna_armature.c for details)
+ */
+ if (arm->flag & ARM_HAS_VIZ_DEPS) {
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+
+ /* send necessary notifiers */
+ WM_main_add_notifier(NC_GEOM | ND_DATA, ob);
+ }
+}
+
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits,
@@ -86,9 +129,16 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
* note, special exception for armature mode so we can do multi-select
* we could check for multi-select explicitly but think its fine to
* always give predictable behavior in weight paint mode - campbell */
- if ((!extend && !deselect && !toggle) ||
- ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0)))
- {
+ if ((ob_act == NULL) || ((ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0)) {
+ /* when we are entering into posemode via toggle-select,
+ * frop another active object - always select the bone. */
+ if (!extend && !deselect && toggle) {
+ /* re-select below */
+ nearBone->flag &= ~BONE_SELECTED;
+ }
+ }
+
+ if (!extend && !deselect && !toggle) {
ED_pose_deselectall(ob, 0);
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
arm->act_bone = nearBone;
@@ -799,55 +849,85 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
/* -------------------------------------- */
-/* context active object, or weightpainted object with armature in posemode */
-static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op))
+/**
+ * \note clone of #armature_select_mirror_exec keep in sync
+ */
+static int pose_select_mirror_exec(bContext *C, wmOperator *op)
{
Object *ob_act = CTX_data_active_object(C);
Object *ob = BKE_object_pose_armature_get(ob_act);
-
- if (ob && (ob->mode & OB_MODE_POSE)) {
- bArmature *arm = ob->data;
-
- if (arm->act_bone) {
- bPoseChannel *pchanf;
- char name[MAXBONENAME];
- flip_side_name(name, arm->act_bone->name, TRUE);
-
- pchanf = BKE_pose_channel_find_name(ob->pose, name);
- if (pchanf && pchanf->bone != arm->act_bone) {
- arm->act_bone->flag &= ~BONE_SELECTED;
- pchanf->bone->flag |= BONE_SELECTED;
-
- arm->act_bone = pchanf->bone;
-
- /* in weightpaint we select the associated vertex group too */
- if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
- ED_vgroup_select_by_name(ob_act, name);
- DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+ bArmature *arm;
+ bPoseChannel *pchan, *pchan_mirror_act = NULL;
+ const bool active_only = RNA_boolean_get(op->ptr, "only_active");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+
+ if ((ob && (ob->mode & OB_MODE_POSE)) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ arm = ob->data;
+
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ const int flag = (pchan->bone->flag & BONE_SELECTED);
+ PBONE_PREV_FLAG_SET(pchan, flag);
+ }
+
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (PBONE_SELECTABLE(arm, pchan->bone)) {
+ bPoseChannel *pchan_mirror;
+ int flag_new = extend ? PBONE_PREV_FLAG_GET(pchan) : 0;
+
+ if ((pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) &&
+ (PBONE_VISIBLE(arm, pchan_mirror->bone)))
+ {
+ const int flag_mirror = PBONE_PREV_FLAG_GET(pchan_mirror);
+ flag_new |= flag_mirror;
+
+ if (pchan->bone == arm->act_bone) {
+ pchan_mirror_act = pchan_mirror;
+ }
+
+ /* skip all but the active or its mirror */
+ if (active_only && !ELEM(arm->act_bone, pchan->bone, pchan_mirror->bone)) {
+ continue;
}
-
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
- return OPERATOR_FINISHED;
}
+
+ pchan->bone->flag = (pchan->bone->flag & ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) | flag_new;
}
}
-
- return OPERATOR_CANCELLED;
+
+ if (pchan_mirror_act) {
+ arm->act_bone = pchan_mirror_act->bone;
+
+ /* in weightpaint we select the associated vertex group too */
+ if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
+ ED_vgroup_select_by_name(ob_act, pchan_mirror_act->name);
+ DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+ }
+ }
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+
+ return OPERATOR_FINISHED;
}
-void POSE_OT_select_flip_active(wmOperatorType *ot)
+void POSE_OT_select_mirror(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Flip Selected Active Bone";
- ot->idname = "POSE_OT_select_flip_active";
- ot->description = "Activate the bone with a flipped name";
+ ot->name = "Flip Active/Selected Bone";
+ ot->idname = "POSE_OT_select_mirror";
+ ot->description = "Mirror the bone selection";
/* api callbacks */
- ot->exec = pose_bone_flip_active_exec;
+ ot->exec = pose_select_mirror_exec;
ot->poll = ED_operator_posemode;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "only_active", false, "Active Only", "Only operate on the active bone");
+ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
}
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index d0e1b15064a..82652702fe7 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -682,11 +682,10 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* common code for cancel() */
-static int pose_slide_cancel(bContext *UNUSED(C), wmOperator *op)
+static void pose_slide_cancel(bContext *UNUSED(C), wmOperator *op)
{
/* cleanup and done */
pose_slide_exit(op);
- return OPERATOR_CANCELLED;
}
/* common code for exec() methods */
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 79ca70a6189..578f048cb15 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -118,7 +118,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
pose = ob->pose;
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- curbone = editbone_name_exists(arm->edbo, pchan->name);
+ curbone = ED_armature_bone_find_name(arm->edbo, pchan->name);
/* simply copy the head/tail values from pchan over to curbone */
copy_v3_v3(curbone->head, pchan->pose_head);
@@ -302,7 +302,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, short se
/* get the name - if flipping, we must flip this first */
if (flip)
- flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */
+ BKE_deform_flip_side_name(name, chan->name, false);
else
BLI_strncpy(name, chan->name, sizeof(name));
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2dc32f711b4..f576440fe92 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -111,7 +111,7 @@ typedef enum eCurveElem_Types {
void selectend_nurb(Object *obedit, enum eEndPoint_Types selfirst, bool doswap, bool selstatus);
static void select_adjacent_cp(ListBase *editnurb, short next, const bool cont, const bool selstatus);
static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, const short flag, const bool split);
-static int curve_delete_selected(Object *obedit, const eCurveElem_Types type, const bool split);
+static int curve_delete_segments(Object *obedit, const bool split);
ListBase *object_editcurve_get(Object *ob)
{
@@ -1279,6 +1279,8 @@ void CU_deselect_all(Object *obedit)
if (editnurb) {
Nurb *nu;
int a;
+ ((Curve *)obedit->data)->lastsel = NULL;
+
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->bezt) {
BezTriple *bezt;
@@ -1373,16 +1375,15 @@ static int separate_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- Nurb *nu, *nu1;
Object *oldob, *newob;
Base *oldbase, *newbase;
Curve *oldcu, *newcu;
- EditNurb *oldedit, *newedit;
+ EditNurb *newedit;
+ ListBase newnurb = {NULL, NULL};
oldbase = CTX_data_active_base(C);
oldob = oldbase->object;
oldcu = oldob->data;
- oldedit = oldcu->editnurb;
if (oldcu->key) {
BKE_report(op->reports, RPT_ERROR, "Cannot separate a curve with vertex keys");
@@ -1390,44 +1391,43 @@ static int separate_exec(bContext *C, wmOperator *op)
}
WM_cursor_wait(1);
-
- /* 1. duplicate the object and data */
+
+ /* 1. duplicate geometry and check for valid selection for separate */
+ adduplicateflagNurb(oldob, &newnurb, SELECT, true);
+
+ if (newnurb.first == NULL) {
+ WM_cursor_wait(0);
+ BKE_report(op->reports, RPT_ERROR, "Cannot separate current selection");
+ return OPERATOR_CANCELLED;
+ }
+
+ /* 2. duplicate the object and data */
newbase = ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */
DAG_relations_tag_update(bmain);
- ED_base_object_select(newbase, BA_DESELECT);
newob = newbase->object;
-
newcu = newob->data = BKE_curve_copy(oldcu);
newcu->editnurb = NULL;
oldcu->id.us--; /* because new curve is a copy: reduce user count */
- /* 2. put new object in editmode and clear it */
+ /* 3. put new object in editmode, clear it and set separated nurbs */
make_editNurb(newob);
newedit = newcu->editnurb;
BKE_nurbList_free(&newedit->nurbs);
BKE_curve_editNurb_keyIndex_free(newedit);
newedit->keyindex = NULL;
+ BLI_movelisttolist(&newedit->nurbs, &newnurb);
- /* 3. move over parts from old object */
- for (nu = oldedit->nurbs.first; nu; nu = nu1) {
- nu1 = nu->next;
-
- if (isNurbsel(nu)) {
- keyIndex_delNurb(oldedit, nu);
- BLI_remlink(&oldedit->nurbs, nu);
- BLI_addtail(&newedit->nurbs, nu);
- }
- }
-
- /* 4. put old object out of editmode */
+ /* 4. put old object out of editmode and delete separated geometry */
load_editNurb(newob);
free_editNurb(newob);
+ curve_delete_segments(oldob, true);
DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
WM_event_add_notifier(C, NC_GEOM | ND_DATA, oldob->data);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob);
WM_cursor_wait(0);
@@ -1439,7 +1439,7 @@ void CURVE_OT_separate(wmOperatorType *ot)
/* identifiers */
ot->name = "Separate";
ot->idname = "CURVE_OT_separate";
- ot->description = "Separate (partly) selected curves or surfaces into a new object";
+ ot->description = "Separate selected points from connected unselected points into a new object";
/* api callbacks */
ot->exec = separate_exec;
@@ -1460,7 +1460,7 @@ static int curve_split_exec(bContext *C, wmOperator *op)
adduplicateflagNurb(obedit, &newnurb, SELECT, true);
if (newnurb.first != NULL) {
- curve_delete_selected(obedit, CURVE_SEGMENT, true);
+ curve_delete_segments(obedit, true);
BLI_movelisttolist(editnurb, &newnurb);
if (ED_curve_updateAnimPaths(obedit->data))
@@ -1486,7 +1486,7 @@ void CURVE_OT_split(wmOperatorType *ot)
/* api callbacks */
ot->exec = curve_split_exec;
- ot->poll = ED_operator_editcurve;
+ ot->poll = ED_operator_editsurfcurve;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1539,6 +1539,57 @@ static short isNurbselUV(Nurb *nu, int *u, int *v, int flag)
return 0;
}
+/* return true if U direction is selected and number of selected columns v */
+static bool isNurbselU(Nurb *nu, int *v, int flag)
+{
+ BPoint *bp;
+ int a, b, sel;
+
+ *v = 0;
+
+ for (b = 0, bp = nu->bp; b < nu->pntsv; b++) {
+ sel = 0;
+ for (a = 0; a < nu->pntsu; a++, bp++) {
+ if (bp->f1 & flag) sel++;
+ }
+ if (sel == nu->pntsu) {
+ (*v)++;
+ }
+ else if (sel >= 1) {
+ *v = 0;
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/* return true if V direction is selected and number of selected rows u */
+static bool isNurbselV(Nurb *nu, int *u, int flag)
+{
+ BPoint *bp;
+ int a, b, sel;
+
+ *u = 0;
+
+ for (a = 0; a < nu->pntsu; a++) {
+ bp = &nu->bp[a];
+ sel = 0;
+ for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) {
+ if (bp->f1 & flag) sel++;
+ }
+ if (sel == nu->pntsv) {
+ (*u)++;
+ }
+ else if (sel >= 1) {
+ *u = 0;
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
static void rotateflagNurb(ListBase *editnurb, short flag, const float cent[3], float rotmat[3][3])
{
/* all verts with (flag & 'flag') rotate */
@@ -1622,7 +1673,7 @@ static int deleteflagNurb(Object *obedit, short flag)
ListBase *editnurb = object_editcurve_get(obedit);
Nurb *nu, *next;
BPoint *bp, *bpn, *newbp;
- int a, b, newu, newv, sel;
+ int a, b, newu, newv;
if (obedit->type != OB_SURF) {
return OPERATOR_CANCELLED;
@@ -1653,62 +1704,36 @@ static int deleteflagNurb(Object *obedit, short flag)
BKE_nurb_free(nu); nu = NULL;
}
else {
- /* is nurb in U direction selected */
- newv = nu->pntsv;
- bp = nu->bp;
- for (b = 0; b < nu->pntsv; b++) {
- sel = 0;
- for (a = 0; a < nu->pntsu; a++, bp++) {
- if (bp->f1 & flag) sel++;
- }
- if (sel == nu->pntsu) {
- newv--;
- }
- else if (sel >= 1) {
- /* don't delete */
- break;
- }
- }
- if (newv != nu->pntsv && b == nu->pntsv) {
- /* delete */
- bp = nu->bp;
- bpn = newbp = (BPoint *)MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb");
- for (b = 0; b < nu->pntsv; b++) {
- if ((bp->f1 & flag) == 0) {
- memcpy(bpn, bp, nu->pntsu * sizeof(BPoint));
- keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu);
- bpn += nu->pntsu;
- }
- else {
- keyIndex_delBP(cu->editnurb, bp);
+ if (isNurbselU(nu, &newv, flag)) {
+ /* U direction selected */
+ newv = nu->pntsv - newv;
+ if (newv != nu->pntsv) {
+ /* delete */
+ bp = nu->bp;
+ bpn = newbp = (BPoint *)MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb");
+ for (b = 0; b < nu->pntsv; b++) {
+ if ((bp->f1 & flag) == 0) {
+ memcpy(bpn, bp, nu->pntsu * sizeof(BPoint));
+ keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu);
+ bpn += nu->pntsu;
+ }
+ else {
+ keyIndex_delBP(cu->editnurb, bp);
+ }
+ bp += nu->pntsu;
}
- bp += nu->pntsu;
- }
- nu->pntsv = newv;
- MEM_freeN(nu->bp);
- nu->bp = newbp;
- BKE_nurb_order_clamp_v(nu);
+ nu->pntsv = newv;
+ MEM_freeN(nu->bp);
+ nu->bp = newbp;
+ BKE_nurb_order_clamp_v(nu);
- BKE_nurb_knot_calc_v(nu);
- }
- else {
- /* is the nurb in V direction selected */
- newu = nu->pntsu;
- for (a = 0; a < nu->pntsu; a++) {
- bp = &nu->bp[a];
- sel = 0;
- for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) {
- if (bp->f1 & flag) sel++;
- }
- if (sel == nu->pntsv) {
- newu--;
- }
- else if (sel >= 1) {
- /* don't delete */
- break;
- }
+ BKE_nurb_knot_calc_v(nu);
}
- if (newu != nu->pntsu && a == nu->pntsu) {
+ }
+ else if (isNurbselV(nu, &newu, flag)) {
+ /* V direction selected */
+ newu = nu->pntsu - newu;
+ if (newu != nu->pntsu) {
/* delete */
bp = nu->bp;
bpn = newbp = (BPoint *)MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb");
@@ -1872,21 +1897,17 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
const short flag, const bool split)
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu, *newnu, *startnu;
+ Nurb *nu = editnurb->last, *newnu;
BezTriple *bezt, *bezt1;
- BPoint *bp, *bp1;
+ BPoint *bp, *bp1, *bp2, *bp3;
Curve *cu = (Curve *)obedit->data;
- int a, b, starta, enda, diffa, newu, newv;
+ int a, b, c, starta, enda, diffa, cyclicu, cyclicv, newu, newv;
char *usel;
- cu->lastsel = NULL;
-
- nu = editnurb->last;
while (nu) {
- startnu = NULL;
+ cyclicu = cyclicv = 0;
if (nu->type == CU_BEZIER) {
- bezt = nu->bezt;
- for (a = 0; a < nu->pntsu; a++) {
+ for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
enda = -1;
starta = a;
while ((bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag)) {
@@ -1897,46 +1918,44 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
bezt++;
}
if (enda >= starta) {
- diffa = enda - starta + 1;
-
- if (startnu != NULL && enda == nu->pntsu - 1) {
- /* end point of cyclic spline selected, so merge end points with start points */
- bezt1 = (BezTriple *)MEM_mallocN((startnu->pntsu + diffa) * sizeof(BezTriple), "adduplicateN");
- memcpy(bezt1, &nu->bezt[starta], diffa * sizeof(BezTriple));
- memcpy(&bezt1[diffa], startnu->bezt, startnu->pntsu * sizeof(BezTriple));
-
- MEM_freeN(startnu->bezt);
- startnu->bezt = bezt1;
- startnu->pntsu += diffa;
- newnu = startnu;
+ newu = diffa = enda - starta + 1; /* set newu and diffa, may use both */
+
+ if (starta == 0 && newu != nu->pntsu && (nu->flagu & CU_NURB_CYCLIC)) {
+ cyclicu = newu;
}
else {
- newnu = ED_curve_nurbcpy(nu, diffa);
+ if (enda == nu->pntsu - 1) newu += cyclicu;
+
+ newnu = BKE_nurb_copy(nu, newu, 1);
BLI_addtail(newnurb, newnu);
- set_actNurb(obedit, newnu);
- memcpy(newnu->bezt, &nu->bezt[starta], newnu->pntsu * sizeof(BezTriple));
- }
+ memcpy(newnu->bezt, &nu->bezt[starta], diffa * sizeof(BezTriple));
+ if (newu != diffa) {
+ memcpy(&newnu->bezt[diffa], nu->bezt, cyclicu * sizeof(BezTriple));
+ cyclicu = 0;
+ }
- b = newnu->pntsu;
- bezt1 = newnu->bezt;
- while (b--) {
- select_beztriple(bezt1, SELECT, flag, HIDDEN);
- bezt1++;
- }
+ if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
- if (nu->flagu & CU_NURB_CYCLIC) {
- if (starta != 0 || enda != nu->pntsu - 1) {
- newnu->flagu &= ~CU_NURB_CYCLIC;
- if (starta == 0) startnu = newnu;
+ for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
+ select_beztriple(bezt1, SELECT, flag, HIDDEN);
}
}
}
- bezt++;
+ }
+
+ if (cyclicu != 0) {
+ newnu = BKE_nurb_copy(nu, cyclicu, 1);
+ BLI_addtail(newnurb, newnu);
+ memcpy(newnu->bezt, nu->bezt, cyclicu * sizeof(BezTriple));
+ newnu->flagu &= ~CU_NURB_CYCLIC;
+
+ for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
+ select_beztriple(bezt1, SELECT, flag, HIDDEN);
+ }
}
}
else if (nu->pntsv == 1) { /* because UV Nurb has a different method for dupli */
- bp = nu->bp;
- for (a = 0; a < nu->pntsu; a++) {
+ for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) {
enda = -1;
starta = a;
while (bp->f1 & flag) {
@@ -1947,46 +1966,45 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
bp++;
}
if (enda >= starta) {
- diffa = enda - starta + 1;
-
- if (startnu != NULL && enda == nu->pntsu - 1) {
- /* end point of cyclic spline selected, so merge end points with start points */
- bp1 = (BPoint *)MEM_mallocN((startnu->pntsu + diffa) * sizeof(BPoint), "adduplicateN2");
- memcpy(bp1, &nu->bp[starta], diffa * sizeof(BPoint));
- memcpy(&bp1[diffa], startnu->bp, startnu->pntsu * sizeof(BPoint));
-
- MEM_freeN(startnu->bp);
- startnu->bp = bp1;
- startnu->pntsu += diffa;
- newnu = startnu;
+ newu = diffa = enda - starta + 1; /* set newu and diffa, may use both */
+
+ if (starta == 0 && newu != nu->pntsu && (nu->flagu & CU_NURB_CYCLIC)) {
+ cyclicu = newu;
}
else {
- newnu = ED_curve_nurbcpy(nu, diffa);
+ if (enda == nu->pntsu - 1) newu += cyclicu;
+
+ newnu = BKE_nurb_copy(nu, newu, 1);
BLI_addtail(newnurb, newnu);
- set_actNurb(obedit, newnu);
- memcpy(newnu->bp, &nu->bp[starta], newnu->pntsu * sizeof(BPoint));
- }
+ memcpy(newnu->bp, &nu->bp[starta], diffa * sizeof(BPoint));
+ if (newu != diffa) {
+ memcpy(&newnu->bp[diffa], nu->bp, cyclicu * sizeof(BPoint));
+ cyclicu = 0;
+ }
- b = newnu->pntsu;
- bp1 = newnu->bp;
- while (b--) {
- select_bpoint(bp1, SELECT, flag, HIDDEN);
- bp1++;
- }
+ if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
- if (nu->flagu & CU_NURB_CYCLIC) {
- if (starta != 0 || enda != nu->pntsu - 1) {
- newnu->flagu &= ~CU_NURB_CYCLIC;
- if (starta == 0) startnu = newnu;
+ for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
+ select_bpoint(bp1, SELECT, flag, HIDDEN);
}
}
}
- bp++;
+ }
+
+ if (cyclicu != 0) {
+ newnu = BKE_nurb_copy(nu, cyclicu, 1);
+ BLI_addtail(newnurb, newnu);
+ memcpy(newnu->bp, nu->bp, cyclicu * sizeof(BPoint));
+ newnu->flagu &= ~CU_NURB_CYCLIC;
+
+ for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
+ select_bpoint(bp1, SELECT, flag, HIDDEN);
+ }
}
}
else {
- /* a rectangular area in nurb has to be selected */
if (isNurbsel(nu)) {
+ /* a rectangular area in nurb has to be selected and if splitting must be in U or V direction */
usel = MEM_callocN(nu->pntsu, "adduplicateN3");
bp = nu->bp;
for (a = 0; a < nu->pntsv; a++) {
@@ -2008,78 +2026,131 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
}
}
}
- if (newu == 0 || newv == 0) {
+ MEM_freeN(usel);
+
+ if ((newu == 0 || newv == 0) ||
+ (split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT)))
+ {
if (G.debug & G_DEBUG)
printf("Can't duplicate Nurb\n");
}
else {
+ for (a = 0, bp1 = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp1++) {
+ newv = newu = 0;
+
+ if ((bp1->f1 & flag) && !(bp1->f1 & SURF_SEEN)) {
+ /* point selected, now loop over points in U and V directions */
+ for (b = a % nu->pntsu, bp2 = bp1; b < nu->pntsu; b++, bp2++) {
+ if (bp2->f1 & flag) {
+ newu++;
+ for (c = a / nu->pntsu, bp3 = bp2; c < nu->pntsv; c++, bp3 += nu->pntsu) {
+ if (bp3->f1 & flag) {
+ bp3->f1 |= SURF_SEEN; /* flag as seen so skipped on future iterations */
+ if (newu == 1) newv++;
+ }
+ else {
+ break;
+ }
+ }
+ }
+ else {
+ break;
+ }
+ }
+ }
- if (newu == 1) SWAP(int, newu, newv);
+ if ((newu + newv) > 2) {
+ /* ignore single points */
+ if (a == 0) {
+ /* check if need to save cyclic selection and continue if so */
+ if (newu == nu->pntsu && (nu->flagv & CU_NURB_CYCLIC)) cyclicv = newv;
+ if (newv == nu->pntsv && (nu->flagu & CU_NURB_CYCLIC)) cyclicu = newu;
+ if (cyclicu != 0 || cyclicv != 0) continue;
+ }
- newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN4");
- memcpy(newnu, nu, sizeof(Nurb));
- BLI_addtail(newnurb, newnu);
- set_actNurb(obedit, newnu);
- newnu->pntsu = newu;
- newnu->pntsv = newv;
- newnu->bp = (BPoint *)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN5");
- BKE_nurb_order_clamp_u(newnu);
- BKE_nurb_order_clamp_v(newnu);
-
- newnu->knotsu = newnu->knotsv = NULL;
-
- bp = newnu->bp;
- bp1 = nu->bp;
- for (a = 0; a < nu->pntsv; a++) {
- for (b = 0; b < nu->pntsu; b++, bp1++) {
- if (bp1->f1 & flag) {
- memcpy(bp, bp1, sizeof(BPoint));
- select_bpoint(bp1, DESELECT, flag, HIDDEN);
- bp++;
+ if (a + newu == nu->pntsu && cyclicu != 0) {
+ /* cyclic in U direction */
+ newnu = BKE_nurb_copy(nu, newu + cyclicu, newv);
+ for (b = 0; b < newv; b++) {
+ memcpy(&newnu->bp[b * newnu->pntsu], &nu->bp[b * nu->pntsu + a], newu * sizeof(BPoint));
+ memcpy(&newnu->bp[b * newnu->pntsu + newu], &nu->bp[b * nu->pntsu], cyclicu * sizeof(BPoint));
+ }
+ cyclicu = cyclicv = 0;
+ }
+ else if ((a / nu->pntsu) + newv == nu->pntsv && cyclicv != 0) {
+ /* cyclic in V direction */
+ newnu = BKE_nurb_copy(nu, newu, newv + cyclicv);
+ memcpy(newnu->bp, &nu->bp[a], newu * newv * sizeof(BPoint));
+ memcpy(&newnu->bp[newu * newv], nu->bp, newu * cyclicv * sizeof(BPoint));
+ cyclicu = cyclicv = 0;
}
+ else {
+ newnu = BKE_nurb_copy(nu, newu, newv);
+ for (b = 0; b < newv; b++) {
+ memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu + a], newu * sizeof(BPoint));
+ }
+ }
+ BLI_addtail(newnurb, newnu);
+
+ if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
+ if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC;
}
}
- if (BKE_nurb_check_valid_u(newnu)) {
- if (nu->pntsu == newnu->pntsu && nu->knotsu) {
- newnu->knotsu = MEM_dupallocN(nu->knotsu);
- }
- else {
- BKE_nurb_knot_calc_u(newnu);
+
+ if (cyclicu != 0 || cyclicv != 0) {
+ /* copy start of a cyclic surface, or copying all selected points */
+ newu = cyclicu == 0 ? nu->pntsu : cyclicu;
+ newv = cyclicv == 0 ? nu->pntsv : cyclicv;
+
+ newnu = BKE_nurb_copy(nu, newu, newv);
+ for (b = 0; b < newv; b++) {
+ memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu], newu * sizeof(BPoint));
}
+ BLI_addtail(newnurb, newnu);
+
+ if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
+ if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC;
}
- if (BKE_nurb_check_valid_v(newnu)) {
- if (nu->pntsv == newnu->pntsv && nu->knotsv) {
- newnu->knotsv = MEM_dupallocN(nu->knotsv);
- }
- else {
- BKE_nurb_knot_calc_v(newnu);
- }
+
+ for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
+ bp1->f1 &= ~SURF_SEEN;
+ if (!split) select_bpoint(bp1, DESELECT, flag, HIDDEN);
}
}
- MEM_freeN(usel);
}
}
-
nu = nu->prev;
}
-
- for (nu = newnurb->first; nu; nu = nu->next) {
- /* knots done after duplicate as pntsu may change */
- if (nu->pntsv == 1) {
- nu->knotsu = NULL;
- BKE_nurb_knot_calc_u(nu);
- }
- if (split) {
+ if (newnurb->first != NULL) {
+ cu->lastsel = NULL;
+ cu->actnu = -1;
+
+ for (nu = newnurb->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
- /* recalc first and last */
- BKE_nurb_handle_calc_simple(nu, &nu->bezt[0]);
- BKE_nurb_handle_calc_simple(nu, &nu->bezt[nu->pntsu - 1]);
+ if (split) {
+ /* recalc first and last */
+ BKE_nurb_handle_calc_simple(nu, &nu->bezt[0]);
+ BKE_nurb_handle_calc_simple(nu, &nu->bezt[nu->pntsu - 1]);
+ }
+ }
+ else {
+ /* knots done after duplicate as pntsu may change */
+ nu->knotsu = nu->knotsv = NULL;
+ BKE_nurb_order_clamp_u(nu);
+ BKE_nurb_knot_calc_u(nu);
+
+ if (obedit->type == OB_SURF) {
+ for (a = 0, bp = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp++) {
+ bp->f1 &= ~SURF_SEEN;
+ }
+
+ BKE_nurb_order_clamp_v(nu);
+ BKE_nurb_knot_calc_v(nu);
+ }
}
}
}
-
- /* actnu changed */
}
/**************** switch direction operator ***************/
@@ -4412,7 +4483,7 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
if (rv3d)
copy_v3_v3(axis, rv3d->viewinv[2]);
- RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
+ RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d));
RNA_float_set_array(op->ptr, "axis", axis);
return spin_exec(C, op);
@@ -4748,7 +4819,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
mul_v3_m4v3(location, vc.obedit->obmat, bp->vec);
}
else {
- copy_v3_v3(location, give_cursor(vc.scene, vc.v3d));
+ copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d));
}
ED_view3d_win_to_3d_int(vc.ar, location, event->mval, location);
@@ -5708,7 +5779,7 @@ void CURVE_OT_select_nth(wmOperatorType *ot)
/********************** add duplicate operator *********************/
-static int duplicate_exec(bContext *C, wmOperator *UNUSED(op))
+static int duplicate_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
ListBase newnurb = {NULL, NULL};
@@ -5719,6 +5790,10 @@ static int duplicate_exec(bContext *C, wmOperator *UNUSED(op))
BLI_movelisttolist(object_editcurve_get(obedit), &newnurb);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
+ else {
+ BKE_report(op->reports, RPT_ERROR, "Cannot duplicate current selection");
+ return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -5727,7 +5802,7 @@ void CURVE_OT_duplicate(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Duplicate Curve";
- ot->description = "Duplicate selected control points and segments between them";
+ ot->description = "Duplicate selected control points";
ot->idname = "CURVE_OT_duplicate";
/* api callbacks */
@@ -5740,178 +5815,296 @@ void CURVE_OT_duplicate(wmOperatorType *ot)
/********************** delete operator *********************/
-static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bool split)
+static int curve_delete_vertices(Object *obedit)
{
Curve *cu = obedit->data;
EditNurb *editnurb = cu->editnurb;
ListBase *nubase = &editnurb->nurbs;
- Nurb *nu, *nu1, *startnu;
- BezTriple *bezt, *bezt1, *bezt2;
- BPoint *bp, *bp1, *bp2;
- int a, b, starta, enda, cut = 0;
- int nuindex = 0;
- ListBase newnurb = {NULL, NULL};
+ Nurb *nu, *next;
+ BezTriple *bezt, *bezt1;
+ BPoint *bp, *bp1;
+ int a, type, nuindex = 0;
if (obedit->type == OB_SURF) {
- if (type == CURVE_VERTEX) {
- return deleteflagNurb(obedit, SELECT);
- }
- else {
- keyIndex_delNurbList(editnurb, nubase);
- BKE_nurbList_free(nubase);
-
- return OPERATOR_FINISHED;
- }
+ return deleteflagNurb(obedit, SELECT);
}
- if (type == CURVE_VERTEX) {
- /* first loop, can we remove entire pieces? */
- Nurb *next;
- nu = nubase->first;
- while (nu) {
- next = nu->next;
- if (nu->type == CU_BEZIER) {
- bezt = nu->bezt;
- a = nu->pntsu;
- if (a) {
- while (a) {
- if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
- /* pass */
- }
- else {
- break;
- }
- a--;
- bezt++;
+ /* first loop, can we remove entire pieces? */
+ nu = nubase->first;
+ while (nu) {
+ next = nu->next;
+ if (nu->type == CU_BEZIER) {
+ bezt = nu->bezt;
+ a = nu->pntsu;
+ if (a) {
+ while (a) {
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ /* pass */
}
- if (a == 0) {
- if (cu->actnu == nuindex)
- cu->actnu = -1;
-
- BLI_remlink(nubase, nu);
- keyIndex_delNurb(editnurb, nu);
- BKE_nurb_free(nu); nu = NULL;
+ else {
+ break;
}
+ a--;
+ bezt++;
+ }
+ if (a == 0) {
+ if (cu->actnu == nuindex)
+ cu->actnu = -1;
+
+ BLI_remlink(nubase, nu);
+ keyIndex_delNurb(editnurb, nu);
+ BKE_nurb_free(nu); nu = NULL;
}
}
- else {
- bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
- if (a) {
- while (a) {
- if (bp->f1 & SELECT) {
- /* pass */
- }
- else {
- break;
- }
- a--;
- bp++;
+ }
+ else {
+ bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
+ if (a) {
+ while (a) {
+ if (bp->f1 & SELECT) {
+ /* pass */
}
- if (a == 0) {
- if (cu->actnu == nuindex)
- cu->actnu = -1;
-
- BLI_remlink(nubase, nu);
- keyIndex_delNurb(editnurb, nu);
- BKE_nurb_free(nu); nu = NULL;
+ else {
+ break;
}
+ a--;
+ bp++;
+ }
+ if (a == 0) {
+ if (cu->actnu == nuindex)
+ cu->actnu = -1;
+
+ BLI_remlink(nubase, nu);
+ keyIndex_delNurb(editnurb, nu);
+ BKE_nurb_free(nu); nu = NULL;
}
}
-
- /* Never allow the order to exceed the number of points
- * - note, this is ok but changes unselected nurbs, disable for now */
+ }
+
+ /* Never allow the order to exceed the number of points
+ * - note, this is ok but changes unselected nurbs, disable for now */
#if 0
- if ((nu != NULL) && (nu->type == CU_NURBS)) {
- clamp_nurb_order_u(nu);
- }
+ if ((nu != NULL) && (nu->type == CU_NURBS)) {
+ clamp_nurb_order_u(nu);
+ }
#endif
- nu = next;
- nuindex++;
+ nu = next;
+ nuindex++;
+ }
+ /* 2nd loop, delete small pieces: just for curves */
+ nu = nubase->first;
+ while (nu) {
+ next = nu->next;
+ type = 0;
+ if (nu->type == CU_BEZIER) {
+ int delta = 0;
+ bezt = nu->bezt;
+ for (a = 0; a < nu->pntsu; a++) {
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ memmove(bezt, bezt + 1, (nu->pntsu - a - 1) * sizeof(BezTriple));
+ keyIndex_delBezt(editnurb, bezt + delta);
+ keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu - a - 1);
+ nu->pntsu--;
+ a--;
+ type = 1;
+ delta++;
+ }
+ else {
+ bezt++;
+ }
+ }
+ if (type) {
+ bezt1 = (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb");
+ memcpy(bezt1, nu->bezt, (nu->pntsu) * sizeof(BezTriple));
+ keyIndex_updateBezt(editnurb, nu->bezt, bezt1, nu->pntsu);
+ MEM_freeN(nu->bezt);
+ nu->bezt = bezt1;
+ BKE_nurb_handles_calc(nu);
+ }
}
- /* 2nd loop, delete small pieces: just for curves */
- nu = nubase->first;
- while (nu) {
- next = nu->next;
- type = 0;
- if (nu->type == CU_BEZIER) {
- int delta = 0;
- bezt = nu->bezt;
- for (a = 0; a < nu->pntsu; a++) {
- if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
- memmove(bezt, bezt + 1, (nu->pntsu - a - 1) * sizeof(BezTriple));
- keyIndex_delBezt(editnurb, bezt + delta);
- keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu - a - 1);
- nu->pntsu--;
- a--;
- type = 1;
- delta++;
- }
- else {
- bezt++;
- }
+ else if (nu->pntsv == 1) {
+ int delta = 0;
+ bp = nu->bp;
+
+ for (a = 0; a < nu->pntsu; a++) {
+ if (bp->f1 & SELECT) {
+ memmove(bp, bp + 1, (nu->pntsu - a - 1) * sizeof(BPoint));
+ keyIndex_delBP(editnurb, bp + delta);
+ keyIndex_updateBP(editnurb, bp + 1, bp, nu->pntsu - a - 1);
+ nu->pntsu--;
+ a--;
+ type = 1;
+ delta++;
}
- if (type) {
- bezt1 = (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb");
- memcpy(bezt1, nu->bezt, (nu->pntsu) * sizeof(BezTriple));
- keyIndex_updateBezt(editnurb, nu->bezt, bezt1, nu->pntsu);
- MEM_freeN(nu->bezt);
- nu->bezt = bezt1;
- BKE_nurb_handles_calc(nu);
+ else {
+ bp++;
}
}
- else if (nu->pntsv == 1) {
- int delta = 0;
- bp = nu->bp;
+ if (type) {
+ bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2");
+ memcpy(bp1, nu->bp, (nu->pntsu) * sizeof(BPoint));
+ keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu);
+ MEM_freeN(nu->bp);
+ nu->bp = bp1;
- for (a = 0; a < nu->pntsu; a++) {
- if (bp->f1 & SELECT) {
- memmove(bp, bp + 1, (nu->pntsu - a - 1) * sizeof(BPoint));
- keyIndex_delBP(editnurb, bp + delta);
- keyIndex_updateBP(editnurb, bp + 1, bp, nu->pntsu - a - 1);
- nu->pntsu--;
- a--;
- type = 1;
- delta++;
+ /* Never allow the order to exceed the number of points
+ * - note, this is ok but changes unselected nurbs, disable for now */
+#if 0
+ if (nu->type == CU_NURBS) {
+ clamp_nurb_order_u(nu);
+ }
+#endif
+ }
+ BKE_nurb_order_clamp_u(nu);
+ BKE_nurb_knot_calc_u(nu);
+ }
+ nu = next;
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+static int curve_delete_segments(Object *obedit, const bool split)
+{
+ Curve *cu = obedit->data;
+ EditNurb *editnurb = cu->editnurb;
+ ListBase *nubase = &editnurb->nurbs, newnurb = {NULL, NULL};
+ Nurb *nu, *nu1;
+ BezTriple *bezt, *bezt1, *bezt2;
+ BPoint *bp, *bp1, *bp2;
+ int a, b, starta, enda, cut, cyclicut;
+
+ for (nu = nubase->first; nu; nu = nu->next) {
+ nu1 = NULL;
+ starta = enda = cut = -1;
+ cyclicut = 0;
+
+ if (nu->type == CU_BEZIER) {
+ for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
+ if (!BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ enda = a;
+ if (starta == -1) starta = a;
+ if (a < nu->pntsu - 1) continue;
+ }
+ else if (a < nu->pntsu - 1 && !BEZSELECTED_HIDDENHANDLES(cu, bezt + 1)) {
+ /* if just single selected point then continue */
+ continue;
+ }
+
+ if (starta >= 0) {
+ /* got selected segment, now check where and copy */
+ if (starta <= 1 && a == nu->pntsu - 1) {
+ /* copying all points in spline */
+ if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC;
+
+ starta = 0;
+ enda = a;
+ cut = enda - starta + 1;
+ nu1 = BKE_nurb_copy(nu, cut, 1);
+ }
+ else if (starta == 0) {
+ /* if start of curve copy next end point */
+ enda++;
+ cut = enda - starta + 1;
+ bezt1 = &nu->bezt[nu->pntsu - 1];
+ bezt2 = &nu->bezt[nu->pntsu - 2];
+
+ if ((nu->flagu & CU_NURB_CYCLIC) &&
+ BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
+ BEZSELECTED_HIDDENHANDLES(cu, bezt2))
+ {
+ /* check if need to join start of spline to end */
+ nu1 = BKE_nurb_copy(nu, cut + 1, 1);
+ ED_curve_beztcpy(editnurb, &nu1->bezt[1], nu->bezt, cut);
+ starta = nu->pntsu - 1;
+ cut = 1;
+ }
+ else {
+ if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut;
+ else nu1 = BKE_nurb_copy(nu, cut, 1);
+ }
+ }
+ else if (enda == nu->pntsu - 1) {
+ /* if end of curve copy previous start point */
+ starta--;
+ cut = enda - starta + 1;
+ bezt1 = nu->bezt;
+ bezt2 = &nu->bezt[1];
+
+ if ((nu->flagu & CU_NURB_CYCLIC) &&
+ BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
+ BEZSELECTED_HIDDENHANDLES(cu, bezt2))
+ {
+ /* check if need to join start of spline to end */
+ nu1 = BKE_nurb_copy(nu, cut + 1, 1);
+ ED_curve_beztcpy(editnurb, &nu1->bezt[cut], nu->bezt, 1);
+ }
+ else if (cyclicut != 0) {
+ /* if cyclicut exists it is a cyclic spline, start and end should be connected */
+ nu1 = BKE_nurb_copy(nu, cut + cyclicut, 1);
+ ED_curve_beztcpy(editnurb, &nu1->bezt[cut], nu->bezt, cyclicut);
+ cyclicut = 0;
+ }
+ else {
+ nu1 = BKE_nurb_copy(nu, cut, 1);
+ }
}
else {
- bp++;
+ /* mid spline selection, copy adjacent start and end */
+ starta--;
+ enda++;
+ cut = enda - starta + 1;
+ nu1 = BKE_nurb_copy(nu, cut, 1);
}
- }
- if (type) {
- bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2");
- memcpy(bp1, nu->bp, (nu->pntsu) * sizeof(BPoint));
- keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu);
- MEM_freeN(nu->bp);
- nu->bp = bp1;
-
- /* Never allow the order to exceed the number of points
- * - note, this is ok but changes unselected nurbs, disable for now */
-#if 0
- if (nu->type == CU_NURBS) {
- clamp_nurb_order_u(nu);
+
+ if (nu1 != NULL) {
+ ED_curve_beztcpy(editnurb, nu1->bezt, &nu->bezt[starta], cut);
+ BLI_addtail(&newnurb, nu1);
+
+ if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
+ nu1 = NULL;
}
-#endif
+ starta = enda = -1;
+ }
+ }
+
+ if (!split && cut != -1 && nu->pntsu > 2 && !(nu->flagu & CU_NURB_CYCLIC)) {
+ /* start and points copied if connecting segment was deleted and not cylic spline */
+ bezt1 = nu->bezt;
+ bezt2 = &nu->bezt[1];
+
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
+ BEZSELECTED_HIDDENHANDLES(cu, bezt2))
+ {
+ nu1 = BKE_nurb_copy(nu, 1, 1);
+ ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1);
+ BLI_addtail(&newnurb, nu1);
+ }
+
+ bezt1 = &nu->bezt[nu->pntsu - 1];
+ bezt2 = &nu->bezt[nu->pntsu - 2];
+
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
+ BEZSELECTED_HIDDENHANDLES(cu, bezt2))
+ {
+ nu1 = BKE_nurb_copy(nu, 1, 1);
+ ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1);
+ BLI_addtail(&newnurb, nu1);
}
- BKE_nurb_order_clamp_u(nu);
- BKE_nurb_knot_calc_u(nu);
}
- nu = next;
}
- }
- else if (type == CURVE_SEGMENT) {
- for (nu = nubase->first; nu; nu = nu->next) {
- startnu = nu1 = NULL;
- starta = enda = cut = -1;
+ else if (nu->pntsv >= 1) {
+ int u, v;
- if (nu->type == CU_BEZIER) {
- for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
- if (!BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ if (isNurbselV(nu, &u, SELECT)) {
+ for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) {
+ if (!(bp->f1 & SELECT)) {
enda = a;
if (starta == -1) starta = a;
if (a < nu->pntsu - 1) continue;
}
- else if (a < nu->pntsu - 1 && !BEZSELECTED_HIDDENHANDLES(cu, bezt + 1)) {
+ else if (a < nu->pntsu - 1 && !((bp + 1)->f1 & SELECT)) {
/* if just single selected point then continue */
continue;
}
@@ -5925,69 +6118,52 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo
starta = 0;
enda = a;
cut = enda - starta + 1;
-
- nu1 = ED_curve_nurbcpy(nu, cut);
+ nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
}
else if (starta == 0) {
/* if start of curve copy next end point */
enda++;
cut = enda - starta + 1;
+ bp1 = &nu->bp[nu->pntsu - 1];
+ bp2 = &nu->bp[nu->pntsu - 2];
- bezt1 = &nu->bezt[nu->pntsu - 1];
- bezt2 = &nu->bezt[nu->pntsu - 2];
-
- if ((nu->flagu & CU_NURB_CYCLIC) &&
- BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
- BEZSELECTED_HIDDENHANDLES(cu, bezt2))
- {
+ if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
/* check if need to join start of spline to end */
- nu1 = ED_curve_nurbcpy(nu, cut + 1);
- ED_curve_beztcpy(editnurb, &nu1->bezt[1], nu->bezt, cut);
+ nu1 = BKE_nurb_copy(nu, cut + 1, nu->pntsv);
+ for (b = 0; b < nu->pntsv; b++) {
+ ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu + 1], &nu->bp[b * nu->pntsu], cut);
+ }
starta = nu->pntsu - 1;
cut = 1;
}
else {
- nu1 = ED_curve_nurbcpy(nu, cut);
-
- if (nu->flagu & CU_NURB_CYCLIC) startnu = nu1;
+ if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut;
+ else nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
}
}
else if (enda == nu->pntsu - 1) {
/* if end of curve copy previous start point */
starta--;
cut = enda - starta + 1;
+ bp1 = nu->bp;
+ bp2 = &nu->bp[1];
- bezt1 = nu->bezt;
- bezt2 = &nu->bezt[1];
-
- if ((nu->flagu & CU_NURB_CYCLIC) &&
- BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
- BEZSELECTED_HIDDENHANDLES(cu, bezt2))
- {
+ if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
/* check if need to join start of spline to end */
- nu1 = ED_curve_nurbcpy(nu, cut + 1);
- ED_curve_beztcpy(editnurb, &nu1->bezt[cut], nu->bezt, 1);
+ nu1 = BKE_nurb_copy(nu, cut + 1, nu->pntsv);
+ for (b = 0; b < nu->pntsv; b++) {
+ ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu + cut], &nu->bp[b * nu->pntsu], 1);
+ }
}
- else if (startnu != NULL) {
- /* if startnu exists it is a cyclic spline, start and end should be connected */
- bezt1 = (BezTriple *)MEM_mallocN((cut + startnu->pntsu) * sizeof(BezTriple), "delNurb3");
- ED_curve_beztcpy(editnurb, bezt1, &nu->bezt[starta], cut);
- ED_curve_beztcpy(editnurb, &bezt1[cut], nu->bezt, startnu->pntsu);
-
- MEM_freeN(startnu->bezt);
- startnu->bezt = bezt1;
- startnu->pntsu += cut;
-
- if (split) {
- for (b = 0; b < startnu->pntsu; b++, bezt1++) {
- select_beztriple(bezt1, DESELECT, SELECT, true);
- }
+ else if (cyclicut != 0) {
+ /* if cyclicut exists it is a cyclic spline, start and end should be connected */
+ nu1 = BKE_nurb_copy(nu, cut + cyclicut, nu->pntsv);
+ for (b = 0; b < nu->pntsv; b++) {
+ ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu + cut], &nu->bp[b * nu->pntsu], cyclicut);
}
-
- BKE_nurb_handles_calc(startnu);
}
else {
- nu1 = ED_curve_nurbcpy(nu, cut);
+ nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
}
}
else {
@@ -5995,24 +6171,16 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo
starta--;
enda++;
cut = enda - starta + 1;
-
- nu1 = ED_curve_nurbcpy(nu, cut);
+ nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
}
if (nu1 != NULL) {
- ED_curve_beztcpy(editnurb, nu1->bezt, &nu->bezt[starta], cut);
-
- if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
-
- if (split) {
- /* deselect for split operator */
- for (b = 0, bezt1 = nu1->bezt; b < nu1->pntsu; b++, bezt1++) {
- select_beztriple(bezt1, DESELECT, SELECT, true);
- }
+ for (b = 0; b < nu->pntsv; b++) {
+ ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu], &nu->bp[b * nu->pntsu + starta], cut);
}
-
BLI_addtail(&newnurb, nu1);
- BKE_nurb_handles_calc(nu1);
+
+ if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
nu1 = NULL;
}
starta = enda = -1;
@@ -6021,102 +6189,91 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo
if (!split && cut != -1 && nu->pntsu > 2 && !(nu->flagu & CU_NURB_CYCLIC)) {
/* start and points copied if connecting segment was deleted and not cylic spline */
- bezt1 = nu->bezt;
- bezt2 = &nu->bezt[1];
- if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && BEZSELECTED_HIDDENHANDLES(cu, bezt2)) {
- nu1 = ED_curve_nurbcpy(nu, 1);
- ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1);
+ bp1 = nu->bp;
+ bp2 = &nu->bp[1];
+
+ if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
+ nu1 = BKE_nurb_copy(nu, 1, nu->pntsv);
+ for (b = 0; b < nu->pntsv; b++) {
+ ED_curve_bpcpy(editnurb, &nu1->bp[b], &nu->bp[b * nu->pntsu], 1);
+ }
BLI_addtail(&newnurb, nu1);
}
- bezt1 = &nu->bezt[nu->pntsu - 1];
- bezt2 = &nu->bezt[nu->pntsu - 2];
- if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && BEZSELECTED_HIDDENHANDLES(cu, bezt2)) {
- nu1 = ED_curve_nurbcpy(nu, 1);
- ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1);
+ bp1 = &nu->bp[nu->pntsu - 1];
+ bp2 = &nu->bp[nu->pntsu - 2];
+
+ if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
+ nu1 = BKE_nurb_copy(nu, 1, nu->pntsv);
+ for (b = 0; b < nu->pntsv; b++) {
+ ED_curve_bpcpy(editnurb, &nu1->bp[b], &nu->bp[b * nu->pntsu + nu->pntsu - 1], 1);
+ }
BLI_addtail(&newnurb, nu1);
}
}
}
- else if (nu->pntsv == 1) {
- for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) {
+ else if (isNurbselU(nu, &v, SELECT)) {
+ for (a = 0, bp = nu->bp; a < nu->pntsv; a++, bp += nu->pntsu) {
if (!(bp->f1 & SELECT)) {
enda = a;
if (starta == -1) starta = a;
- if (a < nu->pntsu - 1) continue;
+ if (a < nu->pntsv - 1) continue;
}
- else if (a < nu->pntsu - 1 && !((bp + 1)->f1 & SELECT)) {
+ else if (a < nu->pntsv - 1 && !((bp + nu->pntsu)->f1 & SELECT)) {
/* if just single selected point then continue */
continue;
}
if (starta >= 0) {
/* got selected segment, now check where and copy */
- if (starta <= 1 && a == nu->pntsu - 1) {
+ if (starta <= 1 && a == nu->pntsv - 1) {
/* copying all points in spline */
- if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC;
+ if (starta == 1 && enda != a) nu->flagv &= ~CU_NURB_CYCLIC;
starta = 0;
enda = a;
cut = enda - starta + 1;
-
- nu1 = ED_curve_nurbcpy(nu, cut);
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
}
else if (starta == 0) {
/* if start of curve copy next end point */
enda++;
cut = enda - starta + 1;
+ bp1 = &nu->bp[nu->pntsv * nu->pntsu - nu->pntsu];
+ bp2 = &nu->bp[nu->pntsv * nu->pntsu - (nu->pntsu * 2)];
- bp1 = &nu->bp[nu->pntsu - 1];
- bp2 = &nu->bp[nu->pntsu - 2];
-
- if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
+ if ((nu->flagv & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
/* check if need to join start of spline to end */
- nu1 = ED_curve_nurbcpy(nu, cut + 1);
- ED_curve_bpcpy(editnurb, &nu1->bp[1], nu->bp, cut);
- starta = nu->pntsu - 1;
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, cut + 1);
+ ED_curve_bpcpy(editnurb, &nu1->bp[nu->pntsu], nu->bp, cut * nu->pntsu);
+ starta = nu->pntsv - 1;
cut = 1;
}
else {
- nu1 = ED_curve_nurbcpy(nu, cut);
-
- if (nu->flagu & CU_NURB_CYCLIC) startnu = nu1;
+ if (nu->flagv & CU_NURB_CYCLIC) cyclicut = cut;
+ else nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
}
}
- else if (enda == nu->pntsu - 1) {
+ else if (enda == nu->pntsv - 1) {
/* if end of curve copy previous start point */
starta--;
cut = enda - starta + 1;
-
bp1 = nu->bp;
- bp2 = &nu->bp[1];
+ bp2 = &nu->bp[nu->pntsu];
- if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
+ if ((nu->flagv & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
/* check if need to join start of spline to end */
- nu1 = ED_curve_nurbcpy(nu, cut + 1);
- ED_curve_bpcpy(editnurb, &nu1->bp[cut], nu->bp, 1);
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, cut + 1);
+ ED_curve_bpcpy(editnurb, &nu1->bp[cut * nu->pntsu], nu->bp, nu->pntsu);
}
- else if (startnu != NULL) {
- /* if startnu exists it is a cyclic spline, start and end should be connected */
- bp1 = (BPoint *)MEM_mallocN((cut + startnu->pntsu) * sizeof(BPoint), "delNurb4");
- ED_curve_bpcpy(editnurb, bp1, &nu->bp[starta], cut);
- ED_curve_bpcpy(editnurb, &bp1[cut], nu->bp, startnu->pntsu);
-
- MEM_freeN(startnu->bp);
- startnu->bp = bp1;
- startnu->pntsu += cut;
-
- if (split) {
- for (b = 0; b < startnu->pntsu; b++, bp1++) {
- select_bpoint(bp1, DESELECT, SELECT, HIDDEN);
- }
- }
-
- BKE_nurb_order_clamp_u(startnu);
- BKE_nurb_knot_calc_u(startnu);
+ else if (cyclicut != 0) {
+ /* if cyclicut exists it is a cyclic spline, start and end should be connected */
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, cut + cyclicut);
+ ED_curve_bpcpy(editnurb, &nu1->bp[cut * nu->pntsu], nu->bp, nu->pntsu * cyclicut);
+ cyclicut = 0;
}
else {
- nu1 = ED_curve_nurbcpy(nu, cut);
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
}
}
else {
@@ -6124,72 +6281,102 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo
starta--;
enda++;
cut = enda - starta + 1;
-
- nu1 = ED_curve_nurbcpy(nu, cut);
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
}
if (nu1 != NULL) {
- ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[starta], cut);
-
- if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
-
- if (split) {
- /* deselect for split operator */
- for (b = 0, bp1 = nu1->bp; b < nu1->pntsu; b++, bp1++) {
- select_bpoint(bp1, DESELECT, SELECT, HIDDEN);
- }
- }
-
+ ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[starta * nu->pntsu], cut * nu->pntsu);
BLI_addtail(&newnurb, nu1);
- nu1->knotsu = NULL;
- BKE_nurb_order_clamp_u(nu1);
- BKE_nurb_knot_calc_u(nu1);
+
+ if (starta != 0 || enda != nu->pntsv - 1) nu1->flagv &= ~CU_NURB_CYCLIC;
nu1 = NULL;
}
starta = enda = -1;
}
}
- if (!split && cut != -1 && nu->pntsu > 2 && !(nu->flagu & CU_NURB_CYCLIC)) {
+ if (!split && cut != -1 && nu->pntsv > 2 && !(nu->flagv & CU_NURB_CYCLIC)) {
/* start and points copied if connecting segment was deleted and not cylic spline */
bp1 = nu->bp;
- bp2 = &nu->bp[1];
+ bp2 = &nu->bp[nu->pntsu];
+
if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
- nu1 = ED_curve_nurbcpy(nu, 1);
- ED_curve_bpcpy(editnurb, nu1->bp, bp1, 1);
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, 1);
+ ED_curve_bpcpy(editnurb, nu1->bp, nu->bp, nu->pntsu);
BLI_addtail(&newnurb, nu1);
- nu1->knotsu = NULL;
}
- bp1 = &nu->bp[nu->pntsu - 1];
- bp2 = &nu->bp[nu->pntsu - 2];
+ bp1 = &nu->bp[nu->pntsu * nu->pntsv - nu->pntsu];
+ bp2 = &nu->bp[nu->pntsu * nu->pntsv - (nu->pntsu * 2)];
+
if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) {
- nu1 = ED_curve_nurbcpy(nu, 1);
- ED_curve_bpcpy(editnurb, nu1->bp, bp1, 1);
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, 1);
+ ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[nu->pntsu * nu->pntsv - nu->pntsu], nu->pntsu);
BLI_addtail(&newnurb, nu1);
- nu1->knotsu = NULL;
}
}
}
+ else {
+ /* selection not valid, just copy nurb to new list */
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, nu->pntsv);
+ ED_curve_bpcpy(editnurb, nu1->bp, nu->bp, nu->pntsu * nu->pntsv);
+ BLI_addtail(&newnurb, nu1);
+ }
}
-
- BKE_nurbList_free(nubase);
- BLI_movelisttolist(nubase, &newnurb);
}
- else {
- BLI_assert(0);
+
+ for (nu = newnurb.first; nu; nu = nu->next) {
+ if (nu->type == CU_BEZIER) {
+ if (split) {
+ /* deselect for split operator */
+ for (b = 0, bezt1 = nu->bezt; b < nu->pntsu; b++, bezt1++) {
+ select_beztriple(bezt1, DESELECT, SELECT, true);
+ }
+ }
+
+ BKE_nurb_handles_calc(nu);
+ }
+ else {
+ if (split) {
+ /* deselect for split operator */
+ for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
+ select_bpoint(bp1, DESELECT, SELECT, HIDDEN);
+ }
+ }
+
+ nu->knotsu = nu->knotsv = NULL;
+ BKE_nurb_order_clamp_u(nu);
+ BKE_nurb_knot_calc_u(nu);
+
+ if (nu->pntsv > 1) {
+ BKE_nurb_order_clamp_v(nu);
+ BKE_nurb_knot_calc_v(nu);
+ }
+ }
}
+ keyIndex_delNurbList(editnurb, nubase);
+ BKE_nurbList_free(nubase);
+ BLI_movelisttolist(nubase, &newnurb);
+
return OPERATOR_FINISHED;
}
static int curve_delete_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
+ Curve *cu = (Curve *)obedit->data;
eCurveElem_Types type = RNA_enum_get(op->ptr, "type");
- int retval = curve_delete_selected(obedit, type, false);
+ int retval;
+
+ if (type == CURVE_VERTEX) retval = curve_delete_vertices(obedit);
+ else if (type == CURVE_SEGMENT) retval = curve_delete_segments(obedit, false);
+ else BLI_assert(0);
if (retval == OPERATOR_FINISHED) {
+ cu->lastsel = NULL;
+ cu->actnu = -1;
+
if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -6210,23 +6397,14 @@ static EnumPropertyItem curve_delete_type_items[] = {
static EnumPropertyItem *rna_curve_delete_type_itemf(bContext *C, PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop), int *free)
{
- Object *obedit;
EnumPropertyItem *item = NULL;
int totitem = 0;
-
if (!C) /* needed for docs and i18n tools */
return curve_delete_type_items;
- obedit = CTX_data_edit_object(C);
- if (obedit->type == OB_SURF) {
- RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX);
- }
- else {
- RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX);
- RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_SEGMENT);
- }
-
+ RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX);
+ RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_SEGMENT);
RNA_enum_item_end(&item, &totitem);
*free = true;
@@ -6615,22 +6793,6 @@ void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count)
keyIndex_updateBP(editnurb, src, dst, count);
}
-Nurb *ED_curve_nurbcpy(Nurb *src, int count)
-{
- Nurb *newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "copyNurb");
- memcpy(newnu, src, sizeof(Nurb));
- newnu->pntsu = count;
-
- if (src->bezt) {
- newnu->bezt = (BezTriple *)MEM_mallocN(count * sizeof(BezTriple), "copyNurb2");
- }
- else {
- newnu->bp = (BPoint *)MEM_mallocN(count * sizeof(BPoint), "copyNurb3");
- }
-
- return newnu;
-}
-
int ED_curve_actSelection(Curve *cu, float center[3])
{
Nurb *nu = get_lastsel_nurb(cu);
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c
index 9b858a2c4e9..6804aa3584f 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -458,6 +458,8 @@ Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type
if (nu) { /* should always be set */
nu->flag |= CU_SMOOTH;
+ cu->actnu = BLI_countlist(editnurb);
+ cu->lastsel = NULL;
BKE_nurb_test2D(nu);
}
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index ac9c338e431..8f536575a28 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -1442,18 +1442,14 @@ void make_editText(Object *obedit)
ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo");
ef->copybuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditcopybuf");
ef->copybufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditcopybufinfo");
- ef->oldstr = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "oldstrbuf");
- ef->oldstrinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "oldstrbuf");
}
/* Convert the original text to wchar_t */
BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); /* length is bogus */
- wcscpy(ef->oldstr, ef->textbuf);
cu->len = wcslen(ef->textbuf);
memcpy(ef->textbufinfo, cu->strinfo, (cu->len) * sizeof(CharInfo));
- memcpy(ef->oldstrinfo, cu->strinfo, (cu->len) * sizeof(CharInfo));
if (cu->pos > cu->len) cu->pos = cu->len;
@@ -1471,11 +1467,6 @@ void load_editText(Object *obedit)
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
- MEM_freeN(ef->oldstr);
- ef->oldstr = NULL;
- MEM_freeN(ef->oldstrinfo);
- ef->oldstrinfo = NULL;
-
update_string(cu);
if (cu->strinfo)
@@ -1484,13 +1475,6 @@ void load_editText(Object *obedit)
memcpy(cu->strinfo, ef->textbufinfo, (cu->len) * sizeof(CharInfo));
cu->len = strlen(cu->str);
-
- /* this memory system is weak... */
-
- if (cu->selboxes) {
- MEM_freeN(cu->selboxes);
- cu->selboxes = NULL;
- }
}
void free_editText(Object *obedit)
@@ -1613,11 +1597,10 @@ static void font_ui_template_init(bContext *C, wmOperator *op)
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
}
-static int font_open_cancel(bContext *UNUSED(C), wmOperator *op)
+static void font_open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
- return OPERATOR_CANCELLED;
}
static int font_open_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index c5dc8654e9d..0298699fac5 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -454,7 +454,7 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin
copy_v3_v3(p3d, &pt->x);
}
else {
- const float *fp = give_cursor(scene, v3d);
+ const float *fp = ED_view3d_cursor3d_get(scene, v3d);
float mvalf[2];
/* get screen coordinate */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 255f0b7cfba..2cf8d9c27af 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -211,7 +211,7 @@ static int gpencil_project_check(tGPsdata *p)
static void gp_get_3d_reference(tGPsdata *p, float vec[3])
{
View3D *v3d = p->sa->spacedata.first;
- const float *fp = give_cursor(p->scene, v3d);
+ const float *fp = ED_view3d_cursor3d_get(p->scene, v3d);
/* the reference point used depends on the owner... */
#if 0 /* XXX: disabled for now, since we can't draw relative to the owner yet */
@@ -1456,11 +1456,10 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
op->customdata = NULL;
}
-static int gpencil_draw_cancel(bContext *C, wmOperator *op)
+static void gpencil_draw_cancel(bContext *C, wmOperator *op)
{
/* this is just a wrapper around exit() */
gpencil_draw_exit(C, op);
- return OPERATOR_CANCELLED;
}
/* ------------------------------- */
@@ -1875,7 +1874,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
//printf("\tGP - handle modal event...\n");
/* exit painting mode (and/or end current stroke)
- * NOTE: cannot do RIGHTMOUSE (as is standard for cancelling) as that would break polyline [#32647]
+ * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647]
*/
if (ELEM4(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY)) {
/* exit() ends the current stroke before cleaning up */
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 61f9cec15d9..8b9bb0a4ab0 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -396,15 +396,15 @@ typedef struct bAnimChannelType {
/* get name (for channel lists) */
void (*name)(bAnimListElem *ale, char *name);
/* get RNA property+pointer for editing the name */
- short (*name_prop)(bAnimListElem *ale, struct PointerRNA *ptr, struct PropertyRNA **prop);
+ bool (*name_prop)(bAnimListElem *ale, struct PointerRNA *ptr, struct PropertyRNA **prop);
/* get icon (for channel lists) */
int (*icon)(bAnimListElem *ale);
/* settings */
/* check if the given setting is valid in the current context */
- short (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting);
+ bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting);
/* get the flag used for this setting */
- int (*setting_flag)(bAnimContext *ac, int setting, short *neg);
+ int (*setting_flag)(bAnimContext *ac, int setting, bool *neg);
/* get the pointer to int/short where data is stored,
* with type being sizeof(ptr_data) which should be fine for runtime use...
* - assume that setting has been checked to be valid for current context
@@ -559,13 +559,19 @@ typedef enum eAnimUnitConv_Flags {
/* only touch selected vertices */
ANIM_UNITCONV_SELVERTS = (1 << 3),
ANIM_UNITCONV_SKIPKNOTS = (1 << 4),
+ /* Scale FCurve i a way it fits to -1..1 space */
+ ANIM_UNITCONV_NORMALIZE = (1 << 5),
+ /* Only whennormalization is used: use scale factor from previous run,
+ * prevents curves from jumping all over the place when tweaking them.
+ */
+ ANIM_UNITCONV_NORMALIZE_FREEZE = (1 << 6),
} eAnimUnitConv_Flags;
-/* Get unit conversion factor for given ID + F-Curve */
-float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FCurve *fcu, short restore);
+/* Normalizatin flags from Space Graph passing to ANIM_unit_mapping_get_factor */
+short ANIM_get_normalization_flags(bAnimContext *ac);
-/* Apply/Unapply units conversions to keyframes */
-void ANIM_unit_mapping_apply_fcurve(struct Scene *scene, struct ID *id, struct FCurve *fcu, short flag);
+/* Get unit conversion factor for given ID + F-Curve */
+float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FCurve *fcu, short flag);
/* ------------- Utility macros ----------------------- */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 225d8a0e5a3..e9caf89d9da 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -106,7 +106,7 @@ typedef struct EditBone {
(((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) \
)
-/* used in bone_select_hierachy() */
+/* used in armature_select_hierarchy_exec() */
#define BONE_SELECT_PARENT 0
#define BONE_SELECT_CHILD 1
@@ -128,7 +128,8 @@ bool mouse_armature(struct bContext *C, const int mval[2], bool extend, bool des
int join_armature_exec(struct bContext *C, struct wmOperator *op);
struct Bone *get_indexed_bone(struct Object *ob, int index);
float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only);
-EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, EditBone *ebo); // XXX this is needed for populating the context iterators
+EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name);
+EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo);
void ED_armature_sync_selection(struct ListBase *edbo);
void ED_armature_validate_active(struct bArmature *arm);
@@ -137,6 +138,7 @@ struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *na
void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
+EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot);
void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]);
void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);
@@ -168,6 +170,7 @@ void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag);
void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
void ED_pose_deselectall(struct Object *ob, int test);
+void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
struct Object *ED_pose_object_from_context(struct bContext *C);
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
index 1842b84a3f5..22aec69838b 100644
--- a/source/blender/editors/include/ED_mball.h
+++ b/source/blender/editors/include/ED_mball.h
@@ -37,6 +37,7 @@ struct Object;
struct wmKeyConfig;
void ED_operatortypes_metaball(void);
+void ED_operatormacros_metaball(void);
void ED_keymap_metaball(struct wmKeyConfig *keyconf);
struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], float dia, int type);
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 5d3d72d0e3d..9d3404aa29b 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -97,16 +97,6 @@ void EDBM_mesh_free(struct BMEditMesh *em);
void EDBM_mesh_load(struct Object *ob);
struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
-void EDBM_index_arrays_ensure(struct BMEditMesh *em, const char htype);
-void EDBM_index_arrays_init(struct BMEditMesh *em, const char htype);
-void EDBM_index_arrays_free(struct BMEditMesh *em);
-#ifndef NDEBUG
-bool EDBM_index_arrays_check(struct BMEditMesh *em);
-#endif
-struct BMVert *EDBM_vert_at_index(struct BMEditMesh *em, int index);
-struct BMEdge *EDBM_edge_at_index(struct BMEditMesh *em, int index);
-struct BMFace *EDBM_face_at_index(struct BMEditMesh *em, int index);
-
/* flushes based on the current select mode. if in vertex select mode,
* verts select/deselect edges and faces, if in edge select mode,
* edges select/deselect faces and vertices, and in face select mode faces select/deselect
@@ -129,16 +119,16 @@ void EDBM_mesh_reveal(struct BMEditMesh *em);
void EDBM_update_generic(struct BMEditMesh *em, const bool do_tessface, const bool is_destructive);
-struct UvElementMap *EDBM_uv_element_map_create(struct BMEditMesh *em, const bool selected, const bool do_islands);
-void EDBM_uv_element_map_free(struct UvElementMap *vmap);
-struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l);
+struct UvElementMap *BM_uv_element_map_create(struct BMesh *em, const bool selected, const bool do_islands);
+void BM_uv_element_map_free(struct UvElementMap *vmap);
+struct UvElement *BM_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l);
bool EDBM_mtexpoly_check(struct BMEditMesh *em);
struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh *em, struct BMFace **r_act_efa, const bool sloppy, const bool selected);
-void EDBM_uv_vert_map_free(struct UvVertMap *vmap);
-struct UvMapVert *EDBM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v);
-struct UvVertMap *EDBM_uv_vert_map_create(struct BMEditMesh *em, bool use_select, const float limit[2]);
+void BM_uv_vert_map_free(struct UvVertMap *vmap);
+struct UvMapVert *BM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v);
+struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm, bool use_select, const float limit[2]);
void EDBM_flag_enable_all(struct BMEditMesh *em, const char hflag);
void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag);
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index 2f16d84aed0..de83df9cc05 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -54,6 +54,8 @@ typedef enum {
NODE_RIGHT = 8
} NodeBorder;
+#define NODE_GRID_STEPS 5
+
/* space_node.c */
int ED_node_tree_path_length(struct SpaceNode *snode);
void ED_node_tree_path_get(struct SpaceNode *snode, char *value);
@@ -81,6 +83,7 @@ void ED_node_tree_update(const struct bContext *C);
void ED_node_tag_update_id(struct ID *id);
void ED_node_tag_update_nodetree(struct Main *bmain, struct bNodeTree *ntree);
void ED_node_sort(struct bNodeTree *ntree);
+float ED_node_grid_size(void);
/* node_relationships.c */
void ED_node_link_intersect_test(struct ScrArea *sa, int test);
diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h
index e7d80d96f89..f46332c9a82 100644
--- a/source/blender/editors/include/ED_numinput.h
+++ b/source/blender/editors/include/ED_numinput.h
@@ -27,7 +27,6 @@
#ifndef __ED_NUMINPUT_H__
#define __ED_NUMINPUT_H__
-
/*
* The ctrl value has different meaning:
* 0 : No value has been typed
@@ -59,11 +58,11 @@ typedef struct NumInput {
void initNumInput(NumInput *n);
#define NUM_STR_REP_LEN 20 /* str must be NUM_STR_LEN * (idx_max + 1) length. */
void outputNumInput(NumInput *n, char *str);
-short hasNumInput(NumInput *n);
+bool hasNumInput(const NumInput *n);
void applyNumInput(NumInput *n, float *vec);
-char handleNumInput(NumInput *n, const struct wmEvent *event);
+bool handleNumInput(NumInput *n, const struct wmEvent *event);
#define NUM_MODAL_INCREMENT_UP 18
#define NUM_MODAL_INCREMENT_DOWN 19
-#endif
+#endif /* __ED_NUMINPUT_H__ */
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index eae2141e527..4155dbb5565 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -51,6 +51,7 @@ struct Main;
struct Mesh;
struct MetaElem;
struct ModifierData;
+struct HookModifierData;
struct Nurb;
struct Object;
struct ReportList;
@@ -218,6 +219,8 @@ struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(
int *free,
const unsigned int selection_mask);
+void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h
index 518bee665ae..8f39502b2fe 100644
--- a/source/blender/editors/include/ED_render.h
+++ b/source/blender/editors/include/ED_render.h
@@ -55,6 +55,7 @@ void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated
void ED_render_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa);
void ED_viewport_render_kill_jobs(const struct bContext *C, bool free_database);
+struct Scene *ED_render_job_get_scene(const struct bContext *C);
/* render_preview.c */
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index a50a8a50eaa..e85f11e5b78 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -37,6 +37,8 @@ struct Object;
struct RegionView3D;
struct wmKeyConfig;
struct wmWindowManager;
+struct ViewContext;
+struct rcti;
/* sculpt.c */
void ED_operatortypes_sculpt(void);
@@ -48,6 +50,8 @@ void ED_sculpt_get_average_stroke(struct Object *ob, float stroke[3]);
int ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]);
int ED_sculpt_mask_layers_ensure(struct Object *ob,
struct MultiresModifierData *mmd);
+int do_sculpt_mask_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
+
enum {
ED_SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
ED_SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1)
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index eff79b6a039..dde1aa30a26 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -62,7 +62,7 @@ enum TfmMode {
TFM_SKIN_RESIZE,
TFM_TOSPHERE,
TFM_SHEAR,
- TFM_WARP,
+ TFM_BEND,
TFM_SHRINKFATTEN,
TFM_TILT,
TFM_TRACKBALL,
@@ -130,8 +130,6 @@ void ED_getTransformOrientationMatrix(const struct bContext *C, float orientatio
int BIF_countTransformOrientation(const struct bContext *C);
-void BIF_TransformSetUndo(const char *str);
-
/* to be able to add operator properties to other operators */
#define P_MIRROR (1 << 0)
diff --git a/source/blender/editors/include/ED_transverts.h b/source/blender/editors/include/ED_transverts.h
new file mode 100644
index 00000000000..a82e54e425b
--- /dev/null
+++ b/source/blender/editors/include/ED_transverts.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) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ED_transverts.h
+ * \ingroup editors
+ */
+
+#ifndef __ED_TRANSVERTS_H__
+#define __ED_TRANSVERTS_H__
+
+struct Object;
+
+typedef struct TransVert {
+ float *loc;
+ float oldloc[3], maploc[3];
+ float *val, oldval;
+ int flag;
+} TransVert;
+
+typedef struct TransVertStore {
+ struct TransVert *transverts;
+ int transverts_tot;
+} TransVertStore;
+
+void ED_transverts_create_from_obedit(TransVertStore *tvs, struct Object *obedit, int mode);
+void ED_transverts_update_obedit(TransVertStore *tvs, struct Object *obedit);
+void ED_transverts_free(TransVertStore *tvs);
+bool ED_transverts_check_obedit(Object *obedit);
+
+/* currently only used for bmesh index values */
+enum {
+ TM_INDEX_ON = 1, /* tag to make trans verts */
+ TM_INDEX_OFF = 0, /* don't make verts */
+ TM_INDEX_SKIP = -1 /* dont make verts (when the index values point to trans-verts) */
+};
+
+/* mode flags: */
+enum {
+ TM_ALL_JOINTS = 1, /* all joints (for bones only) */
+ TM_SKIP_HANDLES = 2 /* skip handles when control point is selected (for curves only) */
+};
+
+
+ /* SELECT == (1 << 0) */
+#define TX_VERT_USE_MAPLOC (1 << 1)
+
+#endif /* __ED_TRANSVERTS_H__ */
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 86abf29c308..0f3106794f5 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -82,8 +82,8 @@ typedef struct ViewDepths {
bool damaged;
} ViewDepths;
-float *give_cursor(struct Scene *scene, struct View3D *v3d);
-void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]);
+float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
+void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]);
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist);
void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist);
@@ -328,6 +328,8 @@ float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float
float ED_scene_grid_scale(struct Scene *scene, const char **grid_unit);
float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit);
+void ED_scene_draw_fps(struct Scene *scene, struct rcti *rect);
+
/* view matrix properties utilities */
/* unused */
#if 0
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 38aad640ee1..0c37d35a93b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -93,7 +93,7 @@ typedef struct uiLayout uiLayout;
/* use for clamping popups within the screen */
#define UI_SCREEN_MARGIN 10
-/* uiBlock->dt */
+/* uiBlock->dt and uiBut->dt */
#define UI_EMBOSS 0 /* use widget style for drawing */
#define UI_EMBOSSN 1 /* Nothing, only icon and/or text */
#define UI_EMBOSSP 2 /* Pulldown menu style */
@@ -130,8 +130,7 @@ typedef struct uiLayout uiLayout;
#define UI_BLOCK_POPUP_MEMORY (1 << 12)
#define UI_BLOCK_CLIP_EVENTS (1 << 13) /* stop handling mouse events */
-/* XXX This comment is no more valid! Maybe it is now bits 14-17? */
-/* block->flag bits 12-15 are identical to but->flag bits */
+/* block->flag bits 14-17 are identical to but->drawflag bits */
#define UI_BLOCK_LIST_ITEM (1 << 19)
@@ -148,46 +147,55 @@ typedef struct uiLayout uiLayout;
#define UI_PNL_CLOSE (1 << 5)
#define UI_PNL_SCALE (1 << 9)
-/* warning the first 6 flags are internal */
-/* but->flag */
-#define UI_TEXT_LEFT (1 << 6)
-#define UI_ICON_LEFT (1 << 7)
-#define UI_ICON_SUBMENU (1 << 8)
-#define UI_ICON_PREVIEW (1 << 9)
-
-#define UI_TEXT_RIGHT (1 << 10)
-#define UI_BUT_NODE_LINK (1 << 11)
-#define UI_BUT_NODE_ACTIVE (1 << 12)
-#define UI_BUT_DRAG_LOCK (1 << 13)
-
-/* button align flag, for drawing groups together */
-#define UI_BUT_ALIGN (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN)
-#define UI_BUT_ALIGN_TOP (1 << 14)
-#define UI_BUT_ALIGN_LEFT (1 << 15)
-#define UI_BUT_ALIGN_RIGHT (1 << 16)
-#define UI_BUT_ALIGN_DOWN (1 << 17)
-
-#define UI_BUT_DISABLED (1 << 18)
-#define UI_BUT_COLOR_LOCK (1 << 19)
-#define UI_BUT_ANIMATED (1 << 20)
-#define UI_BUT_ANIMATED_KEY (1 << 21)
-#define UI_BUT_DRIVEN (1 << 22)
-#define UI_BUT_REDALERT (1 << 23)
-#define UI_BUT_INACTIVE (1 << 24)
-#define UI_BUT_LAST_ACTIVE (1 << 25)
-#define UI_BUT_UNDO (1 << 26)
-#define UI_BUT_IMMEDIATE (1 << 27)
-#define UI_BUT_NO_TOOLTIP (1 << 28)
-#define UI_BUT_NO_UTF8 (1 << 29)
-
-#define UI_BUT_VEC_SIZE_LOCK (1 << 30) /* used to flag if color hsv-circle should keep luminance */
-#define UI_BUT_COLOR_CUBIC (1 << 31) /* cubic saturation for the color wheel */
+/* but->flag - general state flags. */
+enum {
+ /* warning, the first 6 flags are internal */
+ UI_ICON_SUBMENU = (1 << 6),
+ UI_ICON_PREVIEW = (1 << 7),
+
+ UI_BUT_NODE_LINK = (1 << 8),
+ UI_BUT_NODE_ACTIVE = (1 << 9),
+ UI_BUT_DRAG_LOCK = (1 << 10),
+ UI_BUT_DISABLED = (1 << 11),
+ UI_BUT_COLOR_LOCK = (1 << 12),
+ UI_BUT_ANIMATED = (1 << 13),
+ UI_BUT_ANIMATED_KEY = (1 << 14),
+ UI_BUT_DRIVEN = (1 << 15),
+ UI_BUT_REDALERT = (1 << 16),
+ UI_BUT_INACTIVE = (1 << 17),
+ UI_BUT_LAST_ACTIVE = (1 << 18),
+ UI_BUT_UNDO = (1 << 19),
+ UI_BUT_IMMEDIATE = (1 << 20),
+ UI_BUT_NO_UTF8 = (1 << 21),
+
+ UI_BUT_VEC_SIZE_LOCK = (1 << 22), /* used to flag if color hsv-circle should keep luminance */
+ UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */
+ UI_BUT_LIST_ITEM = (1 << 24), /* This but is "inside" a list item (currently used to change theme colors). */
+};
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
-/* uiBut->drawflag */
-#define UI_BUT_DRAW_ENUM_ARROWS (1 << 0) /* draw enum-like up/down arrows for button */
+/* but->drawflag - these flags should only affect how the button is drawn. */
+/* Note: currently, these flags _are not passed_ to the widget's state() or draw() functions
+ * (except for the 'align' ones)!
+ */
+enum {
+ /* draw enum-like up/down arrows for button */
+ UI_BUT_DRAW_ENUM_ARROWS = (1 << 0),
+ /* Text and icon alignment (by default, they are centered). */
+ UI_BUT_TEXT_LEFT = (1 << 1),
+ UI_BUT_ICON_LEFT = (1 << 2),
+ UI_BUT_TEXT_RIGHT = (1 << 3),
+ /* Prevent the button to show any tooltip. */
+ UI_BUT_NO_TOOLTIP = (1 << 4),
+ /* button align flag, for drawing groups together (also used in uiBlock->flag!) */
+ UI_BUT_ALIGN_TOP = (1 << 14),
+ UI_BUT_ALIGN_LEFT = (1 << 15),
+ UI_BUT_ALIGN_RIGHT = (1 << 16),
+ UI_BUT_ALIGN_DOWN = (1 << 17),
+ UI_BUT_ALIGN = (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN),
+};
/* scale fixed button widths by this to account for DPI */
@@ -259,7 +267,6 @@ typedef enum {
PROGRESSBAR = (51 << 9),
SEARCH_MENU_UNLINK = (52 << 9),
NODESOCKET = (53 << 9),
- LISTLABEL = (54 << 9),
} eButType;
#define BUTTYPE (63 << 9)
@@ -641,9 +648,13 @@ void uiButSetFocusOnEnter(struct wmWindow *win, uiBut *but);
typedef struct AutoComplete AutoComplete;
+#define AUTOCOMPLETE_NO_MATCH 0
+#define AUTOCOMPLETE_FULL_MATCH 1
+#define AUTOCOMPLETE_PARTIAL_MATCH 2
+
AutoComplete *autocomplete_begin(const char *startname, size_t maxlen);
void autocomplete_do_name(AutoComplete *autocpl, const char *name);
-bool autocomplete_end(AutoComplete *autocpl, char *autoname);
+int autocomplete_end(AutoComplete *autocpl, char *autoname);
/* Panels
*
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 3bad2577409..3f48446f029 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -78,8 +78,8 @@
#include "interface_intern.h"
-#define PRECISION_FLOAT_MAX 6
-#define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */
+#define PRECISION_FLOAT_MAX 7
+#define PRECISION_FLOAT_MAX_POW 10000000 /* pow(10, PRECISION_FLOAT_MAX) */
/* avoid unneeded calls to ui_get_but_val */
#define UI_BUT_VALUE_UNSET DBL_MAX
@@ -443,7 +443,7 @@ void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int max
static int ui_but_float_precision(uiBut *but, double value)
{
int prec;
- const double pow10_neg[PRECISION_FLOAT_MAX + 1] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001};
+ const double pow10_neg[PRECISION_FLOAT_MAX + 1] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001};
/* first check if prec is 0 and fallback to a simple default */
if ((prec = (int)but->a2) == -1) {
@@ -613,6 +613,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
{
/* flags from the buttons we want to refresh, may want to add more here... */
const int flag_copy = UI_BUT_REDALERT;
+ const int drawflag_copy = 0; /* None currently. */
uiBlock *oldblock;
uiBut *oldbut, *but = *butpp;
@@ -670,8 +671,9 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
SWAP(char *, oldbut->poin, but->poin);
SWAP(void *, oldbut->func_argN, but->func_argN);
}
-
+
oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy);
+ oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy);
/* copy hardmin for list rows to prevent 'sticking' highlight to mouse position
* when scrolling without moving mouse (see [#28432]) */
@@ -2604,7 +2606,7 @@ static void ui_block_do_align_but(uiBut *first, short nr)
next = NULL;
/* clear old flag */
- but->flag &= ~UI_BUT_ALIGN;
+ but->drawflag &= ~UI_BUT_ALIGN;
if (flag == 0) { /* first case */
if (next) {
@@ -2683,7 +2685,7 @@ static void ui_block_do_align_but(uiBut *first, short nr)
}
}
- but->flag |= flag;
+ but->drawflag |= flag;
/* merge coordinates */
if (prev) {
@@ -2863,10 +2865,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
if ((block->flag & UI_BLOCK_LOOP) ||
ELEM8(but->type, MENU, TEX, LABEL, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR, SEARCH_MENU_UNLINK))
{
- but->flag |= (UI_TEXT_LEFT | UI_ICON_LEFT);
+ but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT);
}
- but->flag |= (block->flag & UI_BUT_ALIGN);
+ but->drawflag |= (block->flag & UI_BUT_ALIGN);
if (but->lock == TRUE) {
if (but->lockstr) {
@@ -3041,7 +3043,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
if (icon) {
but->icon = (BIFIconID)icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
}
if (!RNA_property_editable(&but->rnapoin, prop)) {
@@ -3158,9 +3160,14 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, in
return but;
}
-/* if _x_ is a power of two (only one bit) return the power,
+/**
+ * if \a _x_ is a power of two (only one bit) return the power,
* otherwise return -1.
- * (1<<findBitIndex(x))==x for powers of two.
+ *
+ * for powers of two:
+ * \code{.c}
+ * ((1 << findBitIndex(x)) == x);
+ * \endcode
*/
static int findBitIndex(unsigned int x)
{
@@ -3183,6 +3190,7 @@ static int findBitIndex(unsigned int x)
/* autocomplete helper functions */
struct AutoComplete {
size_t maxlen;
+ int matches;
char *truncate;
const char *startname;
};
@@ -3193,6 +3201,7 @@ AutoComplete *autocomplete_begin(const char *startname, size_t maxlen)
autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete");
autocpl->maxlen = maxlen;
+ autocpl->matches = 0;
autocpl->truncate = MEM_callocN(sizeof(char) * maxlen, "AutoCompleteTruncate");
autocpl->startname = startname;
@@ -3211,6 +3220,7 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name)
}
/* found a match */
if (startname[a] == 0) {
+ autocpl->matches++;
/* first match */
if (truncate[0] == 0)
BLI_strncpy(truncate, name, autocpl->maxlen);
@@ -3228,21 +3238,27 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name)
}
}
-bool autocomplete_end(AutoComplete *autocpl, char *autoname)
+int autocomplete_end(AutoComplete *autocpl, char *autoname)
{
- bool change = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
if (autocpl->truncate[0]) {
+ if (autocpl->matches == 1) {
+ match = AUTOCOMPLETE_FULL_MATCH;
+ }
+ else {
+ match = AUTOCOMPLETE_PARTIAL_MATCH;
+ }
BLI_strncpy(autoname, autocpl->truncate, autocpl->maxlen);
- change = true;
}
else {
if (autoname != autocpl->startname) { /* don't copy a string over its self */
BLI_strncpy(autoname, autocpl->startname, autocpl->maxlen);
}
}
+
MEM_freeN(autocpl->truncate);
MEM_freeN(autocpl);
- return change;
+ return match;
}
static void ui_check_but_and_iconize(uiBut *but, int icon)
@@ -3416,7 +3432,7 @@ uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const ch
{
uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
@@ -3467,7 +3483,7 @@ uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const c
uiBut *but;
but = ui_def_but_rna_propname(block, type, retval, str, x, y, width, height, ptr, propname, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip)
@@ -3475,7 +3491,7 @@ uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, co
uiBut *but;
but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip)
@@ -3483,7 +3499,7 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int o
uiBut *but;
but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip)
@@ -3539,7 +3555,7 @@ void uiBlockFlipOrder(uiBlock *block)
return;
for (but = block->buttons.first; but; but = but->next) {
- if (but->flag & UI_BUT_ALIGN) return;
+ if (but->drawflag & UI_BUT_ALIGN) return;
if (but->rect.ymin < miny) miny = but->rect.ymin;
if (but->rect.ymax > maxy) maxy = but->rect.ymax;
}
@@ -3780,7 +3796,7 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
but->flag |= UI_ICON_SUBMENU;
but->menu_create_func = func;
@@ -3795,7 +3811,7 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag &= ~UI_ICON_LEFT;
+ but->drawflag &= ~UI_BUT_ICON_LEFT;
but->menu_create_func = func;
ui_check_but(but);
@@ -3811,7 +3827,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
/* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */
if (icon != ICON_RIGHTARROW_THIN) {
but->icon = (BIFIconID) icon;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
}
but->flag |= UI_HAS_ICON;
but->flag |= UI_ICON_SUBMENU;
@@ -3830,7 +3846,7 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
but->block_create_func = func;
ui_check_but(but);
@@ -3865,7 +3881,7 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
ui_check_but(but);
@@ -4186,5 +4202,6 @@ void UI_reinit_font(void)
void UI_exit(void)
{
ui_resources_free();
+ ui_button_clipboard_free();
}
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 783a777a2fe..a01c7eecda1 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -122,10 +122,9 @@ static void eyedropper_exit(bContext *C, wmOperator *op)
}
}
-static int eyedropper_cancel(bContext *C, wmOperator *op)
+static void eyedropper_cancel(bContext *C, wmOperator *op)
{
eyedropper_exit(C, op);
- return OPERATOR_CANCELLED;
}
/* *** eyedropper_color_ helper functions *** */
@@ -243,7 +242,8 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
- return eyedropper_cancel(C, op);
+ eyedropper_cancel(C, op);
+ return OPERATOR_CANCELLED;
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
if (eye->accum_tot == 0) {
@@ -439,7 +439,9 @@ static void datadropper_exit(bContext *C, wmOperator *op)
if (op->customdata) {
DataDropper *ddr = (DataDropper *)op->customdata;
- ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel);
+ if (ddr->art) {
+ ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel);
+ }
MEM_freeN(op->customdata);
@@ -447,10 +449,9 @@ static void datadropper_exit(bContext *C, wmOperator *op)
}
}
-static int datadropper_cancel(bContext *C, wmOperator *op)
+static void datadropper_cancel(bContext *C, wmOperator *op)
{
datadropper_exit(C, op);
- return OPERATOR_CANCELLED;
}
/* *** datadropper id helper functions *** */
@@ -552,7 +553,8 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
- return datadropper_cancel(C, op);
+ datadropper_cancel(C, op);
+ return OPERATOR_CANCELLED;
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
bool success;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c5faa99e067..db53809c7c4 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -242,7 +242,29 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *userd
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
static void button_timers_tooltip_remove(bContext *C, uiBut *but);
+/* buttons clipboard */
+static ColorBand but_copypaste_coba = {0};
+static CurveMapping but_copypaste_curve = {0};
+static bool but_copypaste_curve_alive = false;
+
/* ******************** menu navigation helpers ************** */
+enum eSnapType {
+ SNAP_OFF = 0,
+ SNAP_ON,
+ SNAP_ON_SMALL,
+};
+
+static enum eSnapType ui_event_to_snap(const wmEvent *event)
+{
+ return (event->ctrl) ? (event->shift) ? SNAP_ON_SMALL : SNAP_ON : SNAP_OFF;
+}
+
+static void ui_color_snap_hue(const enum eSnapType snap, float *r_hue)
+{
+ const float snap_increment = (snap == SNAP_ON_SMALL) ? 24 : 12;
+ BLI_assert(snap != SNAP_OFF);
+ *r_hue = floorf(0.5f + ((*r_hue) * snap_increment)) / snap_increment;
+}
/* assumes event type is MOUSEPAN */
void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
@@ -279,7 +301,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
static bool ui_but_editable(uiBut *but)
{
- return ELEM6(but->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
+ return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
}
static uiBut *ui_but_prev(uiBut *but)
@@ -335,7 +357,7 @@ static bool ui_is_a_warp_but(uiBut *but)
return false;
}
-static float ui_mouse_scale_warp_factor(const short shift)
+static float ui_mouse_scale_warp_factor(const bool shift)
{
return shift ? 0.05f : 1.0f;
}
@@ -343,7 +365,7 @@ static float ui_mouse_scale_warp_factor(const short shift)
static void ui_mouse_scale_warp(uiHandleButtonData *data,
const float mx, const float my,
float *r_mx, float *r_my,
- const short shift)
+ const bool shift)
{
const float fac = ui_mouse_scale_warp_factor(shift);
@@ -837,6 +859,13 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void
}
}
+static bool ui_is_but_drag_toggle(uiBut *but)
+{
+ return ((ui_is_but_bool(but) == true) &&
+ /* menu check is importnt so the button dragged over isn't removed instantly */
+ (ui_block_is_menu(but->block) == false));
+}
+
#endif /* USE_DRAG_TOGGLE */
@@ -852,7 +881,7 @@ static bool ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *eve
if (but->imb) {
/* use button size itself */
}
- else if (but->flag & UI_ICON_LEFT) {
+ else if (but->drawflag & UI_BUT_ICON_LEFT) {
rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
}
else {
@@ -1324,7 +1353,6 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
/* c = copy, v = paste */
static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char mode)
{
- static ColorBand but_copypaste_coba = {0};
char buf[UI_MAX_DRAW_STR + 1] = {0};
if (mode == 'v' && but->lock == TRUE) {
@@ -1372,6 +1400,32 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
}
}
+ /* NORMAL button */
+ else if (but->type == BUT_NORMAL) {
+ float xyz[3];
+
+ if (but->poin == NULL && but->rnapoin.data == NULL) {
+ /* pass */
+ }
+ else if (mode == 'c') {
+ ui_get_but_vectorf(but, xyz);
+ BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", xyz[0], xyz[1], xyz[2]);
+ WM_clipboard_text_set(buf, 0);
+ }
+ else {
+ if (sscanf(buf, "[%f, %f, %f]", &xyz[0], &xyz[1], &xyz[2]) == 3) {
+ if (normalize_v3(xyz) == 0.0f) {
+ /* better set Z up then have a zero vector */
+ xyz[2] = 1.0;
+ }
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+ ui_set_but_vectorf(but, xyz);
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ }
+ }
+
+
/* RGB triple */
else if (but->type == COLOR) {
float rgba[4];
@@ -1458,6 +1512,28 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
+ else if (but->type == BUT_CURVE) {
+ if (mode == 'c') {
+ if (but->poin == NULL)
+ return;
+
+ but_copypaste_curve_alive = true;
+ curvemapping_free_data(&but_copypaste_curve);
+ curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *) but->poin);
+ }
+ else {
+ if (!but_copypaste_curve_alive)
+ return;
+
+ if (!but->poin)
+ but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping");
+
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+ curvemapping_free_data((CurveMapping *) but->poin);
+ curvemapping_copy_data((CurveMapping *) but->poin, &but_copypaste_curve);
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ }
/* operator button (any type) */
else if (but->optype) {
if (mode == 'c') {
@@ -1465,7 +1541,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
char *str;
opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
- str = WM_operator_pystring(C, but->optype, opptr, 0);
+ str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr);
WM_clipboard_text_set(str, 0);
@@ -1716,7 +1792,7 @@ static bool ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char as
}
static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJumpDirection direction,
- int select, strCursorJumpType jump)
+ const bool select, strCursorJumpType jump)
{
const char *str = data->str;
const int len = strlen(str);
@@ -2021,7 +2097,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->next; but; but = but->next) {
@@ -2049,7 +2125,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->prev; but; but = but->prev) {
@@ -2137,7 +2213,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* only select a word in button if there was no selection before */
if (event->val == KM_DBL_CLICK && had_selection == false) {
- ui_textedit_move(but, data, STRCUR_DIR_PREV, 0, STRCUR_JUMP_DELIM);
+ ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_DELIM);
ui_textedit_move(but, data, STRCUR_DIR_NEXT, true, STRCUR_JUMP_DELIM);
retval = WM_UI_HANDLER_BREAK;
changed = true;
@@ -2171,12 +2247,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
break;
case RIGHTARROWKEY:
ui_textedit_move(but, data, STRCUR_DIR_NEXT,
- event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
+ event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
retval = WM_UI_HANDLER_BREAK;
break;
case LEFTARROWKEY:
ui_textedit_move(but, data, STRCUR_DIR_PREV,
- event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
+ event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
retval = WM_UI_HANDLER_BREAK;
break;
case WHEELDOWNMOUSE:
@@ -2191,7 +2267,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* fall-through */
case ENDKEY:
ui_textedit_move(but, data, STRCUR_DIR_NEXT,
- event->shift, STRCUR_JUMP_ALL);
+ event->shift != 0, STRCUR_JUMP_ALL);
retval = WM_UI_HANDLER_BREAK;
break;
case WHEELUPMOUSE:
@@ -2206,7 +2282,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* fall-through */
case HOMEKEY:
ui_textedit_move(but, data, STRCUR_DIR_PREV,
- event->shift, STRCUR_JUMP_ALL);
+ event->shift != 0, STRCUR_JUMP_ALL);
retval = WM_UI_HANDLER_BREAK;
break;
case PADENTER:
@@ -2648,7 +2724,9 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
/* unlink icon is on right */
- if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS) {
+ if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS &&
+ ui_is_but_search_unlink_visible(but))
+ {
ARegion *ar = data->region;
rcti rect;
int x = event->x, y = event->y;
@@ -2659,9 +2737,14 @@ static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHa
rect.xmin = rect.xmax - (BLI_rcti_size_y(&rect));
if (BLI_rcti_isect_pt(&rect, x, y)) {
- ui_set_but_string(C, but, "");
+ /* most likely NULL, but let's check, and give it temp zero string */
+ if (data->str == NULL)
+ data->str = MEM_callocN(1, "temp str");
+ data->str[0] = 0;
+
+ ui_apply_but_TEX(C, but, data);
button_activate_state(C, but, BUTTON_STATE_EXIT);
-
+
return WM_UI_HANDLER_BREAK;
}
}
@@ -2672,7 +2755,7 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons
{
#ifdef USE_DRAG_TOGGLE
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_is_but_bool(but)) {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_is_but_drag_toggle(but)) {
#if 0 /* UNUSED */
data->togdual = event->ctrl;
data->togonly = !event->shift;
@@ -2721,7 +2804,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con
}
}
#ifdef USE_DRAG_TOGGLE
- if (event->type == LEFTMOUSE && ui_is_but_bool(but)) {
+ if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@ -2763,9 +2846,10 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con
}
/* var names match ui_numedit_but_NUM */
-static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap)
+static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange,
+ const enum eSnapType snap)
{
- if (tempf == softmin || tempf == softmax || snap == 0) {
+ if (tempf == softmin || tempf == softmax || snap == SNAP_OFF) {
/* pass */
}
else {
@@ -2791,16 +2875,19 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
softrange /= fac;
}
- if (snap == 1) {
+ if (snap == SNAP_ON) {
if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
else if (softrange < 21.0f) tempf = floorf(tempf);
else tempf = 10.0f * floorf(tempf / 10.0f);
}
- else if (snap == 2) {
+ else if (snap == SNAP_ON_SMALL) {
if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
else tempf = floor(tempf);
}
+ else {
+ BLI_assert(0);
+ }
if (fac != 1.0f)
tempf *= fac;
@@ -2809,18 +2896,19 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
return tempf;
}
-static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int snap)
+static float ui_numedit_apply_snap(int temp, float softmin, float softmax,
+ const enum eSnapType snap)
{
if (temp == softmin || temp == softmax)
return temp;
switch (snap) {
- case 0:
+ case SNAP_OFF:
break;
- case 1:
+ case SNAP_ON:
temp = 10 * (temp / 10);
break;
- case 2:
+ case SNAP_ON_SMALL:
temp = 100 * (temp / 100);
break;
}
@@ -2828,7 +2916,9 @@ static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int s
return temp;
}
-static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx)
+static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data,
+ int mx,
+ const enum eSnapType snap, float fac)
{
float deler, tempf, softmin, softmax, softrange;
int lvalue, temp;
@@ -3037,16 +3127,14 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
click = 1;
}
else if (event->type == MOUSEMOVE) {
+ const enum eSnapType snap = ui_event_to_snap(event);
float fac;
- int snap;
fac = 1.0f;
if (event->shift) fac /= 10.0f;
if (event->alt) fac /= 20.0f;
-
- snap = (event->ctrl) ? (event->shift) ? 2 : 1 : 0;
- if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx : mx)))
+ if (ui_numedit_but_NUM(but, data, (ui_is_a_warp_but(but) ? screen_mx : mx), snap, fac))
ui_numedit_apply(C, block, but, data);
}
retval = WM_UI_HANDLER_BREAK;
@@ -3127,7 +3215,8 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data,
- const bool is_horizontal, const bool shift, const bool ctrl, int mx)
+ int mx, const bool is_horizontal,
+ const bool snap, const bool shift)
{
float deler, f, tempf, softmin, softmax, softrange;
int temp, lvalue;
@@ -3182,7 +3271,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data,
tempf = softmin + f * softrange;
temp = floorf(tempf + 0.5f);
- if (ctrl) {
+ if (snap) {
if (tempf == softmin || tempf == softmax) {
/* pass */
}
@@ -3303,7 +3392,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
click = 1;
}
else if (event->type == MOUSEMOVE) {
- if (ui_numedit_but_SLI(but, data, true, event->shift, event->ctrl, mx))
+ if (ui_numedit_but_SLI(but, data, mx, true, event->ctrl != 0, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
retval = WM_UI_HANDLER_BREAK;
@@ -3419,7 +3508,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (ui_numedit_but_SLI(but, data, horizontal, false, false, (horizontal) ? mx : my))
+ if (ui_numedit_but_SLI(but, data, (horizontal) ? mx : my, horizontal, false, false))
ui_numedit_apply(C, block, but, data);
}
@@ -3541,7 +3630,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
}
#ifdef USE_DRAG_TOGGLE
- if (event->type == LEFTMOUSE && ui_is_but_bool(but)) {
+ if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@ -3610,7 +3699,9 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
return WM_UI_HANDLER_CONTINUE;
}
-static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my)
+static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data,
+ int mx, int my,
+ const enum eSnapType snap)
{
float dx, dy, rad, radsq, mrad, *fp;
int mdx, mdy;
@@ -3666,6 +3757,23 @@ static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx,
}
normalize_v3(fp);
+ if (snap != SNAP_OFF) {
+ const int snap_steps = (snap == SNAP_ON) ? 4 : 12; /* 45 or 15 degree increments */
+ const float snap_steps_angle = M_PI / snap_steps;
+ float angle, angle_snap;
+ int i;
+
+ /* round each axis of 'fp' to the next increment
+ * do this in "angle" space - this gives increments of same size */
+ for (i = 0; i < 3; i++) {
+ angle = asinf(fp[i]);
+ angle_snap = floorf(0.5f + (angle / snap_steps_angle)) * snap_steps_angle;
+ fp[i] = sinf(angle_snap);
+ }
+ normalize_v3(fp);
+ changed = !compare_v3v3(fp, data->origvec, FLT_EPSILON);
+ }
+
data->draglastx = mx;
data->draglasty = my;
@@ -3717,6 +3825,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ const enum eSnapType snap = ui_event_to_snap(event);
data->dragstartx = mx;
data->dragstarty = my;
data->draglastx = mx;
@@ -3724,7 +3833,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_NORMAL(but, data, mx, my))
+ if (ui_numedit_but_NORMAL(but, data, mx, my, snap))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
@@ -3733,7 +3842,8 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_NORMAL(but, data, mx, my))
+ const enum eSnapType snap = ui_event_to_snap(event);
+ if (ui_numedit_but_NORMAL(but, data, mx, my, snap))
ui_numedit_apply(C, block, but, data);
}
}
@@ -3760,15 +3870,17 @@ static void clamp_axis_max_v3(float v[3], const float max)
}
}
-static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, const short shift)
+static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
+ int mx, int my,
+ const enum eSnapType snap, const bool shift)
{
float rgb[3];
float *hsv = ui_block_hsv_get(but->block);
float x, y;
float mx_fl, my_fl;
bool changed = true;
- int color_profile = but->block->color_profile;
-
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
+
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
#ifdef USE_CONT_MOUSE_CORRECT
@@ -3780,14 +3892,9 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
}
#endif
- if (but->rnaprop) {
- if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
- }
-
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3801,7 +3908,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
/* calculate original hsv again */
copy_v3_v3(rgb, data->origvec);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
copy_v3_v3(hsvo, ui_block_hsv_get(but->block));
@@ -3854,9 +3961,15 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
break;
}
+ if (snap != SNAP_OFF) {
+ if (ELEM3((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+ }
+
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && ((int)but->a1 != UI_GRAD_SV))
+ if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
/* clamp because with color conversion we can exceed range [#34295] */
@@ -3872,22 +3985,18 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
return changed;
}
-static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, const short shift)
+static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
+ wmNDOFMotionData *ndof,
+ const enum eSnapType snap, const bool shift)
{
float *hsv = ui_block_hsv_get(but->block);
float rgb[3];
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
-
- int color_profile = but->block->color_profile;
-
- if (but->rnaprop) {
- if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
- }
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3927,9 +4036,15 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
break;
}
+ if (snap != SNAP_OFF) {
+ if (ELEM3((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+ }
+
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
copy_v3_v3(data->vec, rgb);
@@ -3946,6 +4061,8 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ const enum eSnapType snap = ui_event_to_snap(event);
+
data->dragstartx = mx;
data->dragstarty = my;
data->draglastx = mx;
@@ -3953,15 +4070,16 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift))
+ if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
}
else if (event->type == NDOF_MOTION) {
wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
+ const enum eSnapType snap = ui_event_to_snap(event);
- ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift);
+ ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_button(C, but->block, but, data, true);
@@ -4012,7 +4130,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift))
+ const enum eSnapType snap = ui_event_to_snap(event);
+
+ if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
}
@@ -4026,7 +4146,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
return WM_UI_HANDLER_CONTINUE;
}
-static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float mx, float my, int shift)
+static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
+ float mx, float my,
+ const enum eSnapType snap, const bool shift)
{
rcti rect;
bool changed = true;
@@ -4084,6 +4206,10 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float
if (but->flag & UI_BUT_COLOR_CUBIC)
hsv[1] = 1.0f - sqrt3f(1.0f - hsv[1]);
+ if (snap != SNAP_OFF) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+
hsv_to_rgb_v(hsv, rgb);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
@@ -4099,7 +4225,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float
return changed;
}
-static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, const short shift)
+static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
+ wmNDOFMotionData *ndof,
+ const enum eSnapType snap, const bool shift)
{
float *hsv = ui_block_hsv_get(but->block);
float rgb[3];
@@ -4140,7 +4268,11 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
if (but->flag & UI_BUT_COLOR_LOCK) { // lock
if (hsv[2] == 0.0f) hsv[2] = 0.0001f;
}
-
+
+ if (snap != SNAP_OFF) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+
hsv_to_rgb_v(hsv, data->vec);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
@@ -4161,6 +4293,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ const enum eSnapType snap = ui_event_to_snap(event);
data->dragstartx = mx;
data->dragstarty = my;
data->draglastx = mx;
@@ -4168,15 +4301,16 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
+ if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
}
else if (event->type == NDOF_MOTION) {
+ const enum eSnapType snap = ui_event_to_snap(event);
wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
- ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift);
+ ui_ndofedit_but_HSVCIRCLE(but, data, ndof, snap, event->shift != 0);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_button(C, but->block, but, data, true);
@@ -4238,8 +4372,11 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
+ const enum eSnapType snap = ui_event_to_snap(event);
+
+ if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
@@ -4334,8 +4471,9 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
return WM_UI_HANDLER_CONTINUE;
}
-static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, int snap,
- int evtx, int evty, const short shift)
+static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data,
+ int evtx, int evty,
+ bool snap, const bool shift)
{
CurveMapping *cumap = (CurveMapping *)but->poin;
CurveMap *cuma = cumap->cm + cumap->cur;
@@ -4363,7 +4501,7 @@ static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData
d[1] = my - data->dragstarty;
if (len_v2(d) < 3.0f)
- snap = 0;
+ snap = false;
}
if (data->dragsel != -1) {
@@ -4558,7 +4696,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
if (event->type == MOUSEMOVE) {
if (event->x != data->draglastx || event->y != data->draglasty) {
- if (ui_numedit_but_CURVE(block, but, data, event->ctrl, event->x, event->y, event->shift))
+ if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
}
@@ -4867,7 +5005,8 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, con
}
static bool ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data,
- int mx, int my, const short shift)
+ int mx, int my,
+ const bool shift)
{
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
bool changed = true;
@@ -4923,7 +5062,7 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
+ if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
@@ -4939,7 +5078,7 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
+ if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
}
@@ -5536,7 +5675,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
break;
case ROUNDBOX:
case LABEL:
- case LISTLABEL:
case ROW:
case LISTROW:
case BUT_IMAGE:
@@ -5749,7 +5887,7 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
bool ui_is_but_interactive(uiBut *but)
{
/* note, LABEL is included for highlights, this allows drags */
- if (ELEM(but->type, LABEL, LISTLABEL) && but->dragpoin == NULL)
+ if ((but->type == LABEL) && but->dragpoin == NULL)
return false;
if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
return false;
@@ -5761,6 +5899,13 @@ bool ui_is_but_interactive(uiBut *but)
return true;
}
+bool ui_is_but_search_unlink_visible(uiBut *but)
+{
+ BLI_assert(but->type == SEARCH_MENU_UNLINK);
+ return ((but->editstr == NULL) &&
+ (but->drawstr[0] != '\0'));
+}
+
uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
{
uiBlock *block;
@@ -6572,6 +6717,8 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
// retval = WM_UI_HANDLER_BREAK; XXX why ?
}
+ /* may have been re-allocated above (eyedropper for eg) */
+ data = but->active;
if (data->state == BUTTON_STATE_EXIT) {
uiBut *post_but = data->postbut;
uiButtonActivateType post_type = data->posttype;
@@ -6635,7 +6782,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
is_over_dragbut = true;
}
- if (is_over_dragbut && type == LEFTMOUSE && val == KM_PRESS) {
+ if (is_over_dragbut && type == LEFTMOUSE && val == KM_PRESS && !(but->flag & UI_BUT_DISABLED)) {
uiHandleButtonData *data;
int *size = (int *)but->poin;
@@ -7296,7 +7443,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH
for (but = block->buttons.first; but; but = but->next) {
int doit = FALSE;
- if (but->type != LABEL && but->type != LISTLABEL && but->type != SEPR)
+ if (!ELEM(but->type, LABEL, SEPR))
count++;
/* exception for rna layer buts */
@@ -7842,3 +7989,7 @@ bool UI_textbutton_activate_event(const bContext *C, ARegion *ar,
}
}
+void ui_button_clipboard_free(void)
+{
+ curvemapping_free_data(&but_copypaste_curve);
+}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 9cc16d82810..30d8535e471 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -95,7 +95,6 @@ typedef enum {
UI_WTYPE_SCROLL,
UI_WTYPE_LISTITEM,
UI_WTYPE_PROGRESSBAR,
- UI_WTYPE_LISTLABEL,
} uiWidgetTypeEnum;
/* menu scrolling */
@@ -108,13 +107,15 @@ typedef enum {
#define UI_PANEL_MINY 70
/* uiBut->flag */
-#define UI_SELECT 1 /* use when the button is pressed */
-#define UI_SCROLLED 2 /* temp hidden, scrolled away */
-#define UI_ACTIVE 4
-#define UI_HAS_ICON 8
-#define UI_TEXTINPUT 16
-#define UI_HIDDEN 32
-/* warn: rest of uiBut->flag in UI_interface.h */
+enum {
+ UI_SELECT = (1 << 0), /* use when the button is pressed */
+ UI_SCROLLED = (1 << 1), /* temp hidden, scrolled away */
+ UI_ACTIVE = (1 << 2),
+ UI_HAS_ICON = (1 << 3),
+ UI_TEXTINPUT = (1 << 4),
+ UI_HIDDEN = (1 << 5),
+ /* warn: rest of uiBut->flag in UI_interface.h */
+};
/* internal panel drawing defines */
#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */
@@ -385,6 +386,7 @@ extern void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rc
const float mx, const float my);
extern void ui_hsvcircle_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xpos, float *ypos);
extern void ui_hsvcube_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp);
+bool ui_hsvcube_use_display_colorspace(struct uiBut *but);
extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision);
extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen);
@@ -402,6 +404,7 @@ extern bool ui_is_but_unit(uiBut *but);
extern bool ui_is_but_rna_valid(uiBut *but);
extern bool ui_is_but_utf8(uiBut *but);
extern bool ui_is_but_interactive(uiBut *but);
+extern bool ui_is_but_search_unlink_visible(uiBut *but);
extern int ui_is_but_push_ex(uiBut *but, double *value);
extern int ui_is_but_push(uiBut *but);
@@ -522,6 +525,7 @@ extern void ui_button_active_free(const struct bContext *C, uiBut *but);
extern bool ui_button_is_active(struct ARegion *ar);
extern int ui_button_open_menu_direction(uiBut *but);
extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore);
+void ui_button_clipboard_free(void);
/* interface_widgets.c */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b453a3b8363..b85c30b8710 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -54,6 +54,8 @@
#include "UI_interface.h"
+#include "ED_armature.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -375,6 +377,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
int cols = (len >= 20) ? 2 : 1;
const unsigned int colbuts = len / (2 * cols);
unsigned int layer_used = 0;
+ unsigned int layer_active = 0;
uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE));
@@ -384,27 +387,59 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
if (ptr->type == &RNA_Armature) {
bArmature *arm = (bArmature *)ptr->data;
+
layer_used = arm->layer_used;
+
+ if (arm->edbo) {
+ if (arm->act_edbone) {
+ layer_active |= arm->act_edbone->layer;
+ }
+ }
+ else {
+ if (arm->act_bone) {
+ layer_active |= arm->act_bone->layer;
+ }
+ }
}
for (b = 0; b < cols; b++) {
uiBlockBeginAlign(block);
for (a = 0; a < colbuts; a++) {
- if (layer_used & (1 << (a + b * colbuts))) icon = ICON_LAYER_USED;
- else icon = ICON_BLANK1;
+ int layer_num = a + b * colbuts;
+ int layer_flag = 1 << layer_num;
+
+ if (layer_used & layer_flag) {
+ if (layer_active & layer_flag)
+ icon = ICON_LAYER_ACTIVE;
+ else
+ icon = ICON_LAYER_USED;
+ }
+ else {
+ icon = ICON_BLANK1;
+ }
- but = uiDefAutoButR(block, ptr, prop, a + b * colbuts, "", icon, x + butw * a, y + buth, butw, buth);
+ but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + b * colbuts));
+ uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
}
for (a = 0; a < colbuts; a++) {
- if (layer_used & (1 << (a + len / 2 + b * colbuts))) icon = ICON_LAYER_USED;
- else icon = ICON_BLANK1;
+ int layer_num = a + len / 2 + b * colbuts;
+ int layer_flag = 1 << layer_num;
+
+ if (layer_used & layer_flag) {
+ if (layer_active & layer_flag)
+ icon = ICON_LAYER_ACTIVE;
+ else
+ icon = ICON_LAYER_USED;
+ }
+ else {
+ icon = ICON_BLANK1;
+ }
- but = uiDefAutoButR(block, ptr, prop, a + len / 2 + b * colbuts, "", icon, x + butw * a, y, butw, buth);
+ but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + len / 2 + b * colbuts));
+ uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
}
uiBlockEndAlign(block);
@@ -549,7 +584,7 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt
}
if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL)
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
}
uiBlockSetCurLayout(block, layout);
@@ -731,7 +766,7 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam
/* text alignment for toolbar buttons */
if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon)
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
if (flag & UI_ITEM_R_NO_BG)
uiBlockSetEmboss(block, UI_EMBOSS);
@@ -881,7 +916,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
uiItemL(column, item->name, ICON_NONE);
but = block->buttons.last;
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
ui_but_tip_from_enum_item(but, item);
}
else { /* XXX bug here, colums draw bottom item badly */
@@ -1305,7 +1340,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
uiItemL(column, item[i].name, ICON_NONE);
bt = block->buttons.last;
- bt->flag = UI_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
ui_but_tip_from_enum_item(bt, &item[i]);
}
@@ -1455,7 +1490,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
but->hardmax = MAX2(but->hardmax, 256.0f);
but->rnasearchpoin = *searchptr;
but->rnasearchprop = searchprop;
- but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
if (RNA_property_type(prop) == PROP_ENUM) {
/* XXX, this will have a menu string,
@@ -1598,7 +1633,7 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre
(force_menu && layout->root->type != UI_LAYOUT_MENU)) /* We never want a dropdown in menu! */
{
but->type = MENU;
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
}
}
@@ -1650,13 +1685,13 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
* make text aligned right if the layout is aligned right.
*/
if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) {
- but->flag &= ~UI_TEXT_LEFT; /* default, needs to be unset */
- but->flag |= UI_TEXT_RIGHT;
+ but->drawflag &= ~UI_BUT_TEXT_LEFT; /* default, needs to be unset */
+ but->drawflag |= UI_BUT_TEXT_RIGHT;
}
/* Mark as a label inside a listbox. */
if (block->flag & UI_BLOCK_LIST_ITEM) {
- but->type = LISTLABEL;
+ but->flag |= UI_BUT_LIST_ITEM;
}
return but;
@@ -2423,7 +2458,10 @@ void ui_layout_list_set_labels_active(uiLayout *layout)
{
uiButtonItem *bitem;
for (bitem = layout->items.first; bitem; bitem = bitem->item.next) {
- if (bitem->item.type == ITEM_BUTTON && bitem->but->type == LISTLABEL) {
+ if (bitem->item.type != ITEM_BUTTON) {
+ ui_layout_list_set_labels_active((uiLayout *)(&bitem->item));
+ }
+ else if (bitem->but->flag & UI_BUT_LIST_ITEM) {
uiButSetFlag(bitem->but, UI_SELECT);
}
}
@@ -2931,7 +2969,7 @@ static void ui_intro_button(DynStr *ds, uiButtonItem *bitem)
BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */
if (but->optype) {
- char *opstr = WM_operator_pystring(but->block->evil_C, but->optype, but->opptr, 0);
+ char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, but->optype, but->opptr);
BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
MEM_freeN(opstr);
}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 15fbd51c6fc..f869c5de8e6 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -443,7 +443,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL};
uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL};
- if (but->flag & UI_BUT_NO_TOOLTIP)
+ if (but->drawflag & UI_BUT_NO_TOOLTIP)
return NULL;
/* create tooltip data */
@@ -539,7 +539,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* so the context is passed to itemf functions (some py itemf functions use it) */
WM_operator_properties_sanitize(opptr, false);
- str = WM_operator_pystring(C, but->optype, opptr, 0);
+ str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr);
/* operator info */
if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
@@ -1054,17 +1054,17 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
bool ui_searchbox_autocomplete(bContext *C, ARegion *ar, uiBut *but, char *str)
{
uiSearchboxData *data = ar->regiondata;
- bool changed = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
if (str[0]) {
data->items.autocpl = autocomplete_begin(str, ui_get_but_string_max_length(but));
but->search_func(C, but->search_arg, but->editstr, &data->items);
- changed = autocomplete_end(data->items.autocpl, str);
+ match = autocomplete_end(data->items.autocpl, str);
data->items.autocpl = NULL;
}
- return changed;
+ return match != AUTOCOMPLETE_NO_MATCH;
}
static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
@@ -1389,9 +1389,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
/* widget_roundbox_set has this correction too, keep in sync */
if (but->type != PULLDOWN) {
- if (but->flag & UI_BUT_ALIGN_TOP)
+ if (but->drawflag & UI_BUT_ALIGN_TOP)
butrct.ymax += U.pixelsize;
- if (but->flag & UI_BUT_ALIGN_LEFT)
+ if (but->drawflag & UI_BUT_ALIGN_LEFT)
butrct.xmin -= U.pixelsize;
}
@@ -1840,7 +1840,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
else {
uiItemL(layout, md->title, ICON_NONE);
bt = block->buttons.last;
- bt->flag = UI_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
}
}
@@ -1876,7 +1876,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
if (entry->str[0]) {
uiItemL(column, entry->str, entry->icon);
bt = block->buttons.last;
- bt->flag = UI_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
}
else {
uiItemS(column);
@@ -2560,7 +2560,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
}
else {
but = uiDefBut(pup->block, LABEL, 0, title, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
}
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 6b6b7114c84..1d1b7dbb835 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -443,7 +443,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
but->icon = RNA_struct_ui_icon(type);
/* default dragging of icon for id browse buttons */
uiButSetDragID(but, id);
- uiButSetFlag(but, UI_HAS_ICON | UI_ICON_LEFT);
+ uiButSetFlag(but, UI_HAS_ICON);
+ uiButSetDrawFlag(but, UI_BUT_ICON_LEFT);
}
if ((idfrom && idfrom->lib) || !editable)
@@ -967,11 +968,11 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
- if (!(ob->mode & OB_MODE_PARTICLE_EDIT) && psys->pathcache) {
+ if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
"OBJECT_OT_duplicates_make_real");
- else if (psys->part->ren_as == PART_DRAW_PATH)
+ else if (psys->part->ren_as == PART_DRAW_PATH && psys->pathcache)
uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
"OBJECT_OT_modifier_convert");
}
@@ -1921,7 +1922,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
case UICURVE_FUNC_RESET_NEG:
case UICURVE_FUNC_RESET_POS: /* reset */
curvemap_reset(cuma, &cumap->clipr, cumap->preset,
- (event == -1) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE);
+ (event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE);
curvemapping_changed(cumap, FALSE);
break;
case UICURVE_FUNC_RESET_VIEW:
@@ -2855,6 +2856,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
items_shown = dyn_data->items_shown;
if (items_shown >= 0) {
+ bool activei_mapping_pending = true;
items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, AT);
//printf("%s: items shown: %d.\n", __func__, items_shown);
RNA_PROP_BEGIN (dataptr, itemptr, prop)
@@ -2875,8 +2877,10 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
items_ptr[ii].org_idx = i;
items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] : 0;
- if (activei == i) {
+ if (activei_mapping_pending && activei == i) {
activei = ii;
+ /* So that we do not map again activei! */
+ activei_mapping_pending = false;
}
# if 0 /* For now, do not alter active element, even if it will be hidden... */
else if (activei < i) {
@@ -2936,7 +2940,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL);
- uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
+ uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP);
sub = uiLayoutRow(overlap, FALSE);
@@ -3023,7 +3027,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL);
- uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
+ uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP);
sub = uiLayoutRow(overlap, FALSE);
@@ -3065,11 +3069,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
if (ui_list->filter_flag & UILST_FLT_SHOW) {
but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_DOWN, 0, 0,
- UI_UNIT_X, UI_UNIT_Y * 0.6f, &(ui_list->filter_flag), 0, 0, 0, 0,
+ UI_UNIT_X, UI_UNIT_Y * 0.8f, &(ui_list->filter_flag), 0, 0, 0, 0,
TIP_("Hide filtering options"));
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
- but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.6f, ui_list,
+ but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.8f, ui_list,
0.0, 0.0, 0, -1, "");
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
@@ -3083,11 +3087,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
}
else {
but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_RIGHT, 0, 0,
- UI_UNIT_X, UI_UNIT_Y * 0.6f, &(ui_list->filter_flag), 0, 0, 0, 0,
+ UI_UNIT_X, UI_UNIT_Y * 0.8f, &(ui_list->filter_flag), 0, 0, 0, 0,
TIP_("Show filtering options"));
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
- but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.6f, ui_list,
+ but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.8f, ui_list,
0.0, 0.0, 0, -1, "");
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
@@ -3236,6 +3240,16 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
handle_event = B_STOPCOMPO;
break;
}
+ else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) {
+ /* Skip bake jobs in compositor to avoid compo header displaying
+ * progress bar which is not being updated (bake jobs only need
+ * to update NC_IMAGE context.
+ */
+ if (sa->spacetype != SPACE_NODE) {
+ handle_event = B_STOPOTHER;
+ break;
+ }
+ }
else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) {
handle_event = B_STOPOTHER;
break;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 4be8812d68c..3058888c012 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -882,7 +882,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti
}
/* extra feature allows more alpha blending */
- if (ELEM(but->type, LABEL, LISTLABEL) && but->a1 == 1.0f)
+ if ((but->type == LABEL) && but->a1 == 1.0f)
alpha *= but->a2;
glEnable(GL_BLEND);
@@ -890,7 +890,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti
if (icon && icon != ICON_BLANK1) {
float ofs = 1.0f / aspect;
- if (but->flag & UI_ICON_LEFT) {
+ if (but->drawflag & UI_BUT_ICON_LEFT) {
if (but->block->flag & UI_BLOCK_LOOP) {
if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK))
xs = rect->xmin + 4.0f * ofs;
@@ -956,12 +956,12 @@ static void ui_text_clip_give_next_off(uiBut *but)
*/
static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
- int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
int okwidth = BLI_rcti_size_x(rect) - border;
if (but->flag & UI_HAS_ICON)
okwidth -= UI_DPI_ICON_SIZE;
- if (but->type == SEARCH_MENU_UNLINK && !but->editstr)
+ if ((but->type == SEARCH_MENU_UNLINK) && ui_is_but_search_unlink_visible(but))
okwidth -= BLI_rcti_size_y(rect);
okwidth = max_ii(okwidth, 0);
@@ -991,7 +991,7 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
*/
static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
- int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
@@ -1055,7 +1055,7 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
*/
static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
- int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
char *cpoin = NULL;
int drawstr_len = strlen(but->drawstr);
@@ -1140,9 +1140,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
uiStyleFontSet(fstyle);
- if (but->editstr || (but->flag & UI_TEXT_LEFT))
+ if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT))
fstyle->align = UI_STYLE_TEXT_LEFT;
- else if (but->flag & UI_TEXT_RIGHT)
+ else if (but->drawflag & UI_BUT_TEXT_RIGHT)
fstyle->align = UI_STYLE_TEXT_RIGHT;
else
fstyle->align = UI_STYLE_TEXT_CENTER;
@@ -1310,22 +1310,22 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
/* icons default draw 0.8f x height */
rect->xmin += (int)(0.8f * BLI_rcti_size_y(rect));
- if (but->editstr || (but->flag & UI_TEXT_LEFT)) {
+ if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
- else if ((but->flag & UI_TEXT_RIGHT)) {
+ else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
}
- else if ((but->flag & UI_TEXT_LEFT)) {
+ else if ((but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
- else if ((but->flag & UI_TEXT_RIGHT)) {
+ else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
/* unlink icon for this button type */
- if (but->type == SEARCH_MENU_UNLINK && !but->editstr && but->drawstr[0]) {
+ if ((but->type == SEARCH_MENU_UNLINK) && ui_is_but_search_unlink_visible(but)) {
rcti temp = *rect;
temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f);
@@ -2004,10 +2004,11 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
/* ************ custom buttons, old stuff ************** */
-/* draws in resolution of 20x4 colors */
+/* draws in resolution of 48x4 colors */
void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, const float alpha)
{
- const float color_step = (type == UI_GRAD_H) ? 0.02f : 0.05f;
+ /* allows for 4 steps (red->yellow) */
+ const float color_step = (1.0 / 48.0);
int a;
float h = hsv[0], s = hsv[1], v = hsv[2];
float dx, dy, sx1, sx2, sy;
@@ -2066,6 +2067,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
/* old below */
for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
+ const float dx_next = dx + color_step;
+
/* previous color */
copy_v3_v3(col0[0], col1[0]);
copy_v3_v3(col0[1], col1[1]);
@@ -2081,22 +2084,22 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
hsv_to_rgb(h, 1.0, dx, &col1[3][0], &col1[3][1], &col1[3][2]);
break;
case UI_GRAD_HV:
- hsv_to_rgb(dx, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
- hsv_to_rgb(dx, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
- hsv_to_rgb(dx, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
- hsv_to_rgb(dx, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
+ hsv_to_rgb(dx_next, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(dx_next, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
+ hsv_to_rgb(dx_next, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
+ hsv_to_rgb(dx_next, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
break;
case UI_GRAD_HS:
- hsv_to_rgb(dx, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
- hsv_to_rgb(dx, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
- hsv_to_rgb(dx, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
- hsv_to_rgb(dx, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
+ hsv_to_rgb(dx_next, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(dx_next, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
+ hsv_to_rgb(dx_next, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
+ hsv_to_rgb(dx_next, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
break;
case UI_GRAD_H:
{
/* annoying but without this the color shifts - could be solved some other way
* - campbell */
- hsv_to_rgb(dx + color_step, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(dx_next, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
copy_v3_v3(col1[1], col1[0]);
copy_v3_v3(col1[2], col1[0]);
copy_v3_v3(col1[3], col1[0]);
@@ -2117,8 +2120,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
}
/* rect */
- sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
- sx2 = rect->xmin + (dx + color_step) * BLI_rcti_size_x(rect);
+ sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
+ sx2 = rect->xmin + dx_next * BLI_rcti_size_x(rect);
sy = rect->ymin;
dy = (float)BLI_rcti_size_y(rect) / 3.0f;
@@ -2143,6 +2146,19 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
}
+bool ui_hsvcube_use_display_colorspace(uiBut *but)
+{
+ bool color_profile = but->block->color_profile;
+
+ if (but->rnaprop) {
+ if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
+ color_profile = FALSE;
+ }
+
+ /* SV+H gradient does not use display colorspace */
+ return color_profile && !ELEM((int)but->a1, UI_GRAD_SV, UI_GRAD_H);
+}
+
void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp)
{
float x, y;
@@ -2179,16 +2195,13 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
float x = 0.0f, y = 0.0f;
float *hsv = ui_block_hsv_get(but->block);
float hsv_n[3];
- int color_profile = but->block->color_profile;
-
- if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
copy_v3_v3(hsv_n, hsv);
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv_n);
@@ -2853,12 +2866,21 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
/* labels use Editor theme colors for text */
static void widget_state_label(uiWidgetType *wt, int state)
{
- /* call this for option button */
- widget_state(wt, state);
- if (state & UI_SELECT)
- UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
- else
- UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
+ if (state & UI_BUT_LIST_ITEM) {
+ /* Override default label theme's colors. */
+ bTheme *btheme = UI_GetTheme();
+ wt->wcol_theme = &btheme->tui.wcol_list_item;
+ /* call this for option button */
+ widget_state(wt, state);
+ }
+ else {
+ /* call this for option button */
+ widget_state(wt, state);
+ if (state & UI_SELECT)
+ UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
+ else
+ UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
+ }
}
static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
@@ -2978,11 +3000,6 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
case UI_WTYPE_REGULAR:
break;
- case UI_WTYPE_LISTLABEL:
- wt.wcol_theme = &btheme->tui.wcol_list_item;
- wt.draw = NULL;
- /* Can't use usual label code. */
- break;
case UI_WTYPE_LABEL:
wt.draw = NULL;
wt.state = widget_state_label;
@@ -3126,15 +3143,15 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
int roundbox = UI_CNR_ALL;
/* alignment */
- if ((but->flag & UI_BUT_ALIGN) && but->type != PULLDOWN) {
+ if ((but->drawflag & UI_BUT_ALIGN) && but->type != PULLDOWN) {
/* ui_block_position has this correction too, keep in sync */
- if (but->flag & UI_BUT_ALIGN_TOP)
+ if (but->drawflag & UI_BUT_ALIGN_TOP)
rect->ymax += U.pixelsize;
- if (but->flag & UI_BUT_ALIGN_LEFT)
+ if (but->drawflag & UI_BUT_ALIGN_LEFT)
rect->xmin -= U.pixelsize;
- switch (but->flag & UI_BUT_ALIGN) {
+ switch (but->drawflag & UI_BUT_ALIGN) {
case UI_BUT_ALIGN_TOP:
roundbox = UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT;
break;
@@ -3232,11 +3249,6 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
fstyle = &style->widgetlabel;
}
break;
-
- case LISTLABEL:
- wt = widget_type(UI_WTYPE_LISTLABEL);
- fstyle = &style->widgetlabel;
- break;
case SEPR:
break;
@@ -3282,7 +3294,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case OPTIONN:
if (!(but->flag & UI_HAS_ICON)) {
wt = widget_type(UI_WTYPE_OPTION);
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
}
else
wt = widget_type(UI_WTYPE_TOGGLE);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index ace35f0276e..55b353b1031 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1406,6 +1406,7 @@ void init_userdef_do_versions(void)
}
if (U.pad_rot_angle == 0)
U.pad_rot_angle = 15;
+
/* graph editor - unselected F-Curve visibility */
if (U.fcu_inactive_alpha == 0) {
U.fcu_inactive_alpha = 0.25f;
@@ -2224,7 +2225,14 @@ void init_userdef_do_versions(void)
rgba_char_args_test_set(btheme->tima.uv_shadow, 112, 112, 112, 255);
}
}
-
+
+ if (U.versionfile < 270) {
+ /* grease pencil - new layer color */
+ if (U.gpencil_new_layer_col[3] < 0.1f) {
+ /* defaults to black, but must at least be visible! */
+ U.gpencil_new_layer_col[3] = 0.9f;
+ }
+ }
if (U.pixelsize == 0.0f)
U.pixelsize = 1.0f;
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 00113666872..c5c9b1c8ce4 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -284,10 +284,9 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int view_pan_cancel(bContext *UNUSED(C), wmOperator *op)
+static void view_pan_cancel(bContext *UNUSED(C), wmOperator *op)
{
view_pan_exit(op);
- return OPERATOR_CANCELLED;
}
static void VIEW2D_OT_pan(wmOperatorType *ot)
@@ -906,11 +905,9 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
}
}
-static int view_zoomdrag_cancel(bContext *C, wmOperator *op)
+static void view_zoomdrag_cancel(bContext *C, wmOperator *op)
{
view_zoomdrag_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
/* for 'redo' only, with no user input */
@@ -1579,11 +1576,9 @@ static void scroller_activate_exit(bContext *C, wmOperator *op)
}
}
-static int scroller_activate_cancel(bContext *C, wmOperator *op)
+static void scroller_activate_cancel(bContext *C, wmOperator *op)
{
scroller_activate_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
/* apply transform to view (i.e. adjust 'cur' rect) */
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 4cc9d3b59b1..7a78d60e11e 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -385,7 +385,7 @@ static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2]
setup_vertex_point(mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f);
/* TODO - we could pass the spline! */
- BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE);
+ BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, true, true);
masklay->act_spline = spline;
masklay->act_point = new_point;
@@ -486,7 +486,7 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay,
if (masklay->splines_shapes.first) {
point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
- BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, TRUE, TRUE);
+ BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, true, true);
}
if (do_recalc_src) {
@@ -548,7 +548,7 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con
{
int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
- BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, TRUE, TRUE);
+ BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, true, true);
}
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c
index d5fbdca5b0a..78dba382520 100644
--- a/source/blender/editors/mask/mask_shapekey.c
+++ b/source/blender/editors/mask/mask_shapekey.c
@@ -69,7 +69,7 @@ static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op))
continue;
}
- masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, frame);
+ masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame);
BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
change = TRUE;
}
@@ -319,8 +319,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
masklay_shape_tmp;
masklay_shape_tmp = masklay_shape_tmp->next)
{
- BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, TRUE);
- masklay_shape_tmp_rekey = BKE_mask_layer_shape_varify_frame(masklay, masklay_shape_tmp->frame);
+ BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, true);
+ masklay_shape_tmp_rekey = BKE_mask_layer_shape_verify_frame(masklay, masklay_shape_tmp->frame);
BKE_mask_layer_shape_from_mask(masklay, masklay_shape_tmp_rekey);
masklay_shape_tmp_rekey->flag = masklay_shape_tmp->flag & MASK_SHAPE_SELECT;
}
@@ -376,7 +376,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
}
/* re-evaluate */
- BKE_mask_layer_evaluate(masklay, frame, TRUE);
+ BKE_mask_layer_evaluate(masklay, frame, true);
}
}
@@ -417,7 +417,7 @@ void ED_mask_layer_shape_auto_key(MaskLayer *masklay, const int frame)
{
MaskLayerShape *masklay_shape;
- masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, frame);
+ masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame);
BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
}
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 7944c2f0cca..9e1785e27d1 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -797,7 +797,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
if (em) {
if (skip_em_vert_array_init == false) {
- EDBM_index_arrays_ensure(em, BM_VERT);
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT);
}
}
@@ -822,8 +822,8 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
if ((a == totvert) || (topo_pairs[a - 1].hash != topo_pairs[a].hash)) {
if (a - last == 2) {
if (em) {
- index_lookup[topo_pairs[a - 1].v_index] = (intptr_t)EDBM_vert_at_index(em, topo_pairs[a - 2].v_index);
- index_lookup[topo_pairs[a - 2].v_index] = (intptr_t)EDBM_vert_at_index(em, topo_pairs[a - 1].v_index);
+ index_lookup[topo_pairs[a - 1].v_index] = (intptr_t)BM_vert_at_index(em->bm, topo_pairs[a - 2].v_index);
+ index_lookup[topo_pairs[a - 2].v_index] = (intptr_t)BM_vert_at_index(em->bm, topo_pairs[a - 1].v_index);
}
else {
index_lookup[topo_pairs[a - 1].v_index] = topo_pairs[a - 2].v_index;
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 97da0047793..ddb58cd6c7b 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -131,6 +131,7 @@ static bool edbm_bevel_calc(wmOperator *op)
BMEditMesh *em = opdata->em;
BMOperator bmop;
const float offset = RNA_float_get(op->ptr, "offset");
+ const int offset_type = RNA_enum_get(op->ptr, "offset_type");
const int segments = RNA_int_get(op->ptr, "segments");
const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only");
@@ -140,8 +141,8 @@ static bool edbm_bevel_calc(wmOperator *op)
}
EDBM_op_init(em, &bmop, op,
- "bevel geom=%hev offset=%f segments=%i vertex_only=%b",
- BM_ELEM_SELECT, offset, segments, vertex_only);
+ "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i",
+ BM_ELEM_SELECT, offset, segments, vertex_only, offset_type);
BMO_op_exec(em->bm, &bmop);
@@ -185,7 +186,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op)
op->customdata = NULL;
}
-static int edbm_bevel_cancel(bContext *C, wmOperator *op)
+static void edbm_bevel_cancel(bContext *C, wmOperator *op)
{
BevelData *opdata = op->customdata;
if (opdata->is_modal) {
@@ -197,7 +198,6 @@ static int edbm_bevel_cancel(bContext *C, wmOperator *op)
/* need to force redisplay or we may still view the modified result */
ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_CANCELLED;
}
/* bevel! yay!!*/
@@ -257,12 +257,14 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event)
{
BevelData *opdata = op->customdata;
- int use_dist = true;
+ bool use_dist = true;
+ bool is_percent = false;
float mdiff[2];
float factor;
mdiff[0] = opdata->mcenter[0] - event->mval[0];
mdiff[1] = opdata->mcenter[1] - event->mval[1];
+ is_percent = (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT);
if (use_dist) {
factor = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length) * opdata->pixel_size;
@@ -287,7 +289,13 @@ static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event)
if (factor < 0.0f) factor = 0.0f;
}
else {
- CLAMP(factor, 0.0f, 1.0f);
+ if (is_percent) {
+ factor *= 100.0f;
+ CLAMP(factor, 0.0f, 100.0f);
+ }
+ else {
+ CLAMP(factor, 0.0f, 1.0f);
+ }
}
return factor;
@@ -362,6 +370,14 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
void MESH_OT_bevel(wmOperatorType *ot)
{
+ static EnumPropertyItem offset_type_items[] = {
+ {BEVEL_AMT_OFFSET, "OFFSET", 0, "Offset", "Amount is offset of new edges from original"},
+ {BEVEL_AMT_WIDTH, "WIDTH", 0, "Width", "Amount is width of new face"},
+ {BEVEL_AMT_DEPTH, "DEPTH", 0, "Depth", "Amount is perpendicular distance from original edge to bevel face"},
+ {BEVEL_AMT_PERCENT, "PERCENT", 0, "Percent", "Amount is percent of adjacent edge length"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
/* identifiers */
ot->name = "Bevel";
ot->description = "Edge Bevel";
@@ -377,7 +393,8 @@ void MESH_OT_bevel(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING;
- RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Offset", "", 0.0f, 1.0f);
+ RNA_def_enum(ot->srna, "offset_type", offset_type_items, 0, "Amount Type", "What distance Amount measures");
+ RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Amount", "", 0.0f, 1.0f);
RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8);
RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex only", "Bevel only vertices");
}
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index 5431b1deb1c..7bc3ff3ab77 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -203,7 +203,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
RNA_property_float_get_array(op->ptr, prop_plane_co, plane_co);
}
else {
- copy_v3_v3(plane_co, give_cursor(scene, v3d));
+ copy_v3_v3(plane_co, ED_view3d_cursor3d_get(scene, v3d));
RNA_property_float_set_array(op->ptr, prop_plane_co, plane_co);
}
@@ -300,7 +300,7 @@ void MESH_OT_bisect(struct wmOperatorType *ot)
/* identifiers */
ot->name = "Bisect";
- ot->description = "Cut geometry along a plane";
+ ot->description = "Cut geometry along a plane (click-drag to define plane)";
ot->idname = "MESH_OT_bisect";
/* api callbacks */
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 3df4ad738ae..ef300fa9db6 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -377,7 +377,6 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe
BKE_object_handle_update(scene, obedit);
/* individual faces? */
-// BIF_TransformSetUndo("Extrude");
if (nr == 2) {
// initTransform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_MIRROR);
// Transform();
@@ -654,7 +653,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
BM_ELEM_SELECT, min);
}
else {
- const float *curs = give_cursor(vc.scene, vc.v3d);
+ const float *curs = ED_view3d_cursor3d_get(vc.scene, vc.v3d);
BMOperator bmop;
BMOIter oiter;
@@ -752,7 +751,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
- RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
+ RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d));
RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[2]);
return edbm_spin_exec(C, op);
@@ -872,7 +871,7 @@ static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
- RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
+ RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d));
RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[1]);
return edbm_screw_exec(C, op);
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index eb66cf50a1e..137554459ce 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -166,7 +166,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op)
MEM_freeN(op->customdata);
}
-static int edbm_inset_cancel(bContext *C, wmOperator *op)
+static void edbm_inset_cancel(bContext *C, wmOperator *op)
{
InsetData *opdata;
@@ -180,7 +180,6 @@ static int edbm_inset_cancel(bContext *C, wmOperator *op)
/* need to force redisplay or we may still view the modified result */
ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_CANCELLED;
}
static bool edbm_inset_calc(wmOperator *op)
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index b0dc30d73f7..6b99f53a5b8 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -76,6 +76,7 @@
#define KNIFE_FLT_EPS 0.00001f
#define KNIFE_FLT_EPS_SQUARED (KNIFE_FLT_EPS * KNIFE_FLT_EPS)
+#define KNIFE_FLT_EPSBIG 0.001f
typedef struct KnifeColors {
unsigned char line[3];
@@ -111,16 +112,20 @@ typedef struct KnifeEdge {
bool draw;
} KnifeEdge;
-typedef struct BMEdgeHit {
- KnifeEdge *kfe;
+typedef struct KnifeLineHit {
float hit[3], cagehit[3];
- float realhit[3]; /* used in midpoint mode */
float schit[2];
float l; /* lambda along cut line */
float perc; /* lambda along hit line */
- KnifeVert *v; /* set if snapped to a vert */
+ float m; /* depth front-to-back */
+
+ /* Exactly one of kfe, v, or f should be non-NULL,
+ * saying whether cut line crosses and edge,
+ * is snapped to a vert, or is in the middle of some face. */
+ KnifeEdge *kfe;
+ KnifeVert *v;
BMFace *f;
-} BMEdgeHit;
+} KnifeLineHit;
typedef struct KnifePosData {
float co[3];
@@ -152,8 +157,8 @@ typedef struct KnifeTool_OpData {
GHash *origvertmap;
GHash *origedgemap;
-
GHash *kedgefacemap;
+ GHash *facetrimap;
BMBVHTree *bmbvh;
@@ -164,7 +169,7 @@ typedef struct KnifeTool_OpData {
float ethresh;
/* used for drag-cutting */
- BMEdgeHit *linehits;
+ KnifeLineHit *linehits;
int totlinehit;
/* Data for mouse-position-derived data (cur) and previous click (prev) */
@@ -198,7 +203,7 @@ typedef struct KnifeTool_OpData {
} mode;
int prevmode;
- bool snap_midpoints, extend;
+ bool snap_midpoints;
bool ignore_edge_snapping;
bool ignore_vert_snapping;
@@ -215,13 +220,11 @@ typedef struct KnifeTool_OpData {
static ListBase *knife_get_face_kedges(KnifeTool_OpData *kcd, BMFace *f);
-#if 0
-static void knife_input_ray_cast(KnifeTool_OpData *kcd, const float mval[2],
- float r_origin[3], float r_ray[3]);
-#endif
static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], const float ofs,
float r_origin[3], float r_dest[3]);
+static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f);
+
static void knife_update_header(bContext *C, KnifeTool_OpData *kcd)
{
#define HEADER_LENGTH 256
@@ -238,13 +241,6 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd)
ED_area_headerprint(CTX_wm_area(C), header);
}
-#if 0
-BLI_INLINE int round_ftoi(float x)
-{
- return x > 0.0f ? (int)(x + 0.5f) : (int)(x - 0.5f);
-}
-#endif
-
static void knife_project_v2(const KnifeTool_OpData *kcd, const float co[3], float sco[2])
{
ED_view3d_project_float_v2_m4(kcd->ar, co, sco, (float (*)[4])kcd->projmat);
@@ -290,6 +286,12 @@ static Ref *find_ref(ListBase *lb, void *ref)
return NULL;
}
+static void knife_append_list_no_dup(KnifeTool_OpData *kcd, ListBase *lst, void *elem)
+{
+ if (!find_ref(lst, elem))
+ knife_append_list(kcd, lst, elem);
+}
+
static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd)
{
kcd->totkedge++;
@@ -346,12 +348,17 @@ static KnifeVert *new_knife_vert(KnifeTool_OpData *kcd, const float co[3], const
static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v)
{
KnifeVert *kfv = BLI_ghash_lookup(kcd->origvertmap, v);
+ const float *cageco;
if (!kfv) {
BMIter bmiter;
BMFace *f;
- kfv = new_knife_vert(kcd, v->co, kcd->cagecos[BM_elem_index_get(v)]);
+ if (BM_elem_index_get(v) >= 0)
+ cageco = kcd->cagecos[BM_elem_index_get(v)];
+ else
+ cageco = v->co;
+ kfv = new_knife_vert(kcd, v->co, cageco);
kfv->v = v;
BLI_ghash_insert(kcd->origvertmap, v, kfv);
BM_ITER_ELEM (f, &bmiter, v, BM_FACES_OF_VERT) {
@@ -387,6 +394,45 @@ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e)
return kfe;
}
+/* Record the index in kcd->em->looptris of first looptri triple for a given face,
+ * given an index for some triple in that array.
+ * This assumes that all of the triangles for a given face are contiguous
+ * in that array (as they are by the current tesselation routines).
+ * Actually store index + 1 in the hash, because 0 looks like "no entry"
+ * to hash lookup routine; will reverse this in the get routine.
+ * Doing this lazily rather than all at once for all faces.
+ */
+static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index)
+{
+ int i;
+
+ if (BLI_ghash_lookup(kcd->facetrimap, f))
+ return;
+
+ BLI_assert(index >= 0 && index < kcd->em->tottri);
+ BLI_assert(kcd->em->looptris[index][0]->f == f);
+ for (i = index - 1; i >= 0; i--) {
+ if (kcd->em->looptris[i][0]->f != f) {
+ i++;
+ break;
+ }
+ }
+ if (i == -1)
+ i++;
+
+ BLI_ghash_insert(kcd->facetrimap, f, SET_INT_IN_POINTER(i + 1));
+}
+
+/* This should only be called for faces that have had a lowest face tri set by previous function */
+static int get_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f)
+{
+ int ans;
+
+ ans = GET_INT_FROM_POINTER(BLI_ghash_lookup(kcd->facetrimap, f));
+ BLI_assert(ans != 0);
+ return ans - 1;
+}
+
/* User has just clicked for first time or first time after a restart (E key).
* Copy the current position data into prev. */
static void knife_start_cut(KnifeTool_OpData *kcd)
@@ -400,7 +446,7 @@ static void knife_start_cut(KnifeTool_OpData *kcd)
BMVert *v0;
knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs);
- v0 = BM_vert_at_index(kcd->em->bm, 0);
+ v0 = BM_vert_at_index_find(kcd->em->bm, 0);
if (v0) {
closest_to_line_v3(kcd->prev.cage, v0->co, origin_ofs, origin);
copy_v3_v3(kcd->prev.co, kcd->prev.cage); /*TODO: do we need this? */
@@ -430,12 +476,6 @@ static ListBase *knife_get_face_kedges(KnifeTool_OpData *kcd, BMFace *f)
return lst;
}
-/* finds the proper face to restrict face fill to */
-static void knife_find_basef(KnifeEdge *kfe)
-{
- kfe->basef = knife_find_common_face(&kfe->v1->faces, &kfe->v2->faces);
-}
-
static void knife_edge_append_face(KnifeTool_OpData *kcd, KnifeEdge *kfe, BMFace *f)
{
knife_append_list(kcd, knife_get_face_kedges(kcd, f), kfe);
@@ -493,471 +533,272 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd, KnifeEdge *kfe, float
return newkfe->v2;
}
-/* Make a single KnifeEdge for cut from kcd->prev to kcd->curr.
- * and move cur data to prev. */
-static void knife_add_single_cut(KnifeTool_OpData *kcd)
+/* primary key: lambda along cut
+ * secondary key: lambda along depth
+ * tertiary key: pointer comparisons of verts if both snapped to verts
+ */
+static int linehit_compare(const void *vlh1, const void *vlh2)
{
- KnifeEdge *kfe, *kfe2 = NULL, *kfe3 = NULL;
+ const KnifeLineHit *lh1 = vlh1;
+ const KnifeLineHit *lh2 = vlh2;
- if ((kcd->prev.vert && kcd->prev.vert == kcd->curr.vert) ||
- (kcd->prev.edge && kcd->prev.edge == kcd->curr.edge))
- {
- kcd->prev = kcd->curr;
- return;
- }
-
- kfe = new_knife_edge(kcd);
- kfe->draw = true;
-
- if (kcd->prev.vert) {
- kfe->v1 = kcd->prev.vert;
- }
- else if (kcd->prev.edge) {
- kfe->v1 = knife_split_edge(kcd, kcd->prev.edge, kcd->prev.co, &kfe2);
- }
+ if (lh1->l < lh2->l) return -1;
+ else if (lh1->l > lh2->l) return 1;
else {
- kfe->v1 = new_knife_vert(kcd, kcd->prev.co, kcd->prev.co);
- kfe->v1->draw = kfe->draw = !kcd->prev.is_space;
- kfe->v1->in_space = kcd->prev.is_space;
- kfe->draw = !kcd->prev.is_space;
- kfe->v1->is_face = true;
- if (kfe->v1->draw && kcd->prev.bmface)
- knife_append_list(kcd, &kfe->v1->faces, kcd->prev.bmface);
+ if (lh1->m < lh2->m) return -1;
+ else if (lh1->m > lh2->m) return 1;
+ else {
+ if (lh1->v < lh2->v) return -1;
+ else if (lh1->v > lh2->v) return 1;
+ else return 0;
+ }
}
+}
- if (kcd->curr.vert) {
- kfe->v2 = kcd->curr.vert;
- }
- else if (kcd->curr.edge) {
- kfe->v2 = knife_split_edge(kcd, kcd->curr.edge, kcd->curr.co, &kfe3);
- kcd->curr.vert = kfe->v2;
- }
- else {
- kfe->v2 = new_knife_vert(kcd, kcd->curr.co, kcd->curr.co);
- kfe->v2->draw = !kcd->curr.is_space;
- kfe->v2->is_face = true;
- kfe->v2->in_space = kcd->curr.is_space;
- if (kfe->v2->draw && kcd->curr.bmface)
- knife_append_list(kcd, &kfe->v2->faces, kcd->curr.bmface);
+/*
+ * Sort linehits by distance along cut line, and secondarily from
+ * front to back (from eye), and tertiarily by snap vertex,
+ * and remove any duplicates.
+ */
+static void prepare_linehits_for_cut(KnifeTool_OpData *kcd)
+{
+ KnifeLineHit *linehits, *lhi, *lhj;
+ int i, j, n;
- if (kcd->curr.is_space)
- kfe->draw = false;
+ n = kcd->totlinehit;
+ linehits = kcd->linehits;
+ if (n == 0)
+ return;
- kcd->curr.vert = kfe->v2;
+ qsort(linehits, n, sizeof(KnifeLineHit), linehit_compare);
+
+ /* Remove any edge hits that are preceded or followed
+ * by a vertex hit that is very near. Mark such edge hits using
+ * l == -1 and then do another pass to actually remove.
+ * Also remove all but one of a series of vertex hits for the same vertex. */
+ for (i = 0; i < n; i++) {
+ lhi = &linehits[i];
+ if (lhi->v) {
+ for (j = i - 1; j >= 0; j--) {
+ lhj = &linehits[j];
+ if (!lhj->kfe ||
+ fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG ||
+ fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG)
+ {
+ break;
+ }
+ lhj->l = -1.0f;
+ }
+ for (j = i + 1; j < n; j++) {
+ lhj = &linehits[j];
+ if (fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG ||
+ fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG)
+ {
+ break;
+ }
+ if (lhj->kfe || lhi->v == lhj->v) {
+ lhj->l = -1.0f;
+ }
+ }
+ }
}
- knife_find_basef(kfe);
-
- knife_add_to_vert_edges(kcd, kfe);
-
- if (kfe->basef && !find_ref(&kfe->faces, kfe->basef))
- knife_edge_append_face(kcd, kfe, kfe->basef);
-
- /* sanity check to make sure we're in the right edge/face lists */
- if (kcd->curr.bmface) {
- if (!find_ref(&kfe->faces, kcd->curr.bmface)) {
- knife_edge_append_face(kcd, kfe, kcd->curr.bmface);
+ /* delete-in-place loop: copying from pos j to pos i+1 */
+ i = 0;
+ j = 1;
+ while (j < n) {
+ lhi = &linehits[i];
+ lhj = &linehits[j];
+ if (lhj->l == -1.0f) {
+ j++; /* skip copying this one */
}
-
- if (kcd->prev.bmface && kcd->prev.bmface != kcd->curr.bmface) {
- if (!find_ref(&kfe->faces, kcd->prev.bmface)) {
- knife_edge_append_face(kcd, kfe, kcd->prev.bmface);
+ else {
+ /* copy unless a no-op */
+ if (lhi->l == -1.0f) {
+ /* could happen if linehits[0] is being deleted */
+ memcpy(&linehits[i], &linehits[j], sizeof(KnifeLineHit));
}
+ else {
+ if (i + 1 != j)
+ memcpy(&linehits[i + 1], &linehits[j], sizeof(KnifeLineHit));
+ i++;
+ }
+ j++;
}
}
-
- /* set up for next cut */
- kcd->prev = kcd->curr;
+ kcd->totlinehit = i + 1;
}
-static int verge_linehit(const void *vlh1, const void *vlh2)
+/* Add hit to list of hits in facehits[f], where facehits is a map, if not already there */
+static void add_hit_to_facehits(KnifeTool_OpData *kcd, GHash *facehits, BMFace *f, KnifeLineHit *hit)
{
- const BMEdgeHit *lh1 = vlh1, *lh2 = vlh2;
+ ListBase *lst = BLI_ghash_lookup(facehits, f);
- if (lh1->l < lh2->l) return -1;
- else if (lh1->l > lh2->l) return 1;
- else if (lh1->v && lh2->v) {
- /* want like verts to sort together; just compare pointers */
- if (lh1->v < lh2->v) return -1;
- else if (lh1->v > lh2->v) return 1;
- else return 0;
+ if (!lst) {
+ lst = knife_empty_list(kcd);
+ BLI_ghash_insert(facehits, f, lst);
}
- else return 0;
+ knife_append_list_no_dup(kcd, lst, hit);
}
-/* If there's a linehit connected (same face) as testi in range [firsti, lasti], return the first such, else -1.
- * It also counts as connected if both linehits are snapped to the same vertex.
- * If testi is out of range, look for connection to f instead, if f is non-NULL */
-static int find_connected_linehit(KnifeTool_OpData *kcd, int testi, BMFace *f, int firsti, int lasti)
+static void knife_add_single_cut(KnifeTool_OpData *kcd, KnifeLineHit *lh1, KnifeLineHit *lh2, BMFace *f)
{
- int i;
- ListBase *testfaces, *ifaces;
- BMFace *testface, *iface;
- BMEdgeHit *lh;
- bool shareface;
-
- if (testi >= 0 && testi < kcd->totlinehit) {
- testface = NULL;
- testfaces = NULL;
- lh = &kcd->linehits[testi];
- if (lh->v)
- testfaces = &lh->v->faces;
- else if (lh->kfe)
- testfaces = &lh->kfe->faces;
- else if (lh->f) {
- testfaces = NULL;
- testface = lh->f;
- }
- }
- else {
- testface = f;
- testfaces = NULL;
- }
- for (i = firsti; i <= lasti; i++) {
- shareface = false;
- lh = &kcd->linehits[i];
- iface = NULL;
- ifaces = NULL;
- if (lh->v)
- ifaces = &lh->v->faces;
- else if (lh->kfe)
- ifaces = &lh->kfe->faces;
- else if (lh->f) {
- ifaces = NULL;
- iface = lh->f;
- }
- if (testfaces) {
- if (ifaces)
- shareface = (knife_find_common_face(testfaces, ifaces) != NULL);
- else if (iface)
- shareface = (find_ref(testfaces, iface) != NULL);
- }
- else if (ifaces) {
- if (testface)
- shareface = (find_ref(ifaces, testface) != NULL);
- }
- else if (testface && iface) {
- shareface = (testface == iface);
- }
- if (shareface)
- return i;
- }
- return -1;
-}
-
-/* Sort in order of distance along cut line.
- * Remove any successive linehits that are snapped to the same vertex.
- * If joinfaces, treat hits at same distance as follows: try to find
- * ordering so that preceding and succeeding hits will share a face.
- */
-static void knife_sort_linehits(KnifeTool_OpData *kcd, bool joinfaces)
-{
- int i, j, k, nexti, nsame;
+ KnifeEdge *kfe, *kfe2;
- qsort(kcd->linehits, kcd->totlinehit, sizeof(BMEdgeHit), verge_linehit);
+ if ((lh1->v && lh1->v == lh2->v) ||
+ (lh1->kfe && lh1->kfe == lh2->kfe))
+ {
+ return;
+ }
- /* Remove duplicated linehits snapped to same vertex */
- i = j = 0; /* loop copies from j to i */
- while (j < kcd->totlinehit) {
- nsame = 0;
- if (kcd->linehits[j].v) {
- for (k = j + 1; k < kcd->totlinehit; k++) {
- if (kcd->linehits[k].v != kcd->linehits[j].v)
- break;
- nsame++;
- }
+ /* Check if edge actually lies within face (might not, if this face is concave) */
+ if (lh1->v && lh2->v) {
+ if (!knife_verts_edge_in_face(lh1->v, lh2->v, f)) {
+ return;
}
- if (i != j)
- kcd->linehits[i] = kcd->linehits[j];
- i++;
- j += 1 + nsame;
}
- kcd->totlinehit = i;
- if (!joinfaces)
- return;
+ kfe = new_knife_edge(kcd);
+ kfe->draw = true;
+ kfe->basef = f;
- /* for ranges of equal "l", swap if neccesary to make predecessor and
- * successor faces connected to the linehits at either end of the range */
- for (i = 0; i < kcd->totlinehit - 1; i = nexti) {
- for (j = i + 1; j < kcd->totlinehit; j++) {
- if (fabsf(kcd->linehits[j].l - kcd->linehits[i].l) > KNIFE_FLT_EPS)
- break;
- }
- nexti = j;
- j--;
- nsame = j - i;
- if (nsame > 0) {
- /* find something connected to predecessor of equal range */
- k = find_connected_linehit(kcd, i - 1, kcd->prev.bmface, i, j);
- if (k != -1) {
- if (k != i) {
- SWAP(BMEdgeHit, kcd->linehits[i], kcd->linehits[k]);
- }
- i++;
- nsame--;
- }
- if (nsame > 0) {
- /* find something connected to successor of equal range */
- k = find_connected_linehit(kcd, j + 1, kcd->curr.bmface, i, j);
- if (k != -1 && k != j) {
- SWAP(BMEdgeHit, kcd->linehits[j], kcd->linehits[k]);
- }
- }
- /* rest of same range doesn't matter because we won't connect them */
- }
+ if (lh1->v) {
+ kfe->v1 = lh1->v;
+ }
+ else if (lh1->kfe) {
+ kfe->v1 = knife_split_edge(kcd, lh1->kfe, lh1->cagehit, &kfe2);
+ lh1->v = kfe->v1; /* record the KnifeVert for this hit */
+ }
+ else {
+ BLI_assert(lh1->f);
+ kfe->v1 = new_knife_vert(kcd, lh1->hit, lh1->cagehit);
+ kfe->v1->draw = true;
+ kfe->v1->is_face = true;
+ knife_append_list(kcd, &kfe->v1->faces, lh1->f);
+ lh1->v = kfe->v1; /* record the KnifeVert for this hit */
}
-}
-static void knife_add_single_cut_through(KnifeTool_OpData *kcd, KnifeVert *v1, KnifeVert *v2, BMFace *f)
-{
- KnifeEdge *kfenew;
+ if (lh2->v) {
+ kfe->v2 = lh2->v;
+ }
+ else if (lh2->kfe) {
+ kfe->v2 = knife_split_edge(kcd, lh2->kfe, lh2->cagehit, &kfe2);
+ lh2->v = kfe->v2; /* future uses of lh2 won't split again */
+ }
+ else {
+ BLI_assert(lh2->f);
+ kfe->v2 = new_knife_vert(kcd, lh2->hit, lh2->cagehit);
+ kfe->v2->draw = true;
+ kfe->v2->is_face = true;
+ knife_append_list(kcd, &kfe->v2->faces, lh2->f);
+ lh2->v = kfe->v2; /* record the KnifeVert for this hit */
+ }
- kfenew = new_knife_edge(kcd);
- kfenew->basef = f;
- kfenew->v1 = v1;
- kfenew->v2 = v2;
- kfenew->draw = true;
+ knife_add_to_vert_edges(kcd, kfe);
- knife_add_to_vert_edges(kcd, kfenew);
+ /* TODO: check if this is ever needed */
+ if (kfe->basef && !find_ref(&kfe->faces, kfe->basef))
+ knife_edge_append_face(kcd, kfe, kfe->basef);
- if (!find_ref(&kfenew->faces, f))
- knife_edge_append_face(kcd, kfenew, f);
}
-#if 0
-static void knife_get_vert_faces(KnifeTool_OpData *kcd, KnifeVert *kfv, BMFace *facef, ListBase *lst)
+/* Given a list of KnifeLineHits for one face, sorted by l
+ * and then by m, make the required KnifeVerts and
+ * KnifeEdges.
+ */
+static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits)
{
- BMIter bmiter;
- BMFace *f;
Ref *r;
+ KnifeLineHit *lh, *prevlh;
+ int n;
- if (kfv->is_face && facef) {
- knife_append_list(kcd, lst, facef);
- }
- else if (kfv->v) {
- BM_ITER_ELEM (f, &bmiter, kfv->v, BM_FACES_OF_VERT) {
- knife_append_list(kcd, lst, f);
- }
- }
- else {
- for (r = kfv->faces.first; r; r = r->next) {
- knife_append_list(kcd, lst, r->ref);
- }
- }
-}
+ (void) kcd;
-static void knife_get_edge_faces(KnifeTool_OpData *kcd, KnifeEdge *kfe, ListBase *lst)
-{
- BMIter bmiter;
- BMFace *f;
+ n = BLI_countlist(hits);
+ if (n < 2)
+ return;
- if (kfe->e) {
- BM_ITER_ELEM (f, &bmiter, kfe->e, BM_FACES_OF_EDGE) {
- knife_append_list(kcd, lst, f);
- }
+ prevlh = NULL;
+ for (r = hits->first; r; r = r->next) {
+ lh = (KnifeLineHit *)r->ref;
+ if (prevlh)
+ knife_add_single_cut(kcd, prevlh, lh, f);
+ prevlh = lh;
}
-}
-#endif
-static void copy_hit_from_posdata(BMEdgeHit *lh, KnifePosData *pos, float lambda)
-{
- lh->kfe = pos->edge;
- lh->v = pos->vert;
- lh->f = pos->bmface;
- copy_v3_v3(lh->hit, pos->co);
- copy_v3_v3(lh->cagehit, pos->cage);
- copy_v3_v3(lh->realhit, pos->co);
- lh->l = lambda;
- /* perc and schit not used by callers of this function */
}
-/* BMESH_TODO: add more functionality to cut-through:
- * - cutting "in face" (e.g., holes) should cut in all faces, not just visible one
- * - perhaps improve O(n^2) algorithm used here */
-static void knife_cut_through(KnifeTool_OpData *kcd)
+/* User has just left-clicked after the first time.
+ * Add all knife cuts implied by line from prev to curr.
+ * If that line crossed edges then kcd->linehits will be non-NULL.
+ * Make all of the KnifeVerts and KnifeEdges implied by this cut.
+ */
+static void knife_add_cut(KnifeTool_OpData *kcd)
{
- BMEdgeHit *lh, *lh2, *linehits;
+ int i;
+ KnifeLineHit *lh;
+ GHash *facehits;
BMFace *f;
- KnifeEdge *kfe, *kfe2;
- KnifeVert *v1, *v2, *lastv;
- ListBase *faces1, *faces2;
- KnifeEdge **splitkfe;
- bool needprev, needcurr;
- int i, j, n;
+ Ref *r;
+ GHashIterator giter;
+ ListBase *lst;
- if (!kcd->totlinehit) {
- /* if no linehits then no interesting back face stuff to do */
- knife_add_single_cut(kcd);
+ prepare_linehits_for_cut(kcd);
+ if (kcd->totlinehit == 0) {
+ kcd->prev = kcd->curr;
return;
}
- /* sort eliminates hits on same vertices */
- knife_sort_linehits(kcd, false);
-
- /* code is cleaner if make prev and curr into hits (if they are on edges or verts) */
- n = kcd->totlinehit;
- needprev = ((kcd->prev.vert && kcd->prev.vert != kcd->linehits[0].v) || kcd->prev.edge);
- needcurr = ((kcd->curr.vert && kcd->curr.vert != kcd->linehits[n - 1].v) || kcd->curr.edge);
- n += needprev + needcurr;
- linehits = MEM_callocN(n * sizeof(BMEdgeHit), "knife_cut_through");
- i = 0;
- if (needprev) {
- copy_hit_from_posdata(&linehits[0], &kcd->prev, 0.0f);
- i++;
- }
- memcpy(linehits + i, kcd->linehits, kcd->totlinehit * sizeof(BMEdgeHit));
- i += kcd->totlinehit;
- if (needcurr)
- copy_hit_from_posdata(&linehits[i], &kcd->curr, 1.0f);
-
-
- splitkfe = MEM_callocN(n * sizeof(KnifeEdge *), "knife_cut_through");
-
- lastv = NULL;
- for (i = 0, lh = linehits; i < n; i++, lh++) {
- kfe = lh->kfe;
- v1 = NULL;
-
- /* get faces incident on hit lh */
+ /* make facehits: map face -> list of linehits touching it */
+ facehits = BLI_ghash_ptr_new("knife facehits");
+ for (i = 0; i < kcd->totlinehit; i++) {
+ lh = &kcd->linehits[i];
+ if (lh->f) {
+ add_hit_to_facehits(kcd, facehits, lh->f, lh);
+ }
if (lh->v) {
- v1 = lh->v;
- faces1 = &v1->faces;
+ for (r = lh->v->faces.first; r; r = r->next) {
+ add_hit_to_facehits(kcd, facehits, r->ref, lh);
+ }
}
- else if (kfe) {
- faces1 = &kfe->faces;
+ if (lh->kfe) {
+ for (r = lh->kfe->faces.first; r; r = r->next) {
+ add_hit_to_facehits(kcd, facehits, r->ref, lh);
+ }
}
+ }
- /* For each following hit, connect if lh1 an lh2 share a face */
- for (j = i + 1, lh2 = lh + 1; j < n; j++, lh2++) {
- kfe2 = lh2->kfe;
- v2 = NULL;
- if (lh2->v) {
- v2 = lh2->v;
- faces2 = &v2->faces;
- }
- else if (kfe2) {
- faces2 = &kfe2->faces;
- }
+ /* Note: as following loop progresses, the 'v' fields of
+ * the linehits will be filled in (as edges are split or
+ * in-face verts are made), so it may be true that both
+ * the v and the kfe or f fields will be non-NULL. */
+ GHASH_ITER (giter, facehits) {
+ f = (BMFace *)BLI_ghashIterator_getKey(&giter);
+ lst = (ListBase *)BLI_ghashIterator_getValue(&giter);
+ knife_cut_face(kcd, f, lst);
+ }
- f = knife_find_common_face(faces1, faces2);
- if (f) {
- if (!v1)
- v1 = splitkfe[i] ? kfe->v1 : knife_split_edge(kcd, kfe, lh->hit, &splitkfe[i]);
- if (!v2)
- v2 = splitkfe[j] ? kfe2->v1 : knife_split_edge(kcd, kfe2, lh2->hit, &splitkfe[j]);
- knife_add_single_cut_through(kcd, v1, v2, f);
- lastv = v2;
- }
- }
+ /* set up for next cut */
+ kcd->prev = kcd->curr;
+ if (kcd->prev.bmface) {
+ /* was "in face" but now we have a KnifeVert it is snapped to */
+ kcd->prev.bmface = NULL;
+ kcd->prev.vert = kcd->linehits[kcd->totlinehit - 1].v;
}
- MEM_freeN(splitkfe);
- MEM_freeN(linehits);
+ BLI_ghash_free(facehits, NULL, NULL);
MEM_freeN(kcd->linehits);
kcd->linehits = NULL;
kcd->totlinehit = 0;
-
- /* set up for next cut */
- kcd->curr.vert = lastv;
- kcd->prev = kcd->curr;
}
-/* User has just left-clicked after the first time.
- * Add all knife cuts implied by line from prev to curr.
- * If that line crossed edges then kcd->linehits will be non-NULL. */
-static void knife_add_cut(KnifeTool_OpData *kcd)
+static void knife_finish_cut(KnifeTool_OpData *kcd)
{
- KnifePosData savcur = kcd->curr;
-
- if (kcd->cut_through) {
- knife_cut_through(kcd);
- }
- else if (kcd->linehits) {
- BMEdgeHit *lh, *lastlh, *firstlh;
- int i;
-
- knife_sort_linehits(kcd, true);
-
- lh = kcd->linehits;
- lastlh = firstlh = NULL;
- for (i = 0; i < kcd->totlinehit; i++, (lastlh = lh), lh++) {
- BMFace *f = lastlh ? lastlh->f : lh->f;
-
- if (lastlh && len_squared_v3v3(lastlh->hit, lh->hit) == 0.0f) {
- if (!firstlh)
- firstlh = lastlh;
- continue;
- }
- else if (lastlh && firstlh) {
- if (firstlh->v || lastlh->v) {
- KnifeVert *kfv = firstlh->v ? firstlh->v : lastlh->v;
-
- kcd->prev.vert = kfv;
- copy_v3_v3(kcd->prev.co, firstlh->hit);
- copy_v3_v3(kcd->prev.cage, firstlh->cagehit);
- kcd->prev.edge = NULL;
- kcd->prev.bmface = f;
- /* TODO: should we set prev.in_space = 0 ? */
- }
- lastlh = firstlh = NULL;
- }
-
- if (len_squared_v3v3(kcd->prev.cage, lh->realhit) < KNIFE_FLT_EPS_SQUARED)
- continue;
- if (len_squared_v3v3(kcd->curr.cage, lh->realhit) < KNIFE_FLT_EPS_SQUARED)
- continue;
-
- /* first linehit may be down face parallel to view */
- if (!lastlh && !lh->v && fabsf(lh->l) < KNIFE_FLT_EPS)
- continue;
-
- if (kcd->prev.is_space) {
- kcd->prev.is_space = 0;
- copy_v3_v3(kcd->prev.co, lh->hit);
- copy_v3_v3(kcd->prev.cage, lh->cagehit);
- kcd->prev.vert = lh->v;
- kcd->prev.edge = lh->kfe;
- kcd->prev.bmface = lh->f;
- continue;
- }
-
- kcd->curr.is_space = 0;
- kcd->curr.edge = lh->kfe;
- kcd->curr.bmface = lh->f;
- kcd->curr.vert = lh->v;
- copy_v3_v3(kcd->curr.co, lh->hit);
- copy_v3_v3(kcd->curr.cage, lh->cagehit);
-
- /* don't draw edges down faces parallel to view */
- if (lastlh && fabsf(lastlh->l - lh->l) < KNIFE_FLT_EPS) {
- kcd->prev = kcd->curr;
- continue;
- }
-
- knife_add_single_cut(kcd);
- }
-
- if (savcur.is_space) {
- kcd->prev = savcur;
- }
- else {
- kcd->curr = savcur;
- knife_add_single_cut(kcd);
- }
-
+ if (kcd->linehits) {
MEM_freeN(kcd->linehits);
kcd->linehits = NULL;
kcd->totlinehit = 0;
}
- else {
- knife_add_single_cut(kcd);
- }
-}
-
-static void knife_finish_cut(KnifeTool_OpData *UNUSED(kcd))
-{
-
}
static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd)
@@ -1101,6 +942,24 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glLineWidth(1.0);
}
+ if (kcd->prev.vert) {
+ glColor3ubv(kcd->colors.point);
+ glPointSize(11);
+
+ glBegin(GL_POINTS);
+ glVertex3fv(kcd->prev.cage);
+ glEnd();
+ }
+
+ if (kcd->prev.bmface) {
+ glColor3ubv(kcd->colors.curpoint);
+ glPointSize(9);
+
+ glBegin(GL_POINTS);
+ glVertex3fv(kcd->prev.cage);
+ glEnd();
+ }
+
if (kcd->curr.edge) {
glColor3ubv(kcd->colors.edge);
glLineWidth(2.0);
@@ -1131,10 +990,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
}
if (kcd->totlinehit > 0) {
- const float vthresh4 = kcd->vthresh / 4.0f;
- const float vthresh4_sq = vthresh4 * vthresh4;
-
- BMEdgeHit *lh;
+ KnifeLineHit *lh;
int i;
glEnable(GL_BLEND);
@@ -1146,22 +1002,8 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glBegin(GL_POINTS);
lh = kcd->linehits;
for (i = 0; i < kcd->totlinehit; i++, lh++) {
- float sv1[2], sv2[2];
-
- knife_project_v2(kcd, lh->kfe->v1->cageco, sv1);
- knife_project_v2(kcd, lh->kfe->v2->cageco, sv2);
- knife_project_v2(kcd, lh->cagehit, lh->schit);
-
- if (len_squared_v2v2(lh->schit, sv1) < vthresh4_sq) {
- copy_v3_v3(lh->cagehit, lh->kfe->v1->cageco);
- glVertex3fv(lh->cagehit);
- lh->v = lh->kfe->v1;
- }
- else if (len_squared_v2v2(lh->schit, sv2) < vthresh4_sq) {
- copy_v3_v3(lh->cagehit, lh->kfe->v2->cageco);
+ if (lh->v)
glVertex3fv(lh->cagehit);
- lh->v = lh->kfe->v2;
- }
}
glEnd();
@@ -1171,7 +1013,8 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glBegin(GL_POINTS);
lh = kcd->linehits;
for (i = 0; i < kcd->totlinehit; i++, lh++) {
- glVertex3fv(lh->cagehit);
+ if (!lh->v)
+ glVertex3fv(lh->cagehit);
}
glEnd();
glDisable(GL_BLEND);
@@ -1224,274 +1067,72 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
-static float len_v3_tri_side_max(const float v1[3], const float v2[3], const float v3[3])
-{
- const float s1 = len_squared_v3v3(v1, v2);
- const float s2 = len_squared_v3v3(v2, v3);
- const float s3 = len_squared_v3v3(v3, v1);
-
- return sqrtf(max_fff(s1, s2, s3));
-}
-
-/**
- * given a tri, return 3 planes aligned with the tri's normal.
- *
- * If the triangle were extruded along its normal,
- * the planes calculated would be the 3 sides around the extrusion.
- */
-static void plane_from_tri_clip3_v3(
- float tri_plane_clip[3][4],
- const float v0[3], const float v1[3], const float v2[3])
-{
- float tri_norm[3];
- float tvec[3], cross[3];
-
- normal_tri_v3(tri_norm, v0, v1, v2);
-
- sub_v3_v3v3(tvec, v0, v1);
- cross_v3_v3v3(cross, tvec, tri_norm);
- plane_from_point_normal_v3(tri_plane_clip[0], v0, cross);
-
- sub_v3_v3v3(tvec, v1, v2);
- cross_v3_v3v3(cross, tvec, tri_norm);
- plane_from_point_normal_v3(tri_plane_clip[1], v1, cross);
-
- sub_v3_v3v3(tvec, v2, v0);
- cross_v3_v3v3(cross, tvec, tri_norm);
- plane_from_point_normal_v3(tri_plane_clip[2], v2, cross);
-}
-
-/**
- * Given a line that is planar with a tri, clip the segment by that tri.
- *
- * This is needed so we end up with both points in the triangle.
- */
-static bool isect_line_tri_coplanar_v3(
- const float p1[3], const float p2[3],
- const float v0[3], const float v1[3], const float v2[3],
- float r_isects[2][3],
-
- /* avoid re-calculating every time */
- float tri_plane[4], float tri_plane_clip[3][4])
-{
- float p1_tmp[3] = {UNPACK3(p1)};
- float p2_tmp[3] = {UNPACK3(p2)};
-
- (void)v0, (void)v1, (void)v2;
-
- /* first check if the points are planar with the tri */
- if ((fabsf(dist_squared_to_plane_v3(p1, tri_plane)) < KNIFE_FLT_EPS_SQUARED) &&
- (fabsf(dist_squared_to_plane_v3(p2, tri_plane)) < KNIFE_FLT_EPS_SQUARED) &&
- /* clip the segment by planes around the triangle so we can be sure the points
- * aren't outside the triangle */
- (clip_segment_v3_plane_n(p1_tmp, p2_tmp, tri_plane_clip, 3)))
- {
- copy_v3_v3(r_isects[0], p1_tmp);
- copy_v3_v3(r_isects[1], p2_tmp);
-
- return true;
- }
- else {
- return false;
- }
-}
-
-static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree,
- const float v1[3], const float v2[3], const float v3[3],
- SmallHash *ehash, bglMats *mats, int *count)
-{
- BVHTree *tree2 = BLI_bvhtree_new(3, FLT_EPSILON * 4, 8, 8), *tree = BKE_bmbvh_tree_get(bmtree);
- BMEdgeHit *edges = NULL;
- BLI_array_declare(edges);
- BVHTreeOverlap *results, *result;
- BMLoop **ls;
- float cos[9], tri_norm[3], tri_plane[4], isects[2][3], lambda;
- float tri_plane_clip[3][4];
- unsigned int tot = 0;
- int i, j, n_isects;
-
-
- /* for comparing distances, error of intersection depends on triangle scale.
- * need to scale down before squaring for accurate comparison */
- const float depsilon = (FLT_EPSILON / 2.0f) * len_v3_tri_side_max(v1, v2, v3);
- const float depsilon_sq = depsilon * depsilon;
-
- copy_v3_v3(cos + 0, v1);
- copy_v3_v3(cos + 3, v2);
- copy_v3_v3(cos + 6, v3);
-
- /* avoid re-calculation in #isect_line_tri_coplanar_v3 */
- normal_tri_v3(tri_norm, v1, v2, v3);
- plane_from_point_normal_v3(tri_plane, v1, tri_norm);
- plane_from_tri_clip3_v3(tri_plane_clip, v1, v2, v3);
-
- BLI_bvhtree_insert(tree2, 0, cos, 3);
- BLI_bvhtree_balance(tree2);
-
- result = results = BLI_bvhtree_overlap(tree, tree2, &tot);
-
- for (i = 0; i < tot; i++, result++) {
- BMLoop *l1;
- BMFace *f_hit;
- ListBase *lst;
- Ref *ref;
-
- ls = (BMLoop **)kcd->em->looptris[result->indexA];
-
- l1 = ls[0];
- lst = knife_get_face_kedges(kcd, l1->f);
-
- for (ref = lst->first; ref; ref = ref->next) {
- KnifeEdge *kfe = ref->ref;
-
- if (BLI_smallhash_haskey(ehash, (uintptr_t)kfe)) {
- continue; /* We already found a hit on this knife edge */
- }
+/* Find intersection of v1-v2 with face f.
+ * Only take intersections that are at least face_tol (in screen space) away
+ * from other intersection elements.
+ * If v1-v2 is coplanar with f, call that "no intersection though
+ * it really means "infinite number of intersections".
+ * In such a case we should have gotten hits on edges or verts of the face. */
+static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
+ const float s[2],
+ const float v1[2], const float v2[2],
+ BMFace *f,
+ const float face_tol,
+ float intersectp[3])
+{
+ int tottri, tri_i;
+ float lv1[3], lv2[3], lv3[3], raydir[3];
+ float tri_norm[3], tri_plane[4];
+ float se1[2], se2[2];
+ float d, lambda;
+ BMLoop **tri;
+ ListBase *lst;
+ Ref *ref;
+ KnifeEdge *kfe;
- n_isects = 0;
+ sub_v3_v3v3(raydir, v2, v1);
+ normalize_v3(raydir);
+ tri_i = get_lowest_face_tri(kcd, f);
+ tottri = kcd->em->tottri;
+ BLI_assert(tri_i >= 0 && tri_i < tottri);
- if (isect_line_tri_coplanar_v3(kfe->v1->cageco, kfe->v2->cageco, v1, v2, v3,
- isects,
- /* cached values */
- tri_plane, tri_plane_clip))
- {
- /* both kfe ends are in cutting triangle */
- n_isects = 2;
- }
- else if (isect_line_tri_epsilon_v3(kfe->v1->cageco, kfe->v2->cageco, v1, v2, v3,
- &lambda, NULL, depsilon))
+ for (; tri_i < tottri; tri_i++) {
+ tri = kcd->em->looptris[tri_i];
+ if (tri[0]->f != f)
+ break;
+ copy_v3_v3(lv1, kcd->cagecos[BM_elem_index_get(tri[0]->v)]);
+ copy_v3_v3(lv2, kcd->cagecos[BM_elem_index_get(tri[1]->v)]);
+ copy_v3_v3(lv3, kcd->cagecos[BM_elem_index_get(tri[2]->v)]);
+ /* using epsilon test in case ray is directly through an internal
+ * tesselation edge and might not hit either tesselation tri with
+ * an exact test;
+ * we will exclude hits near real edges by a later test */
+ if (isect_ray_tri_epsilon_v3(v1, raydir, lv1, lv2, lv3, &lambda, NULL, KNIFE_FLT_EPS)) {
+ /* check if line coplanar with tri */
+ normal_tri_v3(tri_norm, lv1, lv2, lv3);
+ plane_from_point_normal_v3(tri_plane, lv1, tri_norm);
+ if ((fabsf(dist_squared_to_plane_v3(v1, tri_plane)) < KNIFE_FLT_EPS) &&
+ (fabsf(dist_squared_to_plane_v3(v2, tri_plane)) < KNIFE_FLT_EPS))
{
- /* kfe intersects cutting triangle lambda of the way along kfe */
- interp_v3_v3v3(isects[0], kfe->v1->cageco, kfe->v2->cageco, lambda);
- n_isects = 1;
+ return false;
}
-
- for (j = 0; j < n_isects; j++) {
- float p[3];
-
- copy_v3_v3(p, isects[j]);
- if (kcd->curr.vert && len_squared_v3v3(kcd->curr.vert->cageco, p) < depsilon_sq) {
- continue;
- }
- if (kcd->prev.vert && len_squared_v3v3(kcd->prev.vert->cageco, p) < depsilon_sq) {
- continue;
- }
- if (len_squared_v3v3(kcd->prev.cage, p) < depsilon_sq ||
- len_squared_v3v3(kcd->curr.cage, p) < depsilon_sq)
- {
- continue;
- }
- if ((kcd->vc.rv3d->rflag & RV3D_CLIPPING) &&
- ED_view3d_clipping_test(kcd->vc.rv3d, p, true))
- {
- continue;
- }
-
- if (kcd->cut_through) {
- f_hit = NULL;
- }
- else {
- /* check if this point is visible in the viewport */
- float p1[3], no[3], view[3], sp[2];
- float lambda1;
-
- /* screen projection */
- knife_project_v2(kcd, p, sp);
- ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f);
- mul_m4_v3(kcd->ob->imat, view);
-
- /* if face isn't planer, p may be behind the current tesselated tri,
- * so move it onto that and then a little towards eye */
- if (isect_line_tri_v3(p, view, ls[0]->v->co, ls[1]->v->co, ls[2]->v->co, &lambda1, NULL)) {
- interp_v3_v3v3(p1, p, view, lambda1);
- }
- else {
- copy_v3_v3(p1, p);
- }
- sub_v3_v3(view, p1);
- normalize_v3(view);
-
- copy_v3_v3(no, view);
- mul_v3_fl(no, 0.003);
-
- /* go towards view a bit */
- add_v3_v3(p1, no);
-
- /* ray cast */
- f_hit = BKE_bmbvh_ray_cast(bmtree, p1, no, KNIFE_FLT_EPS, NULL, NULL, NULL);
- }
-
- /* ok, if visible add the new point */
- if (!f_hit && !BLI_smallhash_haskey(ehash, (uintptr_t)kfe)) {
- BMEdgeHit hit;
-
- if (len_squared_v3v3(p, kcd->curr.co) < depsilon_sq ||
- len_squared_v3v3(p, kcd->prev.co) < depsilon_sq)
- {
- continue;
- }
-
- hit.kfe = kfe;
- hit.v = NULL;
- hit.l = 0.0f;
-
- knife_find_basef(kfe);
- hit.f = kfe->basef;
- hit.perc = len_v3v3(p, kfe->v1->cageco) / len_v3v3(kfe->v1->cageco, kfe->v2->cageco);
- copy_v3_v3(hit.cagehit, p);
-
- interp_v3_v3v3(p, kfe->v1->co, kfe->v2->co, hit.perc);
- copy_v3_v3(hit.realhit, p);
-
- if (kcd->snap_midpoints) {
- float perc = hit.perc;
-
- /* select the closest from the edge endpoints or the midpoint */
- if (perc < 0.25f) {
- perc = 0.0f;
- }
- else if (perc < 0.75f) {
- perc = 0.5f;
- }
- else {
- perc = 1.0f;
- }
-
- interp_v3_v3v3(hit.hit, kfe->v1->co, kfe->v2->co, perc);
- interp_v3_v3v3(hit.cagehit, kfe->v1->cageco, kfe->v2->cageco, perc);
- }
- else if (hit.perc < KNIFE_FLT_EPS || hit.perc > 1.0f - KNIFE_FLT_EPS) {
- /* snap to vert */
- hit.v = (hit.perc < KNIFE_FLT_EPS) ? kfe->v1 : kfe->v2;
- copy_v3_v3(hit.hit, hit.v->co);
- copy_v3_v3(hit.cagehit, hit.v->co);
- }
- else {
- copy_v3_v3(hit.hit, p);
- }
- knife_project_v2(kcd, hit.cagehit, hit.schit);
-
- BLI_array_append(edges, hit);
- BLI_smallhash_insert(ehash, (uintptr_t)kfe, NULL);
+ copy_v3_v3(intersectp, v1);
+ madd_v3_v3fl(intersectp, raydir, lambda);
+ /* Now check that far enough away from verts and edges */
+ lst = knife_get_face_kedges(kcd, f);
+ for (ref = lst->first; ref; ref = ref->next) {
+ kfe = ref->ref;
+ knife_project_v2(kcd, kfe->v1->cageco, se1);
+ knife_project_v2(kcd, kfe->v2->cageco, se2);
+ d = dist_to_line_segment_v2(s, se1, se2);
+ if (d < face_tol) {
+ return false;
}
}
+ return true;
}
}
-
- if (results)
- MEM_freeN(results);
-
- BLI_bvhtree_free(tree2);
- *count = BLI_array_count(edges);
-
- return edges;
-}
-
-static void knife_bgl_get_mats(KnifeTool_OpData *UNUSED(kcd), bglMats *mats)
-{
- bgl_get_mats(mats);
- //copy_m4_m4(mats->modelview, kcd->vc.rv3d->viewmat);
- //copy_m4_m4(mats->projection, kcd->vc.rv3d->winmat);
+ return false;
}
/* Calculate maximum excursion from (0,0,0) of mesh */
@@ -1510,6 +1151,43 @@ static void calc_ortho_extent(KnifeTool_OpData *kcd)
kcd->ortho_extent = max_xyz;
}
+/* Check if p is visible (not clipped, not occluded by another face).
+ * s in screen projection of p. */
+static bool point_is_visible(KnifeTool_OpData *kcd, const float p[3], const float s[2], bglMats *mats)
+{
+ float p1[3], no[3], view[3];
+ BMFace *f_hit;
+
+ /* If not cutting through, make sure no face is in front of p */
+ if (!kcd->cut_through) {
+ /* TODO: I think there's a simpler way to get the required raycast ray */
+ ED_view3d_unproject(mats, view, s[0], s[1], 0.0f);
+ mul_m4_v3(kcd->ob->imat, view);
+
+ /* make p1 a little towards view, so ray doesn't hit p's face. */
+ copy_v3_v3(p1, p);
+ sub_v3_v3(view, p1);
+ normalize_v3(view);
+ copy_v3_v3(no, view);
+ mul_v3_fl(no, 3.0f * KNIFE_FLT_EPSBIG);
+ add_v3_v3(p1, no);
+
+ /* see if there's a face hit between p1 and the view */
+ f_hit = BKE_bmbvh_ray_cast(kcd->bmbvh, p1, no, KNIFE_FLT_EPS, NULL, NULL, NULL);
+ if (f_hit)
+ return false;
+ }
+
+ /* If box clipping on, make sure p is not clipped */
+ if (kcd->vc.rv3d->rflag & RV3D_CLIPPING &&
+ ED_view3d_clipping_test(kcd->vc.rv3d, p, true))
+ {
+ return false;
+ }
+
+ return true;
+}
+
/* Clip the line (v1, v2) to planes perpendicular to it and distances d from
* the closest point on the line to the origin */
static void clip_to_ortho_planes(float v1[3], float v2[3], float d)
@@ -1522,16 +1200,49 @@ static void clip_to_ortho_planes(float v1[3], float v2[3], float d)
dist_ensure_v3_v3fl(v2, closest, d);
}
+static void set_linehit_depth(KnifeTool_OpData *kcd, KnifeLineHit *lh)
+{
+ float vnear[3], vfar[3];
+
+ ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, lh->schit, vnear, vfar, true);
+ mul_m4_v3(kcd->ob->imat, vnear);
+ if (kcd->is_ortho) {
+ if (kcd->ortho_extent == 0.0f)
+ calc_ortho_extent(kcd);
+ clip_to_ortho_planes(vnear, vfar, kcd->ortho_extent + 10.0f);
+ }
+ lh->m = len_v3v3(vnear, lh->cagehit);
+}
+
/* Finds visible (or all, if cutting through) edges that intersects the current screen drag line */
static void knife_find_line_hits(KnifeTool_OpData *kcd)
{
bglMats mats;
- BMEdgeHit *e1, *e2;
- SmallHash hash, *ehash = &hash;
- float v1[3], v2[3], v3[3], v4[4], s1[2], s2[2];
- int i, c1, c2;
+ SmallHash faces, kfes, kfvs;
+ float v1[3], v2[3], v3[3], v4[3], s1[2], s2[2];
+ BVHTree *planetree, *tree;
+ BVHTreeOverlap *results, *result;
+ BMLoop **ls;
+ BMFace *f;
+ KnifeEdge *kfe;
+ KnifeVert *v;
+ ListBase *lst;
+ Ref *ref;
+ KnifeLineHit *linehits = NULL;
+ BLI_array_declare(linehits);
+ SmallHashIter hiter;
+ KnifeLineHit hit;
+ void *val;
+ float plane_cos[12];
+ float s[2], se1[2], se2[2], sint[2];
+ float p[3], p2[3], r1[3], r2[3];
+ float d, d1, d2, lambda;
+ float vert_tol, vert_tol_sq, line_tol, face_tol;
+ int isect_kind;
+ unsigned int tot;
+ int i;
- knife_bgl_get_mats(kcd, &mats);
+ bgl_get_mats(&mats);
if (kcd->linehits) {
MEM_freeN(kcd->linehits);
@@ -1568,7 +1279,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
/* numeric error, 'v1' -> 'v2', 'v2' -> 'v4' can end up being ~2000 units apart in otho mode
* (from ED_view3d_win_to_segment_clip() above)
- * this gives precision error in 'knife_edge_tri_isect', rather then solving properly
+ * this gives precision error; rather then solving properly
* (which may involve using doubles everywhere!),
* limit the distance between these points */
if (kcd->is_ortho) {
@@ -1578,70 +1289,176 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
clip_to_ortho_planes(v2, v4, kcd->ortho_extent + 10.0f);
}
- BLI_smallhash_init(ehash);
+ /* First use bvh tree to find faces, knife edges, and knife verts that might
+ * intersect the cut plane with rays v1-v3 and v2-v4.
+ * This deduplicates the candidates before doing more expensive intersection tests. */
+ BLI_smallhash_init(&faces);
+ BLI_smallhash_init(&kfes);
+ BLI_smallhash_init(&kfvs);
+
+ tree = BKE_bmbvh_tree_get(kcd->bmbvh);
+ planetree = BLI_bvhtree_new(4, FLT_EPSILON * 4, 8, 8);
+ copy_v3_v3(plane_cos + 0, v1);
+ copy_v3_v3(plane_cos + 3, v2);
+ copy_v3_v3(plane_cos + 6, v3);
+ copy_v3_v3(plane_cos + 9, v4);
+ BLI_bvhtree_insert(planetree, 0, plane_cos, 4);
+ BLI_bvhtree_balance(planetree);
+
+ results = BLI_bvhtree_overlap(tree, planetree, &tot);
+ if (!results) {
+ BLI_smallhash_release(&faces);
+ BLI_smallhash_release(&kfes);
+ BLI_smallhash_release(&kfvs);
+ BLI_bvhtree_free(planetree);
+ return;
+ }
- /* test two triangles of sceen line's plane */
- e1 = knife_edge_tri_isect(kcd, kcd->bmbvh, v1, v2, v3, ehash, &mats, &c1);
- e2 = knife_edge_tri_isect(kcd, kcd->bmbvh, v2, v3, v4, ehash, &mats, &c2);
- if (c1 && c2) {
- e1 = MEM_reallocN(e1, sizeof(BMEdgeHit) * (c1 + c2));
- memcpy(e1 + c1, e2, sizeof(BMEdgeHit) * c2);
- MEM_freeN(e2);
+ for (i = 0, result = results; i < tot; i++, result++) {
+ ls = (BMLoop **)kcd->em->looptris[result->indexA];
+ f = ls[0]->f;
+ set_lowest_face_tri(kcd, f, result->indexA);
+ /* for faces, store index of lowest hit looptri in hash */
+ if (BLI_smallhash_haskey(&faces, (uintptr_t)f)) {
+ continue;
+ }
+ /* don't care what the value is except that it is non-NULL, for iterator */
+ BLI_smallhash_insert(&faces, (uintptr_t)f, f);
+
+ lst = knife_get_face_kedges(kcd, f);
+ for (ref = lst->first; ref; ref = ref->next) {
+ kfe = ref->ref;
+ if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe))
+ continue;
+ BLI_smallhash_insert(&kfes, (uintptr_t)kfe, kfe);
+ v = kfe->v1;
+ if (!BLI_smallhash_haskey(&kfvs, (uintptr_t)v))
+ BLI_smallhash_insert(&kfvs, (uintptr_t)v, v);
+ v = kfe->v2;
+ if (!BLI_smallhash_haskey(&kfvs, (uintptr_t)v))
+ BLI_smallhash_insert(&kfvs, (uintptr_t)v, v);
+ }
+ }
+
+ /* Now go through the candidates and find intersections */
+ /* These tolerances, in screen space, are for intermediate hits, as ends are already snapped to screen */
+ vert_tol = KNIFE_FLT_EPS * 2000.0f;
+ line_tol = KNIFE_FLT_EPS * 2000.0f;
+ vert_tol_sq = vert_tol * vert_tol;
+ face_tol = max_ff(vert_tol, line_tol);
+ /* Assume these tolerances swamp floating point rounding errors in calculations below */
+
+ /* first look for vertex hits */
+ for (val = BLI_smallhash_iternew(&kfvs, &hiter, (uintptr_t *)&v); val;
+ val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&v))
+ {
+ knife_project_v2(kcd, v->cageco, s);
+ d = dist_squared_to_line_segment_v2(s, s1, s2);
+ if (d <= vert_tol_sq) {
+ if (point_is_visible(kcd, v->cageco, s, &mats)) {
+ memset(&hit, 0, sizeof(hit));
+ hit.v = v;
+ copy_v3_v3(hit.hit, v->cageco);
+ copy_v3_v3(hit.cagehit, v->cageco);
+ copy_v2_v2(hit.schit, s);
+ set_linehit_depth(kcd, &hit);
+ BLI_array_append(linehits, hit);
+ }
+ }
+ }
+ /* now edge hits; don't add if a vertex at end of edge should have hit */
+ for (val = BLI_smallhash_iternew(&kfes, &hiter, (uintptr_t *)&kfe); val;
+ val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&kfe))
+ {
+ knife_project_v2(kcd, kfe->v1->cageco, se1);
+ knife_project_v2(kcd, kfe->v2->cageco, se2);
+ isect_kind = isect_seg_seg_v2_point(s1, s2, se1, se2, sint);
+ if (isect_kind == -1) {
+ /* isect_seg_seg_v2 doesn't do tolerance test around ends of s1-s2 */
+ closest_to_line_segment_v2(sint, s1, se1, se2);
+ if (len_squared_v2v2(sint, s1) <= vert_tol_sq)
+ isect_kind = 1;
+ else {
+ closest_to_line_segment_v2(sint, s2, se1, se2);
+ if (len_squared_v2v2(sint, s2) <= vert_tol_sq)
+ isect_kind = 1;
+ }
+ }
+ if (isect_kind == 1) {
+ d1 = len_v2v2(sint, se1);
+ d2 = len_v2v2(se2, se1);
+ if (!(d1 <= vert_tol || d2 <= vert_tol || fabsf(d1 - d2) <= vert_tol)) {
+ lambda = d1 / d2;
+ /* Can't just interpolate between ends of kfe because
+ * that doesn't work with perspective transformation.
+ * Need to find 3d intersection of ray through sint */
+ knife_input_ray_segment(kcd, sint, 1.0f, r1, r2);
+ isect_kind = isect_line_line_v3(kfe->v1->cageco, kfe->v2->cageco, r1, r2, p, p2);
+ if (isect_kind >= 1 && point_is_visible(kcd, p, sint, &mats)) {
+ memset(&hit, 0, sizeof(hit));
+ hit.kfe = kfe;
+ copy_v3_v3(hit.hit, p);
+ copy_v3_v3(hit.cagehit, p);
+ copy_v2_v2(hit.schit, sint);
+ hit.perc = lambda;
+ set_linehit_depth(kcd, &hit);
+ BLI_array_append(linehits, hit);
+ }
+ }
+ }
}
- else if (c2) {
- e1 = e2;
+ /* now face hits; don't add if a vertex or edge in face should have hit */
+ for (val = BLI_smallhash_iternew(&faces, &hiter, (uintptr_t *)&f); val;
+ val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f))
+ {
+ if (knife_ray_intersect_face(kcd, s1, v1, v3, f, face_tol, p)) {
+ if (point_is_visible(kcd, p, s1, &mats)) {
+ memset(&hit, 0, sizeof(hit));
+ hit.f = f;
+ copy_v3_v3(hit.hit, p);
+ copy_v3_v3(hit.cagehit, p);
+ copy_v2_v2(hit.schit, s1);
+ set_linehit_depth(kcd, &hit);
+ BLI_array_append(linehits, hit);
+ }
+ }
+ if (knife_ray_intersect_face(kcd, s2, v2, v4, f, face_tol, p)) {
+ if (point_is_visible(kcd, p, s2, &mats)) {
+ memset(&hit, 0, sizeof(hit));
+ hit.f = f;
+ copy_v3_v3(hit.hit, p);
+ copy_v3_v3(hit.cagehit, p);
+ copy_v2_v2(hit.schit, s2);
+ set_linehit_depth(kcd, &hit);
+ BLI_array_append(linehits, hit);
+ }
+ }
}
- kcd->linehits = e1;
- kcd->totlinehit = c1 + c2;
+ kcd->linehits = linehits;
+ kcd->totlinehit = BLI_array_count(linehits);
/* find position along screen line, used for sorting */
for (i = 0; i < kcd->totlinehit; i++) {
- BMEdgeHit *lh = e1 + i;
+ KnifeLineHit *lh = kcd->linehits + i;
lh->l = len_v2v2(lh->schit, s1) / len_v2v2(s2, s1);
}
- BLI_smallhash_release(ehash);
-}
-
-/* this works but gives numeric problems [#33400] */
-#if 0
-static void knife_input_ray_cast(KnifeTool_OpData *kcd, const float mval[2],
- float r_origin[3], float r_ray[3])
-{
- bglMats mats;
- float imat[3][3];
-
- knife_bgl_get_mats(kcd, &mats);
-
- /* unproject to find view ray */
- ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f);
-
- if (kcd->is_ortho) {
- negate_v3_v3(r_ray, kcd->vc.rv3d->viewinv[2]);
- }
- else {
- sub_v3_v3v3(r_ray, r_origin, kcd->vc.rv3d->viewinv[3]);
- }
- normalize_v3(r_ray);
-
- /* transform into object space */
- invert_m4_m4(kcd->ob->imat, kcd->ob->obmat);
- copy_m3_m4(imat, kcd->ob->obmat);
- invert_m3(imat);
-
- mul_m4_v3(kcd->ob->imat, r_origin);
- mul_m3_v3(imat, r_ray);
+ BLI_smallhash_release(&faces);
+ BLI_smallhash_release(&kfes);
+ BLI_smallhash_release(&kfvs);
+ BLI_bvhtree_free(planetree);
+ if (results)
+ MEM_freeN(results);
}
-#endif
static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], const float ofs,
float r_origin[3], float r_origin_ofs[3])
{
bglMats mats;
- knife_bgl_get_mats(kcd, &mats);
+ bgl_get_mats(&mats);
/* unproject to find view ray */
ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f);
@@ -1757,7 +1574,8 @@ static float knife_snap_size(KnifeTool_OpData *kcd, float maxsize)
}
/* p is closest point on edge to the mouse cursor */
-static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], float cagep[3], BMFace **fptr, bool *is_space)
+static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], float cagep[3],
+ BMFace **fptr, bool *is_space)
{
BMFace *f;
float co[3], cageco[3], sco[2];
@@ -1867,7 +1685,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo
/* set p to co, in case we don't find anything, means a face cut */
copy_v3_v3(p, co);
- copy_v3_v3(cagep, p);
+ copy_v3_v3(cagep, cageco);
kcd->curr.bmface = f;
if (f) {
@@ -1989,20 +1807,22 @@ static int knife_update_active(KnifeTool_OpData *kcd)
kcd->curr.vert = knife_find_closest_vert(kcd, kcd->curr.co, kcd->curr.cage, &kcd->curr.bmface, &kcd->curr.is_space);
if (!kcd->curr.vert) {
- kcd->curr.edge = knife_find_closest_edge(kcd, kcd->curr.co, kcd->curr.cage, &kcd->curr.bmface, &kcd->curr.is_space);
+ kcd->curr.edge = knife_find_closest_edge(kcd, kcd->curr.co, kcd->curr.cage,
+ &kcd->curr.bmface, &kcd->curr.is_space);
}
/* if no hits are found this would normally default to (0, 0, 0) so instead
* get a point at the mouse ray closest to the previous point.
* Note that drawing lines in `free-space` isn't properly supported
* but theres no guarantee (0, 0, 0) has any geometry either - campbell */
- if (kcd->curr.vert == NULL && kcd->curr.edge == NULL) {
+ if (kcd->curr.vert == NULL && kcd->curr.edge == NULL && kcd->curr.bmface == NULL) {
float origin[3];
float origin_ofs[3];
knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs);
closest_to_line_v3(kcd->curr.cage, kcd->prev.cage, origin_ofs, origin);
+ copy_v3_v3(kcd->curr.co, kcd->curr.cage);
}
if (kcd->mode == MODE_DRAGGING) {
@@ -2011,380 +1831,11 @@ static int knife_update_active(KnifeTool_OpData *kcd)
return 1;
}
-#define SCANFILL_CUTS 0
-#if SCANFILL_CUTS
-
-#define MARK 4
-#define DEL 8
-#define VERT_ON_EDGE 16
-#define VERT_ORIG 32
-#define FACE_FLIP 64
-#define BOUNDARY 128
-#define FACE_NEW 256
-
-typedef struct facenet_entry {
- struct facenet_entry *next, *prev;
- KnifeEdge *kfe;
-} facenet_entry;
-
-static void rnd_offset_co(RNG *rng, float co[3], float scale)
-{
- int i;
-
- for (i = 0; i < 3; i++) {
- co[i] += (BLI_rng_get_float(rng) - 0.5) * scale;
- }
-}
-
-static void remerge_faces(KnifeTool_OpData *kcd)
-{
- BMesh *bm = kcd->em->bm;
- SmallHash svisit, *visit = &svisit;
- BMIter iter;
- BMFace *f;
- BMFace **stack = NULL;
- BLI_array_declare(stack);
- BMFace **faces = NULL;
- BLI_array_declare(faces);
- BMOperator bmop;
- int idx;
-
- BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff edges=%Fe", FACE_NEW, BOUNDARY);
-
- BMO_op_exec(bm, &bmop);
- BMO_slot_buffer_flag_enable(bm, &bmop, "geom.out", BM_FACE, FACE_NEW);
-
- BMO_op_finish(bm, &bmop);
-
- BLI_smallhash_init(visit);
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- BMIter eiter;
- BMEdge *e;
- BMFace *f2;
-
- if (!BMO_elem_flag_test(bm, f, FACE_NEW))
- continue;
-
- if (BLI_smallhash_haskey(visit, (uintptr_t)f))
- continue;
-
- BLI_array_empty(stack);
- BLI_array_empty(faces);
- BLI_array_append(stack, f);
- BLI_smallhash_insert(visit, (uintptr_t)f, NULL);
-
- do {
- f2 = BLI_array_pop(stack);
-
- BLI_array_append(faces, f2);
-
- BM_ITER_ELEM (e, &eiter, f2, BM_EDGES_OF_FACE) {
- BMIter fiter;
- BMFace *f3;
-
- if (BMO_elem_flag_test(bm, e, BOUNDARY))
- continue;
-
- BM_ITER_ELEM (f3, &fiter, e, BM_FACES_OF_EDGE) {
- if (!BMO_elem_flag_test(bm, f3, FACE_NEW))
- continue;
- if (BLI_smallhash_haskey(visit, (uintptr_t)f3))
- continue;
-
- BLI_smallhash_insert(visit, (uintptr_t)f3, NULL);
- BLI_array_append(stack, f3);
- }
- }
- } while (BLI_array_count(stack) > 0);
-
- if (BLI_array_count(faces) > 0) {
- idx = BM_elem_index_get(faces[0]);
-
- f2 = BM_faces_join(bm, faces, BLI_array_count(faces), true);
- if (f2) {
- BMO_elem_flag_enable(bm, f2, FACE_NEW);
- BM_elem_index_set(f2, idx); /* set_dirty! *//* BMESH_TODO, check if this is valid or not */
- }
- }
- }
- /* BMESH_TODO, check if the code above validates the indices */
- /* bm->elem_index_dirty &= ~BM_FACE; */
- bm->elem_index_dirty |= BM_FACE;
-
- BLI_smallhash_release(visit);
-
- BLI_array_free(stack);
- BLI_array_free(faces);
-}
-
-/* use edgenet to fill faces. this is a bit annoying and convoluted.*/
-static void knifenet_fill_faces(KnifeTool_OpData *kcd)
-{
- ScanFillContext sf_ctx;
- BMesh *bm = kcd->em->bm;
- BMIter bmiter;
- BLI_mempool_iter iter;
- BMFace *f;
- BMEdge *e;
- KnifeVert *kfv;
- KnifeEdge *kfe;
- facenet_entry *entry;
- ListBase *face_nets = MEM_callocN(sizeof(ListBase) * bm->totface, "face_nets");
- BMFace **faces = MEM_callocN(sizeof(BMFace *) * bm->totface, "faces knife");
- MemArena *arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "knifenet_fill_faces");
- SmallHash shash;
- RNG *rng;
- int i, j, k = 0, totface = bm->totface;
-
- BMO_push(bm, NULL);
- bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH);
-
- /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
- i = 0;
- BM_ITER_MESH (f, &bmiter, bm, BM_FACES_OF_MESH) {
- BM_elem_index_set(f, i); /* set_inline */
- faces[i] = f;
- i++;
- }
- bm->elem_index_dirty &= ~BM_FACE;
-
- BM_ITER_MESH (e, &bmiter, bm, BM_EDGES_OF_MESH) {
- BMO_elem_flag_enable(bm, e, BOUNDARY);
- }
-
- /* turn knife verts into real verts, as necessary */
- BLI_mempool_iternew(kcd->kverts, &iter);
- for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
- if (!kfv->v) {
- /* shouldn't we be at least copying the normal? - if not some comment here should explain why - campbell */
- kfv->v = BM_vert_create(bm, kfv->co, NULL, BM_CREATE_NOP);
- kfv->flag = 1;
- BMO_elem_flag_enable(bm, kfv->v, DEL);
- }
- else {
- kfv->flag = 0;
- BMO_elem_flag_enable(bm, kfv->v, VERT_ORIG);
- }
-
- BMO_elem_flag_enable(bm, kfv->v, MARK);
- }
-
- /* we want to only do changed faces. first, go over new edges and add to
- * face net lists.*/
- i = j = k = 0;
- BLI_mempool_iternew(kcd->kedges, &iter);
- for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
- Ref *ref;
- if (!kfe->v1 || !kfe->v2 || kfe->v1->inspace || kfe->v2->inspace)
- continue;
-
- i++;
-
- if (kfe->e && kfe->v1->v == kfe->e->v1 && kfe->v2->v == kfe->e->v2) {
- kfe->e_old = kfe->e;
- continue;
- }
-
- j++;
-
- if (kfe->e) {
- kfe->e_old = kfe->e;
-
- BMO_elem_flag_enable(bm, kfe->e, DEL);
- BMO_elem_flag_disable(bm, kfe->e, BOUNDARY);
- kfe->e = NULL;
- }
-
- kfe->e = BM_edge_create(bm, kfe->v1->v, kfe->v2->v, NULL, BM_CREATE_NO_DOUBLE);
- BMO_elem_flag_enable(bm, kfe->e, BOUNDARY);
-
- for (ref = kfe->faces.first; ref; ref = ref->next) {
- f = ref->ref;
-
- entry = BLI_memarena_alloc(arena, sizeof(*entry));
- entry->kfe = kfe;
- BLI_addtail(face_nets + BM_elem_index_get(f), entry);
- }
- }
-
- /* go over original edges, and add to faces with new geometry */
- BLI_mempool_iternew(kcd->kedges, &iter);
- for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
- Ref *ref;
-
- if (!kfe->v1 || !kfe->v2 || kfe->v1->inspace || kfe->v2->inspace)
- continue;
- if (!(kfe->e_old && kfe->v1->v == kfe->e_old->v1 && kfe->v2->v == kfe->e_old->v2))
- continue;
-
- k++;
-
- BMO_elem_flag_enable(bm, kfe->e, BOUNDARY);
- kfe->e_old = kfe->e;
-
- for (ref = kfe->faces.first; ref; ref = ref->next) {
- f = ref->ref;
-
- if (face_nets[BM_elem_index_get(f)].first) {
- entry = BLI_memarena_alloc(arena, sizeof(*entry));
- entry->kfe = kfe;
- BLI_addtail(face_nets + BM_elem_index_get(f), entry);
- }
- }
- }
-
- rng = BLI_rng_new(0);
-
- for (i = 0; i < totface; i++) {
- SmallHash *hash = &shash;
- ScanFillFace *sf_tri;
- ScanFillVert *sf_vert, *sf_vert_last;
- int j;
- float rndscale = (KNIFE_FLT_EPS / 4.0f);
-
- f = faces[i];
- BLI_smallhash_init(hash);
-
- if (face_nets[i].first)
- BMO_elem_flag_enable(bm, f, DEL);
-
- BLI_scanfill_begin(&sf_ctx);
-
- for (entry = face_nets[i].first; entry; entry = entry->next) {
- if (!BLI_smallhash_haskey(hash, (uintptr_t)entry->kfe->v1)) {
- sf_vert = BLI_scanfill_vert_add(&sf_ctx, entry->kfe->v1->v->co);
- sf_vert->poly_nr = 0;
- rnd_offset_co(rng, sf_vert->co, rndscale);
- sf_vert->tmp.p = entry->kfe->v1->v;
- BLI_smallhash_insert(hash, (uintptr_t)entry->kfe->v1, sf_vert);
- }
-
- if (!BLI_smallhash_haskey(hash, (uintptr_t)entry->kfe->v2)) {
- sf_vert = BLI_scanfill_vert_add(&sf_ctx, entry->kfe->v2->v->co);
- sf_vert->poly_nr = 0;
- rnd_offset_co(rng, sf_vert->co, rndscale);
- sf_vert->tmp.p = entry->kfe->v2->v;
- BLI_smallhash_insert(hash, (uintptr_t)entry->kfe->v2, sf_vert);
- }
- }
-
- for (j = 0, entry = face_nets[i].first; entry; entry = entry->next, j++) {
- sf_vert_last = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v1);
- sf_vert = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v2);
-
- sf_vert->poly_nr++;
- sf_vert_last->poly_nr++;
- }
-
- for (j = 0, entry = face_nets[i].first; entry; entry = entry->next, j++) {
- sf_vert_last = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v1);
- sf_vert = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v2);
-
- if (sf_vert->poly_nr > 1 && sf_vert_last->poly_nr > 1) {
- ScanFillEdge *sf_edge;
- sf_edge = BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
- if (entry->kfe->e_old)
- sf_edge->f = SF_EDGE_BOUNDARY; /* mark as original boundary edge */
-
- BMO_elem_flag_disable(bm, entry->kfe->e->v1, DEL);
- BMO_elem_flag_disable(bm, entry->kfe->e->v2, DEL);
- }
- else {
- if (sf_vert_last->poly_nr < 2)
- BLI_remlink(&sf_ctx.fillvertbase, sf_vert_last);
- if (sf_vert->poly_nr < 2)
- BLI_remlink(&sf_ctx.fillvertbase, sf_vert);
- }
- }
-
- BLI_scanfill_calc(&sf_ctx, 0);
-
- for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) {
- BMVert *v1 = sf_tri->v3->tmp.p, *v2 = sf_tri->v2->tmp.p, *v3 = sf_tri->v1->tmp.p;
- BMFace *f2;
- BMLoop *l_iter;
- BMVert *verts[3] = {v1, v2, v3};
-
- if (v1 == v2 || v2 == v3 || v1 == v3)
- continue;
- if (BM_face_exists(bm, verts, 3, &f2))
- continue;
-
- f2 = BM_face_create_quad_tri(bm,
- v1, v2, v3, NULL,
- NULL, false);
-
- BMO_elem_flag_enable(bm, f2, FACE_NEW);
-
- l_iter = BM_FACE_FIRST_LOOP(f2);
- do {
- BMO_elem_flag_disable(bm, l_iter->e, DEL);
- } while ((l_iter = l_iter->next) != BM_FACE_FIRST_LOOP(f2));
-
- BMO_elem_flag_disable(bm, f2, DEL);
- BM_elem_index_set(f2, i); /* set_dirty! *//* note, not 100% sure this is dirty? need to check */
-
- BM_face_normal_update(f2);
- if (dot_v3v3(f->no, f2->no) < 0.0f) {
- BM_face_normal_flip(bm, f2);
- }
- }
-
- BLI_scanfill_end(&sf_ctx);
- BLI_smallhash_release(hash);
- }
- bm->elem_index_dirty |= BM_FACE;
-
- /* interpolate customdata */
- BM_ITER_MESH (f, &bmiter, bm, BM_FACES_OF_MESH) {
- BMLoop *l1;
- BMFace *f2;
- BMIter liter1;
-
- if (!BMO_elem_flag_test(bm, f, FACE_NEW))
- continue;
-
- f2 = faces[BM_elem_index_get(f)];
- if (BM_elem_index_get(f) < 0 || BM_elem_index_get(f) >= totface) {
- fprintf(stderr, "%s: face index out of range! (bmesh internal error)\n", __func__);
- }
-
- BM_elem_attrs_copy(bm, bm, f2, f);
-
- BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) {
- BM_loop_interp_from_face(bm, l1, f2, true, true);
- }
- }
-
- /* merge triangles back into faces */
- remerge_faces(kcd);
-
- /* delete left over faces */
- BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "delete geom=%ff context=%i", DEL, DEL_ONLYFACES);
- BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "delete geom=%fe context=%i", DEL, DEL_EDGES);
- BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "delete geom=%fv context=%i", DEL, DEL_VERTS);
-
- if (face_nets)
- MEM_freeN(face_nets);
- if (faces)
- MEM_freeN(faces);
- BLI_memarena_free(arena);
- BLI_rng_free(rng);
-
- BMO_error_clear(bm); /* remerge_faces sometimes raises errors, so make sure to clear them */
-
- bmesh_edit_end(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH);
- BMO_pop(bm);
-}
-
-#else /* use direct (non-scanfill) method for cuts */
-
/* sort list of kverts by fraction along edge e */
static void sort_by_frac_along(ListBase *lst, BMEdge *e)
{
/* note, since we know the point is along the edge, sort from distance to v1co */
const float *v1co = e->v1->co;
-// const float *v2co = e->v2->co;
Ref *cur = NULL, *prev = NULL, *next = NULL;
if (lst->first == lst->last)
@@ -2392,11 +1843,7 @@ static void sort_by_frac_along(ListBase *lst, BMEdge *e)
for (cur = ((Ref *)lst->first)->next; cur; cur = next) {
KnifeVert *vcur = cur->ref;
-#if 0
- const float vcur_fac = line_point_factor_v3(vcur->co, v1co, v2co);
-#else
const float vcur_fac = len_squared_v3v3(v1co, vcur->co);
-#endif
next = cur->next;
prev = cur->prev;
@@ -2405,13 +1852,8 @@ static void sort_by_frac_along(ListBase *lst, BMEdge *e)
while (prev) {
KnifeVert *vprev = prev->ref;
-#if 0
- if (line_point_factor_v3(vprev->co, v1co, v2co) <= vcur_fac)
- break;
-#else
if (len_squared_v3v3(v1co, vprev->co) <= vcur_fac)
break;
-#endif
prev = prev->prev;
}
@@ -2745,34 +2187,30 @@ static bool find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, L
}
}
-static bool knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BMFace *f)
+static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f)
{
- /* BMesh *bm = kcd->em->bm; */ /* UNUSED */
- BMVert *v1, *v2;
BMLoop *l1, *l2, *l;
float mid[3];
BMIter iter;
int v1inside, v2inside;
- if (!f)
+ if (!f || !v1 || !v2)
return false;
- v1 = kfe->v1->v;
- v2 = kfe->v2->v;
l1 = NULL;
l2 = NULL;
/* find out if v1 and v2, if set, are part of the face */
BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
- if (v1 && l->v == v1)
+ if (v1->v && l->v == v1->v)
l1 = l;
- if (v2 && l->v == v2)
+ if (v2->v && l->v == v2->v)
l2 = l;
}
/* BM_face_point_inside_test uses best-axis projection so this isn't most accurate test... */
- v1inside = l1 ? 0 : BM_face_point_inside_test(f, kfe->v1->co);
- v2inside = l2 ? 0 : BM_face_point_inside_test(f, kfe->v2->co);
+ v1inside = l1 ? 0 : BM_face_point_inside_test(f, v1->co);
+ v2inside = l2 ? 0 : BM_face_point_inside_test(f, v2->co);
if ((l1 && v2inside) || (l2 && v1inside) || (v1inside && v2inside))
return true;
if (l1 && l2) {
@@ -2780,12 +2218,17 @@ static bool knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BM
* BM_face_legal_splits does visibility and self-intersection tests,
* but it is expensive and maybe a bit buggy, so use a simple
* "is the midpoint in the face" test */
- mid_v3_v3v3(mid, kfe->v1->co, kfe->v2->co);
+ mid_v3_v3v3(mid, v1->co, v2->co);
return BM_face_point_inside_test(f, mid);
}
return false;
}
+static bool knife_edge_in_face(KnifeEdge *kfe, BMFace *f)
+{
+ return knife_verts_edge_in_face(kfe->v1, kfe->v2, f);
+}
+
/* Split face f with KnifeEdges on chain. f remains as one side, the face formed is put in *newface.
* The new face will be on the left side of the chain as viewed from the normal-out side of f. */
static void knife_make_chain_cut(KnifeTool_OpData *kcd, BMFace *f, ListBase *chain, BMFace **r_f_new)
@@ -2877,7 +2320,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe
for (ref = kfedges->first; ref; ref = refnext) {
kfe = ref->ref;
refnext = ref->next;
- if (knife_edge_in_face(kcd, kfe, fnew)) {
+ if (knife_edge_in_face(kfe, fnew)) {
BLI_remlink(kfedges, ref);
kfe->basef = fnew;
knife_append_list(kcd, fnew_kfedges, kfe);
@@ -2907,14 +2350,14 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe
return;
}
kfe = ((Ref *)sidechain->first)->ref;
- if (knife_edge_in_face(kcd, kfe, f)) {
+ if (knife_edge_in_face(kfe, f)) {
knife_make_chain_cut(kcd, f, sidechain, &fnew2);
if (fnew2 == NULL) {
return;
}
fhole = f;
}
- else if (knife_edge_in_face(kcd, kfe, fnew)) {
+ else if (knife_edge_in_face(kfe, fnew)) {
knife_make_chain_cut(kcd, fnew, sidechain, &fnew2);
if (fnew2 == NULL) {
return;
@@ -2933,12 +2376,12 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe
for (ref = kfedges->first; ref; ref = refnext) {
kfe = ref->ref;
refnext = ref->next;
- if (knife_edge_in_face(kcd, kfe, fnew)) {
+ if (knife_edge_in_face(kfe, fnew)) {
BLI_remlink(kfedges, ref);
kfe->basef = fnew;
knife_append_list(kcd, fnew_kfedges, kfe);
}
- else if (knife_edge_in_face(kcd, kfe, fnew2)) {
+ else if (knife_edge_in_face(kfe, fnew2)) {
BLI_remlink(kfedges, ref);
kfe->basef = fnew2;
knife_append_list(kcd, fnew2_kfedges, kfe);
@@ -3044,16 +2487,11 @@ static void knife_make_cuts(KnifeTool_OpData *kcd)
BLI_smallhash_release(fhash);
BLI_smallhash_release(ehash);
}
-#endif
/* called on tool confirmation */
static void knifetool_finish_ex(KnifeTool_OpData *kcd)
{
-#if SCANFILL_CUTS
- knifenet_fill_faces(kcd);
-#else
knife_make_cuts(kcd);
-#endif
EDBM_selectmode_flush(kcd->em);
EDBM_mesh_normals_update(kcd->em);
@@ -3096,6 +2534,7 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
BLI_ghash_free(kcd->origedgemap, NULL, NULL);
BLI_ghash_free(kcd->origvertmap, NULL, NULL);
BLI_ghash_free(kcd->kedgefacemap, NULL, NULL);
+ BLI_ghash_free(kcd->facetrimap, NULL, NULL);
BKE_bmbvh_free(kcd->bmbvh);
BLI_memarena_free(kcd->arena);
@@ -3154,17 +2593,15 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(kcd->em, scene, NULL);
- kcd->bmbvh = BKE_bmbvh_new(kcd->em,
- BMBVH_RETURN_ORIG |
- (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN),
- kcd->cagecos, false);
+ kcd->bmbvh = BKE_bmbvh_new_from_editmesh(kcd->em,
+ BMBVH_RETURN_ORIG |
+ (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN),
+ kcd->cagecos, false);
kcd->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), "knife");
kcd->vthresh = KMAXDIST - 1;
kcd->ethresh = KMAXDIST;
- kcd->extend = true;
-
knife_recalc_projmat(kcd);
ED_region_tag_redraw(kcd->ar);
@@ -3175,7 +2612,8 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
kcd->origedgemap = BLI_ghash_ptr_new("knife origedgemap");
kcd->origvertmap = BLI_ghash_ptr_new("knife origvertmap");
- kcd->kedgefacemap = BLI_ghash_ptr_new("knife origvertmap");
+ kcd->kedgefacemap = BLI_ghash_ptr_new("knife kedgefacemap");
+ kcd->facetrimap = BLI_ghash_ptr_new("knife facetrimap");
/* cut all the way through the mesh if use_occlude_geometry button not pushed */
kcd->is_interactive = is_interactive;
@@ -3195,11 +2633,10 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
}
}
-static int knifetool_cancel(bContext *C, wmOperator *op)
+static void knifetool_cancel(bContext *C, wmOperator *op)
{
/* this is just a wrapper around exit() */
knifetool_exit(C, op);
- return OPERATOR_CANCELLED;
}
static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -3382,10 +2819,6 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (kcd->mode == MODE_DRAGGING) {
knife_add_cut(kcd);
- if (!kcd->extend) {
- knife_finish_cut(kcd);
- kcd->mode = MODE_IDLE;
- }
}
else if (kcd->mode != MODE_PANNING) {
knife_start_cut(kcd);
@@ -3476,7 +2909,7 @@ static void edvm_mesh_knife_face_point(BMFace *f, float r_cent[3])
int j;
float const *best_co[3] = {NULL};
- float best_area = -1.0f;
+ float best_area = -1.0f;
bool ok = false;
tottri = BM_face_calc_tessellation(f, loops, index);
@@ -3540,7 +2973,7 @@ static bool edbm_mesh_knife_face_isect(ARegion *ar, LinkNode *polys, BMFace *f,
/**
* \param use_tag When set, tag all faces inside the polylines.
*/
-void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag)
+void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag, bool cut_through)
{
KnifeTool_OpData *kcd;
@@ -3549,7 +2982,6 @@ void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag)
/* init */
{
const bool only_select = false;
- const bool cut_through = false;
const bool is_interactive = false; /* can enable for testing */
kcd = MEM_callocN(sizeof(KnifeTool_OpData), __func__);
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index f473939d0aa..57a85f1162d 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -42,6 +42,9 @@
#include "BKE_editmesh.h"
#include "BKE_report.h"
+#include "RNA_define.h"
+#include "RNA_access.h"
+
#include "MEM_guardedalloc.h"
#include "WM_types.h"
@@ -117,6 +120,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const bool cut_through = RNA_boolean_get(op->ptr, "cut_through");
LinkNode *polys = NULL;
@@ -129,7 +133,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
if (polys) {
- EDBM_mesh_knife(C, polys, true);
+ EDBM_mesh_knife(C, polys, true, cut_through);
/* select only tagged faces */
BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
@@ -166,4 +170,7 @@ void MESH_OT_knife_project(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+
+ /* parameters */
+ RNA_def_boolean(ot->srna, "cut_through", false, "Cut through", "Cut through all faces, not just visible ones");
}
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index ae1007cb98a..9223f6d9450 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -219,7 +219,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select)
}
if (dm) {
- EDBM_index_arrays_ensure(lcd->em, BM_VERT);
+ BM_mesh_elem_table_ensure(lcd->em->bm, BM_VERT);
}
BMW_init(&walker, em->bm, BMW_EDGERING,
@@ -418,11 +418,10 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut)
return 1;
}
-static int ringcut_cancel(bContext *C, wmOperator *op)
+static void ringcut_cancel(bContext *C, wmOperator *op)
{
/* this is just a wrapper around exit() */
ringsel_exit(C, op);
- return OPERATOR_CANCELLED;
}
static void loopcut_update_edge(RingSelOpData *lcd, BMEdge *e, const int previewlines)
@@ -478,8 +477,8 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
else {
const int e_index = RNA_int_get(op->ptr, "edge_index");
BMEdge *e;
- EDBM_index_arrays_ensure(lcd->em, BM_EDGE);
- e = EDBM_edge_at_index(lcd->em, e_index);
+ BM_mesh_elem_table_ensure(lcd->em->bm, BM_EDGE);
+ e = BM_edge_at_index(lcd->em->bm, e_index);
loopcut_update_edge(lcd, e, 0);
}
@@ -549,7 +548,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
ringsel_exit(C, op);
}
else {
- return ringcut_cancel(C, op);
+ ringcut_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
return OPERATOR_FINISHED;
@@ -569,7 +569,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
ED_region_tag_redraw(lcd->ar);
ED_area_headerprint(CTX_wm_area(C), NULL);
- return ringcut_cancel(C, op);
+ ringcut_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
ED_region_tag_redraw(lcd->ar);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index f975d801d10..92bd71e128a 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -392,7 +392,7 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, const float
static bool findnearestvert__backbufIndextest(void *handle, unsigned int index)
{
BMEditMesh *em = (BMEditMesh *)handle;
- BMVert *eve = BM_vert_at_index(em->bm, index - 1);
+ BMVert *eve = BM_vert_at_index_find(em->bm, index - 1);
return !(eve && BM_elem_flag_test(eve, BM_ELEM_SELECT));
}
/**
@@ -420,7 +420,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const bool sel, c
0, NULL, NULL);
}
- eve = index ? BM_vert_at_index(vc->em->bm, index - 1) : NULL;
+ eve = index ? BM_vert_at_index_find(vc->em->bm, index - 1) : NULL;
if (eve && distance < *r_dist) {
*r_dist = distance;
@@ -436,7 +436,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const bool sel, c
static int lastSelectedIndex = 0;
static BMVert *lastSelected = NULL;
- if (lastSelected && BM_vert_at_index(vc->em->bm, lastSelectedIndex) != lastSelected) {
+ if (lastSelected && BM_vert_at_index_find(vc->em->bm, lastSelectedIndex) != lastSelected) {
lastSelectedIndex = 0;
lastSelected = NULL;
}
@@ -512,7 +512,7 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, float *r_dist)
view3d_validate_backbuf(vc);
index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_solidoffs, bm_wireoffs, &distance, 0, NULL, NULL);
- eed = index ? BM_edge_at_index(vc->em->bm, index - 1) : NULL;
+ eed = index ? BM_edge_at_index_find(vc->em->bm, index - 1) : NULL;
if (eed && distance < *r_dist) {
*r_dist = distance;
@@ -585,7 +585,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
view3d_validate_backbuf(vc);
index = view3d_sample_backbuf(vc, vc->mval[0], vc->mval[1]);
- efa = index ? BM_face_at_index(vc->em->bm, index - 1) : NULL;
+ efa = index ? BM_face_at_index_find(vc->em->bm, index - 1) : NULL;
if (efa) {
struct { float mval_fl[2]; float dist; BMFace *toFace; } data;
@@ -612,7 +612,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
static int lastSelectedIndex = 0;
static BMFace *lastSelected = NULL;
- if (lastSelected && BM_face_at_index(vc->em->bm, lastSelectedIndex) != lastSelected) {
+ if (lastSelected && BM_face_at_index_find(vc->em->bm, lastSelectedIndex) != lastSelected) {
lastSelectedIndex = 0;
lastSelected = NULL;
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 9e5782c12f2..203907226e3 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -1615,7 +1615,7 @@ static bool merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob,
const float *vco = NULL;
if (use_cursor) {
- vco = give_cursor(scene, v3d);
+ vco = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(co, vco);
mul_m4_v3(ob->imat, co);
}
@@ -3100,7 +3100,7 @@ void MESH_OT_fill_holes(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "sides", 4, 0, INT_MAX, "Sides", "Number of sides (zero disables)", 0, 100);
+ RNA_def_int(ot->srna, "sides", 4, 0, INT_MAX, "Sides", "Number of sides in hole required to fill (zero fills all holes)", 0, 100);
}
static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
@@ -3124,7 +3124,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
void MESH_OT_beautify_fill(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Beautify Fill";
+ ot->name = "Beautify Faces";
ot->idname = "MESH_OT_beautify_fill";
ot->description = "Rearrange some faces to try to get less degenerated geometry";
@@ -3204,21 +3204,12 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMOperator bmop;
- const bool use_beauty = RNA_boolean_get(op->ptr, "use_beauty");
+ const int quad_method = RNA_enum_get(op->ptr, "quad_method");
+ const int ngon_method = RNA_enum_get(op->ptr, "ngon_method");
- EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty);
+ EDBM_op_init(em, &bmop, op, "triangulate faces=%hf quad_method=%i ngon_method=%i", BM_ELEM_SELECT, quad_method, ngon_method);
BMO_op_exec(em->bm, &bmop);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
-
- /* now call beauty fill */
- if (use_beauty) {
- EDBM_op_call_and_selectf(
- em, op, "geom.out", true,
- "beautify_fill faces=%S edges=%S",
- &bmop, "faces.out", &bmop, "edges.out");
- }
-
if (!EDBM_op_finish(em, &bmop, op, true)) {
return OPERATOR_CANCELLED;
}
@@ -3243,7 +3234,10 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_boolean(ot->srna, "use_beauty", 1, "Beauty", "Use best triangulation division");
+ RNA_def_enum(ot->srna, "quad_method", modifier_triangulate_quad_method_items, MOD_TRIANGULATE_QUAD_BEAUTY,
+ "Quad Method", "Method for splitting the quads into triangles");
+ RNA_def_enum(ot->srna, "ngon_method", modifier_triangulate_ngon_method_items, MOD_TRIANGULATE_NGON_BEAUTY,
+ "Polygon Method", "Method for splitting the polygons into triangles");
}
static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op)
@@ -4712,7 +4706,7 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op)
EDBM_verts_mirror_cache_begin_ex(em, axis, true, true, use_topology, thresh, index);
- EDBM_index_arrays_ensure(em, BM_VERT);
+ BM_mesh_elem_table_ensure(bm, BM_VERT);
BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
@@ -4724,7 +4718,7 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op)
int i_mirr = index[i];
if (i_mirr != -1) {
- BMVert *v_mirr = EDBM_vert_at_index(em, index[i]);
+ BMVert *v_mirr = BM_vert_at_index(bm, index[i]);
if (v != v_mirr) {
float co[3], co_mirr[3];
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index e457f7c45af..697876a3877 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -410,134 +410,6 @@ void EDBM_mesh_free(BMEditMesh *em)
BKE_editmesh_free(em);
}
-
-void EDBM_index_arrays_ensure(BMEditMesh *em, const char htype)
-{
- /* assume if the array is non-null then its valid and no need to recalc */
- const char htype_needed = ((em->vert_index ? 0 : BM_VERT) |
- (em->edge_index ? 0 : BM_EDGE) |
- (em->face_index ? 0 : BM_FACE)) & htype;
-
- BLI_assert((htype & ~BM_ALL_NOLOOP) == 0);
-
- /* in debug mode double check we didn't need to recalculate */
- BLI_assert(EDBM_index_arrays_check(em) == true);
-
- if (htype_needed & BM_VERT) {
- em->vert_index = MEM_mallocN(sizeof(void **) * em->bm->totvert, "em->vert_index");
- }
- if (htype_needed & BM_EDGE) {
- em->edge_index = MEM_mallocN(sizeof(void **) * em->bm->totedge, "em->edge_index");
- }
- if (htype_needed & BM_FACE) {
- em->face_index = MEM_mallocN(sizeof(void **) * em->bm->totface, "em->face_index");
- }
-
-#pragma omp parallel sections if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT)
- {
-#pragma omp section
- {
- if (htype_needed & BM_VERT) {
- BM_iter_as_array(em->bm, BM_VERTS_OF_MESH, NULL, (void **)em->vert_index, em->bm->totvert);
- }
- }
-#pragma omp section
- {
- if (htype_needed & BM_EDGE) {
- BM_iter_as_array(em->bm, BM_EDGES_OF_MESH, NULL, (void **)em->edge_index, em->bm->totedge);
- }
- }
-#pragma omp section
- {
- if (htype_needed & BM_FACE) {
- BM_iter_as_array(em->bm, BM_FACES_OF_MESH, NULL, (void **)em->face_index, em->bm->totface);
- }
- }
- }
-}
-
-/* use EDBM_index_arrays_ensure where possible to avoid full rebuild */
-void EDBM_index_arrays_init(BMEditMesh *em, const char htype)
-{
- BLI_assert((htype & ~BM_ALL_NOLOOP) == 0);
-
- /* force recalc */
- EDBM_index_arrays_free(em);
- EDBM_index_arrays_ensure(em, htype);
-}
-
-void EDBM_index_arrays_free(BMEditMesh *em)
-{
- if (em->vert_index) {
- MEM_freeN(em->vert_index);
- em->vert_index = NULL;
- }
-
- if (em->edge_index) {
- MEM_freeN(em->edge_index);
- em->edge_index = NULL;
- }
-
- if (em->face_index) {
- MEM_freeN(em->face_index);
- em->face_index = NULL;
- }
-}
-
-/* debug check only - no need to optimize */
-#ifndef NDEBUG
-bool EDBM_index_arrays_check(BMEditMesh *em)
-{
- BMIter iter;
- BMElem *ele;
- int i;
-
- if (em->vert_index) {
- BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_VERTS_OF_MESH, i) {
- if (ele != (BMElem *)em->vert_index[i]) {
- return false;
- }
- }
- }
-
- if (em->edge_index) {
- BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_EDGES_OF_MESH, i) {
- if (ele != (BMElem *)em->edge_index[i]) {
- return false;
- }
- }
- }
-
- if (em->face_index) {
- BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_FACES_OF_MESH, i) {
- if (ele != (BMElem *)em->face_index[i]) {
- return false;
- }
- }
- }
-
- return true;
-}
-#endif
-
-BMVert *EDBM_vert_at_index(BMEditMesh *em, int index)
-{
- BLI_assert((index >= 0) && (index < em->bm->totvert));
- return em->vert_index[index];
-}
-
-BMEdge *EDBM_edge_at_index(BMEditMesh *em, int index)
-{
- BLI_assert((index >= 0) && (index < em->bm->totedge));
- return em->edge_index[index];
-}
-
-BMFace *EDBM_face_at_index(BMEditMesh *em, int index)
-{
- BLI_assert((index >= 0) && (index < em->bm->totface));
- return em->face_index[index];
-}
-
void EDBM_selectmode_flush_ex(BMEditMesh *em, const short selectmode)
{
BM_mesh_select_mode_flush_ex(em->bm, selectmode);
@@ -710,7 +582,7 @@ void undo_push_mesh(bContext *C, const char *name)
/**
* Return a new UVVertMap from the editmesh
*/
-UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float limit[2])
+UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool use_select, const float limit[2])
{
BMVert *ev;
BMFace *efa;
@@ -723,15 +595,15 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float
MLoopUV *luv;
unsigned int a;
int totverts, i, totuv;
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
- BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
+ BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
- totverts = em->bm->totvert;
+ totverts = bm->totvert;
totuv = 0;
/* generate UvMapVert array */
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
totuv += efa->len;
}
@@ -754,7 +626,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float
}
a = 0;
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
i = 0;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
@@ -775,7 +647,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float
/* sort individual uvs for each vert */
a = 0;
- BM_ITER_MESH (ev, &iter, em->bm, BM_VERTS_OF_MESH) {
+ BM_ITER_MESH (ev, &iter, bm, BM_VERTS_OF_MESH) {
UvMapVert *newvlist = NULL, *vlist = vmap->vert[a];
UvMapVert *iterv, *v, *lastv, *next;
float *uv, *uv2, uvdiff[2];
@@ -786,10 +658,10 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float
v->next = newvlist;
newvlist = v;
- efa = EDBM_face_at_index(em, v->f);
- /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
+ efa = BM_face_at_index(bm, v->f);
+ /* tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
- l = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa, v->tfindex);
+ l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, v->tfindex);
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
uv = luv->uv;
@@ -798,10 +670,10 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float
while (iterv) {
next = iterv->next;
- efa = EDBM_face_at_index(em, iterv->f);
- /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
+ efa = BM_face_at_index(bm, iterv->f);
+ /* tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
- l = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa, iterv->tfindex);
+ l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, iterv->tfindex);
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
uv2 = luv->uv;
@@ -831,7 +703,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float
}
-UvMapVert *EDBM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v)
+UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v)
{
return vmap->vert[v];
}
@@ -840,7 +712,7 @@ UvMapVert *EDBM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v)
/* A specialized vert map used by stitch operator */
-UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, const bool do_islands)
+UvElementMap *BM_uv_element_map_create(BMesh *bm, const bool selected, const bool do_islands)
{
BMVert *ev;
BMFace *efa;
@@ -860,20 +732,20 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co
BMFace **stack;
int stacksize = 0;
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
- BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
+ BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
- totverts = em->bm->totvert;
+ totverts = bm->totvert;
totuv = 0;
- island_number = MEM_mallocN(sizeof(*stack) * em->bm->totface, "uv_island_number_face");
+ island_number = MEM_mallocN(sizeof(*stack) * bm->totface, "uv_island_number_face");
if (!island_number) {
return NULL;
}
/* generate UvElement array */
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
totuv += efa->len;
}
@@ -893,13 +765,13 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co
buf = element_map->buf = (UvElement *)MEM_callocN(sizeof(*element_map->buf) * totuv, "UvElement");
if (!element_map->vert || !element_map->buf) {
- EDBM_uv_element_map_free(element_map);
+ BM_uv_element_map_free(element_map);
MEM_freeN(island_number);
return NULL;
}
j = 0;
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
island_number[j++] = INVALID_ISLAND;
if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
@@ -918,7 +790,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co
/* sort individual uvs for each vert */
i = 0;
- BM_ITER_MESH (ev, &iter, em->bm, BM_VERTS_OF_MESH) {
+ BM_ITER_MESH (ev, &iter, bm, BM_VERTS_OF_MESH) {
UvElement *newvlist = NULL, *vlist = element_map->vert[i];
UvElement *iterv, *v, *lastv, *next;
float *uv, *uv2, uvdiff[2];
@@ -968,7 +840,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co
if (do_islands) {
/* map holds the map from current vmap->buf to the new, sorted map */
map = MEM_mallocN(sizeof(*map) * totuv, "uvelement_remap");
- stack = MEM_mallocN(sizeof(*stack) * em->bm->totface, "uv_island_face_stack");
+ stack = MEM_mallocN(sizeof(*stack) * bm->totface, "uv_island_face_stack");
islandbuf = MEM_callocN(sizeof(*islandbuf) * totuv, "uvelement_island_buffer");
/* at this point, every UvElement in vert points to a UvElement sharing the same vertex. Now we should sort uv's in islands. */
@@ -1019,7 +891,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co
}
/* remap */
- for (i = 0; i < em->bm->totvert; i++) {
+ for (i = 0; i < bm->totvert; i++) {
/* important since we may do selection only. Some of these may be NULL */
if (element_map->vert[i])
element_map->vert[i] = &islandbuf[map[element_map->vert[i] - element_map->buf]];
@@ -1030,7 +902,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co
MEM_freeN(islandbuf);
MEM_freeN(stack);
MEM_freeN(map);
- EDBM_uv_element_map_free(element_map);
+ BM_uv_element_map_free(element_map);
MEM_freeN(island_number);
}
@@ -1060,7 +932,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co
return element_map;
}
-void EDBM_uv_vert_map_free(UvVertMap *vmap)
+void BM_uv_vert_map_free(UvVertMap *vmap)
{
if (vmap) {
if (vmap->vert) MEM_freeN(vmap->vert);
@@ -1069,7 +941,7 @@ void EDBM_uv_vert_map_free(UvVertMap *vmap)
}
}
-void EDBM_uv_element_map_free(UvElementMap *element_map)
+void BM_uv_element_map_free(UvElementMap *element_map)
{
if (element_map) {
if (element_map->vert) MEM_freeN(element_map->vert);
@@ -1079,7 +951,7 @@ void EDBM_uv_element_map_free(UvElementMap *element_map)
}
}
-UvElement *ED_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l)
+UvElement *BM_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l)
{
UvElement *element;
@@ -1182,7 +1054,7 @@ void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em, const int axis, const bool
struct BMBVHTree *tree = NULL;
MirrTopoStore_t mesh_topo_store = {NULL, -1, -1, -1};
- EDBM_index_arrays_ensure(em, BM_VERT);
+ BM_mesh_elem_table_ensure(bm, BM_VERT);
if (r_index == NULL) {
const char *layer_id = BM_CD_LAYER_ID;
@@ -1204,7 +1076,7 @@ void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em, const int axis, const bool
ED_mesh_mirrtopo_init(me, -1, &mesh_topo_store, true);
}
else {
- tree = BKE_bmbvh_new(em, 0, NULL, false);
+ tree = BKE_bmbvh_new_from_editmesh(em, 0, NULL, false);
}
#define VERT_INTPTR(_v, _i) r_index ? &r_index[_i] : BM_ELEM_CD_GET_VOID_P(_v, cd_vmirr_offset);
@@ -1270,13 +1142,13 @@ BMVert *EDBM_verts_mirror_get(BMEditMesh *em, BMVert *v)
BLI_assert(em->mirror_cdlayer != -1); /* invalid use */
if (mirr && *mirr >= 0 && *mirr < em->bm->totvert) {
- if (!em->vert_index) {
+ if (!em->bm->vtable) {
printf("err: should only be called between "
"EDBM_verts_mirror_cache_begin and EDBM_verts_mirror_cache_end");
return NULL;
}
- return em->vert_index[*mirr];
+ return em->bm->vtable[*mirr];
}
return NULL;
@@ -1335,7 +1207,7 @@ void EDBM_verts_mirror_apply(BMEditMesh *em, const int sel_from, const int sel_t
BMIter iter;
BMVert *v;
- BLI_assert(em->vert_index != NULL);
+ BLI_assert((em->bm->vtable != NULL) && ((em->bm->elem_table_dirty & BM_VERT) == 0));
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT) == sel_from) {
@@ -1447,11 +1319,12 @@ void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_d
}
if (is_destructive) {
- EDBM_index_arrays_free(em);
+ /* TODO. we may be able to remove this now! - Campbell */
+ // BM_mesh_elem_table_free(em->bm, BM_ALL_NOLOOP);
}
else {
/* in debug mode double check we didn't need to recalculate */
- BLI_assert(EDBM_index_arrays_check(em) == true);
+ BLI_assert(BM_mesh_elem_table_check(em->bm) == true);
}
}
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index e8cbf0926d4..f35a46b50d3 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -417,7 +417,7 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set)
}
else {
layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
- if (layernum >= CD_MLOOPCOL) {
+ if (layernum >= MAX_MCOL) {
return -1;
}
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index ed026258e4b..98c145c9ce7 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -116,7 +116,8 @@ void MESH_OT_inset(struct wmOperatorType *ot);
/* *** editmesh_knife.c *** */
void MESH_OT_knife_tool(struct wmOperatorType *ot);
void MESH_OT_knife_project(struct wmOperatorType *ot);
-void EDBM_mesh_knife(struct bContext *C, struct LinkNode *polys, bool use_tag);
+void EDBM_mesh_knife(struct bContext *C, struct LinkNode *polys,
+ bool use_tag, bool cut_through);
struct wmKeyMap *knifetool_modal_keymap(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index 83feed6756f..433fd176217 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -389,7 +389,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
}
/* need to rebuild entirely because array size changes */
- EDBM_index_arrays_init(em, BM_VERT);
+ BM_mesh_elem_table_init(em->bm, BM_VERT);
/* create faces */
for (j = 0; j < trinum; j++) {
@@ -404,9 +404,9 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
face[k] = uniquevbase + tri[k] - nv; /* unique vertex */
}
newFace = BM_face_create_quad_tri(em->bm,
- EDBM_vert_at_index(em, face[0]),
- EDBM_vert_at_index(em, face[2]),
- EDBM_vert_at_index(em, face[1]), NULL,
+ BM_vert_at_index(em->bm, face[0]),
+ BM_vert_at_index(em->bm, face[2]),
+ BM_vert_at_index(em->bm, face[1]), NULL,
NULL, false);
/* set navigation polygon idx to the custom layer */
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index c98ad13acf6..3c42beb8b12 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -29,6 +29,7 @@
*/
#include "DNA_scene_types.h"
+#include "DNA_modifier_types.h"
#include "BLI_math.h"
@@ -244,6 +245,13 @@ void ED_operatormacros_mesh(void)
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", false);
+ ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten", "Extrude Region and Shrink/Fatten",
+ "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
+ otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "mirror", false);
+
ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move",
"Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
@@ -352,9 +360,11 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0);
- RNA_boolean_set(kmi->ptr, "use_beauty", true);
+ RNA_enum_set(kmi->ptr, "quad_method", MOD_TRIANGULATE_QUAD_BEAUTY);
+ RNA_enum_set(kmi->ptr, "ngon_method", MOD_TRIANGULATE_NGON_BEAUTY);
kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
- RNA_boolean_set(kmi->ptr, "use_beauty", false);
+ RNA_enum_set(kmi->ptr, "quad_method", MOD_TRIANGULATE_QUAD_FIXED);
+ RNA_enum_set(kmi->ptr, "ngon_method", MOD_TRIANGULATE_NGON_SCANFILL);
WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 5ee980ef5cb..1d47d4c49df 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -1014,7 +1014,7 @@ BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *e
/**
* Wrapper for objectmode/editmode.
*
- * call #EDBM_index_arrays_ensure first for editmesh.
+ * call #BM_mesh_elem_table_ensure first for editmesh.
*/
int ED_mesh_mirror_get_vert(Object *ob, int index)
{
@@ -1025,7 +1025,7 @@ int ED_mesh_mirror_get_vert(Object *ob, int index)
if (em) {
BMVert *eve, *eve_mirr;
- eve = EDBM_vert_at_index(em, index);
+ eve = BM_vert_at_index(em->bm, index);
eve_mirr = editbmesh_get_x_mirror_vert(ob, em, eve, eve->co, index, use_topology);
index_mirr = eve_mirr ? BM_elem_index_get(eve_mirr) : -1;
}
@@ -1231,6 +1231,29 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int
return true;
}
+static void ed_mesh_pick_face_vert__mpoly_find(
+ /* context */
+ struct ARegion *ar, const float mval[2],
+ /* mesh data */
+ DerivedMesh *dm, MPoly *mp, MLoop *mloop,
+ /* return values */
+ float *r_len_best, int *r_v_idx_best)
+{
+ const MLoop *ml;
+ int j = mp->totloop;
+ for (ml = &mloop[mp->loopstart]; j--; ml++) {
+ float co[3], sco[2], len;
+ const int v_idx = ml->v;
+ dm->getVertCo(dm, v_idx, co);
+ if (ED_view3d_project_float_object(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ len = len_manhattan_v2v2(mval, sco);
+ if (len < *r_len_best) {
+ *r_len_best = len;
+ *r_v_idx_best = v_idx;
+ }
+ }
+ }
+}
/**
* Use when the back buffer stores face index values. but we want a vert.
* This gets the face then finds the closest vertex to mval.
@@ -1247,39 +1270,61 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
struct ARegion *ar = CTX_wm_region(C);
/* derived mesh to find deformed locations */
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
- int v_idx_best = -1;
-
- if (dm->getVertCo) {
- RegionView3D *rv3d = ar->regiondata;
-
- /* find the vert closest to 'mval' */
- const float mval_f[2] = {(float)mval[0],
- (float)mval[1]};
- MPoly *mp = &me->mpoly[poly_index];
- int fidx;
- float len_best = FLT_MAX;
-
- ED_view3d_init_mats_rv3d(ob, rv3d);
-
- fidx = mp->totloop - 1;
- do {
- float co[3], sco[2], len;
- const int v_idx = me->mloop[mp->loopstart + fidx].v;
- dm->getVertCo(dm, v_idx, co);
- if (ED_view3d_project_float_object(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- len = len_manhattan_v2v2(mval_f, sco);
- if (len < len_best) {
- len_best = len;
- v_idx_best = v_idx;
- }
+ DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+
+ int v_idx_best = ORIGINDEX_NONE;
+
+ /* find the vert closest to 'mval' */
+ const float mval_f[2] = {UNPACK2(mval)};
+ float len_best = FLT_MAX;
+
+ MPoly *dm_mpoly;
+ MLoop *dm_mloop;
+ unsigned int dm_mpoly_tot;
+ const int *index_mp_to_orig;
+
+ dm_mpoly = dm->getPolyArray(dm);
+ dm_mloop = dm->getLoopArray(dm);
+
+ dm_mpoly_tot = dm->getNumPolys(dm);
+
+ index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+
+ /* tag all verts using this face */
+ if (index_mp_to_orig) {
+ unsigned int i;
+
+ for (i = 0; i < dm_mpoly_tot; i++) {
+ if (index_mp_to_orig[i] == poly_index) {
+ ed_mesh_pick_face_vert__mpoly_find(
+ ar, mval_f,
+ dm, &dm_mpoly[i], dm_mloop,
+ &len_best, &v_idx_best);
}
- } while (fidx--);
+ }
+ }
+ else {
+ if (poly_index < dm_mpoly_tot) {
+ ed_mesh_pick_face_vert__mpoly_find(
+ ar, mval_f,
+ dm, &dm_mpoly[poly_index], dm_mloop,
+ &len_best, &v_idx_best);
+ }
+ }
+
+ /* map 'dm -> me' index if possible */
+ if (v_idx_best != ORIGINDEX_NONE) {
+ const int *index_mv_to_orig;
+
+ index_mv_to_orig = dm->getVertDataArray(dm, CD_ORIGINDEX);
+ if (index_mv_to_orig) {
+ v_idx_best = index_mv_to_orig[v_idx_best];
+ }
}
dm->release(dm);
- if (v_idx_best != -1) {
+ if ((v_idx_best != ORIGINDEX_NONE) && (v_idx_best < me->totvert)) {
*index = v_idx_best;
return true;
}
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 68ca55651a8..deae9f17992 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -178,6 +178,193 @@ void MBALL_OT_select_all(wmOperatorType *ot)
WM_operator_properties_select_all(ot);
}
+
+/* -------------------------------------------------------------------- */
+/* Select Similar */
+
+enum {
+ SIMMBALL_TYPE = 1,
+ SIMMBALL_RADIUS,
+ SIMMBALL_STIFFNESS,
+ SIMMBALL_ROTATION
+};
+
+static EnumPropertyItem prop_similar_types[] = {
+ {SIMMBALL_TYPE, "TYPE", 0, "Type", ""},
+ {SIMMBALL_RADIUS, "RADIUS", 0, "Radius", ""},
+ {SIMMBALL_STIFFNESS, "STIFFNESS", 0, "Stiffness", ""},
+ {SIMMBALL_ROTATION, "ROTATION", 0, "Rotation", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+static bool mball_select_similar_type(MetaBall *mb)
+{
+ MetaElem *ml;
+ bool change = false;
+
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (ml->flag & SELECT) {
+ MetaElem *ml_iter;
+
+ for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) {
+ if ((ml_iter->flag & SELECT) == 0) {
+ if (ml->type == ml_iter->type) {
+ ml_iter->flag |= SELECT;
+ change = true;
+ }
+ }
+ }
+ }
+ }
+
+ return change;
+}
+
+static bool mball_select_similar_radius(MetaBall *mb, const float thresh)
+{
+ MetaElem *ml;
+ bool change = false;
+
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (ml->flag & SELECT) {
+ MetaElem *ml_iter;
+
+ for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) {
+ if ((ml_iter->flag & SELECT) == 0) {
+ if (fabsf(ml_iter->rad - ml->rad) <= (thresh * ml->rad)) {
+ ml_iter->flag |= SELECT;
+ change = true;
+ }
+ }
+ }
+ }
+ }
+
+ return change;
+}
+
+static bool mball_select_similar_stiffness(MetaBall *mb, const float thresh)
+{
+ MetaElem *ml;
+ bool change = false;
+
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (ml->flag & SELECT) {
+ MetaElem *ml_iter;
+
+ for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) {
+ if ((ml_iter->flag & SELECT) == 0) {
+ if (fabsf(ml_iter->s - ml->s) <= thresh) {
+ ml_iter->flag |= SELECT;
+ change = true;
+ }
+ }
+ }
+ }
+ }
+
+ return change;
+}
+
+static bool mball_select_similar_rotation(MetaBall *mb, const float thresh)
+{
+ const float thresh_rad = thresh * (float)M_PI_2;
+ MetaElem *ml;
+ bool change = false;
+
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (ml->flag & SELECT) {
+ MetaElem *ml_iter;
+
+ float ml_mat[3][3];
+
+ unit_m3(ml_mat);
+ mul_qt_v3(ml->quat, ml_mat[0]);
+ mul_qt_v3(ml->quat, ml_mat[1]);
+ mul_qt_v3(ml->quat, ml_mat[2]);
+ normalize_m3(ml_mat);
+
+ for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) {
+ if ((ml_iter->flag & SELECT) == 0) {
+ float ml_iter_mat[3][3];
+
+ unit_m3(ml_iter_mat);
+ mul_qt_v3(ml_iter->quat, ml_iter_mat[0]);
+ mul_qt_v3(ml_iter->quat, ml_iter_mat[1]);
+ mul_qt_v3(ml_iter->quat, ml_iter_mat[2]);
+ normalize_m3(ml_iter_mat);
+
+ if ((angle_normalized_v3v3(ml_mat[0], ml_iter_mat[0]) +
+ angle_normalized_v3v3(ml_mat[1], ml_iter_mat[1]) +
+ angle_normalized_v3v3(ml_mat[2], ml_iter_mat[2])) < thresh_rad)
+ {
+ ml_iter->flag |= SELECT;
+ change = true;
+ }
+ }
+ }
+ }
+ }
+
+ return change;
+}
+
+static int mball_select_similar_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ MetaBall *mb = (MetaBall *)obedit->data;
+
+ int type = RNA_enum_get(op->ptr, "type");
+ float thresh = RNA_float_get(op->ptr, "threshold");
+ bool change = false;
+
+ switch (type) {
+ case SIMMBALL_TYPE:
+ change = mball_select_similar_type(mb);
+ break;
+ case SIMMBALL_RADIUS:
+ change = mball_select_similar_radius(mb, thresh);
+ break;
+ case SIMMBALL_STIFFNESS:
+ change = mball_select_similar_stiffness(mb, thresh);
+ break;
+ case SIMMBALL_ROTATION:
+ change = mball_select_similar_rotation(mb, thresh);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+
+ if (change) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void MBALL_OT_select_similar(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select Similar";
+ ot->idname = "MBALL_OT_select_similar";
+
+ /* callback functions */
+ ot->invoke = WM_menu_invoke;
+ ot->exec = mball_select_similar_exec;
+ ot->poll = ED_operator_editmball;
+ ot->description = "Select similar metaballs by property types";
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, 0, "Type", "");
+
+ RNA_def_float(ot->srna, "threshold", 0.1, 0.0, 1.0, "Threshold", "", 0.01, 1.0);
+}
+
+
/***************************** Select random operator *****************************/
/* Random metaball selection */
@@ -255,19 +442,6 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- int retv = duplicate_metaelems_exec(C, op);
-
- if (retv == OPERATOR_FINISHED) {
- RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION);
- WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
- }
-
- return retv;
-}
-
-
void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
{
/* identifiers */
@@ -277,14 +451,10 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
/* callback functions */
ot->exec = duplicate_metaelems_exec;
- ot->invoke = duplicate_metaelems_invoke;
ot->poll = ED_operator_editmball;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* to give to transform */
- RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
}
/***************************** Delete operator *****************************/
diff --git a/source/blender/editors/metaball/mball_intern.h b/source/blender/editors/metaball/mball_intern.h
index 0329f8e5bfa..24a4ea86d87 100644
--- a/source/blender/editors/metaball/mball_intern.h
+++ b/source/blender/editors/metaball/mball_intern.h
@@ -43,6 +43,7 @@ void MBALL_OT_delete_metaelems(struct wmOperatorType *ot);
void MBALL_OT_duplicate_metaelems(struct wmOperatorType *ot);
void MBALL_OT_select_all(struct wmOperatorType *ot);
+void MBALL_OT_select_similar(struct wmOperatorType *ot);
void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot);
#endif
diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c
index bba0dc5000b..249e7361cc0 100644
--- a/source/blender/editors/metaball/mball_ops.c
+++ b/source/blender/editors/metaball/mball_ops.c
@@ -52,9 +52,23 @@ void ED_operatortypes_metaball(void)
WM_operatortype_append(MBALL_OT_reveal_metaelems);
WM_operatortype_append(MBALL_OT_select_all);
+ WM_operatortype_append(MBALL_OT_select_similar);
WM_operatortype_append(MBALL_OT_select_random_metaelems);
}
+void ED_operatormacros_metaball(void)
+{
+ wmOperatorType *ot;
+ wmOperatorTypeMacro *otmacro;
+
+ ot = WM_operatortype_append_macro("MBALL_OT_duplicate_move", "Duplicate",
+ "Make copies of the selected bones within the same armature and move them",
+ OPTYPE_UNDO | OPTYPE_REGISTER);
+ WM_operatortype_macro_define(ot, "MBALL_OT_duplicate_metaelems");
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+}
+
void ED_keymap_metaball(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
@@ -73,13 +87,15 @@ void ED_keymap_metaball(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", DELKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "MBALL_OT_duplicate_metaelems", DKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "MBALL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
+ WM_keymap_add_item(keymap, "MBALL_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
+
ED_keymap_proportional_cycle(keyconf, keymap);
ED_keymap_proportional_editmode(keyconf, keymap, TRUE);
}
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 3e7aeba63c3..143a33c3fdd 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -53,6 +53,7 @@ set(SRC
object_select.c
object_shapekey.c
object_transform.c
+ object_warp.c
object_vgroup.c
object_intern.h
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index db68a0eca4d..9dd686326bb 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -152,7 +152,7 @@ void ED_object_location_from_view(bContext *C, float loc[3])
Scene *scene = CTX_data_scene(C);
const float *cursor;
- cursor = give_cursor(scene, v3d);
+ cursor = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(loc, cursor);
}
@@ -1220,9 +1220,11 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
const short use_base_parent,
const short use_hierarchy)
{
+ Main *bmain = CTX_data_main(C);
ListBase *lb;
DupliObject *dob;
GHash *dupli_gh = NULL, *parent_gh = NULL;
+ Object *object;
if (!(base->object->transflag & OB_DUPLI))
return;
@@ -1237,6 +1239,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
for (dob = lb->first; dob; dob = dob->next) {
Base *basen;
Object *ob = BKE_object_copy(dob->ob);
+
/* font duplis can have a totcol without material, we get them from parent
* should be implemented better...
*/
@@ -1330,6 +1333,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
}
}
+ /* The same how BKE_object_unlink detects which object proxies to clear. */
+ if (base->object->transflag & OB_DUPLIGROUP && base->object->dup_group) {
+ for (object = bmain->object.first; object; object = object->id.next) {
+ if (object->proxy_group == base->object) {
+ object->proxy = NULL;
+ object->proxy_from = NULL;
+ DAG_id_tag_update(&object->id, OB_RECALC_OB);
+ }
+ }
+ }
+
if (dupli_gh)
BLI_ghash_free(dupli_gh, NULL, NULL);
if (parent_gh)
@@ -1603,6 +1617,9 @@ static int convert_exec(bContext *C, wmOperator *op)
for (nu = cu->nurb.first; nu; nu = nu->next)
nu->charidx = 0;
+ cu->flag &= ~CU_3D;
+ BKE_curve_curve_dimension_update(cu);
+
if (target == OB_MESH) {
curvetomesh(scene, newob);
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 4a8097f260e..55564703a87 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -156,12 +156,6 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
break;
}
- if (mmd->lvl == 0) {
- BKE_report(op->reports, RPT_ERROR, "Multires data baking is not supported for preview subdivision level 0");
- ok = false;
- break;
- }
-
if (!me->mtpoly) {
BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking");
@@ -214,28 +208,23 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
DerivedMesh *dm;
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
Mesh *me = (Mesh *)ob->data;
+ MultiresModifierData tmp_mmd = *mmd;
+ DerivedMesh *cddm = CDDM_from_mesh(me, ob);
- *lvl = mmd->lvl;
-
- if (*lvl == 0) {
- DerivedMesh *tmp_dm = CDDM_from_mesh(me, ob);
-
- DM_set_only_copy(tmp_dm, CD_MASK_BAREMESH | CD_MASK_MTFACE);
-
- dm = CDDM_copy(tmp_dm);
- tmp_dm->release(tmp_dm);
+ if (mmd->lvl > 0) {
+ *lvl = mmd->lvl;
}
else {
- MultiresModifierData tmp_mmd = *mmd;
- DerivedMesh *cddm = CDDM_from_mesh(me, ob);
+ *lvl = 1;
+ tmp_mmd.simple = true;
+ }
- DM_set_only_copy(cddm, CD_MASK_BAREMESH | CD_MASK_MTFACE);
+ DM_set_only_copy(cddm, CD_MASK_BAREMESH | CD_MASK_MTFACE);
- tmp_mmd.lvl = *lvl;
- tmp_mmd.sculptlvl = *lvl;
- dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0);
- cddm->release(cddm);
- }
+ tmp_mmd.lvl = *lvl;
+ tmp_mmd.sculptlvl = *lvl;
+ dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0);
+ cddm->release(cddm);
return dm;
}
@@ -556,7 +545,7 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake",
WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE);
WM_jobs_customdata_set(wm_job, bkr, multiresbake_freejob);
- WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */
+ WM_jobs_timer(wm_job, 0.5, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */
WM_jobs_callbacks(wm_job, multiresbake_startjob, NULL, NULL, NULL);
G.is_break = FALSE;
@@ -816,7 +805,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake",
WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE);
WM_jobs_customdata_set(wm_job, bkr, bake_freejob);
- WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */
+ WM_jobs_timer(wm_job, 0.5, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */
WM_jobs_callbacks(wm_job, bake_startjob, NULL, bake_update, NULL);
G.is_break = FALSE;
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 8af9401e30f..d4fac49e973 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1331,7 +1331,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
/* do updates */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
return OPERATOR_FINISHED;
}
@@ -1365,7 +1365,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
DAG_relations_tag_update(bmain);
/* do updates */
- WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, NULL);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index bd4c2e997fe..2e011493fce 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -351,7 +351,7 @@ static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata)
load_editNurb(obedit);
if (freedata) free_editNurb(obedit);
}
- else if (obedit->type == OB_FONT && freedata) {
+ else if (obedit->type == OB_FONT) {
load_editText(obedit);
if (freedata) free_editText(obedit);
}
@@ -1110,6 +1110,23 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D *
/* ******************* force field toggle operator ***************** */
+void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object)
+{
+ PartDeflect *pd = object->pd;
+ ModifierData *md = modifiers_findByType(object, eModifierType_Surface);
+
+ /* add/remove modifier as needed */
+ if (!md) {
+ if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && ELEM(pd->forcefield, PFIELD_GUIDE, PFIELD_TEXTURE) == 0)
+ if (ELEM4(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE))
+ ED_object_modifier_add(NULL, bmain, scene, object, NULL, eModifierType_Surface);
+ }
+ else {
+ if (!pd || pd->shape != PFIELD_SHAPE_SURFACE || pd->forcefield != PFIELD_FORCE)
+ ED_object_modifier_remove(NULL, bmain, object, md);
+ }
+}
+
static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
@@ -1122,7 +1139,9 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
else
ob->pd->forcefield = 0;
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
+ ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 37656f82b25..7f97aa0b4c1 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -65,6 +65,7 @@
#include "ED_curve.h"
#include "ED_mesh.h"
#include "ED_screen.h"
+#include "ED_object.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -701,26 +702,9 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
-
- /* reset functionality */
- if (hmd->object) {
- bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget);
-
- if (hmd->subtarget[0] && pchan) {
- float imat[4][4], mat[4][4];
-
- /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
- mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
-
- invert_m4_m4(imat, mat);
- mul_m4_m4m4(hmd->parentinv, imat, ob->obmat);
- }
- else {
- invert_m4_m4(hmd->object->imat, hmd->object->obmat);
- mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat);
- }
- }
-
+
+ BKE_object_modifier_hook_reset(ob, hmd);
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 4ff3bc9ac06..bfed1f2f982 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -222,6 +222,7 @@ void OBJECT_OT_vertex_group_fix(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_invert(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_blend(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_clean(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_quantize(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_limit_total(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_mirror(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_set_active(struct wmOperatorType *ot);
@@ -233,6 +234,9 @@ void OBJECT_OT_vertex_weight_set_active(struct wmOperatorType *ot);
void OBJECT_OT_vertex_weight_normalize_active_vertex(struct wmOperatorType *ot);
void OBJECT_OT_vertex_weight_copy(struct wmOperatorType *ot);
+/* object_warp.c */
+void OBJECT_OT_vertex_warp(struct wmOperatorType *ot);
+
/* object_shapekey.c */
void OBJECT_OT_shape_key_add(struct wmOperatorType *ot);
void OBJECT_OT_shape_key_remove(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index a79b0607421..3425aa08955 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -528,7 +528,7 @@ typedef enum eLattice_FlipAxes {
LATTICE_FLIP_W = 2
} eLattice_FlipAxes;
-/* Flip midpoint value so that relative distances between midpoint and neighbour-pair is maintained
+/* Flip midpoint value so that relative distances between midpoint and neighbor-pair is maintained
* ! Assumes that uvw <=> xyz (i.e. axis-aligned index-axes with coordinate-axes)
* - Helper for lattice_flip_exec()
*/
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 0ba84e27420..01dafe69d31 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -87,7 +87,6 @@
#include "object_intern.h"
-static void modifier_skin_customdata_ensure(struct Object *ob);
static void modifier_skin_customdata_delete(struct Object *ob);
/******************************** API ****************************/
@@ -299,9 +298,6 @@ static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
*sort_depsgraph = 1;
}
else if (md->type == eModifierType_Surface) {
- if (ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE)
- ob->pd->shape = PFIELD_SHAPE_PLANE;
-
*sort_depsgraph = 1;
}
else if (md->type == eModifierType_Multires) {
@@ -1434,7 +1430,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot)
/************************** skin modifier ***********************/
-static void modifier_skin_customdata_ensure(Object *ob)
+void modifier_skin_customdata_ensure(Object *ob)
{
Mesh *me = ob->data;
BMesh *bm = me->edit_btmesh ? me->edit_btmesh->bm : NULL;
@@ -1857,7 +1853,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot)
static int meshdeform_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, (1 << OB_MESH));
+ return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, 0);
}
static int meshdeform_bind_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 333e5ff3006..6d760acb698 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -191,6 +191,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_vertex_group_levels);
WM_operatortype_append(OBJECT_OT_vertex_group_blend);
WM_operatortype_append(OBJECT_OT_vertex_group_clean);
+ WM_operatortype_append(OBJECT_OT_vertex_group_quantize);
WM_operatortype_append(OBJECT_OT_vertex_group_limit_total);
WM_operatortype_append(OBJECT_OT_vertex_group_mirror);
WM_operatortype_append(OBJECT_OT_vertex_group_set_active);
@@ -202,6 +203,8 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_vertex_weight_normalize_active_vertex);
WM_operatortype_append(OBJECT_OT_vertex_weight_copy);
+ WM_operatortype_append(OBJECT_OT_vertex_warp);
+
WM_operatortype_append(OBJECT_OT_game_property_new);
WM_operatortype_append(OBJECT_OT_game_property_remove);
WM_operatortype_append(OBJECT_OT_game_property_copy);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index be4948d8a80..c70a70c47b2 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2211,6 +2211,8 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
int flag = RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */
bool copy_groups = false;
+ clear_id_newpoins();
+
if (RNA_boolean_get(op->ptr, "object"))
single_object_users(bmain, scene, v3d, flag, copy_groups);
@@ -2227,6 +2229,11 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
if (RNA_boolean_get(op->ptr, "animation"))
single_object_action_users(scene, flag);
+ /* TODO(sergey): This should not be needed, however some tool still could rely
+ * on the fact, that id->newid is kept NULL by default.
+ * Need to make sure all the guys are learing newid before they're
+ * using it, not after.
+ */
clear_id_newpoins();
WM_event_add_notifier(C, NC_WINDOW, NULL);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 974dc3acef9..ffa9eed65b9 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -1078,12 +1078,12 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Base *, primbase, selected_bases)
{
- char tmpname[MAXBONENAME];
+ char name_flip[MAXBONENAME];
- flip_side_name(tmpname, primbase->object->id.name + 2, TRUE);
+ BKE_deform_flip_side_name(name_flip, primbase->object->id.name + 2, true);
- if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */
- Object *ob = (Object *)BKE_libblock_find_name(ID_OB, tmpname);
+ if (!STREQ(name_flip, primbase->object->id.name + 2)) {
+ Object *ob = (Object *)BKE_libblock_find_name(ID_OB, name_flip);
if (ob) {
Base *secbase = BKE_scene_base_find(scene, ob);
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index ea96db514b2..6be4a2fed2c 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -290,6 +290,17 @@ static int shape_key_mode_poll(bContext *C)
return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT);
}
+static int shape_key_mode_exists_poll(bContext *C)
+{
+ Object *ob = ED_object_context(C);
+ ID *data = (ob) ? ob->data : NULL;
+
+ /* same as shape_key_mode_poll */
+ return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT) &&
+ /* check a keyblock exists */
+ (BKE_keyblock_from_object(ob) != NULL);
+}
+
static int shape_key_poll(bContext *C)
{
Object *ob = ED_object_context(C);
@@ -359,6 +370,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
/* api callbacks */
ot->poll = shape_key_mode_poll;
+ ot->poll = shape_key_mode_exists_poll;
ot->exec = shape_key_remove_exec;
/* flags */
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 4d7abbe7c39..fef5ae392ea 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -712,7 +712,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
else {
/* get the view settings if 'around' isn't set and the view is available */
View3D *v3d = CTX_wm_view3d(C);
- copy_v3_v3(cursor, give_cursor(scene, v3d));
+ copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d));
if (v3d && !RNA_struct_property_is_set(op->ptr, "center"))
around = v3d->around;
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index d6c365e9247..16ee400fa67 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -348,7 +348,7 @@ void ED_vgroup_parray_mirror_sync(Object *ob,
return;
}
if (em) {
- EDBM_index_arrays_ensure(em, BM_VERT);
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT);
}
for (i = 0; i < dvert_tot; i++) {
@@ -390,7 +390,7 @@ void ED_vgroup_parray_mirror_assign(Object *ob,
}
BLI_assert(dvert_tot == dvert_tot_all);
if (em) {
- EDBM_index_arrays_ensure(em, BM_VERT);
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT);
}
for (i = 0; i < dvert_tot; i++) {
@@ -1283,8 +1283,8 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum)
if (cd_dvert_offset != -1) {
BMVert *eve;
- EDBM_index_arrays_ensure(em, BM_VERT);
- eve = EDBM_vert_at_index(em, vertnum);
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT);
+ eve = BM_vert_at_index(em->bm, vertnum);
dv = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
}
else {
@@ -2179,7 +2179,7 @@ static void vgroup_blend_subset(Object *ob, const bool *vgroup_validmap, const i
memset(vgroup_subset_weights, 0, sizeof(*vgroup_subset_weights) * subset_count);
if (bm) {
- EDBM_index_arrays_ensure(em, BM_VERT);
+ BM_mesh_elem_table_ensure(bm, BM_VERT);
emap = NULL;
emap_mem = NULL;
@@ -2197,7 +2197,7 @@ static void vgroup_blend_subset(Object *ob, const bool *vgroup_validmap, const i
/* in case its not selected */
if (bm) {
- BMVert *v = EDBM_vert_at_index(em, i);
+ BMVert *v = BM_vert_at_index(bm, i);
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
BMIter eiter;
BMEdge *e;
@@ -2398,6 +2398,44 @@ static void vgroup_clean_subset(Object *ob, const bool *vgroup_validmap, const i
}
}
+static void vgroup_quantize_subset(Object *ob, const bool *vgroup_validmap, const int vgroup_tot, const int UNUSED(subset_count),
+ const int steps)
+{
+ MDeformVert **dvert_array = NULL;
+ int dvert_tot = 0;
+ const bool use_vert_sel = vertex_group_use_vert_sel(ob);
+ const bool use_mirror = (ob->type == OB_MESH) ? (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 : false;
+ ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
+
+ if (dvert_array) {
+ const float steps_fl = steps;
+ MDeformVert *dv;
+ int i;
+
+ if (use_mirror && use_vert_sel) {
+ ED_vgroup_parray_mirror_assign(ob, dvert_array, dvert_tot);
+ }
+
+ for (i = 0; i < dvert_tot; i++) {
+ MDeformWeight *dw;
+ int j;
+
+ /* in case its not selected */
+ if (!(dv = dvert_array[i])) {
+ continue;
+ }
+
+ for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) {
+ if ((dw->def_nr < vgroup_tot) && vgroup_validmap[dw->def_nr]) {
+ dw->weight = floorf((dw->weight * steps_fl) + 0.5f) / steps_fl;
+ CLAMP(dw->weight, 0.0f, 1.0f);
+ }
+ }
+ }
+
+ MEM_freeN(dvert_array);
+ }
+}
static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
const char sel, const char sel_mirr,
@@ -3754,6 +3792,44 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot)
"Keep verts assigned to at least one group when cleaning");
}
+static int vertex_group_quantize_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = ED_object_context(C);
+
+ const int steps = RNA_int_get(op->ptr, "steps");
+ eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode");
+
+ int subset_count, vgroup_tot;
+
+ const bool *vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count);
+ vgroup_quantize_subset(ob, vgroup_validmap, vgroup_tot, subset_count, steps);
+ MEM_freeN((void *)vgroup_validmap);
+
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_quantize(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Quantize Vertex Weights";
+ ot->idname = "OBJECT_OT_vertex_group_quantize";
+ ot->description = "Set weights to a fixed number of steps";
+
+ /* api callbacks */
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_quantize_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ vgroup_operator_subset_select_props(ot, true);
+ RNA_def_int(ot->srna, "steps", 4, 1, 1000, "Steps", "Number of steps between 0 and 1", 1, 100);
+}
+
static int vertex_group_limit_total_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
@@ -3777,7 +3853,7 @@ static int vertex_group_limit_total_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
- /* note, would normally return cancelled, except we want the redo
+ /* note, would normally return canceled, except we want the redo
* UI to show up for users to change */
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.c
new file mode 100644
index 00000000000..06b59a8e954
--- /dev/null
+++ b/source/blender/editors/object/object_warp.c
@@ -0,0 +1,325 @@
+/*
+ * ***** 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) 2013 by Blender Foundation
+ * All rights reserved.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/object/object_warp.c
+ * \ingroup edobj
+ */
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BLI_math.h"
+
+#include "BKE_utildefines.h"
+#include "BKE_context.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_view3d.h"
+#include "ED_transverts.h"
+
+#include "object_intern.h"
+
+
+static void object_warp_calc_view_matrix(float r_mat_view[4][4], float r_center_view[3],
+ Object *obedit, float viewmat[4][4], const float center[3],
+ const float offset_angle)
+{
+ float mat_offset[4][4];
+ float viewmat_roll[4][4];
+
+ /* apply the rotation offset by rolling the view */
+ unit_m4(mat_offset);
+ rotate_m4(mat_offset, 'Z', offset_angle);
+ mul_m4_m4m4(viewmat_roll, mat_offset, viewmat);
+
+ /* apply the view and the object matrix */
+ mul_m4_m4m4(r_mat_view, viewmat_roll, obedit->obmat);
+
+ /* get the view-space cursor */
+ mul_v3_m4v3(r_center_view, viewmat_roll, center);
+}
+
+
+static void object_warp_transverts_minmax_x(TransVertStore *tvs,
+ float mat_view[4][4], const float center_view[3],
+ float *r_min, float *r_max)
+{
+ /* no need to apply translation and cursor offset for every vertex, delay this */
+ const float x_ofs = (mat_view[3][0] - center_view[0]);
+ float min = FLT_MAX, max = -FLT_MAX;
+
+ TransVert *tv;
+ int i;
+
+
+ tv = tvs->transverts;
+ for (i = 0; i < tvs->transverts_tot; i++, tv++) {
+ float val;
+
+ /* convert objectspace->viewspace */
+ val = dot_m4_v3_row_x(mat_view, tv->loc);
+
+ min = min_ff(min, val);
+ max = max_ff(max, val);
+ }
+
+ *r_min = min + x_ofs;
+ *r_max = max + x_ofs;
+}
+
+
+static void object_warp_transverts(TransVertStore *tvs,
+ float mat_view[4][4], const float center_view[3],
+ const float angle_, const float min, const float max)
+{
+ TransVert *tv;
+ int i;
+ const float angle = -angle_;
+ /* cache vars for tiny speedup */
+#if 1
+ const float range = max - min;
+ const float range_inv = 1.0f / range;
+ const float min_ofs = min + (0.5f * range);
+#endif
+
+ float dir_min[2], dir_max[2];
+ float imat_view[4][4];
+
+
+ invert_m4_m4(imat_view, mat_view);
+
+ /* calculate the direction vectors outside min/max range */
+ {
+ const float phi = angle * 0.5f;
+
+ dir_max[0] = cosf(phi);
+ dir_max[1] = sinf(phi);
+
+ dir_min[0] = -dir_max[0];
+ dir_min[1] = dir_max[1];
+ }
+
+
+ tv = tvs->transverts;
+ for (i = 0; i < tvs->transverts_tot; i++, tv++) {
+ float co[3], co_add[2];
+ float val, phi;
+
+ /* convert objectspace->viewspace */
+ mul_v3_m4v3(co, mat_view, tv->loc);
+ sub_v2_v2(co, center_view);
+
+ val = co[0];
+ /* is overwritten later anyway */
+ // co[0] = 0.0f;
+
+ if (val < min) {
+ mul_v2_v2fl(co_add, dir_min, min - val);
+ val = min;
+ }
+ else if (val > max) {
+ mul_v2_v2fl(co_add, dir_max, val - max);
+ val = max;
+ }
+ else {
+ zero_v2(co_add);
+ }
+
+ /* map from x axis to (-0.5 - 0.5) */
+#if 0
+ val = ((val - min) / (max - min)) - 0.5f;
+#else
+ val = (val - min_ofs) * range_inv;
+#endif
+
+ /* convert the x axis into a rotation */
+ phi = val * angle;
+
+ co[0] = -sinf(phi) * co[1];
+ co[1] = cosf(phi) * co[1];
+
+ add_v2_v2(co, co_add);
+
+ /* convert viewspace->objectspace */
+ add_v2_v2(co, center_view);
+ mul_v3_m4v3(tv->loc, imat_view, co);
+ }
+}
+
+static int object_warp_verts_exec(bContext *C, wmOperator *op)
+{
+ const float warp_angle = RNA_float_get(op->ptr, "warp_angle");
+ const float offset_angle = RNA_float_get(op->ptr, "offset_angle");
+
+ TransVertStore tvs = {NULL};
+ Object *obedit = CTX_data_edit_object(C);
+
+ /* typically from 'rv3d' and 3d cursor */
+ float viewmat[4][4];
+ float center[3];
+
+ /* 'viewmat' relative vars */
+ float mat_view[4][4];
+ float center_view[3];
+
+ float min, max;
+
+
+ ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES);
+ if (tvs.transverts == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+
+ /* get viewmatrix */
+ {
+ PropertyRNA *prop_viewmat = RNA_struct_find_property(op->ptr, "viewmat");
+ if (RNA_property_is_set(op->ptr, prop_viewmat)) {
+ RNA_property_float_get_array(op->ptr, prop_viewmat, (float *)viewmat);
+ }
+ else {
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+
+ if (rv3d) {
+ copy_m4_m4(viewmat, rv3d->viewmat);
+ }
+ else {
+ unit_m4(viewmat);
+ }
+
+ RNA_property_float_set_array(op->ptr, prop_viewmat, (float *)viewmat);
+ }
+ }
+
+
+ /* get center */
+ {
+ PropertyRNA *prop_center = RNA_struct_find_property(op->ptr, "center");
+ if (RNA_property_is_set(op->ptr, prop_center)) {
+ RNA_property_float_get_array(op->ptr, prop_center, center);
+ }
+ else {
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ const float *cursor;
+
+ cursor = ED_view3d_cursor3d_get(scene, v3d);
+ copy_v3_v3(center, cursor);
+
+ RNA_property_float_set_array(op->ptr, prop_center, center);
+ }
+ }
+
+
+ object_warp_calc_view_matrix(mat_view, center_view, obedit, viewmat, center, offset_angle);
+
+
+ /* get minmax */
+ {
+ PropertyRNA *prop_min = RNA_struct_find_property(op->ptr, "min");
+ PropertyRNA *prop_max = RNA_struct_find_property(op->ptr, "max");
+
+ if (RNA_property_is_set(op->ptr, prop_min) ||
+ RNA_property_is_set(op->ptr, prop_max))
+ {
+ min = RNA_property_float_get(op->ptr, prop_min);
+ max = RNA_property_float_get(op->ptr, prop_max);
+ }
+ else {
+ /* handy to set the bounds of the mesh */
+ object_warp_transverts_minmax_x(&tvs, mat_view, center_view, &min, &max);
+
+ RNA_property_float_set(op->ptr, prop_min, min);
+ RNA_property_float_set(op->ptr, prop_max, max);
+ }
+
+ if (min > max) {
+ SWAP(float, min, max);
+ }
+ }
+
+ if (min != max) {
+ object_warp_transverts(&tvs, mat_view, center_view, warp_angle, min, max);
+ }
+
+ ED_transverts_update_obedit(&tvs, obedit);
+ ED_transverts_free(&tvs);
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
+
+ return OPERATOR_FINISHED;
+}
+
+static int object_warp_verts_poll(bContext *C)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ if (obedit) {
+ if (ED_transverts_check_obedit(obedit)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+void OBJECT_OT_vertex_warp(struct wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Warp";
+ ot->description = "Warp vertices around the cursor";
+ ot->idname = "OBJECT_OT_vertex_warp";
+
+ /* api callbacks */
+ ot->exec = object_warp_verts_exec;
+ ot->poll = object_warp_verts_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ prop = RNA_def_float(ot->srna, "warp_angle", DEG2RADF(360.0f), -FLT_MAX, FLT_MAX, "Warp Angle",
+ "Amount to warp about the cursor", DEG2RADF(-360.0f), DEG2RADF(360.0f));
+ RNA_def_property_subtype(prop, PROP_ANGLE);
+
+ prop = RNA_def_float(ot->srna, "offset_angle", DEG2RADF(0.0f), -FLT_MAX, FLT_MAX, "Offset Angle",
+ "Angle to use as the basis for warping", DEG2RADF(-360.0f), DEG2RADF(360.0f));
+ RNA_def_property_subtype(prop, PROP_ANGLE);
+
+ prop = RNA_def_float(ot->srna, "min", -1.0f, -FLT_MAX, FLT_MAX, "Min", "", -100.0, 100.0);
+ prop = RNA_def_float(ot->srna, "max", 1.0f, -FLT_MAX, FLT_MAX, "Max", "", -100.0, 100.0);
+
+ /* hidden props */
+ prop = RNA_def_float_matrix(ot->srna, "viewmat", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+
+ prop = RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "", -FLT_MAX, FLT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+}
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index b0e19d04e35..65a3e5b558e 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -3880,11 +3880,9 @@ static int brush_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int brush_edit_cancel(bContext *UNUSED(C), wmOperator *op)
+static void brush_edit_cancel(bContext *UNUSED(C), wmOperator *op)
{
brush_edit_exit(op);
-
- return OPERATOR_CANCELLED;
}
void PARTICLE_OT_brush_edit(wmOperatorType *ot)
diff --git a/source/blender/editors/render/SConscript b/source/blender/editors/render/SConscript
index 7406d42f416..41576f9b485 100644
--- a/source/blender/editors/render/SConscript
+++ b/source/blender/editors/render/SConscript
@@ -61,9 +61,6 @@ if env['WITH_BF_QUICKTIME']:
incs += ' ../../quicktime'
env.Append(CFLAGS=['-DWITH_QUICKTIME'])
-if env['USE_QTKIT']:
- env.Append(CFLAGS=['-DUSE_QTKIT'])
-
if env['WITH_BF_INTERNATIONAL']:
defs.append('WITH_INTERNATIONAL')
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index df8d5ec4e84..71bf67220fe 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -564,15 +564,13 @@ static int screen_render_modal(bContext *C, wmOperator *op, const wmEvent *event
return OPERATOR_PASS_THROUGH;
}
-static int screen_render_cancel(bContext *C, wmOperator *op)
+static void screen_render_cancel(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = (Scene *) op->customdata;
/* kill on cancel, because job is using op->reports */
WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER);
-
- return OPERATOR_CANCELLED;
}
/* using context, starts job */
@@ -1239,3 +1237,13 @@ void ED_viewport_render_kill_jobs(const bContext *C, bool free_database)
}
}
+Scene *ED_render_job_get_scene(const bContext *C)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
+
+ if (rj)
+ return rj->scene;
+
+ return NULL;
+}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 21074bdc47c..107674babdd 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -485,11 +485,9 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
MEM_freeN(oglrender);
}
-static int screen_opengl_render_cancel(bContext *C, wmOperator *op)
+static void screen_opengl_render_cancel(bContext *C, wmOperator *op)
{
screen_opengl_render_end(C, op->customdata);
-
- return OPERATOR_CANCELLED;
}
/* share between invoke and exec */
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index 7c52b7d0d39..3401577ee55 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -37,10 +37,6 @@
#include "render_intern.h" // own include
-#if (defined(WITH_QUICKTIME) && !defined(USE_QTKIT))
-#include "quicktime_export.h"
-#endif
-
/***************************** render ***********************************/
void ED_operatortypes_render(void)
@@ -81,10 +77,6 @@ void ED_operatortypes_render(void)
WM_operatortype_append(SCENE_OT_freestyle_modifier_copy);
#endif
-#if (defined(WITH_QUICKTIME) && !defined(USE_QTKIT))
- WM_operatortype_append(SCENE_OT_render_data_set_quicktime_codec);
-#endif
-
WM_operatortype_append(TEXTURE_OT_slot_copy);
WM_operatortype_append(TEXTURE_OT_slot_paste);
WM_operatortype_append(TEXTURE_OT_slot_move);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 553a543390f..3ef1f0db647 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -739,6 +739,10 @@ static int freestyle_active_lineset_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
+ if (!srl) {
+ return FALSE;
+ }
+
return BKE_freestyle_lineset_get_active(&srl->freestyleConfig) != NULL;
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index fbdd90312dd..93923c24c84 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -750,11 +750,9 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int actionzone_cancel(bContext *UNUSED(C), wmOperator *op)
+static void actionzone_cancel(bContext *UNUSED(C), wmOperator *op)
{
actionzone_exit(op);
-
- return OPERATOR_CANCELLED;
}
static void SCREEN_OT_actionzone(wmOperatorType *ot)
@@ -825,10 +823,9 @@ static void area_swap_exit(bContext *C, wmOperator *op)
op->customdata = NULL;
}
-static int area_swap_cancel(bContext *C, wmOperator *op)
+static void area_swap_cancel(bContext *C, wmOperator *op)
{
area_swap_exit(C, op);
- return OPERATOR_CANCELLED;
}
static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -857,8 +854,8 @@ static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE: /* release LMB */
if (event->val == KM_RELEASE) {
if (!sad->sa2 || sad->sa1 == sad->sa2) {
-
- return area_swap_cancel(C, op);
+ area_swap_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
ED_area_tag_redraw(sad->sa1);
@@ -875,7 +872,8 @@ static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event)
break;
case ESCKEY:
- return area_swap_cancel(C, op);
+ area_swap_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
return OPERATOR_RUNNING_MODAL;
}
@@ -917,14 +915,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
sa = sad->sa1;
}
-
- /* poll() checks area context, but we don't accept full-area windows */
- if (sc->full != SCREENNORMAL) {
- if (event->type == EVT_ACTIONZONE_AREA)
- actionzone_exit(op);
- return OPERATOR_CANCELLED;
- }
-
+
/* adds window to WM */
rect = sa->totrct;
BLI_rcti_translate(&rect, win->posx, win->posy);
@@ -1148,14 +1139,12 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int area_move_cancel(bContext *C, wmOperator *op)
+static void area_move_cancel(bContext *C, wmOperator *op)
{
RNA_int_set(op->ptr, "delta", 0);
area_move_apply(C, op);
area_move_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
/* modal callback for while moving edges */
@@ -1186,7 +1175,8 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
case KM_MODAL_CANCEL:
- return area_move_cancel(C, op);
+ area_move_cancel(C, op);
+ return OPERATOR_CANCELLED;
case KM_MODAL_STEP10:
md->step = 10;
@@ -1530,7 +1520,7 @@ static int area_split_exec(bContext *C, wmOperator *op)
}
-static int area_split_cancel(bContext *C, wmOperator *op)
+static void area_split_cancel(bContext *C, wmOperator *op)
{
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
@@ -1546,8 +1536,6 @@ static int area_split_cancel(bContext *C, wmOperator *op)
}
}
area_split_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1640,7 +1628,8 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE: /* cancel operation */
case ESCKEY:
- return area_split_cancel(C, op);
+ area_split_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
return OPERATOR_RUNNING_MODAL;
@@ -1915,12 +1904,10 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
+static void region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
-
- return OPERATOR_CANCELLED;
}
static void SCREEN_OT_region_scale(wmOperatorType *ot)
@@ -2123,6 +2110,66 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "next", TRUE, "Next Keyframe", "");
}
+/* ************** jump to marker operator ***************************** */
+
+/* function to be called outside UI context, or for redo */
+static int marker_jump_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ TimeMarker *marker;
+ int closest;
+ short next = RNA_boolean_get(op->ptr, "next");
+ bool found = false;
+
+ /* find matching marker in the right direction */
+ for (marker = scene->markers.first; marker; marker = marker->next) {
+ if (next) {
+ if (marker->frame > CFRA && (!found || closest > marker->frame)) {
+ closest = marker->frame;
+ found = true;
+ }
+ }
+ else {
+ if (marker->frame < CFRA && (!found || closest < marker->frame)) {
+ closest = marker->frame;
+ found = true;
+ }
+ }
+ }
+
+ /* any success? */
+ if (!found) {
+ BKE_report(op->reports, RPT_INFO, "No more markers to jump to in this direction");
+
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ CFRA = closest;
+
+ sound_seek_scene(bmain, scene);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+ }
+}
+
+static void SCREEN_OT_marker_jump(wmOperatorType *ot)
+{
+ ot->name = "Jump to Marker";
+ ot->description = "Jump to previous/next marker";
+ ot->idname = "SCREEN_OT_marker_jump";
+
+ ot->exec = marker_jump_exec;
+
+ ot->poll = ED_operator_screenactive_norender;
+ ot->flag = OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "next", TRUE, "Next Marker", "");
+}
+
/* ************** switch screen operator ***************************** */
static int screen_set_is_ok(bScreen *screen, bScreen *screen_prev)
@@ -2389,7 +2436,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int area_join_cancel(bContext *C, wmOperator *op)
+static void area_join_cancel(bContext *C, wmOperator *op)
{
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
@@ -2405,8 +2452,6 @@ static int area_join_cancel(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_WINDOW, NULL);
area_join_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
/* modal callback while selecting area (space) that will be removed */
@@ -2494,7 +2539,8 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE:
case ESCKEY:
- return area_join_cancel(C, op);
+ area_join_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
return OPERATOR_RUNNING_MODAL;
@@ -3807,6 +3853,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_frame_offset);
WM_operatortype_append(SCREEN_OT_frame_jump);
WM_operatortype_append(SCREEN_OT_keyframe_jump);
+ WM_operatortype_append(SCREEN_OT_marker_jump);
WM_operatortype_append(SCREEN_OT_animation_step);
WM_operatortype_append(SCREEN_OT_animation_play);
@@ -3984,6 +4031,13 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIAFIRST, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "next", FALSE);
+
+ kmi = WM_keymap_add_item(keymap, "SCREEN_OT_marker_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "next", TRUE);
+
+ kmi = WM_keymap_add_item(keymap, "SCREEN_OT_marker_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "next", FALSE);
+
/* play (forward and backwards) */
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index dbe1197436b..0153d609adb 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -105,7 +105,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy)
dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
glReadBuffer(GL_FRONT);
- screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char*)dumprect);
+ screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char *)dumprect);
glReadBuffer(GL_BACK);
}
@@ -237,10 +237,9 @@ static bool screenshot_check(bContext *UNUSED(C), wmOperator *op)
return WM_operator_filesel_ensure_ext_imtype(op, &scd->im_format);
}
-static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op)
+static void screenshot_cancel(bContext *UNUSED(C), wmOperator *op)
{
screenshot_data_free(op);
- return OPERATOR_CANCELLED;
}
static bool screenshot_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index a5d4ff98b4b..003db8a9c43 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -898,10 +898,9 @@ static int grab_clone_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int grab_clone_cancel(bContext *UNUSED(C), wmOperator *op)
+static void grab_clone_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
- return OPERATOR_CANCELLED;
}
void PAINT_OT_grab_clone(wmOperatorType *ot)
@@ -936,11 +935,23 @@ static int sample_color_exec(bContext *C, wmOperator *op)
Paint *paint = BKE_paint_get_active_from_context(C);
Brush *brush = BKE_paint_brush(paint);
ARegion *ar = CTX_wm_region(C);
+ wmWindow *win = CTX_wm_window(C);
+ bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
int location[2];
+ paint->flags &= ~PAINT_SHOW_BRUSH;
+
+ /* force redraw without cursor */
+ WM_paint_cursor_tag_redraw(win, ar);
+ WM_redraw_windows(C);
+
RNA_int_get_array(op->ptr, "location", location);
paint_sample_color(C, ar, location[0], location[1]);
+ if (show_cursor) {
+ paint->flags |= PAINT_SHOW_BRUSH;
+ }
+
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
return OPERATOR_FINISHED;
@@ -950,14 +961,20 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
{
Paint *paint = BKE_paint_get_active_from_context(C);
SampleColorData *data = MEM_mallocN(sizeof(SampleColorData), "sample color custom data");
+ ARegion *ar = CTX_wm_region(C);
+ wmWindow *win = CTX_wm_window(C);
data->event_type = event->type;
data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
op->customdata = data;
paint->flags &= ~PAINT_SHOW_BRUSH;
+ /* force redraw without cursor */
+ WM_paint_cursor_tag_redraw(win, ar);
+ WM_redraw_windows(C);
+
RNA_int_set_array(op->ptr, "location", event->mval);
- sample_color_exec(C, op);
+ paint_sample_color(C, ar, event->mval[0], event->mval[1]);
WM_event_add_modal_handler(C, op);
@@ -967,11 +984,11 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
SampleColorData *data = op->customdata;
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
if ((event->type == data->event_type) && (event->val == KM_RELEASE)) {
- Paint *paint = BKE_paint_get_active_from_context(C);
-
- if(data->show_cursor) {
+ if (data->show_cursor) {
paint->flags |= PAINT_SHOW_BRUSH;
}
@@ -981,9 +998,13 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case MOUSEMOVE:
+ {
+ ARegion *ar = CTX_wm_region(C);
RNA_int_set_array(op->ptr, "location", event->mval);
- sample_color_exec(C, op);
+ paint_sample_color(C, ar, event->mval[0], event->mval[1]);
+ WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
break;
+ }
}
return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 4a2046f6682..88cc954fb17 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -164,6 +164,7 @@ BLI_INLINE unsigned char f_to_char(const float val)
/* used for testing doubles, if a point is on a line etc */
#define PROJ_GEOM_TOLERANCE 0.00075f
+#define PROJ_PIXEL_TOLERANCE 0.01f
/* vert flags */
#define PROJ_VERT_CULL 1
@@ -514,8 +515,8 @@ static void uvco_to_wrapped_pxco(const float uv[2], int ibuf_x, int ibuf_y, floa
}
/* Set the top-most face color that the screen space coord 'pt' touches (or return 0 if none touch) */
-static int project_paint_PickColor(const ProjPaintState *ps, const float pt[2],
- float *rgba_fp, unsigned char *rgba, const int interp)
+static bool project_paint_PickColor(const ProjPaintState *ps, const float pt[2],
+ float *rgba_fp, unsigned char *rgba, const bool interp)
{
float w[3], uv[2];
int side;
@@ -575,11 +576,8 @@ static int project_paint_PickColor(const ProjPaintState *ps, const float pt[2],
//if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0;
/* wrap */
- xi = ((int)(uv[0] * ibuf->x)) % ibuf->x;
- if (xi < 0) xi += ibuf->x;
- yi = ((int)(uv[1] * ibuf->y)) % ibuf->y;
- if (yi < 0) yi += ibuf->y;
-
+ xi = mod_i((int)(uv[0] * ibuf->x), ibuf->x);
+ yi = mod_i((int)(uv[1] * ibuf->y), ibuf->y);
if (rgba) {
if (ibuf->rect_float) {
@@ -611,7 +609,9 @@ static int project_paint_PickColor(const ProjPaintState *ps, const float pt[2],
* 1 : occluded
* 2 : occluded with w[3] weights set (need to know in some cases) */
-static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho)
+static int project_paint_occlude_ptv(const float pt[3],
+ const float v1[4], const float v2[4], const float v3[4],
+ float w[3], const bool is_ortho)
{
/* if all are behind us, return false */
if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2])
@@ -642,7 +642,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], floa
static int project_paint_occlude_ptv_clip(const ProjPaintState *ps, const MFace *mf,
- float pt[3], float v1[4], float v2[4], float v3[4],
+ const float pt[3], const float v1[4], const float v2[4], const float v3[4],
const int side)
{
float w[3], wco[3];
@@ -671,7 +671,8 @@ static int project_paint_occlude_ptv_clip(const ProjPaintState *ps, const MFace
/* Check if a screenspace location is occluded by any other faces
* check, pixelScreenCo must be in screenspace, its Z-Depth only needs to be used for comparison
* and doesn't need to be correct in relation to X and Y coords (this is the case in perspective view) */
-static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace, const int orig_face, float pixelScreenCo[4])
+static bool project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace,
+ const int orig_face, const float pixelScreenCo[4])
{
MFace *mf;
int face_index;
@@ -702,11 +703,11 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc
if (isect_ret >= 1) {
/* TODO - we may want to cache the first hit,
* it is not possible to swap the face order in the list anymore */
- return 1;
+ return true;
}
}
}
- return 0;
+ return false;
}
/* basic line intersection, could move to math_geom.c, 2 points with a horiz line
@@ -785,7 +786,7 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve
* tile, but do not do this for the adjacent face, it could return a false positive.
* This is so unlikely that Id not worry about it. */
#ifndef PROJ_DEBUG_NOSEAMBLEED
-static int cmp_uv(const float vec2a[2], const float vec2b[2])
+static bool cmp_uv(const float vec2a[2], const float vec2b[2])
{
/* if the UV's are not between 0.0 and 1.0 */
float xa = (float)fmodf(vec2a[0], 1.0f);
@@ -807,11 +808,11 @@ static int cmp_uv(const float vec2a[2], const float vec2b[2])
/* set min_px and max_px to the image space bounds of the UV coords
* return zero if there is no area in the returned rectangle */
#ifndef PROJ_DEBUG_NOSEAMBLEED
-static int pixel_bounds_uv(
+static bool pixel_bounds_uv(
const float uv1[2], const float uv2[2], const float uv3[2], const float uv4[2],
rcti *bounds_px,
const int ibuf_x, const int ibuf_y,
- int is_quad
+ const bool is_quad
)
{
float min_uv[2], max_uv[2]; /* UV bounds */
@@ -837,7 +838,7 @@ static int pixel_bounds_uv(
}
#endif
-static int pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot)
+static bool pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot)
{
float min_uv[2], max_uv[2]; /* UV bounds */
@@ -868,7 +869,9 @@ static int pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x,
/* This function returns 1 if this face has a seam along the 2 face-vert indices
* 'orig_i1_fidx' and 'orig_i2_fidx' */
-static int check_seam(const ProjPaintState *ps, const int orig_face, const int orig_i1_fidx, const int orig_i2_fidx, int *other_face, int *orig_fidx)
+static bool check_seam(const ProjPaintState *ps,
+ const int orig_face, const int orig_i1_fidx, const int orig_i2_fidx,
+ int *other_face, int *orig_fidx)
{
LinkNode *node;
int face_index;
@@ -941,7 +944,7 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o
* since the outset coords are a margin that keep an even distance from the original UV's,
* note that the image aspect is taken into account */
static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const float scaler,
- const int ibuf_x, const int ibuf_y, const int is_quad)
+ const int ibuf_x, const int ibuf_y, const bool is_quad)
{
float a1, a2, a3, a4 = 0.0f;
float puv[4][2]; /* pixelspace uv's */
@@ -1339,7 +1342,7 @@ static ProjPixel *project_paint_uvpixel_init(
const ProjPaintState *ps,
MemArena *arena,
const ImBuf *ibuf,
- short x_px, short y_px,
+ int x_px, int y_px,
const float mask,
const int face_index,
const int image_index,
@@ -1351,10 +1354,9 @@ static ProjPixel *project_paint_uvpixel_init(
ProjPixel *projPixel;
/* wrap pixel location */
- x_px = x_px % ibuf->x;
- if (x_px < 0) x_px += ibuf->x;
- y_px = y_px % ibuf->y;
- if (y_px < 0) y_px += ibuf->y;
+
+ x_px = mod_i(x_px, ibuf->x);
+ y_px = mod_i(y_px, ibuf->y);
BLI_assert(ps->pixel_sizeof == project_paint_pixel_sizeof(ps->tool));
projPixel = (ProjPixel *)BLI_memarena_alloc(arena, ps->pixel_sizeof);
@@ -1465,7 +1467,7 @@ static ProjPixel *project_paint_uvpixel_init(
return projPixel;
}
-static int line_clip_rect2f(
+static bool line_clip_rect2f(
rctf *rect,
const float l1[2], const float l2[2],
float l1_clip[2], float l2_clip[2])
@@ -1681,7 +1683,7 @@ static float len_squared_v2v2_alt(const float *v1, const float v2_1, const float
/* note, use a squared value so we can use len_squared_v2v2
* be sure that you have done a bounds check first or this may fail */
/* only give bucket_bounds as an arg because we need it elsewhere */
-static int project_bucket_isect_circle(const float cent[2], const float radius_squared, rctf *bucket_bounds)
+static bool project_bucket_isect_circle(const float cent[2], const float radius_squared, rctf *bucket_bounds)
{
/* Would normally to a simple intersection test, however we know the bounds of these 2 already intersect
@@ -1823,9 +1825,11 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa
#define ISECT_ALL4 ((1 << 4) - 1)
/* limit must be a fraction over 1.0f */
-static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2], float limit)
+static bool IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2], float limit)
{
- return ((area_tri_v2(pt, v1, v2) + area_tri_v2(pt, v2, v3) + area_tri_v2(pt, v3, v1)) / (area_tri_v2(v1, v2, v3))) < limit;
+ return ((area_tri_v2(pt, v1, v2) +
+ area_tri_v2(pt, v2, v3) +
+ area_tri_v2(pt, v3, v1)) / (area_tri_v2(v1, v2, v3))) < limit;
}
/* Clip the face by a bucket and set the uv-space bucket_bounds_uv
@@ -2004,8 +2008,8 @@ static void project_bucket_clip_face(
/* remove doubles */
/* first/last check */
- if (fabsf(isectVCosSS[0][0] - isectVCosSS[(*tot) - 1][0]) < PROJ_GEOM_TOLERANCE &&
- fabsf(isectVCosSS[0][1] - isectVCosSS[(*tot) - 1][1]) < PROJ_GEOM_TOLERANCE)
+ if (fabsf(isectVCosSS[0][0] - isectVCosSS[(*tot) - 1][0]) < PROJ_PIXEL_TOLERANCE &&
+ fabsf(isectVCosSS[0][1] - isectVCosSS[(*tot) - 1][1]) < PROJ_PIXEL_TOLERANCE)
{
(*tot)--;
}
@@ -2021,8 +2025,8 @@ static void project_bucket_clip_face(
while (doubles == TRUE) {
doubles = FALSE;
for (i = 1; i < (*tot); i++) {
- if (fabsf(isectVCosSS[i - 1][0] - isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE &&
- fabsf(isectVCosSS[i - 1][1] - isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE)
+ if (fabsf(isectVCosSS[i - 1][0] - isectVCosSS[i][0]) < PROJ_PIXEL_TOLERANCE &&
+ fabsf(isectVCosSS[i - 1][1] - isectVCosSS[i][1]) < PROJ_PIXEL_TOLERANCE)
{
int j;
for (j = i + 1; j < (*tot); j++) {
@@ -2136,7 +2140,7 @@ static void project_bucket_clip_face(
/* checks if pt is inside a convex 2D polyline, the polyline must be ordered rotating clockwise
* otherwise it would have to test for mixed (line_point_side_v2 > 0.0f) cases */
-static int IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
+static bool IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
{
int i;
if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f)
@@ -2150,7 +2154,7 @@ static int IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
return 1;
}
-static int IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot)
+static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot)
{
int i;
int side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f);
@@ -2410,7 +2414,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
if (outset_uv[0][0] == FLT_MAX) /* first time initialize */
- uv_image_outset(tf_uv_pxoffset, outset_uv, ps->seam_bleed_px, ibuf->x, ibuf->y, mf->v4);
+ uv_image_outset(tf_uv_pxoffset, outset_uv, ps->seam_bleed_px, ibuf->x, ibuf->y, mf->v4 != 0);
/* ps->faceSeamUVs cant be modified when threading, now this is done we can unlock */
if (ps->thread_tot > 1)
@@ -2465,7 +2469,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
interp_v3_v3v3(edge_verts_inset_clip[1], insetCos[fidx1], insetCos[fidx2], fac2);
- if (pixel_bounds_uv(seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3], &bounds_px, ibuf->x, ibuf->y, 1)) {
+ if (pixel_bounds_uv(seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3], &bounds_px, ibuf->x, ibuf->y, true)) {
/* bounds between the seam rect and the uvspace bucket pixels */
has_isect = 0;
@@ -2671,7 +2675,7 @@ static void project_bucket_init(const ProjPaintState *ps, const int thread_index
* calculated when it might not be needed later, (at the moment at least)
* obviously it shouldn't have bugs though */
-static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucket_y, const MFace *mf)
+static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucket_y, const MFace *mf)
{
/* TODO - replace this with a tricker method that uses sideofline for all screenCoords's edges against the closest bucket corner */
rctf bucket_bounds;
@@ -3303,7 +3307,7 @@ static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2])
/* setup clone offset */
if (ps->tool == PAINT_TOOL_CLONE) {
float projCo[4];
- copy_v3_v3(projCo, give_cursor(ps->scene, ps->v3d));
+ copy_v3_v3(projCo, ED_view3d_cursor3d_get(ps->scene, ps->v3d));
mul_m4_v3(ps->ob->imat, projCo);
projCo[3] = 1.0f;
@@ -3465,9 +3469,9 @@ static void partial_redraw_array_init(ImagePaintPartialRedraw *pr)
}
-static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot)
+static bool partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot)
{
- int touch = 0;
+ bool touch = 0;
while (tot--) {
pr->x1 = min_ii(pr->x1, pr_other->x1);
pr->y1 = min_ii(pr->y1, pr_other->y1);
@@ -3485,12 +3489,12 @@ static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPar
}
/* Loop over all images on this mesh and update any we have touched */
-static int project_image_refresh_tagged(ProjPaintState *ps)
+static bool project_image_refresh_tagged(ProjPaintState *ps)
{
ImagePaintPartialRedraw *pr;
ProjPaintImage *projIma;
int a, i;
- int redraw = 0;
+ bool redraw = false;
for (a = 0, projIma = ps->projImages; a < ps->image_tot; a++, projIma++) {
@@ -3513,7 +3517,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps)
}
/* run this per painting onto each mouse location */
-static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
+static bool project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
{
if (ps->source == PROJ_SRC_VIEW) {
float min_brush[2], max_brush[2];
@@ -3553,7 +3557,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
}
-static int project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2])
+static bool project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2])
{
const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush);
@@ -3815,7 +3819,7 @@ static void *do_projectpaint_thread(void *ph_v)
float falloff;
int bucket_index;
- int is_floatbuf = 0;
+ bool is_floatbuf = false;
const short tool = ps->tool;
rctf bucket_bounds;
@@ -3870,7 +3874,7 @@ static void *do_projectpaint_thread(void *ph_v)
last_projIma = projImages + last_index;
last_projIma->touch = 1;
- is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
+ is_floatbuf = (last_projIma->ibuf->rect_float != NULL);
}
/* end copy */
@@ -3996,7 +4000,7 @@ static void *do_projectpaint_thread(void *ph_v)
last_projIma = projImages + last_index;
last_projIma->touch = 1;
- is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
+ is_floatbuf = (last_projIma->ibuf->rect_float != NULL);
}
/* end copy */
@@ -4075,11 +4079,11 @@ static void *do_projectpaint_thread(void *ph_v)
return NULL;
}
-static int project_paint_op(void *state, const float lastpos[2], const float pos[2])
+static bool project_paint_op(void *state, const float lastpos[2], const float pos[2])
{
/* First unpack args from the struct */
ProjPaintState *ps = (ProjPaintState *)state;
- int touch_any = 0;
+ bool touch_any = false;
ProjectHandle handles[BLENDER_MAX_THREADS];
ListBase threads;
@@ -4159,7 +4163,7 @@ void paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const fl
if (ps->tool == PAINT_TOOL_CLONE && ps->mode == BRUSH_STROKE_INVERT) {
Scene *scene = ps->scene;
View3D *v3d = ps->v3d;
- float *cursor = give_cursor(scene, v3d);
+ float *cursor = ED_view3d_cursor3d_get(scene, v3d);
int mval_i[2] = {(int)pos[0], (int)pos[1]};
view3d_operator_needs_opengl(C);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 2545328ec65..5fff02f016b 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -80,7 +80,7 @@ bool paint_supports_jitter(enum PaintMode mode);
struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf);
int paint_stroke_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
-int paint_stroke_cancel(struct bContext *C, struct wmOperator *op);
+void paint_stroke_cancel(struct bContext *C, struct wmOperator *op);
struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
void *paint_stroke_mode_data(struct PaintStroke *stroke);
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
@@ -264,5 +264,7 @@ typedef enum {
} PaintMaskFloodMode;
void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot);
+void PAINT_OT_mask_box_fill(struct wmOperatorType *ot);
+void PAINT_OT_mask_lasso_gesture(struct wmOperatorType *ot);
#endif /* __PAINT_INTERN_H__ */
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 8767b080355..9b906c460e3 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -36,7 +36,13 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
+#include "BIF_glutil.h"
+
+#include "BLI_math_matrix.h"
+#include "BLI_math_geom.h"
#include "BLI_utildefines.h"
+#include "BLI_lasso.h"
+
#include "BKE_pbvh.h"
#include "BKE_ccg.h"
#include "BKE_context.h"
@@ -53,6 +59,7 @@
#include "ED_screen.h"
#include "ED_sculpt.h"
+#include "ED_view3d.h"
#include "bmesh.h"
@@ -110,7 +117,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
mask_flood_fill_set_elem(vi.mask, mode, value);
} BKE_pbvh_vertex_iter_end;
- BKE_pbvh_node_mark_update(nodes[i]);
+ BKE_pbvh_node_mark_redraw(nodes[i]);
if (BKE_pbvh_type(pbvh) == PBVH_GRIDS)
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
}
@@ -148,3 +155,264 @@ void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
RNA_def_float(ot->srna, "value", 0, 0, 1, "Value",
"Mask level to use when mode is 'Value'; zero means no masking and one is fully masked", 0, 1);
}
+
+/* Box select, operator is VIEW3D_OT_select_border, defined in view3d_select.c */
+
+static int is_effected(float planes[4][4], const float co[3])
+{
+ return isect_point_planes_v3(planes, 4, co);
+}
+
+static void flip_plane(float out[4], const float in[4], const char symm)
+{
+ if (symm & SCULPT_SYMM_X)
+ out[0] = -in[0];
+ else
+ out[0] = in[0];
+ if (symm & SCULPT_SYMM_Y)
+ out[1] = -in[1];
+ else
+ out[1] = in[1];
+ if (symm & SCULPT_SYMM_Z)
+ out[2] = -in[2];
+ else
+ out[2] = in[2];
+
+ out[3] = in[3];
+}
+
+int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNUSED(extend))
+{
+ Sculpt *sd = vc->scene->toolsettings->sculpt;
+ BoundBox bb;
+ bglMats mats = {{0}};
+ float clip_planes[4][4];
+ float clip_planes_final[4][4];
+ ARegion *ar = vc->ar;
+ struct Scene *scene = vc->scene;
+ Object *ob = vc->obact;
+ struct MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
+ PaintMaskFloodMode mode;
+ float value;
+ DerivedMesh *dm;
+ PBVH *pbvh;
+ PBVHNode **nodes;
+ int totnode, i, symmpass;
+ int symm = sd->flags & 7;
+
+ mode = PAINT_MASK_FLOOD_VALUE;
+ value = select ? 1.0 : 0.0;
+
+ /* transform the clip planes in object space */
+ view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, &mats);
+ ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
+ mul_m4_fl(clip_planes, -1.0f);
+
+ ED_sculpt_mask_layers_ensure(ob, mmd);
+
+ dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ pbvh = dm->getPBVH(ob, dm);
+ ob->sculpt->pbvh = pbvh;
+
+ sculpt_undo_push_begin("Mask box fill");
+
+ for (symmpass = 0; symmpass <= symm; ++symmpass) {
+ if (symmpass == 0 ||
+ (symm & symmpass &&
+ (symm != 5 || symmpass != 3) &&
+ (symm != 6 || (symmpass != 3 && symmpass != 5))))
+ {
+ int j = 0;
+
+ /* flip the planes symmetrically as needed */
+ for (; j < 4; j++) {
+ flip_plane(clip_planes_final[j], clip_planes[j], symmpass);
+ }
+
+ BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, clip_planes_final, &nodes, &totnode);
+
+#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+ for (i = 0; i < totnode; i++) {
+ PBVHVertexIter vi;
+ bool any_masked = false;
+
+ BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) {
+ if (is_effected(clip_planes_final, vi.co)) {
+ if (!any_masked) {
+ any_masked = true;
+
+ sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
+
+ BKE_pbvh_node_mark_redraw(nodes[i]);
+ if (BKE_pbvh_type(pbvh) == PBVH_GRIDS)
+ multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
+ mask_flood_fill_set_elem(vi.mask, mode, value);
+ }
+ } BKE_pbvh_vertex_iter_end;
+ }
+
+ if (nodes)
+ MEM_freeN(nodes);
+ }
+ }
+
+ sculpt_undo_push_end();
+
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_FINISHED;
+}
+
+typedef struct LassoMaskData {
+ struct ViewContext *vc;
+ float projviewobjmat[4][4];
+ bool *px;
+ int width;
+ rcti rect; /* bounding box for scanfilling */
+} LassoMaskData;
+
+
+/* Lasso select. This could be defined as part of VIEW3D_OT_select_lasso, still the shortcuts conflict,
+ * so we will use a separate operator */
+
+static bool is_effected_lasso(LassoMaskData *data, float co[3])
+{
+ float scr_co_f[2];
+ short scr_co_s[2];
+
+ /* first project point to 2d space */
+ ED_view3d_project_float_v2_m4(data->vc->ar, co, scr_co_f, data->projviewobjmat);
+
+ scr_co_s[0] = scr_co_f[0];
+ scr_co_s[1] = scr_co_f[1];
+
+ /* clip against screen, because lasso is limited to screen only */
+ if (scr_co_s[0] < data->rect.xmin || scr_co_s[1] < data->rect.ymin || scr_co_s[0] >= data->rect.xmax || scr_co_s[1] >= data->rect.ymax)
+ return false;
+
+ scr_co_s[0] -= data->rect.xmin;
+ scr_co_s[1] -= data->rect.ymin;
+
+ return data->px[scr_co_s[1] * data->width + scr_co_s[0]];
+}
+
+static void mask_lasso_px_cb(int x, int y, void *user_data)
+{
+ struct LassoMaskData *data = user_data;
+ data->px[(y * data->width) + x] = true;
+}
+
+static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
+{
+ int mcords_tot;
+ int (*mcords)[2] = (int (*)[2])WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
+
+ if (mcords) {
+ float clip_planes[4][4];
+ BoundBox bb;
+ bglMats mats = {{0}};
+ Object *ob;
+ ViewContext vc;
+ LassoMaskData data;
+#ifdef _OPENMP
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+#endif
+ struct MultiresModifierData *mmd;
+ DerivedMesh *dm;
+ PBVH *pbvh;
+ PBVHNode **nodes;
+ int totnode, i;
+ PaintMaskFloodMode mode = PAINT_MASK_FLOOD_VALUE;
+ bool select = true; /* TODO: see how to implement deselection */
+ float value = select ? 1.0 : 0.0;
+
+ /* Calculations of individual vertices are done in 2D screen space to diminish the amount of
+ * calculations done. Bounding box PBVH collision is not computed against enclosing rectangle
+ * of lasso */
+ view3d_set_viewcontext(C, &vc);
+ view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats);
+
+ /* lasso data calculations */
+ data.vc = &vc;
+ ob = vc.obact;
+ ED_view3d_ob_project_mat_get(vc.rv3d, ob, data.projviewobjmat);
+
+ BLI_lasso_boundbox(&data.rect, (const int (*)[2])mcords, mcords_tot);
+ data.width = data.rect.xmax - data.rect.xmin;
+ data.px = MEM_callocN(sizeof(*data.px) * data.width * (data.rect.ymax - data.rect.ymin), "lasso_mask_pixel_buffer");
+
+ fill_poly_v2i_n(
+ data.rect.xmin, data.rect.ymin, data.rect.xmax, data.rect.ymax,
+ (const int (*)[2])mcords, mcords_tot,
+ mask_lasso_px_cb, &data);
+
+ ED_view3d_clipping_calc(&bb, clip_planes, &mats, &data.rect);
+ mul_m4_fl(clip_planes, -1.0f);
+
+ mmd = sculpt_multires_active(vc.scene, ob);
+ ED_sculpt_mask_layers_ensure(ob, mmd);
+ dm = mesh_get_derived_final(vc.scene, ob, CD_MASK_BAREMESH);
+ pbvh = dm->getPBVH(ob, dm);
+ ob->sculpt->pbvh = pbvh;
+
+ /* gather nodes inside lasso's enclosing rectangle (should greatly help with bigger meshes) */
+ BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, clip_planes, &nodes, &totnode);
+
+ sculpt_undo_push_begin("Mask lasso fill");
+
+#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+ for (i = 0; i < totnode; i++) {
+ PBVHVertexIter vi;
+ bool any_masked = false;
+
+ BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) {
+ if (is_effected_lasso(&data, vi.co)) {
+ if (!any_masked) {
+ any_masked = true;
+
+ sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
+
+ BKE_pbvh_node_mark_redraw(nodes[i]);
+ if (BKE_pbvh_type(pbvh) == PBVH_GRIDS)
+ multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
+
+ mask_flood_fill_set_elem(vi.mask, mode, value);
+ }
+ } BKE_pbvh_vertex_iter_end;
+ }
+
+ sculpt_undo_push_end();
+
+ if (nodes)
+ MEM_freeN(nodes);
+
+ ED_region_tag_redraw(vc.ar);
+ MEM_freeN((void *)mcords);
+ MEM_freeN(data.px);
+
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_PASS_THROUGH;
+}
+
+void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ ot->name = "Mask Lasso Gesture";
+ ot->idname = "PAINT_OT_mask_lasso_gesture";
+ ot->description = "Add mask within the lasso as you move the pointer";
+
+ ot->invoke = WM_gesture_lasso_invoke;
+ ot->modal = WM_gesture_lasso_modal;
+ ot->exec = paint_mask_gesture_lasso_exec;
+
+ ot->poll = sculpt_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
+}
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 8b038973831..809e9911e09 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -613,13 +613,12 @@ static void stencil_restore(StencilControlData *scd)
*scd->rot_target = scd->init_rot;
}
-static int stencil_control_cancel(bContext *UNUSED(C), wmOperator *op)
+static void stencil_control_cancel(bContext *UNUSED(C), wmOperator *op)
{
StencilControlData *scd = op->customdata;
stencil_restore(scd);
MEM_freeN(op->customdata);
- return OPERATOR_CANCELLED;
}
static void stencil_control_calculate(StencilControlData *scd, const int mval[2])
@@ -987,6 +986,7 @@ void ED_operatortypes_paint(void)
/* paint masking */
WM_operatortype_append(PAINT_OT_mask_flood_fill);
+ WM_operatortype_append(PAINT_OT_mask_lasso_gesture);
}
@@ -1149,6 +1149,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_INVERT);
+ WM_keymap_add_item(keymap, "PAINT_OT_mask_lasso_gesture", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+
/* Toggle dynamic topology */
WM_keymap_add_item(keymap, "SCULPT_OT_dynamic_topology_toggle", DKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index b00b1c3ecff..397baeae4c9 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -718,10 +718,13 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Cancel */
if (event->type == EVT_MODAL_MAP && event->val == PAINT_STROKE_MODAL_CANCEL) {
- if (op->type->cancel)
- return op->type->cancel(C, op);
- else
- return paint_stroke_cancel(C, op);
+ if (op->type->cancel) {
+ op->type->cancel(C, op);
+ }
+ else {
+ paint_stroke_cancel(C, op);
+ }
+ return OPERATOR_CANCELLED;
}
if (event->type == stroke->event_type && event->val == KM_RELEASE && !first_modal) {
@@ -787,10 +790,9 @@ int paint_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-int paint_stroke_cancel(bContext *C, wmOperator *op)
+void paint_stroke_cancel(bContext *C, wmOperator *op)
{
stroke_done(C, op);
- return OPERATOR_CANCELLED;
}
ViewContext *paint_stroke_view_context(PaintStroke *stroke)
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 1c3caf5d8bc..714d67c8039 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -378,12 +378,12 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
if (defgroup) {
int mirrdef;
- char name[MAXBONENAME];
+ char name_flip[MAXBONENAME];
- flip_side_name(name, defgroup->name, FALSE);
- mirrdef = defgroup_name_index(ob, name);
+ BKE_deform_flip_side_name(name_flip, defgroup->name, false);
+ mirrdef = defgroup_name_index(ob, name_flip);
if (mirrdef == -1) {
- if (BKE_defgroup_new(ob, name)) {
+ if (BKE_defgroup_new(ob, name_flip)) {
mirrdef = BLI_countlist(&ob->defbase) - 1;
}
}
@@ -2059,7 +2059,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
BKE_mesh_flush_select_from_polys(me);
}
- /* weight paint spesific */
+ /* weight paint specific */
mesh_octree_table(NULL, NULL, NULL, 'e');
mesh_mirrtopo_table(NULL, 'e');
@@ -2075,7 +2075,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
BKE_paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
- /* weight paint spesific */
+ /* weight paint specific */
mesh_octree_table(ob, NULL, NULL, 's');
ED_vgroup_sync_from_pose(ob);
}
@@ -2593,11 +2593,9 @@ static int wpaint_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int wpaint_cancel(bContext *C, wmOperator *op)
+static void wpaint_cancel(bContext *C, wmOperator *op)
{
paint_stroke_cancel(C, op);
-
- return OPERATOR_CANCELLED;
}
void PAINT_OT_weight_paint(wmOperatorType *ot)
@@ -3144,11 +3142,9 @@ static int vpaint_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int vpaint_cancel(bContext *C, wmOperator *op)
+static void vpaint_cancel(bContext *C, wmOperator *op)
{
paint_stroke_cancel(C, op);
-
- return OPERATOR_CANCELLED;
}
void PAINT_OT_vertex_paint(wmOperatorType *ot)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 2a6b6d4b3d9..6bd935af436 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1082,6 +1082,7 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod
float out_flip[3] = {0.0f, 0.0f, 0.0f};
SculptSession *ss = ob->sculpt;
+ const Brush *brush = BKE_paint_brush(&sd->paint);
int n, original;
/* Grab brush requires to test on original data (see r33888 and
@@ -1090,8 +1091,14 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod
TRUE : ss->cache->original);
/* In general the original coords are not available with dynamic
- * topology */
- if (ss->bm)
+ * topology
+ *
+ * Mask tool could not use undo nodes to get coordinates from
+ * since the coordinates are not stored in those odes.
+ * And mask tool is not gonna to modify vertex coordinates,
+ * so we don't actually need to use modified coords.
+ */
+ if (ss->bm || brush->sculpt_tool == SCULPT_TOOL_MASK)
original = FALSE;
(void)sd; /* unused w/o openmp */
@@ -2481,7 +2488,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
/* for flatten center */
add_v3_v3(fc, private_fc);
- add_v3_v3(fc_flip, private_fc);
+ add_v3_v3(fc_flip, private_fc_flip);
count += private_count;
count_flipped += private_count_flip;
}
@@ -4560,7 +4567,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
+static void sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
@@ -4578,8 +4585,6 @@ static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
}
sculpt_brush_exit_tex(sd);
-
- return OPERATOR_CANCELLED;
}
static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
@@ -4653,7 +4658,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
static void sculpt_dynamic_topology_triangulate(BMesh *bm)
{
if (bm->totloop != bm->totface * 3) {
- BM_mesh_triangulate(bm, false, false, NULL, NULL);
+ BM_mesh_triangulate(bm, MOD_TRIANGULATE_QUAD_FIXED, MOD_TRIANGULATE_NGON_SCANFILL, false, NULL, NULL);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 7a973d8c1ae..626df03a5d4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -480,7 +480,7 @@ static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op)
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), data->timer);
}
if (data->elementMap) {
- EDBM_uv_element_map_free(data->elementMap);
+ BM_uv_element_map_free(data->elementMap);
}
if (data->uv) {
MEM_freeN(data->uv);
@@ -501,7 +501,7 @@ static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op)
static int uv_element_offset_from_face_get(UvElementMap *map, BMFace *efa, BMLoop *l, int island_index, int doIslands)
{
- UvElement *element = ED_uv_element_get(map, efa, l);
+ UvElement *element = BM_uv_element_get(map, efa, l);
if (!element || (doIslands && element->island != island_index)) {
return -1;
}
@@ -566,18 +566,18 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
if (do_island_optimization) {
/* We will need island information */
if (ts->uv_flag & UV_SYNC_SELECTION) {
- data->elementMap = EDBM_uv_element_map_create(em, 0, 1);
+ data->elementMap = BM_uv_element_map_create(bm, false, true);
}
else {
- data->elementMap = EDBM_uv_element_map_create(em, 1, 1);
+ data->elementMap = BM_uv_element_map_create(bm, true, true);
}
}
else {
if (ts->uv_flag & UV_SYNC_SELECTION) {
- data->elementMap = EDBM_uv_element_map_create(em, 0, 0);
+ data->elementMap = BM_uv_element_map_create(bm, false, false);
}
else {
- data->elementMap = EDBM_uv_element_map_create(em, 1, 0);
+ data->elementMap = BM_uv_element_map_create(bm, true, false);
}
}
@@ -596,7 +596,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
Image *ima = CTX_data_edit_image(C);
uv_find_nearest_vert(scene, ima, em, co, NULL, &hit);
- element = ED_uv_element_get(data->elementMap, hit.efa, hit.l);
+ element = BM_uv_element_get(data->elementMap, hit.efa, hit.l);
island_index = element->island;
}
diff --git a/source/blender/editors/sound/SConscript b/source/blender/editors/sound/SConscript
index 016f8055da0..33feedf51cc 100644
--- a/source/blender/editors/sound/SConscript
+++ b/source/blender/editors/sound/SConscript
@@ -44,4 +44,10 @@ incs = ' '.join(incs)
defs = []
+if env['WITH_BF_FFMPEG']:
+ defs.append('WITH_FFMPEG')
+
+if env['WITH_BF_SNDFILE']:
+ defs.append('WITH_SNDFILE')
+
env.BlenderLib ( 'bf_editors_sound', sources, Split(incs), defs, libtype=['core'], priority=[35] )
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index a2189f6237c..81b0992c878 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -77,11 +77,10 @@
/******************** open sound operator ********************/
-static int sound_open_cancel(bContext *UNUSED(C), wmOperator *op)
+static void sound_open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
- return OPERATOR_CANCELLED;
}
static void sound_open_init(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 7d238bf7887..346ffcbc3e2 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -97,12 +97,9 @@ void ED_operatormacros_action(void)
ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate",
"Make a copy of all selected keyframes and move them",
OPTYPE_UNDO | OPTYPE_REGISTER);
- if (ot) {
- WM_operatortype_macro_define(ot, "ACTION_OT_duplicate");
- otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
- RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
- }
-
+ WM_operatortype_macro_define(ot, "ACTION_OT_duplicate");
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
+ RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
}
/* ************************** registration - keymaps **********************************/
@@ -112,21 +109,38 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
wmKeyMapItem *kmi;
/* action_select.c - selection tools */
- /* click-select */
+ /* click-select: keyframe (replace) */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
RNA_boolean_set(kmi->ptr, "column", FALSE);
+ RNA_boolean_set(kmi->ptr, "channel", FALSE);
+ /* click-select: all on same frame (replace) */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
RNA_boolean_set(kmi->ptr, "column", TRUE);
+ RNA_boolean_set(kmi->ptr, "channel", FALSE);
+ /* click-select: keyframe (add) */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
RNA_boolean_set(kmi->ptr, "column", FALSE);
+ RNA_boolean_set(kmi->ptr, "channel", FALSE);
+ /* click-select: all on same frame (add) */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
RNA_boolean_set(kmi->ptr, "column", TRUE);
+ RNA_boolean_set(kmi->ptr, "channel", FALSE);
+ /* click-select: all on same channel (replace) */
+ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", FALSE);
+ RNA_boolean_set(kmi->ptr, "column", FALSE);
+ RNA_boolean_set(kmi->ptr, "channel", TRUE);
+ /* click-select: all on same channel (add) */
+ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT | KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", TRUE);
+ RNA_boolean_set(kmi->ptr, "column", FALSE);
+ RNA_boolean_set(kmi->ptr, "channel", TRUE);
- /* select left/right */
+ /* click-select: left/right */
kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST);
@@ -163,7 +177,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
- /* select linekd */
+ /* select linked */
WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 9d124cf08ee..d62dd88418f 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -930,6 +930,7 @@ void ACTION_OT_select_leftright(wmOperatorType *ot)
* - 1) keyframe under mouse - no special modifiers
* - 2) all keyframes on the same side of current frame indicator as mouse - ALT modifier
* - 3) column select all keyframes in frame under mouse - CTRL modifier
+ * - 4) all keyframes in channel under mouse - CTRL+ALT modifiers
*
* In addition to these basic options, the SHIFT modifier can be used to toggle the
* selection mode between replacing the selection (without) and inverting the selection (with).
@@ -949,24 +950,31 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s
ked.f1 = selx;
/* select the nominated keyframe on the given frame */
- if (ale->type == ANIMTYPE_GPLAYER)
+ if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale->data, selx, select_mode);
- else if (ale->type == ANIMTYPE_MASKLAYER)
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frame(ale->data, selx, select_mode);
+ }
else {
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK) &&
(ale->type == ANIMTYPE_SUMMARY) && (ale->datatype == ALE_ALL))
{
ListBase anim_data = {NULL, NULL};
int filter;
+
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ale->type == ANIMTYPE_GPLAYER)
+ if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale->data, selx, select_mode);
- else if (ale->type == ANIMTYPE_MASKLAYER)
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frame(ale->data, selx, select_mode);
+ }
}
+
BLI_freelistN(&anim_data);
}
else {
@@ -1023,10 +1031,52 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
BLI_freelistN(&ked.list);
BLI_freelistN(&anim_data);
}
+
+/* option 4) select all keyframes in same channel */
+static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, short select_mode)
+{
+ KeyframeEditFunc select_cb;
+
+ /* get functions for selecting keyframes */
+ select_cb = ANIM_editkeyframes_select(select_mode);
+
+ /* select all keyframes in this channel */
+ if (ale->type == ANIMTYPE_GPLAYER) {
+ ED_gpencil_select_frames(ale->data, select_mode);
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
+ ED_mask_select_frames(ale->data, select_mode);
+ }
+ else {
+ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK) &&
+ (ale->type == ANIMTYPE_SUMMARY) && (ale->datatype == ALE_ALL))
+ {
+ ListBase anim_data = {NULL, NULL};
+ int filter;
+
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ if (ale->type == ANIMTYPE_GPLAYER) {
+ ED_gpencil_select_frames(ale->data, select_mode);
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
+ ED_mask_select_frames(ale->data, select_mode);
+ }
+ }
+
+ BLI_freelistN(&anim_data);
+ }
+ else {
+ ANIM_animchannel_keyframes_loop(NULL, ac->ads, ale, NULL, select_cb, NULL);
+ }
+ }
+}
/* ------------------- */
-static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, short column)
+static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel)
{
ListBase anim_data = {NULL, NULL};
DLRBT_Tree anim_keys;
@@ -1211,6 +1261,10 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
/* select all keyframes in the same frame as the one we hit on the active channel */
actkeys_mselect_column(ac, select_mode, selx);
}
+ else if (same_channel) {
+ /* select all keyframes in the active channel */
+ actkeys_mselect_channel_only(ac, ale, select_mode);
+ }
else {
/* select the nominated keyframe on the given frame */
actkeys_mselect_single(ac, ale, select_mode, selx);
@@ -1227,7 +1281,8 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
{
bAnimContext ac;
/* ARegion *ar; */ /* UNUSED */
- short selectmode, column;
+ short selectmode;
+ bool column, channel;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -1244,9 +1299,10 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
/* column selection */
column = RNA_boolean_get(op->ptr, "column");
+ channel = RNA_boolean_get(op->ptr, "channel");
/* select keyframe(s) based upon mouse position*/
- mouse_action_keys(&ac, event->mval, selectmode, column);
+ mouse_action_keys(&ac, event->mval, selectmode, column, channel);
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL);
@@ -1272,10 +1328,16 @@ void ACTION_OT_clickselect(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
- prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
+ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select",
+ "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select",
+ "Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", ""); // ALTKEY
+ prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel",
+ "Select all the keyframes in the channel under the mouse"); // CTRLKEY + ALTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index a89a02b7e01..fdccedd9c3c 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -541,7 +541,7 @@ void ED_spacetype_action(void)
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 200;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
art->init = action_channel_area_init;
art->draw = action_channel_area_draw;
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index bb0521d6589..e2262398a52 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -133,6 +133,7 @@ void ED_spacetypes_init(void)
* maybe we'll need to have them go after python operators too? */
ED_operatormacros_armature();
ED_operatormacros_mesh();
+ ED_operatormacros_metaball();
ED_operatormacros_node();
ED_operatormacros_object();
ED_operatormacros_file();
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index cf277957e70..4fbf5aa5fb7 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -158,12 +158,10 @@ static int file_browse_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int file_browse_cancel(bContext *UNUSED(C), wmOperator *op)
+static void file_browse_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
-
- return OPERATOR_CANCELLED;
}
static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 8508123f942..975123f244c 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -516,7 +516,7 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS
if (!last_category || strcmp(last_category, user->category) != 0) {
uiItemL(layout, user->category, ICON_NONE);
but = block->buttons.last;
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
}
/* create button */
@@ -577,7 +577,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C)
/* some cosmetic tweaks */
but->type = MENU;
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
but->flag &= ~UI_ICON_SUBMENU;
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index f5db34d87d7..0e1a2f98d40 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -639,7 +639,7 @@ static unsigned char *prefetch_read_file_to_memory(MovieClip *clip, int current_
BKE_movieclip_filename_for_frame(clip, &user, name);
- file = open(name, O_BINARY | O_RDONLY, 0);
+ file = BLI_open(name, O_BINARY | O_RDONLY, 0);
if (file < 0) {
return NULL;
}
@@ -711,7 +711,7 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip
current_frame = prefetch_find_uncached_frame(clip, queue->current_frame + 1, queue->end_frame,
queue->render_size, queue->render_flag, 1);
/* switch direction if read frames from current up to scene end frames */
- if (current_frame >= queue->end_frame) {
+ if (current_frame > queue->end_frame) {
queue->current_frame = queue->initial_frame;
queue->direction = -1;
}
@@ -752,6 +752,7 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip
static void *do_prefetch_thread(void *data_v)
{
PrefetchThread *data = (PrefetchThread *) data_v;
+ MovieClip *clip = data->clip;
unsigned char *mem;
size_t size;
int current_frame;
@@ -766,7 +767,7 @@ static void *do_prefetch_thread(void *data_v)
user.render_size = data->queue->render_size;
user.render_flag = data->queue->render_flag;
- ibuf = IMB_ibImageFromMemory(mem, size, flag, NULL, "prefetch frame");
+ ibuf = IMB_ibImageFromMemory(mem, size, flag, clip->colorspace_settings.name, "prefetch frame");
result = BKE_movieclip_put_frame_if_possible(data->clip, &user, ibuf);
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 173d65ee4fc..80b844464db 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -123,10 +123,16 @@ static void tracking_segment_end_cb(void *UNUSED(userdata))
glLineWidth(1.0f);
}
+typedef struct TrackMotionCurveUserData {
+ MovieTrackingTrack *act_track;
+ bool sel;
+ float xscale, yscale, hsize;
+} TrackMotionCurveUserData;
+
static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
MovieTrackingMarker *marker, int coord, int scene_framenr, float val)
{
- struct { MovieTrackingTrack *act_track; bool sel; float xscale, yscale, hsize; } *data = userdata;
+ TrackMotionCurveUserData *data = (TrackMotionCurveUserData *) userdata;
int sel = 0, sel_flag;
if (track != data->act_track)
@@ -151,7 +157,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
int width, height;
- struct { MovieTrackingTrack *act_track; bool sel; float xscale, yscale, hsize; } userdata;
+ TrackMotionCurveUserData userdata;
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
@@ -163,19 +169,25 @@ 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, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
&userdata, tracking_segment_knot_cb, NULL, NULL);
/* draw graph lines */
glEnable(GL_BLEND);
- clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
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, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
&userdata, tracking_segment_knot_cb, NULL, NULL);
}
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 393f92f5af5..d1c44693995 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -190,8 +190,10 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
if (!extend) {
SelectUserData selectdata = {SEL_DESELECT};
- clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
- sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata,
+ clip_graph_tracking_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
+ &selectdata,
toggle_selection_cb);
}
@@ -217,7 +219,9 @@ static bool mouse_select_curve(bContext *C, float co[2], bool extend)
MouseSelectUserData userdata;
mouse_select_init_data(&userdata, co);
- clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
&userdata, find_nearest_tracking_segment_cb,
NULL, find_nearest_tracking_segment_end_cb);
@@ -237,9 +241,10 @@ static bool mouse_select_curve(bContext *C, float co[2], bool extend)
BKE_tracking_track_select(tracksbase, userdata.track, TRACK_AREA_ALL, TRUE);
/* deselect all knots on newly selected curve */
- clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
- sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata,
- toggle_selection_cb);
+ clip_graph_tracking_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
+ &selectdata, toggle_selection_cb);
}
return true;
@@ -565,9 +570,10 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
userdata.max = -FLT_MAX;
userdata.min = FLT_MAX;
- 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);
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
+ &userdata, view_all_cb, NULL, NULL);
/* set extents of view to start/end frames */
v2d->cur.xmin = (float) SFRA;
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 39af856d280..513014a2d0d 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -126,12 +126,12 @@ void clip_graph_tracking_values_iterate_track(struct SpaceClip *sc, struct Movie
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 clip_graph_tracking_values_iterate(struct SpaceClip *sc, bool selected_only, bool 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, int selected_only, int include_hidden, void *userdata,
+void clip_graph_tracking_iterate(struct SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata,
void (*func)(void *userdata, struct MovieTrackingMarker *marker));
void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track);
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index a76f4364492..9aa6eab7fc8 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -159,12 +159,10 @@ static void open_init(bContext *C, wmOperator *op)
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
}
-static int open_cancel(bContext *UNUSED(C), wmOperator *op)
+static void open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
-
- return OPERATOR_CANCELLED;
}
static int open_exec(bContext *C, wmOperator *op)
@@ -444,11 +442,9 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int view_pan_cancel(bContext *C, wmOperator *op)
+static void view_pan_cancel(bContext *C, wmOperator *op)
{
- view_pan_exit(C, op, 1);
-
- return OPERATOR_CANCELLED;
+ view_pan_exit(C, op, true);
}
void CLIP_OT_view_pan(wmOperatorType *ot)
@@ -578,11 +574,9 @@ static int view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int view_zoom_cancel(bContext *C, wmOperator *op)
+static void view_zoom_cancel(bContext *C, wmOperator *op)
{
- view_zoom_exit(C, op, 1);
-
- return OPERATOR_CANCELLED;
+ view_zoom_exit(C, op, true);
}
void CLIP_OT_view_zoom(wmOperatorType *ot)
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 635aa388541..060531ae82c 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -37,7 +37,9 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
@@ -125,7 +127,7 @@ void clip_graph_tracking_values_iterate_track(
}
void clip_graph_tracking_values_iterate(
- SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
+ SpaceClip *sc, bool selected_only, bool 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),
@@ -147,7 +149,7 @@ void clip_graph_tracking_values_iterate(
}
}
-void clip_graph_tracking_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
+void clip_graph_tracking_iterate(SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata,
void (*func)(void *userdata, MovieTrackingMarker *marker))
{
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -184,8 +186,8 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track)
MovieTrackingPlaneTrack *plane_track, *next_plane_track;
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
-
bool has_bundle = false, update_stab = false;
+ char track_name_escaped[MAX_NAME], prefix[MAX_NAME * 2];
if (track == act_track)
tracking->act_track = NULL;
@@ -245,6 +247,11 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track)
}
}
+ /* Delete f-curves associated with the track (such as weight, i.e.) */
+ BLI_strescape(track_name_escaped, track->name, sizeof(track_name_escaped));
+ BLI_snprintf(prefix, sizeof(prefix), "tracks[\"%s\"]", track_name_escaped);
+ BKE_animdata_fix_paths_remove(&clip->id, prefix);
+
BKE_tracking_track_free(track);
BLI_freelinkN(tracksbase, track);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 246ea7fe140..5607d7dc635 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -1097,16 +1097,16 @@ static int track_markers_testbreak(void)
return G.is_break;
}
-static int track_count_markers(SpaceClip *sc, MovieClip *clip)
+static int track_count_markers(SpaceClip *sc, MovieClip *clip, int framenr)
{
int tot = 0;
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
- int framenr = ED_space_clip_get_clip_frame_number(sc);
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
+ bool selected = sc ? TRACK_VIEW_SELECTED(sc, track) : TRACK_SELECTED(track);
+ if (selected && (track->flag & TRACK_LOCKED) == 0) {
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (!marker || (marker->flag & MARKER_DISABLED) == 0)
@@ -1142,18 +1142,20 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip)
}
}
-static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit_r)
+static void track_init_markers(SpaceClip *sc, MovieClip *clip, int framenr, int *frames_limit_r)
{
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
- int framenr = ED_space_clip_get_clip_frame_number(sc);
int frames_limit = 0;
- clear_invisible_track_selection(sc, clip);
+ if (sc != NULL) {
+ clear_invisible_track_selection(sc, clip);
+ }
track = tracksbase->first;
while (track) {
- if (TRACK_VIEW_SELECTED(sc, track)) {
+ bool selected = sc ? TRACK_VIEW_SELECTED(sc, track) : TRACK_SELECTED(track);
+ if (selected) {
if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) {
BKE_tracking_marker_ensure(track, framenr);
@@ -1193,8 +1195,9 @@ static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backward
Scene *scene = CTX_data_scene(C);
MovieTrackingSettings *settings = &clip->tracking.settings;
int frames_limit;
+ int framenr = ED_space_clip_get_clip_frame_number(sc);
- track_init_markers(sc, clip, &frames_limit);
+ track_init_markers(sc, clip, framenr, &frames_limit);
tmj->sfra = ED_space_clip_get_clip_frame_number(sc);
tmj->clip = clip;
@@ -1317,20 +1320,49 @@ static void track_markers_freejob(void *tmv)
static int track_markers_exec(bContext *C, wmOperator *op)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip_get_clip(sc);
+ SpaceClip *sc;
+ MovieClip *clip;
Scene *scene = CTX_data_scene(C);
struct MovieTrackingContext *context;
- int framenr = ED_space_clip_get_clip_frame_number(sc);
- int sfra = framenr, efra;
+ MovieClipUser *user, fake_user = {0};
+ int framenr, sfra, efra;
int backwards = RNA_boolean_get(op->ptr, "backwards");
int sequence = RNA_boolean_get(op->ptr, "sequence");
int frames_limit;
- if (track_count_markers(sc, clip) == 0)
+ if (RNA_struct_property_is_set(op->ptr, "clip")) {
+ Main *bmain = CTX_data_main(C);
+ char clip_name[MAX_ID_NAME - 2];
+
+ RNA_string_get(op->ptr, "clip", clip_name);
+ clip = (MovieClip *)BLI_findstring(&bmain->movieclip, clip_name, offsetof(ID, name) + 2);
+ sc = NULL;
+
+ if (clip == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+ framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, CFRA);
+ fake_user.framenr = framenr;
+ user = &fake_user;
+ }
+ else {
+ sc = CTX_wm_space_clip(C);
+
+ if (sc == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ clip = ED_space_clip_get_clip(sc);
+ framenr = ED_space_clip_get_clip_frame_number(sc);
+ user = &sc->user;
+ }
+
+ sfra = framenr;
+
+ if (track_count_markers(sc, clip, framenr) == 0)
return OPERATOR_CANCELLED;
- track_init_markers(sc, clip, &frames_limit);
+ track_init_markers(sc, clip, framenr, &frames_limit);
if (backwards)
efra = SFRA;
@@ -1351,7 +1383,7 @@ static int track_markers_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
/* do not disable tracks due to threshold when tracking frame-by-frame */
- context = BKE_tracking_context_new(clip, &sc->user, backwards, sequence);
+ context = BKE_tracking_context_new(clip, user, backwards, sequence);
while (framenr != efra) {
if (!BKE_tracking_context_step(context))
@@ -1382,10 +1414,21 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
TrackMarkersJob *tmj;
ScrArea *sa = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip_get_clip(sc);
+ MovieClip *clip;
wmJob *wm_job;
- int backwards = RNA_boolean_get(op->ptr, "backwards");
- int sequence = RNA_boolean_get(op->ptr, "sequence");
+ bool backwards = RNA_boolean_get(op->ptr, "backwards");
+ bool sequence = RNA_boolean_get(op->ptr, "sequence");
+ int framenr;
+
+ if (sc == NULL) {
+ /* TODO(sergey): Support clip for invoke as well. */
+ BKE_report(op->reports, RPT_ERROR,
+ "Invoking this operator only supported from Clip Editor space");
+ return OPERATOR_CANCELLED;
+ }
+
+ clip = ED_space_clip_get_clip(sc);
+ framenr = ED_space_clip_get_clip_frame_number(sc);
if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) {
/* only one tracking is allowed at a time */
@@ -1395,7 +1438,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
if (clip->tracking_context)
return OPERATOR_CANCELLED;
- if (track_count_markers(sc, clip) == 0)
+ if (track_count_markers(sc, clip, framenr) == 0)
return OPERATOR_CANCELLED;
if (!sequence)
@@ -1453,6 +1496,8 @@ static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), const wmEven
void CLIP_OT_track_markers(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Track Markers";
ot->description = "Track selected markers";
@@ -1461,7 +1506,6 @@ void CLIP_OT_track_markers(wmOperatorType *ot)
/* api callbacks */
ot->exec = track_markers_exec;
ot->invoke = track_markers_invoke;
- ot->poll = ED_space_clip_tracking_poll;
ot->modal = track_markers_modal;
/* flags */
@@ -1470,6 +1514,8 @@ void CLIP_OT_track_markers(wmOperatorType *ot)
/* properties */
RNA_def_boolean(ot->srna, "backwards", 0, "Backwards", "Do backwards tracking");
RNA_def_boolean(ot->srna, "sequence", 0, "Track Sequence", "Track marker during image sequence rather than single image");
+ prop = RNA_def_string(ot->srna, "clip", "", MAX_NAME, "Movie Clip", "Movie Clip to be tracked");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/********************** refine track position operator *********************/
@@ -1550,7 +1596,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
scj->reports = op->reports;
scj->user = sc->user;
- scj->context = BKE_tracking_reconstruction_context_new(tracking, object,
+ scj->context = BKE_tracking_reconstruction_context_new(clip, object,
object->keyframe1, object->keyframe2, width, height);
tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats");
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index 289986d7fba..f24a204912e 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -1123,10 +1123,9 @@ static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *even
return OPERATOR_RUNNING_MODAL;
}
-static int console_modal_select_cancel(bContext *C, wmOperator *op)
+static void console_modal_select_cancel(bContext *C, wmOperator *op)
{
console_cursor_set_exit(C, op);
- return OPERATOR_FINISHED;
}
void CONSOLE_OT_select_set(wmOperatorType *ot)
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 43df3be45ac..1ec2e3c804b 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -188,7 +188,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
uiButSetFlag(but, UI_BUT_NO_UTF8);
if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
- but = uiDefBut(block, TEX, B_FS_FILENAME, "",
+ but = uiDefButTextO(block, TEX, "FILE_OT_filename", 0, "",
min_x, line2_y, line2_w - chan_offs, btn_h,
params->file, 0.0, (float)FILE_MAXFILE, 0, 0,
TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name")));
@@ -251,6 +251,9 @@ static int get_file_icon(struct direntry *file)
if (strcmp(file->relname, "..") == 0) {
return ICON_FILE_PARENT;
}
+ if (file->flags & APPLICATIONBUNDLE) {
+ return ICON_UGLYPACKAGE;
+ }
if (file->flags & BLENDERFILE) {
return ICON_FILE_BLEND;
}
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index d01286442be..134fe0ac6bc 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -73,6 +73,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot);
void FILE_OT_parent(struct wmOperatorType *ot);
void FILE_OT_directory_new(struct wmOperatorType *ot);
void FILE_OT_directory(struct wmOperatorType *ot);
+void FILE_OT_filename(struct wmOperatorType *ot);
void FILE_OT_previous(struct wmOperatorType *ot);
void FILE_OT_next(struct wmOperatorType *ot);
void FILE_OT_refresh(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index a97b3b1d719..ca2f7b41334 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -32,6 +32,8 @@
#include "BLI_utildefines.h"
#include "BLI_fileops_types.h"
+#include "BLO_readfile.h"
+
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_global.h"
@@ -1240,13 +1242,31 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
return OPERATOR_FINISHED;
}
+static int file_filename_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ SpaceFile *sfile = CTX_wm_space_file(C);
+
+ if (sfile->params) {
+ file_expand_directory(C);
+
+ return file_filename_exec(C, op);
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
int file_filename_exec(bContext *C, wmOperator *UNUSED(unused))
{
SpaceFile *sfile = CTX_wm_space_file(C);
char matched_file[FILE_MAX];
+ char filepath[sizeof(sfile->params->dir)];
+
if (sfile->params) {
+ int matches = 0;
matched_file[0] = '\0';
- if (file_select_match(sfile, sfile->params->file, matched_file)) {
+ filepath[0] = '\0';
+
+ if ((matches = file_select_match(sfile, sfile->params->file, matched_file))) {
/* int i, numfiles = filelist_numfiles(sfile->files); */ /* XXX UNUSED */
sfile->params->file[0] = '\0';
/* replace the pattern (or filename that the user typed in, with the first selected file of the match */
@@ -1254,6 +1274,31 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused))
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
}
+
+ if (matches == 1) {
+
+ BLI_join_dirfile(filepath, sizeof(sfile->params->dir), sfile->params->dir, sfile->params->file);
+
+ /* if directory, open it and empty filename field */
+ if (BLI_is_dir(filepath)) {
+ BLI_cleanup_dir(G.main->name, filepath);
+ BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
+ sfile->params->file[0] = '\0';
+ file_change_dir(C, 1);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ }
+ else if (sfile->params->type == FILE_LOADLIB) {
+ char tdir[FILE_MAX], tgroup[FILE_MAX];
+ BLI_add_slash(filepath);
+ if (BLO_is_a_library(filepath, tdir, tgroup)) {
+ BLI_cleanup_dir(G.main->name, filepath);
+ BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
+ sfile->params->file[0] = '\0';
+ file_change_dir(C, 0);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
+ }
+ }
+ }
}
return OPERATOR_FINISHED;
@@ -1281,6 +1326,18 @@ void FILE_OT_directory(struct wmOperatorType *ot)
ot->poll = file_directory_poll; /* <- important, handler is on window level */
}
+void FILE_OT_filename(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Enter File Name";
+ ot->description = "Enter a file name";
+ ot->idname = "FILE_OT_filename";
+
+ /* api callbacks */
+ ot->invoke = file_filename_invoke;
+ ot->exec = file_filename_exec;
+}
+
void FILE_OT_refresh(struct wmOperatorType *ot)
{
/* identifiers */
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index f4161c7da1c..1809c6cb835 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -116,7 +116,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat
but = uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, nr, 0, i, 0, 0, entry);
uiButSetFunc(but, file_panel_cb, entry, NULL);
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
- uiButSetFlag(but, UI_ICON_LEFT | UI_TEXT_LEFT);
+ uiButSetDrawFlag(but, UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT);
/* create delete button */
if (allow_delete && fsmenu_can_save(fsmenu, category, i)) {
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 19a6296993d..a2f81498dd3 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -764,56 +764,73 @@ static int file_is_blend_backup(const char *str)
return (retval);
}
-
-static int file_extension_type(const char *relname)
+static int path_extension_type(const char *path)
{
- if (BLO_has_bfile_extension(relname)) {
+ if (BLO_has_bfile_extension(path)) {
return BLENDERFILE;
}
- else if (file_is_blend_backup(relname)) {
+ else if (file_is_blend_backup(path)) {
return BLENDERFILE_BACKUP;
}
- else if (BLI_testextensie(relname, ".py")) {
+ else if (BLI_testextensie(path, ".app")) {
+ return APPLICATIONBUNDLE;
+ }
+ else if (BLI_testextensie(path, ".py")) {
return PYSCRIPTFILE;
}
- else if (BLI_testextensie(relname, ".txt") ||
- BLI_testextensie(relname, ".glsl") ||
- BLI_testextensie(relname, ".osl") ||
- BLI_testextensie(relname, ".data"))
+ else if (BLI_testextensie(path, ".txt") ||
+ BLI_testextensie(path, ".glsl") ||
+ BLI_testextensie(path, ".osl") ||
+ BLI_testextensie(path, ".data"))
{
return TEXTFILE;
}
- else if (BLI_testextensie(relname, ".ttf") ||
- BLI_testextensie(relname, ".ttc") ||
- BLI_testextensie(relname, ".pfb") ||
- BLI_testextensie(relname, ".otf") ||
- BLI_testextensie(relname, ".otc"))
+ else if (BLI_testextensie(path, ".ttf") ||
+ BLI_testextensie(path, ".ttc") ||
+ BLI_testextensie(path, ".pfb") ||
+ BLI_testextensie(path, ".otf") ||
+ BLI_testextensie(path, ".otc"))
{
return FTFONTFILE;
}
- else if (BLI_testextensie(relname, ".btx")) {
+ else if (BLI_testextensie(path, ".btx")) {
return BTXFILE;
}
- else if (BLI_testextensie(relname, ".dae")) {
+ else if (BLI_testextensie(path, ".dae")) {
return COLLADAFILE;
}
- else if (BLI_testextensie_array(relname, imb_ext_image) ||
- (G.have_quicktime && BLI_testextensie_array(relname, imb_ext_image_qt)))
+ else if (BLI_testextensie_array(path, imb_ext_image) ||
+ (G.have_quicktime && BLI_testextensie_array(path, imb_ext_image_qt)))
{
return IMAGEFILE;
}
- else if (BLI_testextensie_array(relname, imb_ext_movie)) {
+ else if (BLI_testextensie(path, ".ogg")) {
+ if (IMB_isanim(path)) {
+ return MOVIEFILE;
+ }
+ else {
+ return SOUNDFILE;
+ }
+ }
+ else if (BLI_testextensie_array(path, imb_ext_movie)) {
return MOVIEFILE;
}
- else if (BLI_testextensie_array(relname, imb_ext_audio)) {
+ else if (BLI_testextensie_array(path, imb_ext_audio)) {
return SOUNDFILE;
}
return 0;
}
-int ED_file_extension_icon(const char *relname)
+static int file_extension_type(const char *dir, const char *relname)
{
- int type = file_extension_type(relname);
+ char path[FILE_MAX];
+ BLI_join_dirfile(path, sizeof(path), dir, relname);
+ return path_extension_type(path);
+}
+
+int ED_file_extension_icon(const char *path)
+{
+ int type = path_extension_type(path);
if (type == BLENDERFILE)
return ICON_FILE_BLEND;
@@ -848,12 +865,13 @@ static void filelist_setfiletypes(struct FileList *filelist)
for (num = 0; num < filelist->numfiles; num++, file++) {
file->type = file->s.st_mode; /* restore the mess below */
-
- /* Don't check extensions for directories */
+#ifndef __APPLE__
+ /* Don't check extensions for directories, allow in OSX cause bundles have extensions*/
if (file->type & S_IFDIR) {
continue;
}
- file->flags = file_extension_type(file->relname);
+#endif
+ file->flags = file_extension_type(filelist->dir, file->relname);
if (filelist->filter_glob[0] &&
BLI_testextensie_glob(file->relname, filelist->filter_glob))
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 9d762c80405..3cda5dd5e80 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -627,7 +627,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche
if (!match) {
BLI_strncpy(matched_file, file->relname, FILE_MAX);
}
- match = 1;
+ match++;
}
}
@@ -637,7 +637,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche
bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
{
SpaceFile *sfile = CTX_wm_space_file(C);
- bool change = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
/* search if str matches the beginning of name */
if (str[0] && sfile->files) {
@@ -672,9 +672,9 @@ bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
}
closedir(dir);
- change = autocomplete_end(autocpl, str);
- if (change) {
- if (BLI_exists(str)) {
+ match = autocomplete_end(autocpl, str);
+ if (match) {
+ if (match == AUTOCOMPLETE_FULL_MATCH) {
BLI_add_slash(str);
}
else {
@@ -684,13 +684,13 @@ bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
}
}
- return change;
+ return match == AUTOCOMPLETE_FULL_MATCH;
}
bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
{
SpaceFile *sfile = CTX_wm_space_file(C);
- bool change = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
/* search if str matches the beginning of name */
if (str[0] && sfile->files) {
@@ -700,13 +700,13 @@ bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
for (i = 0; i < nentries; ++i) {
struct direntry *file = filelist_file(sfile->files, i);
- if (file && S_ISREG(file->type)) {
+ if (file && (S_ISREG(file->type) || S_ISDIR(file->type))) {
autocomplete_do_name(autocpl, file->relname);
}
}
- change = autocomplete_end(autocpl, str);
+ match = autocomplete_end(autocpl, str);
}
- return change;
+ return match == AUTOCOMPLETE_FULL_MATCH;
}
void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile)
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 04c68e5ea68..62cf4889797 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -55,9 +55,7 @@
#endif
#ifdef __APPLE__
-/* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */
-# define ID ID_
-# include <CoreServices/CoreServices.h>
+#include <Carbon/Carbon.h>
#endif /* __APPLE__ */
#ifdef __linux__
@@ -350,7 +348,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
#else
#ifdef __APPLE__
{
-#if (MAC_OS_X_VERSION_MIN_REQUIRED <= 1040)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED <= 1050)
OSErr err = noErr;
int i;
const char *home;
@@ -399,71 +397,38 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
-#else
- /* 10.5 provides ability to retrieve Finder favorite places */
- UInt32 seed;
- OSErr err = noErr;
- CFArrayRef pathesArray;
- LSSharedFileListRef list;
- LSSharedFileListItemRef itemRef;
- CFIndex i, pathesCount;
- CFURLRef cfURL = NULL;
- CFStringRef pathString = NULL;
+#else /* OSX 10.6+ */
+ /* Get mounted volumes better method OSX 10.6 and higher, see: */
+ /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/
+ /* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */
- /* First get local mounted volumes */
- list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteVolumes, NULL);
- pathesArray = LSSharedFileListCopySnapshot(list, &seed);
- pathesCount = CFArrayGetCount(pathesArray);
+ CFURLRef cfURL = NULL;
+ CFURLEnumeratorResult result = kCFURLEnumeratorSuccess;
+ CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL);
- for (i = 0; i < pathesCount; i++) {
- itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i);
-
- err = LSSharedFileListItemResolve(itemRef,
- kLSSharedFileListNoUserInteraction |
- kLSSharedFileListDoNotMountVolumes,
- &cfURL, NULL);
- if (err != noErr)
- continue;
-
- pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
-
- if (!CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingASCII))
+ while (result != kCFURLEnumeratorEnd) {
+ unsigned char defPath[FILE_MAX];
+
+ result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL);
+ if (result != kCFURLEnumeratorSuccess)
continue;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED);
- CFRelease(pathString);
- CFRelease(cfURL);
+ CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)defPath, FS_INSERT_SORTED);
}
- CFRelease(pathesArray);
- CFRelease(list);
-
- /* Then get network volumes */
- err = noErr;
- for (i = 1; err != nsvErr; i++) {
- FSRef dir;
- FSVolumeRefNum volRefNum;
- struct GetVolParmsInfoBuffer volParmsBuffer;
- unsigned char path[FILE_MAX];
-
- err = FSGetVolumeInfo(kFSInvalidVolumeRefNum, i, &volRefNum, kFSVolInfoNone, NULL, NULL, &dir);
- if (err != noErr)
- continue;
-
- err = FSGetVolumeParms(volRefNum, &volParmsBuffer, sizeof(volParmsBuffer));
- if ((err != noErr) || (volParmsBuffer.vMServerAdr == 0)) /* Exclude local devices */
- continue;
-
-
- FSRefMakePath(&dir, path, FILE_MAX);
- if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) {
- /* /net and /home are meaningless on OSX, home folders are stored in /Users */
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
- }
- }
+ CFRelease(volEnum);
/* Finally get user favorite places */
if (read_bookmarks) {
+ UInt32 seed;
+ OSErr err = noErr;
+ CFArrayRef pathesArray;
+ LSSharedFileListRef list;
+ LSSharedFileListItemRef itemRef;
+ CFIndex i, pathesCount;
+ CFURLRef cfURL = NULL;
+ CFStringRef pathString = NULL;
list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL);
pathesArray = LSSharedFileListCopySnapshot(list, &seed);
pathesCount = CFArrayGetCount(pathesArray);
@@ -491,7 +456,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
CFRelease(pathesArray);
CFRelease(list);
}
-#endif /* OSX 10.5+ */
+#endif /* OSX 10.6+ */
}
#else
/* unix */
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 1a8565a58b1..0bc2d073e0a 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -396,6 +396,7 @@ static void file_operatortypes(void)
WM_operatortype_append(FILE_OT_rename);
WM_operatortype_append(FILE_OT_smoothscroll);
WM_operatortype_append(FILE_OT_directory);
+ WM_operatortype_append(FILE_OT_filename);
}
/* NOTE: do not add .blend file reading on this level */
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 23c39a5e99a..e7c98437b9f 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -206,7 +206,7 @@ static void draw_fcurve_handle_control(float x, float y, float xscale, float ysc
}
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
-static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only)
+static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only, float units_scale)
{
BezTriple *bezt = fcu->bezt;
BezTriple *prevbezt = NULL;
@@ -216,6 +216,9 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2
/* get view settings */
hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
UI_view2d_getscale(v2d, &xscale, &yscale);
+
+ /* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */
+ yscale *= units_scale;
/* set handle color */
if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
@@ -271,7 +274,7 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel)
}
-static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only)
+static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only, float units_scale)
{
View2D *v2d = &ar->v2d;
@@ -287,10 +290,10 @@ static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short
/* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */
if (do_handles) {
set_fcurve_vertex_color(fcu, 0);
- draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only);
+ draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only, units_scale);
set_fcurve_vertex_color(fcu, 1);
- draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only);
+ draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only, units_scale);
}
/* draw keyframes over the handles */
@@ -487,6 +490,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
float stime, etime;
float unitFac;
float dx, dy;
+ short mapping_flag = ANIM_get_normalization_flags(ac);
/* when opening a blend file on a different sized screen or while dragging the toolbar this can happen
* best just bail out in this case */
@@ -500,7 +504,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
fcu->driver = NULL;
/* compute unit correction factor */
- unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0);
+ unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag);
/* Note about sampling frequency:
* Ideally, this is chosen such that we have 1-2 pixels = 1 segment
@@ -547,11 +551,15 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
FPoint *fpt = prevfpt + 1;
float fac, v[2];
int b = fcu->totvert - 1;
-
- glBegin(GL_LINE_STRIP);
-
+ float unit_scale;
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+
/* apply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0);
+ glPushMatrix();
+ unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag);
+ glScalef(1.0f, unit_scale, 1.0f);
+
+ glBegin(GL_LINE_STRIP);
/* extrapolate to left? - left-side of view comes before first keyframe? */
if (prevfpt->vec[0] > v2d->cur.xmin) {
@@ -611,10 +619,8 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
glVertex2fv(v);
}
- /* unapply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE);
-
glEnd();
+ glPopMatrix();
}
/* helper func - draw one repeat of an F-Curve */
@@ -627,11 +633,15 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
float fac = 0.0f;
int b = fcu->totvert - 1;
int resol;
-
- glBegin(GL_LINE_STRIP);
-
+ float unit_scale;
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+
/* apply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0);
+ glPushMatrix();
+ unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag);
+ glScalef(1.0f, unit_scale, 1.0f);
+
+ glBegin(GL_LINE_STRIP);
/* extrapolate to left? */
if (prevbezt->vec[1][0] > v2d->cur.xmin) {
@@ -766,10 +776,8 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
glVertex2fv(v1);
}
- /* unapply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE);
-
glEnd();
+ glPopMatrix();
}
/* Debugging -------------------------------- */
@@ -783,7 +791,8 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
{
ChannelDriver *driver = fcu->driver;
View2D *v2d = &ac->ar->v2d;
- float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, false);
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+ float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag);
/* for now, only show when debugging driver... */
//if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
@@ -1014,9 +1023,12 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
}
}
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
- /* apply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, fcu, 0);
-
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag);
+
+ glPushMatrix();
+ glScalef(1.0f, unit_scale, 1.0f);
+
if (fcu->bezt) {
int do_handles = draw_fcurve_handles_check(sipo, fcu);
@@ -1027,15 +1039,14 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
glDisable(GL_BLEND);
}
- draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY));
+ draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY), unit_scale);
}
else {
/* samples: only draw two indicators at either end as indicators */
draw_fcurve_samples(sipo, ar, fcu);
}
-
- /* unapply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, fcu, ANIM_UNITCONV_RESTORE);
+
+ glPopMatrix();
}
}
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 274c06bf871..db13e2a4024 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -116,6 +116,8 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
/* get range */
if (calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, do_sel_only, include_handles)) {
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+
/* apply NLA scaling */
if (adt) {
txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP);
@@ -123,7 +125,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
}
/* apply unit corrections */
- unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
+ unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag);
tymin *= unitFac;
tymax *= unitFac;
@@ -330,12 +332,14 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
FPoint *fpt;
float unitFac;
int cfra;
-
+ SpaceIpo *sipo = (SpaceIpo *) ac->sl;
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+
/* disable driver so that it don't muck up the sampling process */
fcu->driver = NULL;
/* calculate unit-mapping factor */
- unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
+ unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag);
/* create samples, but store them in a new curve
* - we cannot use fcurve_store_samples() as that will only overwrite the original curve
@@ -578,6 +582,8 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
* keyframes if these will be visible after doing so...
*/
if (fcurve_is_keyframable(fcu)) {
+ short mapping_flag = ANIM_get_normalization_flags(&ac);
+
/* get frame and value from props */
frame = RNA_float_get(op->ptr, "frame");
val = RNA_float_get(op->ptr, "value");
@@ -587,7 +593,7 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
frame = BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP);
/* apply inverse unit-mapping to value to get correct value for F-Curves */
- val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1);
+ val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, mapping_flag | ANIM_UNITCONV_RESTORE);
/* insert keyframe on the specified frame + value */
insert_vert_fcurve(fcu, frame, val, 0);
@@ -1787,20 +1793,24 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
-
+ short mapping_flag = ANIM_get_normalization_flags(&ac);
+ KeyframeEditData current_ked;
+ float unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS);
+
+ memset(&current_ked, 0, sizeof(current_ked));
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
- ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
+ ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
- ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | ANIM_UNITCONV_ONLYKEYS);
+ ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
+
+ ked.f1 += current_ked.f1;
+ ked.i1 += current_ked.i1;
+ ked.f2 += current_ked.f2 / unit_scale;
+ ked.i2 += current_ked.i2;
}
BLI_freelistN(&anim_data);
@@ -1865,6 +1875,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
KeyframeEditData ked;
KeyframeEditFunc edit_cb;
+ float cursor_value = 0.0f;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
@@ -1881,16 +1892,17 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
}
else if (mode == GRAPHKEYS_SNAP_VALUE) {
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
- ked.f1 = (sipo) ? sipo->cursorVal : 0.0f;
+ cursor_value = (sipo) ? sipo->cursorVal : 0.0f;
}
/* snap keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0);
-
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag);
+
+ ked.f1 = cursor_value / unit_scale;
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -1898,9 +1910,6 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
}
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE);
}
BLI_freelistN(&anim_data);
@@ -1977,7 +1986,8 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
KeyframeEditData ked;
KeyframeEditFunc edit_cb;
-
+ float cursor_value = 0.0f;
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_mirror(mode);
@@ -2000,7 +2010,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
}
else if (mode == GRAPHKEYS_MIRROR_VALUE) {
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
- ked.f1 = (sipo) ? sipo->cursorVal : 0.0f;
+ cursor_value = (sipo) ? sipo->cursorVal : 0.0f;
}
/* filter data */
@@ -2010,10 +2020,12 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
/* mirror keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS);
+
/* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
-
+ ked.f1 = cursor_value * unit_scale;
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -2021,9 +2033,6 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
}
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS | ANIM_UNITCONV_RESTORE);
}
BLI_freelistN(&anim_data);
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index e2bc88cf0eb..74114f8ca9d 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -254,11 +254,9 @@ void ED_operatormacros_graph(void)
ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate",
"Make a copy of all selected keyframes and move them",
OPTYPE_UNDO | OPTYPE_REGISTER);
- if (ot) {
- WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate");
- otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
- RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
- }
+ WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate");
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
+ RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
}
@@ -279,33 +277,38 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* graph_select.c - selection tools */
- /* click-select */
+ /* click-select: keyframe (replace) */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
RNA_boolean_set(kmi->ptr, "curves", FALSE);
RNA_boolean_set(kmi->ptr, "column", FALSE);
+ /* click-select: all keyframes on same frame (replace) */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
RNA_boolean_set(kmi->ptr, "curves", FALSE);
RNA_boolean_set(kmi->ptr, "column", TRUE);
+ /* click-select: keyframe (add) */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
RNA_boolean_set(kmi->ptr, "curves", FALSE);
RNA_boolean_set(kmi->ptr, "column", FALSE);
+ /* click-select: all keyframes on same frame (add) */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
RNA_boolean_set(kmi->ptr, "curves", FALSE);
RNA_boolean_set(kmi->ptr, "column", TRUE);
+ /* click-select: all keyframes in same curve (replace) */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
RNA_boolean_set(kmi->ptr, "curves", TRUE);
RNA_boolean_set(kmi->ptr, "column", FALSE);
+ /* click-select: all keyframes in same curve (add) */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
RNA_boolean_set(kmi->ptr, "curves", TRUE);
RNA_boolean_set(kmi->ptr, "column", FALSE);
- /* select left/right */
+ /* click-select left/right */
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index d87bd9a5077..d0dcaf91e77 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -227,7 +227,7 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
KeyframeEditData ked;
KeyframeEditFunc ok_cb, select_cb;
View2D *v2d = &ac->ar->v2d;
- rctf rectf;
+ rctf rectf, scaled_rectf;
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
@@ -243,7 +243,7 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
- ked.data = &rectf;
+ ked.data = &scaled_rectf;
/* treat handles separately? */
if (incl_handles) {
@@ -252,21 +252,26 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
}
else
mapping_flag = ANIM_UNITCONV_ONLYKEYS;
-
+
+ mapping_flag |= ANIM_get_normalization_flags(ac);
+
/* loop over data, doing border select */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, mapping_flag);
-
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
+
/* apply NLA mapping to all the keyframes, since it's easier than trying to
* guess when a callback might use something different
*/
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0);
-
+
+ scaled_rectf.xmin = rectf.xmin;
+ scaled_rectf.xmax = rectf.xmax;
+ scaled_rectf.ymin = rectf.ymin / unit_scale;
+ scaled_rectf.ymax = rectf.ymax / unit_scale;
+
/* set horizontal range (if applicable)
* NOTE: these values are only used for x-range and y-range but not region
* (which uses ked.data, i.e. rectf)
@@ -296,9 +301,6 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
/* un-apply NLA mapping from all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | mapping_flag);
}
/* cleanup */
@@ -936,7 +938,7 @@ static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
/* check if the given vertex is within bounds or not */
// TODO: should we return if we hit something?
-static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2])
+static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale)
{
/* Keyframes or Samples? */
if (bezt) {
@@ -947,7 +949,7 @@ static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fc
* needed to access the relevant vertex coordinates in the 3x3
* 'vec' matrix
*/
- UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1], &screen_co[0], &screen_co[1]);
+ UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, &screen_co[0], &screen_co[1]);
/* check if distance from mouse cursor to vert in screen space is within tolerance */
// XXX: inlined distance calculation, since we cannot do this on ints using the math lib...
@@ -996,6 +998,7 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
View2D *v2d = &ac->ar->v2d;
+ short mapping_flag = 0;
/* get curves to search through
* - if the option to only show keyframes that belong to selected F-Curves is enabled,
@@ -1004,37 +1007,36 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code...
filter |= ANIMFILTER_SEL;
+ mapping_flag |= ANIM_get_normalization_flags(ac);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0);
-
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag);
+
/* apply NLA mapping to all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
-
+
if (fcu->bezt) {
BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL;
int i;
for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) {
/* keyframe */
- nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval);
+ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval, unit_scale);
/* handles - only do them if they're visible */
if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) {
/* first handle only visible if previous segment had handles */
if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
- nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval);
+ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval, unit_scale);
}
/* second handle only visible if this segment is bezier */
if (bezt1->ipo == BEZT_IPO_BEZ) {
- nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval);
+ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval, unit_scale);
}
}
}
@@ -1047,9 +1049,6 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
/* un-apply NLA mapping from all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE);
}
/* free channels */
@@ -1365,7 +1364,8 @@ void GRAPH_OT_clickselect(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
- prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
+ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select",
+ "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select",
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 710d5c8cd81..b7d3407b826 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -256,7 +256,7 @@ static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *even
WM_event_add_modal_handler(C, op);
}
-static void image_view_pan_exit(bContext *C, wmOperator *op, int cancel)
+static void image_view_pan_exit(bContext *C, wmOperator *op, bool cancel)
{
SpaceImage *sima = CTX_wm_space_image(C);
ViewPanData *vpd = op->customdata;
@@ -330,7 +330,7 @@ static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *even
break;
default:
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
- image_view_pan_exit(C, op, 0);
+ image_view_pan_exit(C, op, false);
return OPERATOR_FINISHED;
}
break;
@@ -339,10 +339,9 @@ static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *even
return OPERATOR_RUNNING_MODAL;
}
-static int image_view_pan_cancel(bContext *C, wmOperator *op)
+static void image_view_pan_cancel(bContext *C, wmOperator *op)
{
- image_view_pan_exit(C, op, 1);
- return OPERATOR_CANCELLED;
+ image_view_pan_exit(C, op, true);
}
void IMAGE_OT_view_pan(wmOperatorType *ot)
@@ -412,7 +411,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve
WM_event_add_modal_handler(C, op);
}
-static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel)
+static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
{
SpaceImage *sima = CTX_wm_space_image(C);
ViewZoomData *vpd = op->customdata;
@@ -547,17 +546,16 @@ static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *eve
image_zoom_apply(vpd, op, event->x, event->y, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0);
}
else if (event_code == VIEW_CONFIRM) {
- image_view_zoom_exit(C, op, 0);
+ image_view_zoom_exit(C, op, false);
return OPERATOR_FINISHED;
}
return OPERATOR_RUNNING_MODAL;
}
-static int image_view_zoom_cancel(bContext *C, wmOperator *op)
+static void image_view_zoom_cancel(bContext *C, wmOperator *op)
{
- image_view_zoom_exit(C, op, 1);
- return OPERATOR_CANCELLED;
+ image_view_zoom_exit(C, op, true);
}
void IMAGE_OT_view_zoom(wmOperatorType *ot)
@@ -921,11 +919,10 @@ static void image_open_init(bContext *C, wmOperator *op)
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
}
-static int image_open_cancel(bContext *UNUSED(C), wmOperator *op)
+static void image_open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
- return OPERATOR_CANCELLED;
}
static int image_open_exec(bContext *C, wmOperator *op)
@@ -1505,11 +1502,9 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
return OPERATOR_RUNNING_MODAL;
}
-static int image_save_as_cancel(bContext *UNUSED(C), wmOperator *op)
+static void image_save_as_cancel(bContext *UNUSED(C), wmOperator *op)
{
image_save_as_free(op);
-
- return OPERATOR_CANCELLED;
}
static bool image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)
@@ -1905,7 +1900,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- ibuf->userflags |= IB_BITMAPDIRTY;
+ ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID;
@@ -2358,10 +2353,9 @@ static int image_sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int image_sample_cancel(bContext *C, wmOperator *op)
+static void image_sample_cancel(bContext *C, wmOperator *op)
{
image_sample_exit(C, op);
- return OPERATOR_CANCELLED;
}
void IMAGE_OT_sample(wmOperatorType *ot)
@@ -2625,7 +2619,7 @@ static int image_record_composite_modal(bContext *C, wmOperator *op, const wmEve
return OPERATOR_RUNNING_MODAL;
}
-static int image_record_composite_cancel(bContext *C, wmOperator *op)
+static void image_record_composite_cancel(bContext *C, wmOperator *op)
{
image_record_composite_exit(C, op);
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 7b20af340ae..2ba9123b30b 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -56,6 +56,7 @@
#include "ED_mask.h"
#include "ED_mesh.h"
#include "ED_node.h"
+#include "ED_render.h"
#include "ED_space_api.h"
#include "ED_screen.h"
#include "ED_uvedit.h"
@@ -653,7 +654,16 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* put scene context variable in iuser */
- sima->iuser.scene = scene;
+ if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) {
+ /* for render result, try to use the currently rendering scene */
+ Scene *render_scene = ED_render_job_get_scene(C);
+ if (render_scene)
+ sima->iuser.scene = render_scene;
+ else
+ sima->iuser.scene = scene;
+ }
+ else
+ sima->iuser.scene = scene;
/* we set view2d from own zoom and offset each time */
image_main_area_set_view2d(sima, ar);
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 07f4b64d187..96e0de17918 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -220,6 +220,9 @@ static void info_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "INFO_OT_report_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "INFO_OT_report_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_CTRL, 0);
+#ifdef __APPLE__
+ WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
+#endif
}
/* add handlers, stuff you only do once or on area/region changes */
@@ -327,7 +330,7 @@ void ED_spacetype_info(void)
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
art->init = info_main_area_init;
art->draw = info_main_area_draw;
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index b4c52a5b1ca..c9a86547984 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -638,53 +638,13 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
{
AnimData *adt = ale->adt;
- short indent = 0, offset = 0, sel = 0, group = 0, nonSolo = 0;
- int expand = -1, protect = -1, special = -1, mute = -1;
+ short indent = 0, offset = 0, sel = 0, group = 0;
+ int special = -1;
char name[128];
short do_draw = FALSE;
/* determine what needs to be drawn */
switch (ale->type) {
- case ANIMTYPE_NLATRACK: /* NLA Track */
- {
- NlaTrack *nlt = (NlaTrack *)ale->data;
-
- /* 'solo' as the 'special' button? */
- if (nlt->flag & NLATRACK_SOLO)
- special = ICON_SOLO_ON;
- else
- special = ICON_SOLO_OFF;
-
- /* if this track is active and we're tweaking it, don't draw these toggles */
- // TODO: need a special macro for this...
- if (((nlt->flag & NLATRACK_ACTIVE) && (nlt->flag & NLATRACK_DISABLED)) == 0) {
- if (nlt->flag & NLATRACK_MUTED)
- mute = ICON_MUTE_IPO_ON;
- else
- mute = ICON_MUTE_IPO_OFF;
-
- if (EDITABLE_NLT(nlt))
- protect = ICON_UNLOCKED;
- else
- protect = ICON_LOCKED;
- }
-
- /* is track enabled for solo drawing? */
- if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) {
- if ((nlt->flag & NLATRACK_SOLO) == 0) {
- /* tag for special non-solo handling; also hide the mute toggles */
- nonSolo = 1;
- mute = 0;
- }
- }
-
- sel = SEL_NLT(nlt);
- BLI_strncpy(name, nlt->name, sizeof(name));
-
- /* draw manually still */
- do_draw = TRUE;
- break;
- }
case ANIMTYPE_NLAACTION: /* NLA Action-Line */
{
bAction *act = (bAction *)ale->data;
@@ -700,7 +660,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
break;
}
default: /* handled by standard channel-drawing API */
- // draw backdrops only...
+ /* (draw backdrops only...) */
ANIM_channel_draw(ac, ale, yminc, ymaxc);
break;
}
@@ -783,25 +743,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
/* clear group value, otherwise we cause errors... */
group = 0;
}
- else {
- /* NLA tracks - darker color if not solo track when we're showing solo */
- UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0) ? 20 : -20));
-
- indent += group;
- offset += 0.35f * U.widget_unit * indent;
- glBegin(GL_QUADS);
- glVertex2f(x + offset, yminc);
- glVertex2f(x + offset, ymaxc);
- glVertex2f((float)v2d->cur.xmax, ymaxc);
- glVertex2f((float)v2d->cur.xmax, yminc);
- glEnd();
- }
- /* draw expand/collapse triangle */
- if (expand > 0) {
- UI_icon_draw(x + offset, ydatac, expand);
- offset += 0.85f * U.widget_unit;
- }
/* draw special icon indicating certain data-types */
if (special > -1) {
@@ -826,17 +768,6 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- /* draw protect 'lock' */
- if (protect > -1) {
- offset = 0.8f * U.widget_unit;
- UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, protect);
- }
-
- /* draw mute 'eye' */
- if (mute > -1) {
- offset += 0.8f * U.widget_unit;
- UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, mute);
- }
/* draw NLA-action line 'status-icons' - only when there's an action */
if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) {
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 4d4f27cf1ad..d0ba33358e4 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -544,7 +544,7 @@ void ED_spacetype_nla(void)
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 200;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
art->init = nla_channel_area_init;
art->draw = nla_channel_area_draw;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index ba28f502349..b33c3d6c228 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -384,19 +384,21 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
node->totr = rect;
}
-static void node_draw_frame_label(bNode *node, const float aspect)
+static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float aspect)
{
/* XXX font id is crap design */
const int fontid = UI_GetStyle()->widgetlabel.uifont_id;
NodeFrame *data = (NodeFrame *)node->storage;
rctf *rct = &node->totr;
int color_id = node_get_colorid(node);
- const char *label = nodeLabel(node);
+ char label[MAX_NAME];
/* XXX a bit hacky, should use separate align values for x and y */
float width, ascender;
float x, y;
const int font_size = data->label_size / aspect;
+ nodeLabel(ntree, node, label, sizeof(label));
+
BLF_enable(fontid, BLF_ASPECT);
BLF_aspect(fontid, aspect, aspect, 1.0f);
BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
@@ -418,7 +420,7 @@ static void node_draw_frame_label(bNode *node, const float aspect)
}
static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
- bNodeTree *UNUSED(ntree), bNode *node, bNodeInstanceKey UNUSED(key))
+ bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key))
{
rctf *rct = &node->totr;
int color_id = node_get_colorid(node);
@@ -467,7 +469,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
}
/* label */
- node_draw_frame_label(node, snode->aspect);
+ node_draw_frame_label(ntree, node, snode->aspect);
UI_ThemeClearColor(color_id);
@@ -1444,7 +1446,7 @@ static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C),
col = uiLayoutColumn(layout, FALSE);
uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "threshold_neighbor", 0, NULL, ICON_NONE);
}
static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -1633,7 +1635,7 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
else {
col = uiLayoutColumn(layout, TRUE);
- uiItemL(col, IFACE_("File Path:"), ICON_NONE);
+ uiItemL(col, IFACE_("File Subpath:"), ICON_NONE);
row = uiLayoutRow(col, FALSE);
uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE);
uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 65eb75f8523..6f2f8dee105 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -72,6 +72,11 @@
/* XXX interface.h */
extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select);
+float ED_node_grid_size(void)
+{
+ return U.widget_unit;
+}
+
void ED_node_tree_update(const bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -863,7 +868,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_ThemeColor(TH_TEXT);
#endif
- BLI_strncpy(showname, nodeLabel(node), sizeof(showname));
+ nodeLabel(ntree, node, showname, sizeof(showname));
//if (node->flag & NODE_MUTED)
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */
@@ -1030,8 +1035,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_ThemeColor(TH_TEXT);
if (node->miniwidth > 0.0f) {
- BLI_strncpy(showname, nodeLabel(node), sizeof(showname));
-
+ nodeLabel(ntree, node, showname, sizeof(showname));
+
//if (node->flag & NODE_MUTED)
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */
@@ -1325,7 +1330,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
snode_setup_v2d(snode, ar, center);
/* grid, uses theme color based on node path depth */
- UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), U.widget_unit, 5, 2);
+ UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), ED_node_grid_size(), NODE_GRID_STEPS, 2);
/* backdrop */
draw_nodespace_back_pix(C, ar, snode, path->parent_key);
@@ -1350,7 +1355,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
}
else {
/* default grid */
- UI_view2d_multi_grid_draw(v2d, TH_BACK, U.widget_unit, 5, 2);
+ UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, 2);
/* backdrop */
draw_nodespace_back_pix(C, ar, snode, NODE_INSTANCE_KEY_NONE);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 1d93fe65c09..f58bc83e5d2 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -859,7 +859,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(
WM_event_add_modal_handler(C, op);
}
-static void node_resize_exit(bContext *C, wmOperator *op, int UNUSED(cancel))
+static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel))
{
WM_cursor_modal_restore(CTX_wm_window(C));
@@ -961,7 +961,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
case MIDDLEMOUSE:
case RIGHTMOUSE:
- node_resize_exit(C, op, 0);
+ node_resize_exit(C, op, false);
ED_node_post_apply_transform(C, snode->edittree);
return OPERATOR_FINISHED;
@@ -990,11 +990,9 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
-static int node_resize_cancel(bContext *C, wmOperator *op)
+static void node_resize_cancel(bContext *C, wmOperator *op)
{
- node_resize_exit(C, op, 1);
-
- return OPERATOR_CANCELLED;
+ node_resize_exit(C, op, true);
}
void NODE_OT_resize(wmOperatorType *ot)
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 176b81f9503..f598a13bea9 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -116,6 +116,7 @@ void NODE_OT_select_all(struct wmOperatorType *ot);
void NODE_OT_select_linked_to(struct wmOperatorType *ot);
void NODE_OT_select_linked_from(struct wmOperatorType *ot);
void NODE_OT_select_border(struct wmOperatorType *ot);
+void NODE_OT_select_circle(struct wmOperatorType *ot);
void NODE_OT_select_lasso(struct wmOperatorType *ot);
void NODE_OT_select_same_type(struct wmOperatorType *ot);
void NODE_OT_select_same_type_step(struct wmOperatorType *ot);
@@ -169,7 +170,6 @@ void NODE_OT_join(struct wmOperatorType *ot);
void NODE_OT_attach(struct wmOperatorType *ot);
void NODE_OT_detach(struct wmOperatorType *ot);
-void NODE_OT_show_cyclic_dependencies(struct wmOperatorType *ot);
void NODE_OT_link_viewer(struct wmOperatorType *ot);
/* node_edit.c */
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index f0d3deb24df..edd422b8148 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -56,6 +56,7 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_select_linked_to);
WM_operatortype_append(NODE_OT_select_linked_from);
WM_operatortype_append(NODE_OT_select_border);
+ WM_operatortype_append(NODE_OT_select_circle);
WM_operatortype_append(NODE_OT_select_lasso);
WM_operatortype_append(NODE_OT_select_same_type);
WM_operatortype_append(NODE_OT_select_same_type_step);
@@ -70,7 +71,6 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_preview_toggle);
WM_operatortype_append(NODE_OT_options_toggle);
WM_operatortype_append(NODE_OT_hide_socket_toggle);
- WM_operatortype_append(NODE_OT_show_cyclic_dependencies);
WM_operatortype_append(NODE_OT_node_copy_color);
WM_operatortype_append(NODE_OT_duplicate);
@@ -233,6 +233,8 @@ void node_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "deselect", TRUE);
+ WM_keymap_add_item(keymap, "NODE_OT_select_circle", CKEY, KM_PRESS, 0, 0);
+
/* each of these falls through if not handled... */
kmi = WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "detach", FALSE);
@@ -272,8 +274,6 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_preview_toggle", HKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "NODE_OT_show_cyclic_dependencies", CKEY, KM_PRESS, 0, 0);
-
WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 4b5cc9e42b6..b50066560fb 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -395,38 +395,33 @@ void NODE_OT_link_viewer(wmOperatorType *ot)
/* *************************** add link op ******************** */
-static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeLink *link)
+static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
{
- bNodeLink *tlink;
- bNodeSocket *sock;
-
- if (tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) {
-
- for (tlink = snode->edittree->links.first; tlink; tlink = tlink->next) {
- if (link != tlink && tlink->tosock == link->tosock)
- break;
+ bNodeTree *ntree = snode->edittree;
+ bNodeSocket *from = link->fromsock, *to = link->tosock;
+ int max_from = from->limit, max_to = to->limit;
+ int count_from = 1, count_to = 1; /* start at 1, link is included */
+ bNodeLink *tlink, *tlink_next;
+
+ for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
+ tlink_next = tlink->next;
+ if (tlink == link)
+ continue;
+
+ if (tlink && tlink->fromsock == from) {
+ ++count_from;
+ if (count_from > max_from) {
+ nodeRemLink(ntree, tlink);
+ tlink = NULL;
+ }
}
- if (tlink) {
- /* try to move the existing link to the next available socket */
- if (tlink->tonode) {
- /* is there a free input socket with the target type? */
- for (sock = tlink->tonode->inputs.first; sock; sock = sock->next) {
- if (sock->type == tlink->tosock->type)
- if (nodeCountSocketLinks(snode->edittree, sock) < sock->limit)
- break;
- }
- if (sock) {
- tlink->tosock = sock;
- sock->flag &= ~SOCK_HIDDEN;
- }
- else {
- nodeRemLink(snode->edittree, tlink);
- }
+
+ if (tlink && tlink->tosock == to) {
+ ++count_to;
+ if (count_to > max_to) {
+ nodeRemLink(ntree, tlink);
+ tlink = NULL;
}
- else
- nodeRemLink(snode->edittree, tlink);
-
- snode->edittree->update |= NTREE_UPDATE_LINKS;
}
}
}
@@ -527,8 +522,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
link->tonode->update |= NODE_UPDATE;
/* we might need to remove a link */
- if (in_out == SOCK_OUT)
- node_remove_extra_links(snode, link->tosock, link);
+ node_remove_extra_links(snode, link);
}
else
nodeRemLink(ntree, link);
@@ -669,7 +663,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
-static int node_link_cancel(bContext *C, wmOperator *op)
+static void node_link_cancel(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeLinkDrag *nldrag = op->customdata;
@@ -678,8 +672,6 @@ static int node_link_cancel(bContext *C, wmOperator *op)
BLI_freelistN(&nldrag->links);
MEM_freeN(nldrag);
-
- return OPERATOR_CANCELLED;
}
void NODE_OT_link(wmOperatorType *ot)
@@ -878,34 +870,6 @@ void NODE_OT_links_detach(wmOperatorType *ot)
}
-/* ****************** Show Cyclic Dependencies Operator ******************* */
-
-static int node_show_cycles_exec(bContext *C, wmOperator *UNUSED(op))
-{
- SpaceNode *snode = CTX_wm_space_node(C);
-
- /* this is just a wrapper around this call... */
- ntreeUpdateTree(CTX_data_main(C), snode->nodetree);
- snode_notify(C, snode);
-
- return OPERATOR_FINISHED;
-}
-
-void NODE_OT_show_cyclic_dependencies(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Show Cyclic Dependencies";
- ot->description = "Sort the nodes and show the cyclic dependencies between the nodes";
- ot->idname = "NODE_OT_show_cyclic_dependencies";
-
- /* callbacks */
- ot->exec = node_show_cycles_exec;
- ot->poll = ED_operator_node_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
/* ****************** Set Parent ******************* */
static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1214,52 +1178,62 @@ void NODE_OT_detach(wmOperatorType *ot)
/* prevent duplicate testing code below */
-static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select)
+static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, bNode **r_select)
{
SpaceNode *snode = sa ? sa->spacedata.first : NULL;
- bNode *node;
+ bNode *node, *select = NULL;
bNodeLink *link;
+ *r_snode = snode;
+ *r_select = NULL;
+
/* no unlucky accidents */
- if (sa == NULL || sa->spacetype != SPACE_NODE) return NULL;
+ if (sa == NULL || sa->spacetype != SPACE_NODE)
+ return false;
- *select = NULL;
+ if (!test) {
+ /* no need to look for a node */
+ return true;
+ }
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
- if (*select)
+ if (select)
break;
else
- *select = node;
+ select = node;
}
}
/* only one selected */
- if (node || *select == NULL) return NULL;
+ if (node || select == NULL)
+ return false;
/* correct node */
- if ((*select)->inputs.first == NULL || (*select)->outputs.first == NULL) return NULL;
+ if (select->inputs.first == NULL || select->outputs.first == NULL)
+ return false;
/* test node for links */
for (link = snode->edittree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link))
continue;
- if (link->tonode == *select || link->fromnode == *select)
- return NULL;
+ if (link->tonode == select || link->fromnode == select)
+ return false;
}
- return snode;
+ *r_select = select;
+ return true;
}
/* test == 0, clear all intersect flags */
void ED_node_link_intersect_test(ScrArea *sa, int test)
{
bNode *select;
- SpaceNode *snode = ed_node_link_conditions(sa, &select);
+ SpaceNode *snode;
bNodeLink *link, *selink = NULL;
float mcoords[6][2];
- if (snode == NULL) return;
+ if (!ed_node_link_conditions(sa, test, &snode, &select)) return;
/* clear flags */
for (link = snode->edittree->links.first; link; link = link->next)
@@ -1334,11 +1308,11 @@ static bNodeSocket *socket_best_match(ListBase *sockets)
void ED_node_link_insert(ScrArea *sa)
{
bNode *node, *select;
- SpaceNode *snode = ed_node_link_conditions(sa, &select);
+ SpaceNode *snode;
bNodeLink *link;
bNodeSocket *sockto;
- if (snode == NULL) return;
+ if (!ed_node_link_conditions(sa, true, &snode, &select)) return;
/* get the link */
for (link = snode->edittree->links.first; link; link = link->next)
@@ -1355,7 +1329,7 @@ void ED_node_link_insert(ScrArea *sa)
link->tonode = select;
link->tosock = best_input;
- node_remove_extra_links(snode, link->tosock, link);
+ node_remove_extra_links(snode, link);
link->flag &= ~NODE_LINKFLAG_HILITE;
nodeAddLink(snode->edittree, select, best_output, node, sockto);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 958a3433337..2e3e747618b 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -514,6 +514,63 @@ void NODE_OT_select_border(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture");
}
+/* ****** Circle Select ****** */
+
+static int node_circleselect_exec(bContext *C, wmOperator *op)
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ ARegion *ar = CTX_wm_region(C);
+ bNode *node;
+
+ int x, y, radius, gesture_mode;
+ float offset[2];
+
+ float zoom = (float)(BLI_rcti_size_x(&ar->winrct)) / (float)(BLI_rctf_size_x(&ar->v2d.cur));
+
+ gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
+
+ /* get operator properties */
+ x = RNA_int_get(op->ptr, "x");
+ y = RNA_int_get(op->ptr, "y");
+ radius = RNA_int_get(op->ptr, "radius");
+
+ UI_view2d_region_to_view(&ar->v2d, x, y, &offset[0], &offset[1]);
+
+ for (node = snode->edittree->nodes.first; node; node = node->next) {
+ if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) {
+ nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT));
+ }
+ }
+
+ WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void NODE_OT_select_circle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Circle Select";
+ ot->idname = "NODE_OT_select_circle";
+ ot->description = "Use circle selection to select nodes";
+
+ /* api callbacks */
+ ot->invoke = WM_gesture_circle_invoke;
+ ot->exec = node_circleselect_exec;
+ ot->modal = WM_gesture_circle_modal;
+
+ ot->poll = ED_operator_node_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* rna */
+ 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);
+}
+
/* ****** Lasso Select ****** */
static int do_lasso_select_node(bContext *C, const int mcords[][2], short moves, short select)
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index a67a8791a64..f8eb0ede262 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -461,7 +461,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
uiItemL(column, IFACE_(cname), ICON_NODE);
but = block->buttons.last;
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
first = 0;
}
@@ -471,7 +471,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
cur_node_name = items[i].node_name;
uiItemL(column, IFACE_(cur_node_name), ICON_NODE);
but = block->buttons.last;
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
}
BLI_snprintf(name, UI_MAX_NAME_STR, " %s", IFACE_(items[i].socket_name));
@@ -528,7 +528,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
if (sock->link) {
uiItemL(column, IFACE_("Link"), ICON_NONE);
but = block->buttons.last;
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input"));
@@ -564,7 +564,8 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo
but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
but->type = MENU;
- but->flag |= UI_TEXT_LEFT | UI_BUT_NODE_LINK;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
+ but->flag |= UI_BUT_NODE_LINK;
but->poin = (char *)but;
but->func_argN = arg;
@@ -654,7 +655,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
uiItemL(row, label, ICON_NONE);
bt = block->buttons.last;
- bt->flag = UI_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
if (dependency_loop) {
row = uiLayoutRow(split, FALSE);
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index f889a8ec97b..ff441d63479 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -220,6 +220,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
CLAMP(snode->yof, nvm->ymin, nvm->ymax);
ED_region_tag_redraw(ar);
+ WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
break;
@@ -273,12 +274,10 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
return OPERATOR_RUNNING_MODAL;
}
-static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
+static void snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
-
- return OPERATOR_CANCELLED;
}
void NODE_OT_backimage_move(wmOperatorType *ot)
@@ -306,6 +305,7 @@ static int backimage_zoom_exec(bContext *C, wmOperator *op)
snode->zoom *= fac;
ED_region_tag_redraw(ar);
+ WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -363,6 +363,7 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
snode->yof = 0;
ED_region_tag_redraw(ar);
+ WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -612,10 +613,9 @@ static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int sample_cancel(bContext *C, wmOperator *op)
+static void sample_cancel(bContext *C, wmOperator *op)
{
sample_exit(C, op);
- return OPERATOR_CANCELLED;
}
void NODE_OT_backimage_sample(wmOperatorType *ot)
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index fe706ce2365..5168c3c873a 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -765,286 +765,6 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
uiBlockSetEmboss(block, UI_EMBOSS);
}
-static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2)
-{
- wmOperatorType *ot = arg2;
- wmKeyMapItem *kmi = arg_kmi;
-
- if (ot)
- BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME);
-}
-
-static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi),
- const char *str, uiSearchItems *items)
-{
- GHashIterator *iter = WM_operatortype_iter();
-
- for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) {
- wmOperatorType *ot = BLI_ghashIterator_getValue(iter);
-
- if (BLI_strcasestr(ot->idname, str)) {
- char name[OP_MAX_TYPENAME];
-
- /* display name for menu */
- WM_operator_py_idname(name, ot->idname);
-
- if (false == uiSearchItemAdd(items, name, ot, 0))
- break;
- }
- }
- BLI_ghashIterator_free(iter);
-}
-
-/* operator Search browse menu, open */
-static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
-{
- static char search[OP_MAX_TYPENAME];
- wmEvent event;
- wmWindow *win = CTX_wm_window(C);
- wmKeyMapItem *kmi = arg_kmi;
- wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0);
- uiBlock *block;
- uiBut *but;
-
- /* clear initial search string, then all items show */
- search[0] = 0;
-
- block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
-
- /* fake button, it holds space for search items */
- uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
-
- but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, UI_UNIT_Y, 0, 0, "");
- uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot);
-
- uiBoundsBlock(block, 6);
- uiBlockSetDirection(block, UI_DOWN);
- uiEndBlock(C, block);
-
- wm_event_init_from_window(win, &event);
- event.type = EVT_BUT_OPEN;
- event.val = KM_PRESS;
- event.customdata = but;
- event.customdatafree = FALSE;
- wm_event_add(win, &event);
-
- return block;
-}
-
-#define OL_KM_KEYBOARD 0
-#define OL_KM_MOUSE 1
-#define OL_KM_TWEAK 2
-#define OL_KM_SPECIALS 3
-
-static short keymap_menu_type(short type)
-{
- if (ISKEYBOARD(type)) return OL_KM_KEYBOARD;
- if (ISTWEAK(type)) return OL_KM_TWEAK;
- if (ISMOUSE(type)) return OL_KM_MOUSE;
-// return OL_KM_SPECIALS;
- return 0;
-}
-
-static const char *keymap_type_menu(void)
-{
- static const char string[] =
- "Event Type%t"
- "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD)
- "|Mouse%x" STRINGIFY(OL_KM_MOUSE)
- "|Tweak%x" STRINGIFY(OL_KM_TWEAK)
-// "|Specials%x" STRINGIFY(OL_KM_SPECIALS)
- ;
-
- return string;
-}
-
-static const char *keymap_mouse_menu(void)
-{
- static const char string[] =
- "Mouse Event%t"
- "|Left Mouse%x" STRINGIFY(LEFTMOUSE)
- "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE)
- "|Right Mouse%x" STRINGIFY(RIGHTMOUSE)
- "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE)
- "|Right Mouse%x" STRINGIFY(RIGHTMOUSE)
- "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE)
- "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE)
- "|Action Mouse%x" STRINGIFY(ACTIONMOUSE)
- "|Select Mouse%x" STRINGIFY(SELECTMOUSE)
- "|Mouse Move%x" STRINGIFY(MOUSEMOVE)
- "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE)
- "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE)
- "|Wheel In%x" STRINGIFY(WHEELINMOUSE)
- "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE)
- "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN)
- "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM)
- "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE)
- ;
-
- return string;
-}
-
-static const char *keymap_tweak_menu(void)
-{
- static const char string[] =
- "Tweak Event%t"
- "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L)
- "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M)
- "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R)
- "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A)
- "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S)
- ;
-
- return string;
-}
-
-static const char *keymap_tweak_dir_menu(void)
-{
- static const char string[] =
- "Tweak Direction%t"
- "|Any%x" STRINGIFY(KM_ANY)
- "|North%x" STRINGIFY(EVT_GESTURE_N)
- "|North-East%x" STRINGIFY(EVT_GESTURE_NE)
- "|East%x" STRINGIFY(EVT_GESTURE_E)
- "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE)
- "|South%x" STRINGIFY(EVT_GESTURE_S)
- "|South-West%x" STRINGIFY(EVT_GESTURE_SW)
- "|West%x" STRINGIFY(EVT_GESTURE_W)
- "|North-West%x" STRINGIFY(EVT_GESTURE_NW)
- ;
-
- return string;
-}
-
-
-static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v))
-{
- wmKeyMapItem *kmi = kmi_v;
- short maptype = keymap_menu_type(kmi->type);
-
- if (maptype != kmi->maptype) {
- switch (kmi->maptype) {
- case OL_KM_KEYBOARD:
- kmi->type = AKEY;
- kmi->val = KM_PRESS;
- break;
- case OL_KM_MOUSE:
- kmi->type = LEFTMOUSE;
- kmi->val = KM_PRESS;
- break;
- case OL_KM_TWEAK:
- kmi->type = EVT_TWEAK_L;
- kmi->val = KM_ANY;
- break;
- case OL_KM_SPECIALS:
- kmi->type = AKEY;
- kmi->val = KM_PRESS;
- break;
- }
- ED_region_tag_redraw(CTX_wm_region(C));
- }
-}
-
-static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb)
-{
- TreeElement *te;
- TreeStoreElem *tselem;
-
- uiBlockSetEmboss(block, UI_EMBOSST);
-
- for (te = lb->first; te; te = te->next) {
- tselem = TREESTORE(te);
- if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
- uiBut *but;
- const char *str;
- int xstart = 240;
- int butw1 = UI_UNIT_X; /* operator */
- int butw2 = 90; /* event type, menus */
- int butw3 = 43; /* modifiers */
-
- if (tselem->type == TSE_KEYMAP_ITEM) {
- wmKeyMapItem *kmi = te->directdata;
-
- /* modal map? */
- if (kmi->propvalue) {
- /* pass */
- }
- else {
- uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, te->ys + 1, butw1, UI_UNIT_Y - 1,
- TIP_("Assign new Operator"));
- }
- xstart += butw1 + 10;
-
- /* map type button */
- kmi->maptype = keymap_menu_type(kmi->type);
-
- str = keymap_type_menu();
- but = uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype,
- 0, 0, 0, 0, TIP_("Event type"));
- uiButSetFunc(but, keymap_type_cb, kmi, NULL);
- xstart += butw2 + 5;
-
- /* edit actual event */
- switch (kmi->maptype) {
- case OL_KM_KEYBOARD:
- uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
- TIP_("Key code"));
- xstart += butw2 + 5;
- break;
- case OL_KM_MOUSE:
- str = keymap_mouse_menu();
- uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
- 0, 0, 0, 0, TIP_("Mouse button"));
- xstart += butw2 + 5;
- break;
- case OL_KM_TWEAK:
- str = keymap_tweak_menu();
- uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
- 0, 0, 0, 0, TIP_("Tweak gesture"));
- xstart += butw2 + 5;
- str = keymap_tweak_dir_menu();
- uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val,
- 0, 0, 0, 0, TIP_("Tweak gesture direction"));
- xstart += butw2 + 5;
- break;
- }
-
- /* modifiers */
- uiDefButS(block, OPTION, 0, IFACE_("Shift"), xstart, te->ys + 1, butw3 + 5, UI_UNIT_Y - 1,
- &kmi->shift, 0, 0, 0, 0, TIP_("Modifier"));
- xstart += butw3 + 5;
- uiDefButS(block, OPTION, 0, IFACE_("Ctrl"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl,
- 0, 0, 0, 0, TIP_("Modifier"));
- xstart += butw3;
- uiDefButS(block, OPTION, 0, IFACE_("Alt"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt,
- 0, 0, 0, 0, TIP_("Modifier"));
- xstart += butw3;
- uiDefButS(block, OPTION, 0, IFACE_("OS"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey,
- 0, 0, 0, 0, TIP_("Modifier"));
- xstart += butw3 + 5;
- uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier,
- TIP_("Key Modifier code"));
- xstart += butw3 + 5;
-
- /* rna property */
- if (kmi->ptr && kmi->ptr->data) {
- uiDefBut(block, LABEL, 0, IFACE_("(RNA property)"), xstart, te->ys + 1, butw2, UI_UNIT_Y - 1,
- NULL, 0, 0, 0, 0, "");
- xstart += butw2;
- }
-
- (void)xstart;
- }
- }
-
- if (TSELEM_OPEN(tselem, soops)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree);
- }
-
- uiBlockSetEmboss(block, UI_EMBOSS);
-}
-
-
static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, TreeElement *te)
{
uiBut *bt;
@@ -1864,7 +1584,7 @@ void draw_outliner(const bContext *C)
/* get extents of data */
outliner_height(soops, &soops->tree, &sizey);
- if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) {
+ if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
/* RNA has two columns:
* - column 1 is (max_width + OL_RNA_COL_SPACEX) or
* (OL_RNA_COL_X), whichever is wider...
@@ -1878,11 +1598,7 @@ void draw_outliner(const bContext *C)
sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX);
/* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */
- if (soops->outlinevis == SO_KEYMAP)
- // XXX this is only really a quick hack to make this wide enough...
- sizex = sizex_rna + OL_RNA_COL_SIZEX * 3 + 50;
- else
- sizex = sizex_rna + OL_RNA_COL_SIZEX + 50;
+ sizex = sizex_rna + OL_RNA_COL_SIZEX + 50;
}
else {
/* width must take into account restriction columns (if visible) so that entries will still be visible */
@@ -1908,7 +1624,7 @@ void draw_outliner(const bContext *C)
/* set matrix for 2d-view controls */
UI_view2d_view_ortho(v2d);
- /* draw outliner stuff (background, hierachy lines and names) */
+ /* draw outliner stuff (background, hierarchy lines and names) */
outliner_back(ar);
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
outliner_draw_tree((bContext *)C, block, scene, ar, soops, &te_edit);
@@ -1918,9 +1634,6 @@ void draw_outliner(const bContext *C)
outliner_draw_rnacols(ar, sizex_rna);
outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree);
}
- else if (soops->outlinevis == SO_KEYMAP) {
- outliner_draw_keymapbuts(block, ar, soops, &soops->tree);
- }
else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) {
/* draw restriction columns */
outliner_draw_restrictcols(ar);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 41ad75bb14f..d1d512409ee 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -902,7 +902,7 @@ int outliner_item_do_activate(bContext *C, int x, int y, bool extend, bool recur
UI_view2d_region_to_view(&ar->v2d, x, y, fmval, fmval + 1);
- if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) &&
+ if (!ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF) &&
!(soops->flag & SO_HIDE_RESTRICTCOLS) &&
(fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX))
{
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 10890a305fb..036db3bae91 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -428,8 +428,9 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s
outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0);
outliner_add_element(soops, lb, sce->world, te, 0, 0);
-
- outliner_add_line_styles(soops, lb, sce, te);
+
+ if (STREQ(sce->r.engine, "BLENDER_RENDER") && (sce->r.mode & R_EDGE_FRS))
+ outliner_add_line_styles(soops, lb, sce, te);
}
// can be inlined if necessary
@@ -1675,14 +1676,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
tselem->flag &= ~TSE_CLOSED;
}
}
- else if (soops->outlinevis == SO_KEYMAP) {
- wmWindowManager *wm = mainvar->wm.first;
- wmKeyMap *km;
-
- for (km = wm->defaultconf->keymaps.first; km; km = km->next) {
- /* ten = */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0);
- }
- }
else {
ten = outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0);
if (ten) ten->directdata = BASACT;
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index d695ffa46d5..3a7d001f432 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -476,9 +476,9 @@ void ED_spacetype_outliner(void)
st->dropboxes = outliner_dropboxes;
/* regions: main window */
- art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
+ art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region");
art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
art->init = outliner_main_area_init;
art->draw = outliner_main_area_draw;
@@ -487,7 +487,7 @@ void ED_spacetype_outliner(void)
BLI_addhead(&st->regiontypes, art);
/* regions: header */
- art = MEM_callocN(sizeof(ARegionType), "spacetype time header region");
+ art = MEM_callocN(sizeof(ARegionType), "spacetype outliner header region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 8b2e7067eb9..63aa92517a7 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -821,7 +821,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe)
/* like duplicate, but only duplicate and cut overlapping strips,
* strips to the left of the cutframe are ignored and strips to the right
* are moved to the end of slist
- * we have to work on the same slist (not using a seperate list), since
+ * we have to work on the same slist (not using a separate list), since
* otherwise dupli_seq can't check for duplicate names properly and
* may generate strips with the same name (which will mess up animdata)
*/
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index deb37f8d943..f39b30adf37 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -211,11 +211,9 @@ static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int sample_cancel(bContext *C, wmOperator *op)
+static void sample_cancel(bContext *C, wmOperator *op)
{
sample_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
static int sample_poll(bContext *C)
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 84c6329db53..4a4754e8adc 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -54,6 +54,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -534,8 +535,9 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar)
ScrArea *sa = CTX_wm_area(C);
SpaceSeq *sseq = sa->spacedata.first;
Scene *scene = CTX_data_scene(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
int show_split = scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF;
-
+
/* XXX temp fix for wrong setting in sseq->mainb */
if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
@@ -554,6 +556,11 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar)
draw_image_seq(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, TRUE);
}
+ if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) {
+ rcti rect;
+ ED_region_visible_rect(ar, &rect);
+ ED_scene_draw_fps(scene, &rect);
+ }
}
static void sequencer_preview_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index c668c8063a8..ee64d680319 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -239,7 +239,11 @@ static void text_keymap(struct wmKeyConfig *keyconf)
#ifdef __APPLE__
WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_OSKEY, 0);
#endif
-
+ WM_keymap_add_item(keymap, "TEXT_OT_jump", JKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "TEXT_OT_find", GKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "TEXT_OT_replace", HKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0);
+
keymap = WM_keymap_find(keyconf, "Text", SPACE_TEXT, 0);
#ifdef __APPLE__
@@ -265,7 +269,6 @@ static void text_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_find_set_selected", EKEY, KM_PRESS, KM_OSKEY, 0);
- WM_keymap_add_item(keymap, "TEXT_OT_find", GKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_select_line", AKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0);
#endif
@@ -309,13 +312,6 @@ static void text_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "selection", TRUE);
}
- WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0);
-
- WM_keymap_add_item(keymap, "TEXT_OT_jump", JKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "TEXT_OT_find", GKEY, KM_PRESS, KM_CTRL, 0);
-
- WM_keymap_add_item(keymap, "TEXT_OT_replace", HKEY, KM_PRESS, KM_CTRL, 0);
-
kmi = WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "split_lines", FALSE);
kmi = WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_CTRL, 0);
@@ -476,13 +472,26 @@ static void text_drop_copy(wmDrag *drag, wmDropBox *drop)
RNA_string_set(drop->ptr, "filepath", drag->path);
}
+static int text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
+{
+ if (drag->type == WM_DRAG_ID)
+ return true;
+
+ return false;
+}
+
+static void text_drop_paste(wmDrag *drag, wmDropBox *drop)
+{
+ RNA_string_set(drop->ptr, "text", ((ID *)drag->poin)->name + 2);
+}
+
/* this region dropbox definition */
static void text_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy);
-
+ WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste);
}
/* ************* end drop *********** */
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index eaba537c0a8..692cefd3ee9 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -529,10 +529,9 @@ static void text_autocomplete_free(bContext *C, wmOperator *op)
}
}
-static int text_autocomplete_cancel(bContext *C, wmOperator *op)
+static void text_autocomplete_cancel(bContext *C, wmOperator *op)
{
text_autocomplete_free(C, op);
- return OPERATOR_CANCELLED;
}
void TEXT_OT_autocomplete(wmOperatorType *ot)
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index c078e612d68..dd5e282587d 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -174,12 +174,6 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
uiIDContextProperty(C, &ptr, &prop);
if (prop) {
- /* when creating new ID blocks, use is already 1, but RNA
- * pointer se also increases user, so this compensates it */
- /* doesnt always seem to happen... (ton) */
- if (text->id.us > 1)
- text->id.us--;
-
RNA_id_pointer_create(&text->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);
@@ -220,10 +214,9 @@ static void text_open_init(bContext *C, wmOperator *op)
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
}
-static int text_open_cancel(bContext *UNUSED(C), wmOperator *op)
+static void text_open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
- return OPERATOR_CANCELLED;
}
static int text_open_exec(bContext *C, wmOperator *op)
@@ -252,10 +245,6 @@ static int text_open_exec(bContext *C, wmOperator *op)
pprop = op->customdata;
if (pprop->prop) {
- /* when creating new ID blocks, use is already 1, but RNA
- * pointer se also increases user, so this compensates it */
- text->id.us--;
-
RNA_id_pointer_create(&text->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
RNA_property_update(C, &pprop->ptr, pprop->prop);
@@ -2241,11 +2230,9 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int text_scroll_cancel(bContext *C, wmOperator *op)
+static void text_scroll_cancel(bContext *C, wmOperator *op)
{
scroll_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2716,10 +2703,9 @@ static int text_set_selection_modal(bContext *C, wmOperator *op, const wmEvent *
return OPERATOR_RUNNING_MODAL;
}
-static int text_set_selection_cancel(bContext *C, wmOperator *op)
+static void text_set_selection_cancel(bContext *C, wmOperator *op)
{
text_cursor_set_exit(C, op);
- return OPERATOR_FINISHED;
}
void TEXT_OT_selection_set(wmOperatorType *ot)
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 16423c60cac..a08a6cc1478 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -345,7 +345,10 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
else {
/* draw with lights in the scene otherwise */
solidtex = false;
- Gtexdraw.is_lit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp);
+ if (v3d->flag2 & V3D_SHADELESS_TEX)
+ Gtexdraw.is_lit = 0;
+ else
+ Gtexdraw.is_lit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp);
}
rgba_float_to_uchar(obcol, ob->col);
@@ -571,7 +574,7 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index)
if (UNLIKELY(index >= em->bm->totface))
return DM_DRAW_OPTION_NORMAL;
- efa = EDBM_face_at_index(em, index);
+ efa = BM_face_at_index(em->bm, index);
if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
return DM_DRAW_OPTION_SKIP;
@@ -933,7 +936,7 @@ static bool tex_mat_set_face_editmesh_cb(void *userData, int index)
if (UNLIKELY(index >= em->bm->totface))
return DM_DRAW_OPTION_NORMAL;
- efa = EDBM_face_at_index(em, index);
+ efa = BM_face_at_index(em->bm, index);
return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
}
@@ -955,7 +958,10 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
else glFrontFace(GL_CCW);
- glEnable(GL_LIGHTING);
+ if ((v3d->drawtype == OB_TEXTURE) && (v3d->flag2 & V3D_SHADELESS_TEX))
+ glColor3f(1.0f, 1.0f, 1.0f);
+ else
+ glEnable(GL_LIGHTING);
{
Mesh *me = ob->data;
@@ -977,7 +983,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
if (glsl || picking) {
- /* draw glsl */
+ /* draw glsl or solid */
dm->drawMappedFacesMat(dm,
tex_mat_set_material_cb,
set_face_cb, &data);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 1ea1dcfb33d..9c053ee35bc 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -103,7 +103,7 @@ typedef enum eWireDrawMode {
} eWireDrawMode;
typedef struct drawDMVerts_userData {
- BMEditMesh *em;
+ BMesh *bm;
BMVert *eve_act;
char sel;
@@ -121,7 +121,7 @@ typedef struct drawDMVerts_userData {
} drawDMVerts_userData;
typedef struct drawDMEdgesSel_userData {
- BMEditMesh *em;
+ BMesh *bm;
unsigned char *baseCol, *selCol, *actCol;
BMEdge *eed_act;
@@ -135,7 +135,7 @@ typedef struct drawDMFacesSel_userData {
#endif
DerivedMesh *dm;
- BMEditMesh *em;
+ BMesh *bm;
BMFace *efa_act;
int *orig_index_mf_to_mpoly;
@@ -143,7 +143,7 @@ typedef struct drawDMFacesSel_userData {
} drawDMFacesSel_userData;
typedef struct drawDMNormal_userData {
- BMEditMesh *em;
+ BMesh *bm;
int uniform_scale;
float normalsize;
float tmat[3][3];
@@ -156,7 +156,7 @@ typedef struct bbsObmodeMeshVerts_userData {
} bbsObmodeMeshVerts_userData;
typedef struct drawDMLayer_userData {
- BMEditMesh *em;
+ BMesh *bm;
int cd_layer_offset;
} drawDMLayer_userData;
@@ -610,6 +610,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
if (ibuf && ibuf->rect) {
const bool use_clip = (U.glalphaclip != 1.0f);
+ int zoomfilter = (U.gameflags & USER_DISABLE_MIPMAP )? GL_NEAREST : GL_LINEAR;
/* Setup GL params */
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -623,7 +624,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
glColor4fv(ob->col);
/* Draw the Image on the screen */
- glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect);
+ glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_RGBA, GL_UNSIGNED_BYTE, zoomfilter, ibuf->rect);
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
glDisable(GL_BLEND);
@@ -1356,6 +1357,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
}
/* and back to viewspace */
+ glPushMatrix();
glLoadMatrixf(rv3d->viewmat);
copy_v3_v3(vec, ob->obmat[3]);
@@ -1391,6 +1393,8 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
/* restore for drawing extra stuff */
glColor3ubv(ob_wire_col);
}
+ /* and finally back to org object space! */
+ glPopMatrix();
}
static void draw_limit_line(float sta, float end, const short dflag, unsigned int col)
@@ -2038,7 +2042,7 @@ static void calcDrawDMNormalScale(Object *ob, drawDMNormal_userData *data)
static void draw_dm_face_normals__mapFunc(void *userData, int index, const float cent[3], const float no[3])
{
drawDMNormal_userData *data = userData;
- BMFace *efa = EDBM_face_at_index(data->em, index);
+ BMFace *efa = BM_face_at_index(data->bm, index);
float n[3];
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
@@ -2062,7 +2066,7 @@ static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv
{
drawDMNormal_userData data;
- data.em = em;
+ data.bm = em->bm;
data.normalsize = scene->toolsettings->normalsize;
calcDrawDMNormalScale(ob, &data);
@@ -2074,7 +2078,7 @@ static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv
static void draw_dm_face_centers__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
{
- BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index);
+ BMFace *efa = BM_face_at_index(((void **)userData)[0], index);
const char sel = *(((char **)userData)[1]);
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) &&
@@ -2085,7 +2089,7 @@ static void draw_dm_face_centers__mapFunc(void *userData, int index, const float
}
static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, char sel)
{
- void *ptrs[2] = {em, &sel};
+ void *ptrs[2] = {em->bm, &sel};
bglBegin(GL_POINTS);
dm->foreachMappedFaceCenter(dm, draw_dm_face_centers__mapFunc, ptrs, DM_FOREACH_NOP);
@@ -2095,7 +2099,7 @@ static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, char sel)
static void draw_dm_vert_normals__mapFunc(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3])
{
drawDMNormal_userData *data = userData;
- BMVert *eve = EDBM_vert_at_index(data->em, index);
+ BMVert *eve = BM_vert_at_index(data->bm, index);
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
float no[3], n[3];
@@ -2127,7 +2131,7 @@ static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv
{
drawDMNormal_userData data;
- data.em = em;
+ data.bm = em->bm;
data.normalsize = scene->toolsettings->normalsize;
calcDrawDMNormalScale(ob, &data);
@@ -2142,7 +2146,7 @@ static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3],
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
{
drawDMVerts_userData *data = userData;
- BMVert *eve = EDBM_vert_at_index(data->em, index);
+ BMVert *eve = BM_vert_at_index(data->bm, index);
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->sel) {
/* skin nodes: draw a red circle around the root
@@ -2188,7 +2192,7 @@ static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, const char sel, BMVer
drawDMVerts_userData data;
data.sel = sel;
data.eve_act = eve_act;
- data.em = em;
+ data.bm = em->bm;
/* Cache theme values */
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, data.th_editmesh_active);
@@ -2216,7 +2220,7 @@ static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index)
drawDMEdgesSel_userData *data = userData;
unsigned char *col;
- eed = EDBM_edge_at_index(data->em, index);
+ eed = BM_edge_at_index(data->bm, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
if (eed == data->eed_act) {
@@ -2249,7 +2253,7 @@ static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
data.baseCol = baseCol;
data.selCol = selCol;
data.actCol = actCol;
- data.em = em;
+ data.bm = em->bm;
data.eed_act = eed_act;
dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, &data);
}
@@ -2257,7 +2261,7 @@ static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
/* Draw edges */
static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index)
{
- if (BM_elem_flag_test(EDBM_edge_at_index(userData, index), BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(BM_edge_at_index(userData, index), BM_ELEM_HIDDEN))
return DM_DRAW_OPTION_SKIP;
else
return DM_DRAW_OPTION_NORMAL;
@@ -2265,20 +2269,20 @@ static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index)
static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm)
{
- dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em);
+ dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em->bm);
}
/* Draw edges with color interpolated based on selection */
static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index)
{
- if (BM_elem_flag_test(EDBM_edge_at_index(((void **)userData)[0], index), BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(BM_edge_at_index(((void **)userData)[0], index), BM_ELEM_HIDDEN))
return DM_DRAW_OPTION_SKIP;
else
return DM_DRAW_OPTION_NORMAL;
}
static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t)
{
- BMEdge *eed = EDBM_edge_at_index(((void **)userData)[0], index);
+ BMEdge *eed = BM_edge_at_index(((void **)userData)[0], index);
unsigned char **cols = userData;
unsigned char *col0 = cols[(BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1];
unsigned char *col1 = cols[(BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1];
@@ -2291,7 +2295,7 @@ static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int i
static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
{
- void *cols[3] = {em, baseCol, selCol};
+ void *cols[3] = {em->bm, baseCol, selCol};
dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols);
}
@@ -2299,7 +2303,7 @@ static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned c
/* Draw only seam edges */
static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index)
{
- BMEdge *eed = EDBM_edge_at_index(userData, index);
+ BMEdge *eed = BM_edge_at_index(userData, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM))
return DM_DRAW_OPTION_NORMAL;
@@ -2309,13 +2313,13 @@ static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int inde
static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm)
{
- dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em);
+ dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em->bm);
}
/* Draw only sharp edges */
static DMDrawOption draw_dm_edges_sharp__setDrawOptions(void *userData, int index)
{
- BMEdge *eed = EDBM_edge_at_index(userData, index);
+ BMEdge *eed = BM_edge_at_index(userData, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && !BM_elem_flag_test(eed, BM_ELEM_SMOOTH))
return DM_DRAW_OPTION_NORMAL;
@@ -2325,14 +2329,14 @@ static DMDrawOption draw_dm_edges_sharp__setDrawOptions(void *userData, int inde
static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm)
{
- dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em);
+ dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em->bm);
}
#ifdef WITH_FREESTYLE
-static int draw_dm_test_freestyle_edge_mark(BMEditMesh *em, BMEdge *eed)
+static int draw_dm_test_freestyle_edge_mark(BMesh *bm, BMEdge *eed)
{
- FreestyleEdge *fed = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_FREESTYLE_EDGE);
+ FreestyleEdge *fed = CustomData_bmesh_get(&bm->edata, eed->head.data, CD_FREESTYLE_EDGE);
if (!fed)
return 0;
return (fed->flag & FREESTYLE_EDGE_MARK) != 0;
@@ -2341,7 +2345,7 @@ static int draw_dm_test_freestyle_edge_mark(BMEditMesh *em, BMEdge *eed)
/* Draw only Freestyle feature edges */
static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int index)
{
- BMEdge *eed = EDBM_edge_at_index(userData, index);
+ BMEdge *eed = BM_edge_at_index(userData, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && draw_dm_test_freestyle_edge_mark(userData, eed))
return DM_DRAW_OPTION_NORMAL;
@@ -2351,12 +2355,12 @@ static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int
static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm)
{
- dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em);
+ dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em->bm);
}
-static int draw_dm_test_freestyle_face_mark(BMEditMesh *em, BMFace *efa)
+static int draw_dm_test_freestyle_face_mark(BMesh *bm, BMFace *efa)
{
- FreestyleFace *ffa = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_FREESTYLE_FACE);
+ FreestyleFace *ffa = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_FREESTYLE_FACE);
if (!ffa)
return 0;
return (ffa->flag & FREESTYLE_FACE_MARK) != 0;
@@ -2369,7 +2373,7 @@ static int draw_dm_test_freestyle_face_mark(BMEditMesh *em, BMFace *efa)
static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
{
drawDMFacesSel_userData *data = userData;
- BMFace *efa = EDBM_face_at_index(data->em, index);
+ BMFace *efa = BM_face_at_index(data->bm, index);
unsigned char *col;
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
@@ -2379,7 +2383,7 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
}
else {
#ifdef WITH_FREESTYLE
- col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->em, efa) ? 3 : 0];
+ col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0];
#else
col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
#endif
@@ -2406,9 +2410,9 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int
return 0;
i = DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, index);
- efa = (i != ORIGINDEX_NONE) ? EDBM_face_at_index(data->em, i) : NULL;
+ efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL;
i = DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, next_index);
- next_efa = (i != ORIGINDEX_NONE) ? EDBM_face_at_index(data->em, i) : NULL;
+ next_efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL;
if (ELEM(NULL, efa, next_efa))
return 0;
@@ -2420,8 +2424,8 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int
return 0;
#ifdef WITH_FREESTYLE
- col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->em, efa) ? 3 : 0];
- next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->em, efa) ? 3 : 0];
+ col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0];
+ next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0];
#else
col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : 0];
@@ -2445,7 +2449,7 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
drawDMFacesSel_userData data;
data.dm = dm;
data.cols[0] = baseCol;
- data.em = em;
+ data.bm = em->bm;
data.cols[1] = selCol;
data.cols[2] = actCol;
#ifdef WITH_FREESTYLE
@@ -2465,8 +2469,8 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index)
{
drawDMLayer_userData *data = userData;
- BMEditMesh *em = data->em;
- BMEdge *eed = EDBM_edge_at_index(em, index);
+ BMesh *bm = data->bm;
+ BMEdge *eed = BM_edge_at_index(bm, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
const float crease = BM_ELEM_CD_GET_FLOAT(eed, data->cd_layer_offset);
@@ -2481,7 +2485,7 @@ static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm)
{
drawDMLayer_userData data;
- data.em = em;
+ data.bm = em->bm;
data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
if (data.cd_layer_offset != -1) {
@@ -2494,8 +2498,8 @@ static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm)
static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index)
{
drawDMLayer_userData *data = userData;
- BMEditMesh *em = data->em;
- BMEdge *eed = EDBM_edge_at_index(em, index);
+ BMesh *bm = data->bm;
+ BMEdge *eed = BM_edge_at_index(bm, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
const float bweight = BM_ELEM_CD_GET_FLOAT(eed, data->cd_layer_offset);
@@ -2510,8 +2514,8 @@ static void draw_dm_bweights__mapFunc(void *userData, int index, const float co[
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
{
drawDMLayer_userData *data = userData;
- BMEditMesh *em = data->em;
- BMVert *eve = EDBM_vert_at_index(em, index);
+ BMesh *bm = data->bm;
+ BMVert *eve = BM_vert_at_index(bm, index);
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
const float bweight = BM_ELEM_CD_GET_FLOAT(eve, data->cd_layer_offset);
@@ -2528,7 +2532,7 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
if (ts->selectmode & SCE_SELECT_VERTEX) {
drawDMLayer_userData data;
- data.em = em;
+ data.bm = em->bm;
data.cd_layer_offset = CustomData_get_offset(&em->bm->vdata, CD_BWEIGHT);
if (data.cd_layer_offset != -1) {
@@ -2541,7 +2545,7 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
else {
drawDMLayer_userData data;
- data.em = em;
+ data.bm = em->bm;
data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
if (data.cd_layer_offset != -1) {
@@ -2692,7 +2696,10 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d,
static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMesh *em, UnitSettings *unit)
{
- const short txt_flag = V3D_CACHE_TEXT_ASCII | V3D_CACHE_TEXT_LOCALCLIP;
+ /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, etc.).
+ * See bug #36090.
+ */
+ const short txt_flag = V3D_CACHE_TEXT_LOCALCLIP | (unit->system ? 0 : V3D_CACHE_TEXT_ASCII);
Mesh *me = ob->data;
float v1[3], v2[3], v3[3], vmid[3], fvec[3];
char numstr[32]; /* Stores the measurement display text here */
@@ -2865,14 +2872,11 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
bUnit_AsString(numstr, sizeof(numstr), \
(double)(area * unit->scale_length * unit->scale_length), \
3, unit->system, B_UNIT_AREA, do_split, false); \
- view3d_cached_text_draw_add(vmid, numstr, 0, \
- /* Metric system uses unicode "squared" sign! */ \
- txt_flag ^ V3D_CACHE_TEXT_ASCII, col); \
} \
else { \
BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \
- view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col); \
} \
+ view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col); \
} (void)0
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
@@ -3060,7 +3064,7 @@ static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index)
if (UNLIKELY(index >= em->bm->totface))
return DM_DRAW_OPTION_NORMAL;
- efa = EDBM_face_at_index(em, index);
+ efa = BM_face_at_index(em->bm, index);
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
GPU_enable_material(efa->mat_nr + 1, NULL);
return DM_DRAW_OPTION_NORMAL;
@@ -3078,7 +3082,7 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
if (UNLIKELY(index >= em->bm->totface))
return DM_DRAW_OPTION_NORMAL;
- efa = EDBM_face_at_index(em, index);
+ efa = BM_face_at_index(em->bm, index);
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
return DM_DRAW_OPTION_NORMAL;
@@ -3116,7 +3120,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
}
}
- EDBM_index_arrays_ensure(em, BM_VERT | BM_EDGE | BM_FACE);
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
if (check_object_draw_editweight(me, finalDM)) {
if (dt > OB_WIRE) {
@@ -3128,7 +3132,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
else {
glEnable(GL_DEPTH_TEST);
draw_mesh_paint_weight_faces(finalDM, false, draw_em_fancy__setFaceOpts, me->edit_btmesh);
- draw_mesh_paint_weight_edges(rv3d, finalDM, true, draw_dm_edges__setDrawOptions, me->edit_btmesh);
+ draw_mesh_paint_weight_edges(rv3d, finalDM, true, draw_dm_edges__setDrawOptions, me->edit_btmesh->bm);
glDisable(GL_DEPTH_TEST);
}
}
@@ -4054,7 +4058,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
if (BKE_mball_is_basis(ob)) {
lb = ob->curve_cache ? &ob->curve_cache->disp : NULL;
- if (ELEM(lb, lb->first, NULL)) {
+ if (ELEM(NULL, lb, lb->first)) {
BKE_displist_make_mball(scene, ob);
lb = &ob->curve_cache->disp;
}
@@ -6357,7 +6361,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
RegionView3D *rv3d = ar->regiondata;
Object *ob = base->object;
- glLineWidth(2.0);
+ glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(0);
if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
@@ -6644,6 +6648,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
char dt;
short zbufoff = 0;
const bool is_obact = (ob == OBACT);
+ const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
+ bool particle_skip_object = false; /* Draw particles but not their emitter object. */
/* only once set now, will be removed too, should become a global standard */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -6652,16 +6658,30 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (ob->restrictflag & OB_RESTRICT_VIEW) {
return;
}
- else if ((ob->restrictflag & OB_RESTRICT_RENDER) &&
- (v3d->flag2 & V3D_RENDER_OVERRIDE))
- {
+ else if ((ob->restrictflag & OB_RESTRICT_RENDER) && render_override) {
return;
}
}
- /* XXX particles are not safe for simultaneous threaded render */
- if (G.is_rendering && ob->particlesystem.first)
- return;
+ if (ob->particlesystem.first) {
+ /* XXX particles are not safe for simultaneous threaded render */
+ if (G.is_rendering) {
+ return;
+ }
+
+ if (ob->mode == OB_MODE_OBJECT) {
+ ParticleSystem *psys;
+
+ particle_skip_object = render_override;
+ for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+ /* Once we have found a psys which renders its emitter object, we are done. */
+ if (psys->part->draw & PART_DRAW_EMITTER) {
+ particle_skip_object = false;
+ break;
+ }
+ }
+ }
+ }
/* xray delay? */
if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
@@ -6687,7 +6707,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
view3d_cached_text_draw_begin();
/* draw motion paths (in view space) */
- if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ if (ob->mpath && !render_override) {
bAnimVizSettings *avs = &ob->avs;
/* setup drawing environment for paths */
@@ -6728,7 +6748,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* faceselect exception: also draw solid when (dt == wire), except in editmode */
if (is_obact && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
- if (ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
if (dt < OB_SOLID) {
zbufoff = 1;
dt = OB_SOLID;
@@ -6760,240 +6780,240 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
- /* bad exception, solve this! otherwise outline shows too late */
- if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
- if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) {
- BKE_displist_make_curveTypes(scene, ob, 0);
+ if (!particle_skip_object) {
+ /* bad exception, solve this! otherwise outline shows too late */
+ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
+ /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
+ if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) {
+ BKE_displist_make_curveTypes(scene, ob, 0);
+ }
}
- }
-
- /* draw outline for selected objects, mesh does itself */
- if ((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && ob->type != OB_MESH) {
- if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
- if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
- drawObjectSelect(scene, v3d, ar, base, ob_wire_col);
+
+ /* draw outline for selected objects, mesh does itself */
+ if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) {
+ if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
+ if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
+ drawObjectSelect(scene, v3d, ar, base, ob_wire_col);
+ }
}
}
- }
- switch (ob->type) {
- case OB_MESH:
- empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
- if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself
+ switch (ob->type) {
+ case OB_MESH:
+ empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
+ if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself
- break;
- case OB_FONT:
- cu = ob->data;
- if (cu->editfont) {
- draw_textcurs(rv3d, cu->editfont->textcurs);
-
- if (cu->flag & CU_FAST) {
- cpack(0xFFFFFF);
- set_inverted_drawing(1);
- drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
- set_inverted_drawing(0);
- }
- else {
- drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
- }
-
- if (cu->linewidth != 0.0f) {
- UI_ThemeColor(TH_WIRE_EDIT);
- copy_v3_v3(vec1, ob->orig);
- copy_v3_v3(vec2, ob->orig);
- vec1[0] += cu->linewidth;
- vec2[0] += cu->linewidth;
- vec1[1] += cu->linedist * cu->fsize;
- vec2[1] -= cu->lines * cu->linedist * cu->fsize;
- setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
- setlinestyle(0);
- }
+ break;
+ case OB_FONT:
+ cu = ob->data;
+ if (cu->editfont) {
+ draw_textcurs(rv3d, cu->editfont->textcurs);
+
+ if (cu->flag & CU_FAST) {
+ cpack(0xFFFFFF);
+ set_inverted_drawing(1);
+ drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
+ set_inverted_drawing(0);
+ }
+ else {
+ drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ }
- setlinestyle(3);
- for (i = 0; i < cu->totbox; i++) {
- if (cu->tb[i].w != 0.0f) {
- UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
- vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x;
- vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize;
- vec1[2] = 0.001;
+ if (cu->linewidth != 0.0f) {
+ UI_ThemeColor(TH_WIRE_EDIT);
+ copy_v3_v3(vec1, ob->orig);
+ copy_v3_v3(vec2, ob->orig);
+ vec1[0] += cu->linewidth;
+ vec2[0] += cu->linewidth;
+ vec1[1] += cu->linedist * cu->fsize;
+ vec2[1] -= cu->lines * cu->linedist * cu->fsize;
+ setlinestyle(3);
glBegin(GL_LINE_STRIP);
- glVertex3fv(vec1);
- vec1[0] += cu->tb[i].w;
- glVertex3fv(vec1);
- vec1[1] -= cu->tb[i].h;
- glVertex3fv(vec1);
- vec1[0] -= cu->tb[i].w;
- glVertex3fv(vec1);
- vec1[1] += cu->tb[i].h;
- glVertex3fv(vec1);
+ glVertex2fv(vec1);
+ glVertex2fv(vec2);
glEnd();
+ setlinestyle(0);
}
- }
- setlinestyle(0);
+ setlinestyle(3);
+ for (i = 0; i < cu->totbox; i++) {
+ if (cu->tb[i].w != 0.0f) {
+ UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
+ vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x;
+ vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize;
+ vec1[2] = 0.001;
+ glBegin(GL_LINE_STRIP);
+ glVertex3fv(vec1);
+ vec1[0] += cu->tb[i].w;
+ glVertex3fv(vec1);
+ vec1[1] -= cu->tb[i].h;
+ glVertex3fv(vec1);
+ vec1[0] -= cu->tb[i].w;
+ glVertex3fv(vec1);
+ vec1[1] += cu->tb[i].h;
+ glVertex3fv(vec1);
+ glEnd();
+ }
+ }
+ setlinestyle(0);
- if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) {
- float selboxw;
- cpack(0xffffff);
- set_inverted_drawing(1);
- for (i = 0; i <= (selend - selstart); i++) {
- SelBox *sb = &(cu->selboxes[i]);
+ if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) {
+ float selboxw;
- if (i < (selend - selstart)) {
- if (cu->selboxes[i + 1].y == sb->y)
- selboxw = cu->selboxes[i + 1].x - sb->x;
- else
+ cpack(0xffffff);
+ set_inverted_drawing(1);
+ for (i = 0; i <= (selend - selstart); i++) {
+ SelBox *sb = &(cu->selboxes[i]);
+
+ if (i < (selend - selstart)) {
+ if (cu->selboxes[i + 1].y == sb->y)
+ selboxw = cu->selboxes[i + 1].x - sb->x;
+ else
+ selboxw = sb->w;
+ }
+ else {
selboxw = sb->w;
+ }
+ glBegin(GL_QUADS);
+ glVertex3f(sb->x, sb->y, 0.001);
+ glVertex3f(sb->x + selboxw, sb->y, 0.001);
+ glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001);
+ glVertex3f(sb->x, sb->y + sb->h, 0.001);
+ glEnd();
}
- else {
- selboxw = sb->w;
- }
- glBegin(GL_QUADS);
- glVertex3f(sb->x, sb->y, 0.001);
- glVertex3f(sb->x + selboxw, sb->y, 0.001);
- glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001);
- glVertex3f(sb->x, sb->y + sb->h, 0.001);
- glEnd();
+ set_inverted_drawing(0);
}
- set_inverted_drawing(0);
}
- }
- else if (dt == OB_BOUNDBOX) {
- if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0) {
- draw_bounding_volume(scene, ob, ob->boundtype);
+ else if (dt == OB_BOUNDBOX) {
+ if ((render_override && v3d->drawtype >= OB_WIRE) == 0) {
+ draw_bounding_volume(scene, ob, ob->boundtype);
+ }
+ }
+ else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
+ empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
- }
- else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
- empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
- }
- break;
- case OB_CURVE:
- case OB_SURF:
- cu = ob->data;
+ break;
+ case OB_CURVE:
+ case OB_SURF:
+ cu = ob->data;
- if (cu->editnurb) {
- ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
- }
- else if (dt == OB_BOUNDBOX) {
- if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) {
- draw_bounding_volume(scene, ob, ob->boundtype);
+ if (cu->editnurb) {
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+ drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
}
- }
- else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
- empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ else if (dt == OB_BOUNDBOX) {
+ if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
+ draw_bounding_volume(scene, ob, ob->boundtype);
+ }
+ }
+ else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
+ empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
//XXX old animsys if (cu->path)
// curve_draw_speed(scene, ob);
- }
- break;
- case OB_MBALL:
- {
- MetaBall *mb = ob->data;
-
- if (mb->editelems)
- drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
- else if (dt == OB_BOUNDBOX) {
- if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) {
- draw_bounding_volume(scene, ob, ob->boundtype);
}
+ break;
+ case OB_MBALL:
+ {
+ MetaBall *mb = ob->data;
+
+ if (mb->editelems)
+ drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ else if (dt == OB_BOUNDBOX) {
+ if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
+ draw_bounding_volume(scene, ob, ob->boundtype);
+ }
+ }
+ else
+ empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ break;
}
- else
- empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
- break;
- }
- case OB_EMPTY:
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
- draw_empty_image(ob, dflag, ob_wire_col);
+ case OB_EMPTY:
+ if (!render_override) {
+ if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
+ draw_empty_image(ob, dflag, ob_wire_col);
+ }
+ else {
+ drawaxes(ob->empty_drawsize, ob->empty_drawtype);
+ }
}
- else {
- drawaxes(ob->empty_drawsize, ob->empty_drawtype);
+ break;
+ case OB_LAMP:
+ if (!render_override) {
+ drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
- }
- break;
- case OB_LAMP:
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
- if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat);
- }
- break;
- case OB_CAMERA:
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 ||
- (rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */
- {
- drawcamera(scene, v3d, rv3d, base, dflag, ob_wire_col);
- }
- break;
- case OB_SPEAKER:
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
- drawspeaker(scene, v3d, rv3d, ob, dflag);
- break;
- case OB_LATTICE:
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- /* Do not allow boundbox in edit nor pose mode! */
- if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT))
- dt = OB_WIRE;
- if (dt == OB_BOUNDBOX) {
- draw_bounding_volume(scene, ob, ob->boundtype);
+ break;
+ case OB_CAMERA:
+ if (!render_override ||
+ (rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */
+ {
+ drawcamera(scene, v3d, rv3d, base, dflag, ob_wire_col);
}
- else {
- drawlattice(scene, v3d, ob);
+ break;
+ case OB_SPEAKER:
+ if (!render_override)
+ drawspeaker(scene, v3d, rv3d, ob, dflag);
+ break;
+ case OB_LATTICE:
+ if (!render_override) {
+ /* Do not allow boundbox in edit nor pose mode! */
+ if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT))
+ dt = OB_WIRE;
+ if (dt == OB_BOUNDBOX) {
+ draw_bounding_volume(scene, ob, ob->boundtype);
+ }
+ else {
+ drawlattice(scene, v3d, ob);
+ }
}
- }
- break;
- case OB_ARMATURE:
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- /* Do not allow boundbox in edit nor pose mode! */
- if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE)))
- dt = OB_WIRE;
- if (dt == OB_BOUNDBOX) {
- draw_bounding_volume(scene, ob, ob->boundtype);
+ break;
+ case OB_ARMATURE:
+ if (!render_override) {
+ /* Do not allow boundbox in edit nor pose mode! */
+ if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE)))
+ dt = OB_WIRE;
+ if (dt == OB_BOUNDBOX) {
+ draw_bounding_volume(scene, ob, ob->boundtype);
+ }
+ else {
+ if (dt > OB_WIRE)
+ GPU_enable_material(0, NULL); /* we use default material */
+ empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, false);
+ if (dt > OB_WIRE)
+ GPU_disable_material();
+ }
}
- else {
- if (dt > OB_WIRE)
- GPU_enable_material(0, NULL); /* we use default material */
- empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, false);
- if (dt > OB_WIRE)
- GPU_disable_material();
+ break;
+ default:
+ if (!render_override) {
+ drawaxes(1.0, OB_ARROWS);
}
- }
- break;
- default:
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- drawaxes(1.0, OB_ARROWS);
- }
- break;
- }
-
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
-
- if (ob->soft /*&& dflag & OB_SBMOTION*/) {
- float mrt[3][3], msc[3][3], mtr[3][3];
- SoftBody *sb = NULL;
- float tipw = 0.5f, tiph = 0.5f, drawsize = 4.0f;
- if ((sb = ob->soft)) {
- if (sb->solverflags & SBSO_ESTIMATEIPO) {
+ break;
+ }
- glLoadMatrixf(rv3d->viewmat);
- copy_m3_m3(msc, sb->lscale);
- copy_m3_m3(mrt, sb->lrot);
- mul_m3_m3m3(mtr, mrt, msc);
- ob_draw_RE_motion(sb->lcom, mtr, tipw, tiph, drawsize);
- glMultMatrixf(ob->obmat);
+ if (!render_override) {
+ if (ob->soft /*&& dflag & OB_SBMOTION*/) {
+ float mrt[3][3], msc[3][3], mtr[3][3];
+ SoftBody *sb = NULL;
+ float tipw = 0.5f, tiph = 0.5f, drawsize = 4.0f;
+ if ((sb = ob->soft)) {
+ if (sb->solverflags & SBSO_ESTIMATEIPO) {
+
+ glLoadMatrixf(rv3d->viewmat);
+ copy_m3_m3(msc, sb->lscale);
+ copy_m3_m3(mrt, sb->lrot);
+ mul_m3_m3m3(mtr, mrt, msc);
+ ob_draw_RE_motion(sb->lcom, mtr, tipw, tiph, drawsize);
+ glMultMatrixf(ob->obmat);
+ }
}
}
- }
- if (ob->pd && ob->pd->forcefield) {
- draw_forcefield(ob, rv3d, dflag, ob_wire_col);
+ if (ob->pd && ob->pd->forcefield) {
+ draw_forcefield(ob, rv3d, dflag, ob_wire_col);
+ }
}
}
@@ -7156,7 +7176,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
}
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ if (!render_override) {
if ((v3d->flag2 & V3D_NO_PHYSICS) == 0) {
bConstraint *con;
@@ -7213,9 +7233,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
}
- if ((dt <= OB_SOLID) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0))
- {
+ if ((dt <= OB_SOLID) && !render_override) {
if (((ob->gameflag & OB_DYNAMIC) &&
!ELEM(ob->collision_boundtype, OB_BOUND_TRIANGLE_MESH, OB_BOUND_CONVEX_HULL)) ||
@@ -7249,9 +7267,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
glDisable(GL_DEPTH_TEST);
}
- if ((base->flag & OB_FROMDUPLI) ||
- (v3d->flag2 & V3D_RENDER_OVERRIDE))
- {
+ if ((base->flag & OB_FROMDUPLI) || render_override) {
ED_view3d_clear_mats_rv3d(rv3d);
return;
}
@@ -7260,7 +7276,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) {
int do_draw_center = -1; /* defines below are zero or positive... */
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
+ if (render_override) {
/* don't draw */
}
else if ((scene->basact) == base)
@@ -7288,7 +7304,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
/* not for sets, duplicators or picking */
- if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && !render_override) {
ListBase *list;
RigidBodyCon *rbc = ob->rigidbody_constraint;
@@ -7437,7 +7453,7 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3]
{
void **ptrs = userData;
int offset = (intptr_t) ptrs[0];
- BMVert *eve = EDBM_vert_at_index(ptrs[1], index);
+ BMVert *eve = BM_vert_at_index(ptrs[1], index);
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
WM_framebuffer_index_set(offset + index);
@@ -7446,7 +7462,7 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3]
}
static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
{
- void *ptrs[2] = {(void *)(intptr_t) offset, em};
+ void *ptrs[2] = {(void *)(intptr_t) offset, em->bm};
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
bglBegin(GL_POINTS);
@@ -7459,7 +7475,7 @@ static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index)
{
void **ptrs = userData;
int offset = (intptr_t) ptrs[0];
- BMEdge *eed = EDBM_edge_at_index(ptrs[1], index);
+ BMEdge *eed = BM_edge_at_index(ptrs[1], index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
WM_framebuffer_index_set(offset + index);
@@ -7471,13 +7487,13 @@ static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index)
}
static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
{
- void *ptrs[2] = {(void *)(intptr_t) offset, em};
+ void *ptrs[2] = {(void *)(intptr_t) offset, em->bm};
dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs);
}
static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int index)
{
- BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index);
+ BMFace *efa = BM_face_at_index(((void **)userData)[0], index);
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
if (((void **)userData)[1]) {
@@ -7492,7 +7508,7 @@ static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int inde
static void bbs_mesh_solid__drawCenter(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
{
- BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index);
+ BMFace *efa = BM_face_at_index(((void **)userData)[0], index);
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
WM_framebuffer_index_set(index + 1);
@@ -7505,7 +7521,7 @@ static void bbs_mesh_solid__drawCenter(void *userData, int index, const float ce
static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
Object *ob, DerivedMesh *dm, int facecol)
{
- void *ptrs[2] = {em, NULL}; //second one being null means to draw black
+ void *ptrs[2] = {em->bm, NULL}; //second one being null means to draw black
cpack(0);
if (facecol) {
@@ -7603,7 +7619,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
- EDBM_index_arrays_ensure(em, BM_VERT | BM_EDGE | BM_FACE);
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
bbs_mesh_solid_EM(em, scene, v3d, ob, dm, ts->selectmode & SCE_SELECT_FACE);
if (ts->selectmode & SCE_SELECT_FACE)
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 58c0df6b6bd..b803a4a8473 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -62,6 +62,7 @@
#include "WM_types.h"
#include "RE_engine.h"
+#include "RE_pipeline.h"
#include "RNA_access.h"
@@ -271,6 +272,8 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa)
if (rv3d && rv3d->render_engine) {
WM_jobs_kill_type(wm, ar, WM_JOB_TYPE_RENDER_PREVIEW);
+ if (rv3d->render_engine->re)
+ RE_Database_Free(rv3d->render_engine->re);
RE_engine_free(rv3d->render_engine);
rv3d->render_engine = NULL;
}
@@ -840,14 +843,6 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN
case ND_WORLD_DRAW:
/* handled by space_view3d_listener() for v3d access */
break;
- case ND_WORLD_STARS:
- {
- RegionView3D *rv3d = ar->regiondata;
- if (rv3d->persp == RV3D_CAMOB) {
- ED_region_tag_redraw(ar);
- }
- break;
- }
}
break;
case NC_LAMP:
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index eea084b4750..dc6f3a0274c 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -482,7 +482,15 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- add_v3_v3(eve->co, &median[LOC_X]);
+ if (tot == 1) {
+ /* In case we only have one element selected, copy directly the value instead of applying
+ * the diff. Avoids some glitches when going e.g. from 3 to 0.0001 (see [#37327]).
+ */
+ copy_v3_v3(eve->co, &ve_median[LOC_X]);
+ }
+ else {
+ add_v3_v3(eve->co, &median[LOC_X]);
+ }
}
}
@@ -623,10 +631,12 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
nu = nurbs->first;
while (nu) {
if (nu->type == CU_BEZIER) {
- bezt = nu->bezt;
- a = nu->pntsu;
- while (a--) {
+ for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) {
if (bezt->f2 & SELECT) {
+ /* Here we always have to use the diff... :/
+ * Cannot avoid some glitches when going e.g. from 3 to 0.0001 (see [#37327]),
+ * unless we use doubles.
+ */
add_v3_v3(bezt->vec[0], &median[LOC_X]);
add_v3_v3(bezt->vec[1], &median[LOC_X]);
add_v3_v3(bezt->vec[2], &median[LOC_X]);
@@ -647,22 +657,39 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
else {
if (bezt->f1 & SELECT) {
- add_v3_v3(bezt->vec[0], &median[LOC_X]);
+ if (tot == 1) {
+ copy_v3_v3(bezt->vec[0], &ve_median[LOC_X]);
+ }
+ else {
+ add_v3_v3(bezt->vec[0], &median[LOC_X]);
+ }
}
if (bezt->f3 & SELECT) {
- add_v3_v3(bezt->vec[2], &median[LOC_X]);
+ if (tot == 1) {
+ copy_v3_v3(bezt->vec[2], &ve_median[LOC_X]);
+ }
+ else {
+ add_v3_v3(bezt->vec[2], &median[LOC_X]);
+ }
}
}
- bezt++;
}
}
else {
- bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
- while (a--) {
+ for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a--; bp++) {
if (bp->f1 & SELECT) {
- add_v3_v3(bp->vec, &median[LOC_X]);
- bp->vec[3] += median[C_BWEIGHT];
+ if (tot == 1) {
+ copy_v3_v3(bp->vec, &ve_median[LOC_X]);
+ bp->vec[3] = ve_median[C_BWEIGHT];
+ bp->radius = ve_median[C_RADIUS];
+ bp->alfa = ve_median[C_TILT];
+ }
+ else {
+ add_v3_v3(bp->vec, &median[LOC_X]);
+ bp->vec[3] += median[C_BWEIGHT];
+ bp->radius += median[C_RADIUS];
+ bp->alfa += median[C_TILT];
+ }
if (median[C_WEIGHT] != 0.0f) {
if (ELEM(scale_w, 0.0f, 1.0f)) {
@@ -674,11 +701,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
CLAMP(bp->weight, 0.0f, 1.0f);
}
}
-
- bp->radius += median[C_RADIUS];
- bp->alfa += median[C_TILT];
}
- bp++;
}
}
BKE_nurb_test2D(nu);
@@ -697,7 +720,12 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
bp = lt->editlatt->latt->def;
while (a--) {
if (bp->f1 & SELECT) {
- add_v3_v3(bp->vec, &median[LOC_X]);
+ if (tot == 1) {
+ copy_v3_v3(bp->vec, &ve_median[LOC_X]);
+ }
+ else {
+ add_v3_v3(bp->vec, &median[LOC_X]);
+ }
if (median[L_WEIGHT] != 0.0f) {
if (ELEM(scale_w, 0.0f, 1.0f)) {
@@ -831,7 +859,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
xco, yco, (x = UI_UNIT_X * 5), UI_UNIT_Y, "");
but_ptr = uiButGetOperatorPtrRNA(but);
RNA_int_set(but_ptr, "weight_group", i);
- uiButSetFlag(but, UI_TEXT_RIGHT);
+ uiButSetDrawFlag(but, UI_BUT_TEXT_RIGHT);
if (ob->actdef != i + 1) {
uiButSetFlag(but, UI_BUT_INACTIVE);
}
@@ -845,7 +873,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
but = uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + i, "",
xco, yco, (x = UI_UNIT_X * 4), UI_UNIT_Y,
&dw->weight, 0.0, 1.0, 1, 3, "");
- uiButSetFlag(but, UI_TEXT_LEFT);
+ uiButSetDrawFlag(but, UI_BUT_TEXT_LEFT);
if (locked) {
lock_count++;
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index e8e4e75472f..a0943883efd 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -64,7 +64,6 @@
#include "BKE_movieclip.h"
#include "RE_engine.h"
-#include "RE_pipeline.h" /* make_stars */
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -107,21 +106,6 @@ extern void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const f
extern void bl_debug_draw_edge_add(const float v0[3], const float v1[3]);
#endif
-static void star_stuff_init_func(void)
-{
- cpack(0xFFFFFF);
- glPointSize(1.0);
- glBegin(GL_POINTS);
-}
-static void star_stuff_vertex_func(const float vec[3])
-{
- glVertex3fv(vec);
-}
-static void star_stuff_term_func(void)
-{
- glEnd();
-}
-
void circf(float x, float y, float rad)
{
GLUquadricObj *qobj = gluNewQuadric();
@@ -567,7 +551,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
int co[2];
/* we don't want the clipping for cursor */
- if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ if (ED_view3d_project_int_global(ar, ED_view3d_cursor3d_get(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
const float f5 = 0.25f * U.widget_unit;
const float f10 = 0.5f * U.widget_unit;
const float f20 = U.widget_unit;
@@ -2037,8 +2021,11 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
/* negative scale flag has to propagate */
transflag = tbase.object->transflag;
- if (base->object->transflag & OB_NEG_SCALE)
- tbase.object->transflag ^= OB_NEG_SCALE;
+
+ if (is_negative_m4(dob->mat))
+ tbase.object->transflag |= OB_NEG_SCALE;
+ else
+ tbase.object->transflag &= ~OB_NEG_SCALE;
UI_ThemeColorBlend(color, TH_BACK, 0.5);
@@ -2857,7 +2844,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
/* NOTE: the info that this uses is updated in ED_refresh_viewport_fps(),
* which currently gets called during SCREEN_OT_animation_step.
*/
-static void draw_viewport_fps(Scene *scene, rcti *rect)
+void ED_scene_draw_fps(Scene *scene, rcti *rect)
{
ScreenFrameRateInfo *fpsi = scene->fps_info;
float fps;
@@ -3276,14 +3263,6 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
drawfloor(scene, v3d, grid_unit);
}
- if (rv3d->persp == RV3D_CAMOB) {
- if (scene->world) {
- if (scene->world->mode & WO_STARS) {
- RE_make_stars(NULL, scene, star_stuff_init_func, star_stuff_vertex_func,
- star_stuff_term_func);
- }
- }
- }
}
else {
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
@@ -3457,7 +3436,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) {
- draw_viewport_fps(scene, &rect);
+ ED_scene_draw_fps(scene, &rect);
}
else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
draw_viewport_name(ar, v3d, &rect);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 67c9ea4599c..80e5d194d45 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1062,11 +1062,9 @@ static int view3d_lock_poll(bContext *C)
return false;
}
-static int viewrotate_cancel(bContext *C, wmOperator *op)
+static void viewrotate_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
-
- return OPERATOR_CANCELLED;
}
void VIEW3D_OT_rotate(wmOperatorType *ot)
@@ -1699,11 +1697,9 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
-static int viewmove_cancel(bContext *C, wmOperator *op)
+static void viewmove_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
-
- return OPERATOR_CANCELLED;
}
void VIEW3D_OT_move(wmOperatorType *ot)
@@ -2091,11 +2087,9 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
-static int viewzoom_cancel(bContext *C, wmOperator *op)
+static void viewzoom_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
-
- return OPERATOR_CANCELLED;
}
void VIEW3D_OT_zoom(wmOperatorType *ot)
@@ -2332,11 +2326,9 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
-static int viewdolly_cancel(bContext *C, wmOperator *op)
+static void viewdolly_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
-
- return OPERATOR_CANCELLED;
}
void VIEW3D_OT_dolly(wmOperatorType *ot)
@@ -2476,7 +2468,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in
if (center) {
/* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
- curs = give_cursor(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d);
zero_v3(min);
zero_v3(max);
zero_v3(curs);
@@ -2757,7 +2749,7 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
/* non camera center */
float new_ofs[3];
- negate_v3_v3(new_ofs, give_cursor(scene, v3d));
+ negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d));
ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
new_ofs, NULL, NULL, NULL,
smooth_viewtx);
@@ -3772,11 +3764,9 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
-static int viewroll_cancel(bContext *C, wmOperator *op)
+static void viewroll_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
-
- return OPERATOR_CANCELLED;
}
void VIEW3D_OT_view_roll(wmOperatorType *ot)
@@ -4172,7 +4162,7 @@ static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- float *fp = give_cursor(scene, v3d);
+ float *fp = ED_view3d_cursor3d_get(scene, v3d);
ED_view3d_cursor3d_position(C, fp, event->mval);
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 9341ea9d3e6..373e57d5708 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -218,7 +218,7 @@ typedef struct FlyInfo {
short persp_backup; /* remember if were ortho or not, only used for restoring the view if it was a ortho view */
/* are we flying an ortho camera in perspective view,
- * which was originall in ortho view?
+ * which was originally in ortho view?
* could probably figure it out but better be explicit */
bool is_ortho_cam;
void *obtfm; /* backup the objects transform */
@@ -1254,15 +1254,13 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int fly_cancel(bContext *C, wmOperator *op)
+static void fly_cancel(bContext *C, wmOperator *op)
{
FlyInfo *fly = op->customdata;
fly->state = FLY_CANCEL;
flyEnd(C, fly);
op->customdata = NULL;
-
- return OPERATOR_CANCELLED;
}
static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 094204f868b..204054b24cd 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -356,7 +356,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
/* masks aren't used for sculpt and particle painting */
PointerRNA meshptr;
- RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr);
+ RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
if (ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT)) {
uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
}
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 2023513ad92..4df8010be9d 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -40,6 +40,7 @@
#include "BKE_curve.h"
#include "BKE_DerivedMesh.h"
#include "BKE_displist.h"
+#include "BKE_editmesh.h"
#include "bmesh.h"
@@ -133,7 +134,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
{
foreachScreenVert_userData *data = userData;
- BMVert *eve = EDBM_vert_at_index(data->vc.em, index);
+ BMVert *eve = BM_vert_at_index(data->vc.em->bm, index);
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
float screen_co[2];
@@ -165,7 +166,7 @@ void mesh_foreachScreenVert(
ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
}
- EDBM_index_arrays_ensure(vc->em, BM_VERT);
+ BM_mesh_elem_table_ensure(vc->em->bm, BM_VERT);
dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data, DM_FOREACH_NOP);
dm->release(dm);
@@ -176,7 +177,7 @@ void mesh_foreachScreenVert(
static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const float v0co[3], const float v1co[3])
{
foreachScreenEdge_userData *data = userData;
- BMEdge *eed = EDBM_edge_at_index(data->vc.em, index);
+ BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
float screen_co_a[2];
@@ -225,7 +226,7 @@ void mesh_foreachScreenEdge(
ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
}
- EDBM_index_arrays_ensure(vc->em, BM_EDGE);
+ BM_mesh_elem_table_ensure(vc->em->bm, BM_EDGE);
dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data);
dm->release(dm);
@@ -236,7 +237,7 @@ void mesh_foreachScreenEdge(
static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
{
foreachScreenFace_userData *data = userData;
- BMFace *efa = EDBM_face_at_index(data->vc.em, index);
+ BMFace *efa = BM_face_at_index(data->vc.em->bm, index);
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
float screen_co[2];
@@ -261,7 +262,7 @@ void mesh_foreachScreenFace(
data.userData = userData;
data.clip_flag = clip_flag;
- EDBM_index_arrays_ensure(vc->em, BM_FACE);
+ BM_mesh_elem_table_ensure(vc->em->bm, BM_FACE);
dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data, DM_FOREACH_NOP);
dm->release(dm);
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index bca162d156b..288ada3f852 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -809,15 +809,13 @@ static int view3d_ruler_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
return OPERATOR_RUNNING_MODAL;
}
-static int view3d_ruler_cancel(bContext *C, wmOperator *op)
+static void view3d_ruler_cancel(bContext *C, wmOperator *op)
{
RulerInfo *ruler_info = op->customdata;
view3d_ruler_end(C, ruler_info);
view3d_ruler_free(ruler_info);
op->customdata = NULL;
-
- return OPERATOR_CANCELLED;
}
static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index c48ce8a2343..a6ef70a5e33 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -89,6 +89,7 @@
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"
+#include "ED_sculpt.h"
#include "ED_mball.h"
#include "UI_interface.h"
@@ -272,9 +273,6 @@ static int view3d_selectable_data(bContext *C)
}
}
else {
- if (ob->mode & OB_MODE_SCULPT) {
- return 0;
- }
if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) &&
!paint_facesel_test(ob) && !paint_vertsel_test(ob))
{
@@ -1374,13 +1372,15 @@ static void deselect_all_tracks(MovieTracking *tracking)
}
/* mval is region coords */
-static bool mouse_select(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool obcenter, short enumerate)
+static bool mouse_select(bContext *C, const int mval[2],
+ bool extend, bool deselect, bool toggle, bool obcenter, bool enumerate, bool object)
{
ViewContext vc;
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL;
+ bool is_obedit;
float dist = 100.0f;
int retval = false;
short hits;
@@ -1389,6 +1389,12 @@ static bool mouse_select(bContext *C, const int mval[2], bool extend, bool desel
/* setup view context for argument to callbacks */
view3d_set_viewcontext(C, &vc);
+
+ is_obedit = (vc.obedit != NULL);
+ if (object) {
+ /* signal for view3d_opengl_select to skip editmode objects */
+ vc.obedit = NULL;
+ }
/* always start list from basact in wire mode */
startbase = FIRSTBASE;
@@ -1564,7 +1570,7 @@ static bool mouse_select(bContext *C, const int mval[2], bool extend, bool desel
ED_base_object_select(basact, BA_SELECT);
}
- if (oldbasact != basact) {
+ if ((oldbasact != basact) && (is_obedit == false)) {
ED_base_object_activate(C, basact); /* adds notifier */
}
}
@@ -2117,7 +2123,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
else { /* no editmode, unified for bones and objects */
if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
- /* pass */
+ ret = do_sculpt_mask_box_select(&vc, &rect, select, extend);
}
else if (vc.obact && paint_facesel_test(vc.obact)) {
ret = do_paintface_box_select(&vc, &rect, select, extend);
@@ -2256,7 +2262,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
else if (paint_vertsel_test(obact))
retval = mouse_weight_paint_vertex_select(C, location, extend, deselect, toggle, obact);
else
- retval = mouse_select(C, location, extend, deselect, toggle, center, enumerate);
+ retval = mouse_select(C, location, extend, deselect, toggle, center, enumerate, object);
/* passthrough allows tweaks
* FINISHED to signal one operator worked
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 7c29ab01c24..25458613842 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -30,35 +30,21 @@
*/
-#include <math.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meta_types.h"
-#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_linklist.h"
#include "BLI_utildefines.h"
+#include "BLI_math.h"
#include "BKE_armature.h"
#include "BKE_context.h"
-#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_lattice.h"
-#include "BKE_main.h"
#include "BKE_mball.h"
#include "BKE_object.h"
#include "BKE_editmesh.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_scene.h"
#include "BKE_tracking.h"
#include "WM_api.h"
@@ -67,468 +53,14 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "ED_armature.h"
-#include "ED_mesh.h"
+#include "ED_transverts.h"
#include "ED_keyframing.h"
#include "ED_screen.h"
-#include "ED_curve.h" /* for curve_editnurbs */
#include "view3d_intern.h"
-/* ************************************************** */
-/* ********************* old transform stuff ******** */
-/* *********** will get replaced with new transform * */
-/* ************************************************** */
-
static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]);
-typedef struct TransVert {
- float *loc;
- float oldloc[3], maploc[3];
- float *val, oldval;
- int flag;
-} TransVert;
-
- /* SELECT == (1 << 0) */
-#define TX_VERT_USE_MAPLOC (1 << 1)
-
-static TransVert *transvmain = NULL;
-static int tottrans = 0;
-
-/* copied from editobject.c, now uses (almost) proper depgraph */
-static void special_transvert_update(Object *obedit)
-{
- if (obedit) {
- DAG_id_tag_update(obedit->data, 0);
-
- if (obedit->type == OB_MESH) {
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BM_mesh_normals_update(em->bm);
- }
- else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
- Curve *cu = obedit->data;
- ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- Nurb *nu = nurbs->first;
-
- while (nu) {
- /* keep handles' vectors unchanged */
- if (nu->bezt) {
- int a = nu->pntsu;
- TransVert *tv = transvmain;
- BezTriple *bezt = nu->bezt;
-
- while (a--) {
- if (bezt->f1 & SELECT) tv++;
-
- if (bezt->f2 & SELECT) {
- float v[3];
-
- if (bezt->f1 & SELECT) {
- sub_v3_v3v3(v, (tv - 1)->oldloc, tv->oldloc);
- add_v3_v3v3(bezt->vec[0], bezt->vec[1], v);
- }
-
- if (bezt->f3 & SELECT) {
- sub_v3_v3v3(v, (tv + 1)->oldloc, tv->oldloc);
- add_v3_v3v3(bezt->vec[2], bezt->vec[1], v);
- }
-
- tv++;
- }
-
- if (bezt->f3 & SELECT) tv++;
-
- bezt++;
- }
- }
-
- BKE_nurb_test2D(nu);
- BKE_nurb_handles_test(nu, true); /* test for bezier too */
- nu = nu->next;
- }
- }
- else if (obedit->type == OB_ARMATURE) {
- bArmature *arm = obedit->data;
- EditBone *ebo;
- TransVert *tv = transvmain;
- int a = 0;
-
- /* Ensure all bone tails are correctly adjusted */
- for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
- /* adjust tip if both ends selected */
- if ((ebo->flag & BONE_ROOTSEL) && (ebo->flag & BONE_TIPSEL)) {
- if (tv) {
- float diffvec[3];
-
- sub_v3_v3v3(diffvec, tv->loc, tv->oldloc);
- add_v3_v3(ebo->tail, diffvec);
-
- a++;
- if (a < tottrans) tv++;
- }
- }
- }
-
- /* Ensure all bones are correctly adjusted */
- for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
- 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 this bone has a parent tip that has NOT been moved */
- else {
- copy_v3_v3(ebo->parent->tail, ebo->head);
- }
- }
- }
- if (arm->flag & ARM_MIRROR_EDIT)
- transform_armature_mirror_update(obedit);
- }
- else if (obedit->type == OB_LATTICE) {
- Lattice *lt = obedit->data;
-
- if (lt->editlatt->latt->flag & LT_OUTSIDE)
- outside_lattice(lt->editlatt->latt);
- }
- }
-}
-
-/* currently only used for bmesh index values */
-enum {
- TM_INDEX_ON = 1, /* tag to make trans verts */
- TM_INDEX_OFF = 0, /* don't make verts */
- TM_INDEX_SKIP = -1 /* dont make verts (when the index values point to trans-verts) */
-};
-
-/* copied from editobject.c, needs to be replaced with new transform code still */
-/* mode flags: */
-enum {
- TM_ALL_JOINTS = 1, /* all joints (for bones only) */
- TM_SKIP_HANDLES = 2 /* skip handles when control point is selected (for curves only) */
-};
-
-static void set_mapped_co(void *vuserdata, int index, const float co[3],
- const float UNUSED(no[3]), const short UNUSED(no_s[3]))
-{
- void **userdata = vuserdata;
- BMEditMesh *em = userdata[0];
- TransVert *tv = userdata[1];
- BMVert *eve = EDBM_vert_at_index(em, index);
-
- if (BM_elem_index_get(eve) != TM_INDEX_SKIP) {
- tv = &tv[BM_elem_index_get(eve)];
-
- /* be clever, get the closest vertex to the original,
- * behaves most logically when the mirror modifier is used for eg [#33051]*/
- if ((tv->flag & TX_VERT_USE_MAPLOC) == 0) {
- /* first time */
- copy_v3_v3(tv->maploc, co);
- tv->flag |= TX_VERT_USE_MAPLOC;
- }
- else {
- /* find best location to use */
- if (len_squared_v3v3(eve->co, co) < len_squared_v3v3(eve->co, tv->maploc)) {
- copy_v3_v3(tv->maploc, co);
- }
- }
- }
-}
-
-static void make_trans_verts(Object *obedit, float min[3], float max[3], int mode)
-{
- Nurb *nu;
- BezTriple *bezt;
- BPoint *bp;
- TransVert *tv = NULL;
- MetaElem *ml;
- BMVert *eve;
- EditBone *ebo;
- float total, center[3], centroid[3];
- int a;
-
- tottrans = 0; /* global! */
-
- INIT_MINMAX(min, max);
- zero_v3(centroid);
-
- if (obedit->type == OB_MESH) {
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
- BMIter iter;
- void *userdata[2] = {em, NULL};
- /*int proptrans = 0; */ /*UNUSED*/
-
- /* abuses vertex index all over, set, just set dirty here,
- * perhaps this could use its own array instead? - campbell */
-
- /* transform now requires awareness for select mode, so we tag the f1 flags in verts */
- tottrans = 0;
- if (em->selectmode & SCE_SELECT_VERTEX) {
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- BM_elem_index_set(eve, TM_INDEX_ON); /* set_dirty! */
- tottrans++;
- }
- else {
- BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
- }
- }
- }
- else if (em->selectmode & SCE_SELECT_EDGE) {
- BMEdge *eed;
-
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
- }
-
- BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
- if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- BM_elem_index_set(eed->v1, TM_INDEX_ON); /* set_dirty! */
- BM_elem_index_set(eed->v2, TM_INDEX_ON); /* set_dirty! */
- }
- }
-
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++;
- }
- }
- else {
- BMFace *efa;
-
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
- }
-
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
- BMIter liter;
- BMLoop *l;
-
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- BM_elem_index_set(l->v, TM_INDEX_ON); /* set_dirty! */
- }
- }
- }
-
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++;
- }
- }
- /* for any of the 3 loops above which all dirty the indices */
- bm->elem_index_dirty |= BM_VERT;
-
- /* and now make transverts */
- if (tottrans) {
- tv = transvmain = MEM_callocN(tottrans * sizeof(TransVert), "maketransverts");
-
- a = 0;
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve)) {
- BM_elem_index_set(eve, a); /* set_dirty! */
- copy_v3_v3(tv->oldloc, eve->co);
- tv->loc = eve->co;
- tv->flag = (BM_elem_index_get(eve) == TM_INDEX_ON) ? SELECT : 0;
- tv++;
- a++;
- }
- else {
- BM_elem_index_set(eve, TM_INDEX_SKIP); /* set_dirty! */
- }
- }
- /* set dirty already, above */
-
- userdata[1] = transvmain;
- }
-
- if (transvmain && em->derivedCage) {
- EDBM_index_arrays_ensure(em, BM_VERT);
- em->derivedCage->foreachMappedVert(em->derivedCage, set_mapped_co, userdata, DM_FOREACH_NOP);
- }
- }
- else if (obedit->type == OB_ARMATURE) {
- bArmature *arm = obedit->data;
- int totmalloc = BLI_countlist(arm->edbo);
-
- totmalloc *= 2; /* probably overkill but bones can have 2 trans verts each */
-
- tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts armature");
-
- for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
- if (ebo->layer & arm->layer) {
- short tipsel = (ebo->flag & BONE_TIPSEL);
- short rootsel = (ebo->flag & BONE_ROOTSEL);
- short rootok = (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && (ebo->parent->flag & BONE_TIPSEL)));
-
- if ((tipsel && rootsel) || (rootsel)) {
- /* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints),
- * otherwise we get zero-length bones as tips will snap to the same
- * location as heads.
- */
- if (rootok) {
- copy_v3_v3(tv->oldloc, ebo->head);
- tv->loc = ebo->head;
- tv->flag = SELECT;
- tv++;
- tottrans++;
- }
-
- if ((mode & TM_ALL_JOINTS) && (tipsel)) {
- copy_v3_v3(tv->oldloc, ebo->tail);
- tv->loc = ebo->tail;
- tv->flag = SELECT;
- tv++;
- tottrans++;
- }
- }
- else if (tipsel) {
- copy_v3_v3(tv->oldloc, ebo->tail);
- tv->loc = ebo->tail;
- tv->flag = SELECT;
- tv++;
- tottrans++;
- }
- }
- }
- }
- else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
- Curve *cu = obedit->data;
- int totmalloc = 0;
- ListBase *nurbs = BKE_curve_editNurbs_get(cu);
-
- for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER)
- totmalloc += 3 * nu->pntsu;
- else
- totmalloc += nu->pntsu * nu->pntsv;
- }
- tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts curve");
-
- nu = nurbs->first;
- while (nu) {
- if (nu->type == CU_BEZIER) {
- a = nu->pntsu;
- bezt = nu->bezt;
- while (a--) {
- if (bezt->hide == 0) {
- int skip_handle = 0;
- if (bezt->f2 & SELECT)
- skip_handle = mode & TM_SKIP_HANDLES;
-
- if ((bezt->f1 & SELECT) && !skip_handle) {
- copy_v3_v3(tv->oldloc, bezt->vec[0]);
- tv->loc = bezt->vec[0];
- tv->flag = bezt->f1 & SELECT;
- tv++;
- tottrans++;
- }
- if (bezt->f2 & SELECT) {
- copy_v3_v3(tv->oldloc, bezt->vec[1]);
- tv->loc = bezt->vec[1];
- tv->val = &(bezt->alfa);
- tv->oldval = bezt->alfa;
- tv->flag = bezt->f2 & SELECT;
- tv++;
- tottrans++;
- }
- if ((bezt->f3 & SELECT) && !skip_handle) {
- copy_v3_v3(tv->oldloc, bezt->vec[2]);
- tv->loc = bezt->vec[2];
- tv->flag = bezt->f3 & SELECT;
- tv++;
- tottrans++;
- }
- }
- bezt++;
- }
- }
- else {
- a = nu->pntsu * nu->pntsv;
- bp = nu->bp;
- while (a--) {
- if (bp->hide == 0) {
- if (bp->f1 & SELECT) {
- copy_v3_v3(tv->oldloc, bp->vec);
- tv->loc = bp->vec;
- tv->val = &(bp->alfa);
- tv->oldval = bp->alfa;
- tv->flag = bp->f1 & SELECT;
- tv++;
- tottrans++;
- }
- }
- bp++;
- }
- }
- nu = nu->next;
- }
- }
- else if (obedit->type == OB_MBALL) {
- MetaBall *mb = obedit->data;
- int totmalloc = BLI_countlist(mb->editelems);
-
- tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts mball");
-
- ml = mb->editelems->first;
- while (ml) {
- if (ml->flag & SELECT) {
- tv->loc = &ml->x;
- copy_v3_v3(tv->oldloc, tv->loc);
- tv->val = &(ml->rad);
- tv->oldval = ml->rad;
- tv->flag = SELECT;
- tv++;
- tottrans++;
- }
- ml = ml->next;
- }
- }
- else if (obedit->type == OB_LATTICE) {
- Lattice *lt = obedit->data;
-
- bp = lt->editlatt->latt->def;
-
- a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-
- tv = transvmain = MEM_callocN(a * sizeof(TransVert), "maketransverts latt");
-
- while (a--) {
- if (bp->f1 & SELECT) {
- if (bp->hide == 0) {
- copy_v3_v3(tv->oldloc, bp->vec);
- tv->loc = bp->vec;
- tv->flag = bp->f1 & SELECT;
- tv++;
- tottrans++;
- }
- }
- bp++;
- }
- }
-
- if (!tottrans && transvmain) {
- /* prevent memory leak. happens for curves/latticies due to */
- /* difficult condition of adding points to trans data */
- MEM_freeN(transvmain);
- transvmain = NULL;
- }
-
- /* cent etc */
- tv = transvmain;
- total = 0.0;
- for (a = 0; a < tottrans; a++, tv++) {
- if (tv->flag & SELECT) {
- add_v3_v3(centroid, tv->oldloc);
- total += 1.0f;
- minmax_v3v3_v3(min, max, tv->oldloc);
- }
- }
- if (total != 0.0f) {
- mul_v3_fl(centroid, 1.0f / total);
- }
-
- mid_v3_v3v3(center, min, max);
-}
/* *********************** operators ******************** */
@@ -537,6 +69,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
RegionView3D *rv3d = CTX_wm_region_data(C);
+ TransVertStore tvs = {NULL};
TransVert *tv;
float gridf, imat[3][3], bmat[3][3], vec[3];
int a;
@@ -544,17 +77,16 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
gridf = rv3d->gridview;
if (obedit) {
- tottrans = 0;
-
- if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL))
- make_trans_verts(obedit, bmat[0], bmat[1], 0);
- if (tottrans == 0) return OPERATOR_CANCELLED;
-
+ if (ED_transverts_check_obedit(obedit))
+ ED_transverts_create_from_obedit(&tvs, obedit, 0);
+ if (tvs.transverts_tot == 0)
+ return OPERATOR_CANCELLED;
+
copy_m3_m4(bmat, obedit->obmat);
invert_m3_m3(imat, bmat);
- tv = transvmain;
- for (a = 0; a < tottrans; a++, tv++) {
+ tv = tvs.transverts;
+ for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, tv->loc);
mul_m3_v3(bmat, vec);
add_v3_v3(vec, obedit->obmat[3]);
@@ -567,10 +99,8 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
copy_v3_v3(tv->loc, vec);
}
- special_transvert_update(obedit);
-
- MEM_freeN(transvmain);
- transvmain = NULL;
+ ED_transverts_update_obedit(&tvs, obedit);
+ ED_transverts_free(&tvs);
}
else {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
@@ -593,9 +123,9 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
copy_v3_v3(nLoc, pchan->pose_mat[3]);
/* We must operate in world space! */
mul_m4_v3(ob->obmat, nLoc);
- vec[0] = gridf * (float)(floor(0.5f + nLoc[0] / gridf));
- vec[1] = gridf * (float)(floor(0.5f + nLoc[1] / gridf));
- vec[2] = gridf * (float)(floor(0.5f + nLoc[2] / gridf));
+ vec[0] = gridf * floorf(0.5f + nLoc[0] / gridf);
+ vec[1] = gridf * floorf(0.5f + nLoc[1] / gridf);
+ vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf);
/* Back in object space... */
mul_m4_v3(ob->imat, vec);
@@ -678,6 +208,7 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
+ TransVertStore tvs = {NULL};
TransVert *tv;
float imat[3][3], bmat[3][3];
const float *cursor_global;
@@ -687,7 +218,7 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op)
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
- cursor_global = give_cursor(scene, v3d);
+ cursor_global = ED_view3d_cursor3d_get(scene, v3d);
if (use_offset) {
snap_curs_to_sel_ex(C, center_global);
@@ -696,13 +227,12 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op)
if (obedit) {
float cursor_local[3];
-
- tottrans = 0;
-
- if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL))
- make_trans_verts(obedit, bmat[0], bmat[1], 0);
- if (tottrans == 0) return OPERATOR_CANCELLED;
+ if (ED_transverts_check_obedit(obedit))
+ ED_transverts_create_from_obedit(&tvs, obedit, 0);
+ if (tvs.transverts_tot == 0)
+ return OPERATOR_CANCELLED;
+
copy_m3_m4(bmat, obedit->obmat);
invert_m3_m3(imat, bmat);
@@ -715,22 +245,20 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op)
mul_v3_m3v3(offset_local, imat, offset_global);
- tv = transvmain;
- for (a = 0; a < tottrans; a++, tv++) {
+ tv = tvs.transverts;
+ for (a = 0; a < tvs.transverts_tot; a++, tv++) {
add_v3_v3(tv->loc, offset_local);
}
}
else {
- tv = transvmain;
- for (a = 0; a < tottrans; a++, tv++) {
+ tv = tvs.transverts;
+ for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(tv->loc, cursor_local);
}
}
- special_transvert_update(obedit);
-
- MEM_freeN(transvmain);
- transvmain = NULL;
+ ED_transverts_update_obedit(&tvs, obedit);
+ ED_transverts_free(&tvs);
}
else {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
@@ -852,7 +380,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
float gridf, *curs;
gridf = rv3d->gridview;
- curs = give_cursor(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d);
curs[0] = gridf * floorf(0.5f + curs[0] / gridf);
curs[1] = gridf * floorf(0.5f + curs[1] / gridf);
@@ -937,6 +465,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
+ TransVertStore tvs = {NULL};
TransVert *tv;
float bmat[3][3], vec[3], min[3], max[3], centroid[3];
int count, a;
@@ -946,19 +475,18 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
zero_v3(centroid);
if (obedit) {
- tottrans = 0;
- if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL))
- make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS | TM_SKIP_HANDLES);
+ if (ED_transverts_check_obedit(obedit))
+ ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES);
- if (tottrans == 0) {
+ if (tvs.transverts_tot == 0) {
return false;
}
copy_m3_m4(bmat, obedit->obmat);
- tv = transvmain;
- for (a = 0; a < tottrans; a++, tv++) {
+ tv = tvs.transverts;
+ for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, tv->loc);
mul_m3_v3(bmat, vec);
add_v3_v3(vec, obedit->obmat[3]);
@@ -967,14 +495,14 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
}
if (v3d->around == V3D_CENTROID) {
- mul_v3_fl(centroid, 1.0f / (float)tottrans);
+ mul_v3_fl(centroid, 1.0f / (float)tvs.transverts_tot);
copy_v3_v3(cursor, centroid);
}
else {
mid_v3_v3v3(cursor, min, max);
}
- MEM_freeN(transvmain);
- transvmain = NULL;
+
+ ED_transverts_free(&tvs);
}
else {
Object *obact = CTX_data_active_object(C);
@@ -1035,7 +563,7 @@ static int snap_curs_to_sel_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
float *curs;
- curs = give_cursor(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d);
if (snap_curs_to_sel_ex(C, curs)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
@@ -1072,7 +600,7 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
float *curs;
- curs = give_cursor(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d);
if (obedit) {
if (obedit->type == OB_MESH) {
@@ -1127,7 +655,7 @@ static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
float *curs;
- curs = give_cursor(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d);
zero_v3(curs);
@@ -1156,6 +684,7 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3])
{
+ TransVertStore tvs = {NULL};
TransVert *tv;
float centroid[3], vec[3], bmat[3][3];
int a;
@@ -1173,16 +702,16 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3])
return change;
}
- tottrans = 0;
- if (ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE))
- make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS);
+ if (ED_transverts_check_obedit(obedit))
+ ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS);
- if (tottrans == 0) return false;
+ if (tvs.transverts_tot == 0)
+ return false;
copy_m3_m4(bmat, obedit->obmat);
- tv = transvmain;
- for (a = 0; a < tottrans; a++, tv++) {
+ tv = tvs.transverts;
+ for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, (tv->flag & TX_VERT_USE_MAPLOC) ? tv->maploc : tv->loc);
mul_m3_v3(bmat, vec);
add_v3_v3(vec, obedit->obmat[3]);
@@ -1190,8 +719,7 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3])
minmax_v3v3_v3(min, max, vec);
}
- MEM_freeN(transvmain);
- transvmain = NULL;
+ ED_transverts_free(&tvs);
return true;
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 74d72061995..e321e7c9c4b 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -104,7 +104,7 @@ void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar)
}
}
-float *give_cursor(Scene *scene, View3D *v3d)
+float *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
{
if (v3d && v3d->localvd) return v3d->cursor;
else return scene->cursor;
@@ -774,33 +774,31 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
mat3_to_quat(rv3d->viewquat, tmat);
}
-#define QUATSET(a, b, c, d, e) { a[0] = b; a[1] = c; a[2] = d; a[3] = e; } (void)0
-
bool ED_view3d_lock(RegionView3D *rv3d)
{
switch (rv3d->view) {
case RV3D_VIEW_BOTTOM:
- QUATSET(rv3d->viewquat, 0.0, -1.0, 0.0, 0.0);
+ copy_v4_fl4(rv3d->viewquat, 0.0, -1.0, 0.0, 0.0);
break;
case RV3D_VIEW_BACK:
- QUATSET(rv3d->viewquat, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2);
+ copy_v4_fl4(rv3d->viewquat, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2);
break;
case RV3D_VIEW_LEFT:
- QUATSET(rv3d->viewquat, 0.5, -0.5, 0.5, 0.5);
+ copy_v4_fl4(rv3d->viewquat, 0.5, -0.5, 0.5, 0.5);
break;
case RV3D_VIEW_TOP:
- QUATSET(rv3d->viewquat, 1.0, 0.0, 0.0, 0.0);
+ copy_v4_fl4(rv3d->viewquat, 1.0, 0.0, 0.0, 0.0);
break;
case RV3D_VIEW_FRONT:
- QUATSET(rv3d->viewquat, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0);
+ copy_v4_fl4(rv3d->viewquat, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0);
break;
case RV3D_VIEW_RIGHT:
- QUATSET(rv3d->viewquat, 0.5, -0.5, -0.5, -0.5);
+ copy_v4_fl4(rv3d->viewquat, 0.5, -0.5, -0.5, -0.5);
break;
default:
return false;
@@ -849,7 +847,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
}
else if (v3d->ob_centre_cursor) {
float vec[3];
- copy_v3_v3(vec, give_cursor(scene, v3d));
+ copy_v3_v3(vec, ED_view3d_cursor3d_get(scene, v3d));
translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]);
use_lock_ofs = true;
}
@@ -876,10 +874,12 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
}
}
-/* IGLuint-> GLuint */
-/* Warning: be sure to account for a negative return value
- * This is an error, "Too many objects in select buffer"
- * and no action should be taken (can crash blender) if this happens
+/**
+ * \warning be sure to account for a negative return value
+ * This is an error, "Too many objects in select buffer"
+ * and no action should be taken (can crash blender) if this happens
+ *
+ * \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection.
*/
short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input)
{
@@ -890,6 +890,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
short code, hits;
char dt;
short dtx;
+ const bool use_obedit_skip = (scene->obedit != NULL) && (vc->obedit == NULL);
G.f |= G_PICKSEL;
@@ -937,8 +938,11 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
for (base = scene->base.first; base; base = base->next) {
if (base->lay & v3d->lay) {
- if (base->object->restrictflag & OB_RESTRICT_SELECT)
+ if ((base->object->restrictflag & OB_RESTRICT_SELECT) ||
+ (use_obedit_skip && (scene->obedit->data == base->object->data)))
+ {
base->selcol = 0;
+ }
else {
base->selcol = code;
glLoadName(code);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index ea039c15be4..2756685e9f6 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -82,6 +82,7 @@
#include "ED_mesh.h"
#include "ED_clip.h"
#include "ED_mask.h"
+#include "ED_node.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -108,6 +109,95 @@ static void drawVertSlide(const struct bContext *C, TransInfo *t);
static void len_v3_ensure(float v[3], const float length);
static void postInputRotation(TransInfo *t, float values[3]);
+
+/* Transform Callbacks */
+static void initBend(TransInfo *t);
+static eRedrawFlag handleEventBend(TransInfo *t, const struct wmEvent *event);
+static void Bend(TransInfo *t, const int mval[2]);
+
+static void initShear(TransInfo *t);
+static eRedrawFlag handleEventShear(TransInfo *t, const struct wmEvent *event);
+static void applyShear(TransInfo *t, const int mval[2]);
+
+static void initResize(TransInfo *t);
+static void applyResize(TransInfo *t, const int mval[2]);
+
+static void initSkinResize(TransInfo *t);
+static void applySkinResize(TransInfo *t, const int mval[2]);
+
+static void initTranslation(TransInfo *t);
+static void applyTranslation(TransInfo *t, const int mval[2]);
+
+static void initToSphere(TransInfo *t);
+static void applyToSphere(TransInfo *t, const int mval[2]);
+
+static void initRotation(TransInfo *t);
+static void applyRotation(TransInfo *t, const int mval[2]);
+
+static void initShrinkFatten(TransInfo *t);
+static void applyShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initTilt(TransInfo *t);
+static void applyTilt(TransInfo *t, const int mval[2]);
+
+static void initCurveShrinkFatten(TransInfo *t);
+static void applyCurveShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initMaskShrinkFatten(TransInfo *t);
+static void applyMaskShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initTrackball(TransInfo *t);
+static void applyTrackball(TransInfo *t, const int mval[2]);
+
+static void initPushPull(TransInfo *t);
+static void applyPushPull(TransInfo *t, const int mval[2]);
+
+static void initBevelWeight(TransInfo *t);
+static void applyBevelWeight(TransInfo *t, const int mval[2]);
+
+static void initCrease(TransInfo *t);
+static void applyCrease(TransInfo *t, const int mval[2]);
+
+static void initBoneSize(TransInfo *t);
+static void applyBoneSize(TransInfo *t, const int mval[2]);
+
+static void initBoneEnvelope(TransInfo *t);
+static void applyBoneEnvelope(TransInfo *t, const int mval[2]);
+
+static void initBoneRoll(TransInfo *t);
+static void applyBoneRoll(TransInfo *t, const int mval[2]);
+
+static void initEdgeSlide(TransInfo *t);
+static eRedrawFlag handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event);
+static void applyEdgeSlide(TransInfo *t, const int mval[2]);
+
+static void initVertSlide(TransInfo *t);
+static eRedrawFlag handleEventVertSlide(TransInfo *t, const struct wmEvent *event);
+static void applyVertSlide(TransInfo *t, const int mval[2]);
+
+static void initTimeTranslate(TransInfo *t);
+static void applyTimeTranslate(TransInfo *t, const int mval[2]);
+
+static void initTimeSlide(TransInfo *t);
+static void applyTimeSlide(TransInfo *t, const int mval[2]);
+
+static void initTimeScale(TransInfo *t);
+static void applyTimeScale(TransInfo *t, const int mval[2]);
+
+static void initBakeTime(TransInfo *t);
+static void applyBakeTime(TransInfo *t, const int mval[2]);
+
+static void initMirror(TransInfo *t);
+static void applyMirror(TransInfo *t, const int mval[2]);
+
+static void initAlign(TransInfo *t);
+static void applyAlign(TransInfo *t, const int mval[2]);
+
+static void initSeqSlide(TransInfo *t);
+static void applySeqSlide(TransInfo *t, const int mval[2]);
+/* end transform callbacks */
+
+
static bool transdata_check_local_center(TransInfo *t)
{
return ((t->around == V3D_LOCAL) && (
@@ -1131,8 +1221,10 @@ int transformEvent(TransInfo *t, const wmEvent *event)
break;
}
- // Modal numinput events
- t->redraw |= handleNumInput(&(t->num), event);
+ /* Modal numinput events */
+ if (handleNumInput(&(t->num), event)) {
+ t->redraw |= TREDRAW_HARD;
+ }
}
/* else do non-mapped events */
else if (event->val == KM_PRESS) {
@@ -1236,7 +1328,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
t->flag ^= T_PROP_CONNECTED;
sort_trans_data_dist(t);
calculatePropRatio(t);
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
}
else {
stopConstraint(t);
@@ -1262,7 +1354,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far);
calculatePropRatio(t);
}
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
break;
case PAGEUPKEY:
case WHEELDOWNMOUSE:
@@ -1272,14 +1364,14 @@ int transformEvent(TransInfo *t, const wmEvent *event)
else {
view_editmove(event->type);
}
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
break;
case PADMINUS:
if (event->alt && t->flag & T_PROP_EDIT) {
t->prop_size *= 0.90909090f;
calculatePropRatio(t);
}
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
break;
case PAGEDOWNKEY:
case WHEELUPMOUSE:
@@ -1289,7 +1381,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
else {
view_editmove(event->type);
}
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
break;
case LEFTALTKEY:
case RIGHTALTKEY:
@@ -1304,10 +1396,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
break;
}
- // Numerical input events
- t->redraw |= handleNumInput(&(t->num), event);
+ /* Numerical input events */
+ if (handleNumInput(&(t->num), event)) {
+ t->redraw |= TREDRAW_HARD;
+ }
- // Snapping key events
+ /* Snapping key events */
t->redraw |= handleSnapping(t, event);
}
@@ -1975,8 +2069,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
case TFM_SHEAR:
initShear(t);
break;
- case TFM_WARP:
- initWarp(t);
+ case TFM_BEND:
+ initBend(t);
break;
case TFM_SHRINKFATTEN:
initShrinkFatten(t);
@@ -2197,7 +2291,7 @@ int transformEnd(bContext *C, TransInfo *t)
/* ************************** TRANSFORM LOCKS **************************** */
-static void protectedTransBits(short protectflag, float *vec)
+static void protectedTransBits(short protectflag, float vec[3])
{
if (protectflag & OB_LOCK_LOCX)
vec[0] = 0.0f;
@@ -2207,7 +2301,7 @@ static void protectedTransBits(short protectflag, float *vec)
vec[2] = 0.0f;
}
-static void protectedSizeBits(short protectflag, float *size)
+static void protectedSizeBits(short protectflag, float size[3])
{
if (protectflag & OB_LOCK_SCALEX)
size[0] = 1.0f;
@@ -2217,7 +2311,7 @@ static void protectedSizeBits(short protectflag, float *size)
size[2] = 1.0f;
}
-static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
+static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3])
{
if (protectflag & OB_LOCK_ROTX)
eul[0] = oldeul[0];
@@ -2272,7 +2366,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
}
/* this function only does the delta rotation */
-static void protectedQuaternionBits(short protectflag, float *quat, float *oldquat)
+static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4])
{
/* check that protection flags are set */
if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
@@ -2576,9 +2670,14 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
}
-/* ************************** WARP *************************** */
-struct WarpCustomData {
+/* -------------------------------------------------------------------- */
+/* Transform (Bend) */
+
+/** \name Transform Bend
+ * \{ */
+
+struct BendCustomData {
float warp_sta[3];
float warp_end[3];
@@ -2589,16 +2688,16 @@ struct WarpCustomData {
float warp_init_dist;
};
-void initWarp(TransInfo *t)
+static void initBend(TransInfo *t)
{
const float mval_fl[2] = {UNPACK2(t->mval)};
const float *curs;
float tvec[3];
- struct WarpCustomData *data;
+ struct BendCustomData *data;
- t->mode = TFM_WARP;
- t->transform = Warp;
- t->handleEvent = handleEventWarp;
+ t->mode = TFM_BEND;
+ t->transform = Bend;
+ t->handleEvent = handleEventBend;
setInputPostFct(&t->mouse, postInputRotation);
initMouseInputMode(t, &t->mouse, INPUT_ANGLE_SPRING);
@@ -2613,14 +2712,14 @@ void initWarp(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
- //copy_v3_v3(t->center, give_cursor(t->scene, t->view));
+ //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
calculateCenterCursor(t);
t->val = 0.0f;
data = MEM_callocN(sizeof(*data), __func__);
- curs = give_cursor(t->scene, t->view);
+ curs = ED_view3d_cursor3d_get(t->scene, t->view);
copy_v3_v3(data->warp_sta, curs);
ED_view3d_win_to_3d(t->ar, curs, mval_fl, data->warp_end);
@@ -2641,20 +2740,18 @@ void initWarp(TransInfo *t)
t->customData = data;
}
-int handleEventWarp(TransInfo *t, const wmEvent *event)
+static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event)
{
- int status = 0;
+ eRedrawFlag status = TREDRAW_NOTHING;
if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
- (void)t;
-
- status = 1;
+ status = TREDRAW_HARD;
}
return status;
}
-int Warp(TransInfo *t, const int UNUSED(mval[2]))
+static void Bend(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
float vec[3];
@@ -2662,7 +2759,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
float warp_end_radius[3];
int i;
char str[MAX_INFO_LEN];
- const struct WarpCustomData *data = t->customData;
+ const struct BendCustomData *data = t->customData;
const bool is_clamp = (t->flag & T_ALT_TRANSFORM) == 0;
union {
@@ -2670,7 +2767,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
float vector[2];
} values;
- /* amount of radians for warp */
+ /* amount of radians for bend */
copy_v2_v2(values.vector, t->values);
#if 0
@@ -2682,7 +2779,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
const float radius_snap = 0.1f;
const float snap_hack = (t->snap[1] * data->warp_init_dist) / radius_snap;
values.scale *= snap_hack;
- snapGrid(t, values.vector);
+ snapGridIncrement(t, values.vector);
values.scale /= snap_hack;
}
#endif
@@ -2695,7 +2792,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c);
- BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp Angle: %s Radius: %s Alt, Clamp %s"),
+ BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bend Angle: %s Radius: %s Alt, Clamp %s"),
&c[0], &c[NUM_STR_REP_LEN],
WM_bool_as_string(is_clamp));
@@ -2704,7 +2801,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
}
else {
/* default header print */
- BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp Angle: %.3f Radius: %.4f, Alt, Clamp %s"),
+ BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bend Angle: %.3f Radius: %.4f, Alt, Clamp %s"),
RAD2DEGF(values.angle), values.scale * data->warp_init_dist,
WM_bool_as_string(is_clamp));
}
@@ -2771,21 +2868,25 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
-/* ************************** SHEAR *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Shear) */
+
+/** \name Transform Shear
+ * \{ */
static void postInputShear(TransInfo *UNUSED(t), float values[3])
{
mul_v3_fl(values, 0.05f);
}
-void initShear(TransInfo *t)
+static void initShear(TransInfo *t)
{
t->mode = TFM_SHEAR;
- t->transform = Shear;
+ t->transform = applyShear;
t->handleEvent = handleEventShear;
setInputPostFct(&t->mouse, postInputShear);
@@ -2802,9 +2903,9 @@ void initShear(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
}
-int handleEventShear(TransInfo *t, const wmEvent *event)
+static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event)
{
- int status = 0;
+ eRedrawFlag status = TREDRAW_NOTHING;
if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
// Use customData pointer to signal Shear direction
@@ -2817,26 +2918,26 @@ int handleEventShear(TransInfo *t, const wmEvent *event)
t->customData = NULL;
}
- status = 1;
+ status = TREDRAW_HARD;
}
else if (event->type == XKEY && event->val == KM_PRESS) {
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
t->customData = NULL;
- status = 1;
+ status = TREDRAW_HARD;
}
else if (event->type == YKEY && event->val == KM_PRESS) {
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
t->customData = (void *)1;
- status = 1;
+ status = TREDRAW_HARD;
}
return status;
}
-int Shear(TransInfo *t, const int UNUSED(mval[2]))
+static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
float vec[3];
@@ -2850,7 +2951,7 @@ int Shear(TransInfo *t, const int UNUSED(mval[2]))
value = t->values[0];
- snapGrid(t, &value);
+ snapGridIncrement(t, &value);
applyNumInput(&t->num, &value);
@@ -2910,16 +3011,20 @@ int Shear(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Resize) */
-/* ************************** RESIZE *************************** */
+/** \name Transform Resize
+ * \{ */
-void initResize(TransInfo *t)
+static void initResize(TransInfo *t)
{
t->mode = TFM_RESIZE;
- t->transform = Resize;
+ t->transform = applyResize;
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
@@ -2940,8 +3045,7 @@ void initResize(TransInfo *t)
t->num.increment = t->snap[1];
}
-/* We assume str is MAX_INFO_LEN long. */
-static void headerResize(TransInfo *t, float vec[3], char *str)
+static void headerResize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
{
char tvec[NUM_STR_REP_LEN * 3];
size_t ofs = 0;
@@ -3117,7 +3221,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
constraintTransLim(t, td);
}
-int Resize(TransInfo *t, const int mval[2])
+static void applyResize(TransInfo *t, const int mval[2])
{
TransData *td;
float size[3], mat[3][3];
@@ -3135,7 +3239,7 @@ int Resize(TransInfo *t, const int mval[2])
size[0] = size[1] = size[2] = ratio;
- snapGrid(t, size);
+ snapGridIncrement(t, size);
if (hasNumInput(&t->num)) {
applyNumInput(&t->num, size);
@@ -3192,16 +3296,20 @@ int Resize(TransInfo *t, const int mval[2])
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Skin) */
-/* ************************** SKIN *************************** */
+/** \name Transform Skin
+ * \{ */
-void initSkinResize(TransInfo *t)
+static void initSkinResize(TransInfo *t)
{
t->mode = TFM_SKIN_RESIZE;
- t->transform = SkinResize;
+ t->transform = applySkinResize;
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
@@ -3222,7 +3330,7 @@ void initSkinResize(TransInfo *t)
t->num.increment = t->snap[1];
}
-int SkinResize(TransInfo *t, const int UNUSED(mval[2]))
+static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td;
float size[3], mat[3][3];
@@ -3233,7 +3341,7 @@ int SkinResize(TransInfo *t, const int UNUSED(mval[2]))
ratio = t->values[0];
size[0] = size[1] = size[2] = ratio;
- snapGrid(t, size);
+ snapGridIncrement(t, size);
if (hasNumInput(&t->num)) {
applyNumInput(&t->num, size);
@@ -3282,19 +3390,23 @@ int SkinResize(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
-/* ************************** TOSPHERE *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (ToSphere) */
-void initToSphere(TransInfo *t)
+/** \name Transform ToSphere
+ * \{ */
+
+static void initToSphere(TransInfo *t)
{
TransData *td = t->data;
int i;
t->mode = TFM_TOSPHERE;
- t->transform = ToSphere;
+ t->transform = applyToSphere;
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
@@ -3317,7 +3429,7 @@ void initToSphere(TransInfo *t)
t->val /= (float)t->total;
}
-int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
+static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
{
float vec[3];
float ratio, radius;
@@ -3327,7 +3439,7 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
ratio = t->values[0];
- snapGrid(t, &ratio);
+ snapGridIncrement(t, &ratio);
applyNumInput(&t->num, &ratio);
@@ -3375,12 +3487,15 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
-/* ************************** ROTATION *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Rotation) */
+/** \name Transform Rotation
+ * \{ */
static void postInputRotation(TransInfo *t, float values[3])
{
@@ -3389,10 +3504,10 @@ static void postInputRotation(TransInfo *t, float values[3])
}
}
-void initRotation(TransInfo *t)
+static void initRotation(TransInfo *t)
{
t->mode = TFM_ROTATION;
- t->transform = Rotation;
+ t->transform = applyRotation;
setInputPostFct(&t->mouse, postInputRotation);
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
@@ -3638,7 +3753,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
}
-static void applyRotation(TransInfo *t, float angle, float axis[3])
+static void applyRotationValue(TransInfo *t, float angle, float axis[3])
{
TransData *td = t->data;
float mat[3][3];
@@ -3666,7 +3781,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
}
}
-int Rotation(TransInfo *t, const int UNUSED(mval[2]))
+static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
{
char str[MAX_INFO_LEN];
size_t ofs = 0;
@@ -3675,7 +3790,7 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
final = t->values[0];
- snapGrid(t, &final);
+ snapGridIncrement(t, &final);
if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
t->con.applyRot(t, NULL, t->axis, NULL);
@@ -3710,22 +3825,25 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
t->values[0] = final;
- applyRotation(t, final, t->axis);
+ applyRotationValue(t, final, t->axis);
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ************************** TRACKBALL *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Rotation - Trackball) */
-void initTrackball(TransInfo *t)
+/** \name Transform Rotation - Trackball
+ * \{ */
+
+static void initTrackball(TransInfo *t)
{
t->mode = TFM_TRACKBALL;
- t->transform = Trackball;
+ t->transform = applyTrackball;
initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
@@ -3740,7 +3858,7 @@ void initTrackball(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
}
-static void applyTrackball(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2])
+static void applyTrackballValue(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2])
{
TransData *td = t->data;
float mat[3][3], smat[3][3], totmat[3][3];
@@ -3769,7 +3887,7 @@ static void applyTrackball(TransInfo *t, const float axis1[3], const float axis2
}
}
-int Trackball(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
{
char str[MAX_INFO_LEN];
size_t ofs = 0;
@@ -3785,7 +3903,7 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
phi[0] = t->values[0];
phi[1] = t->values[1];
- snapGrid(t, phi);
+ snapGridIncrement(t, phi);
if (hasNumInput(&t->num)) {
char c[NUM_STR_REP_LEN * 2];
@@ -3817,18 +3935,22 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
// TRANSFORM_FIX_ME
//copy_m3_m3(t->mat, mat); // used in manipulator
- applyTrackball(t, axis1, axis2, phi);
+ applyTrackballValue(t, axis1, axis2, phi);
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Translation) */
-/* ************************** TRANSLATION *************************** */
+/** \name Transform Translation
+ * \{ */
-void initTranslation(TransInfo *t)
+static void initTranslation(TransInfo *t)
{
if (t->spacetype == SPACE_ACTION) {
/* this space uses time translate */
@@ -3836,7 +3958,7 @@ void initTranslation(TransInfo *t)
}
t->mode = TFM_TRANSLATION;
- t->transform = Translation;
+ t->transform = applyTranslation;
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
@@ -3860,8 +3982,8 @@ void initTranslation(TransInfo *t)
}
else if (t->spacetype == SPACE_NODE) {
t->snap[0] = 0.0f;
- t->snap[1] = 125.0f;
- t->snap[2] = 25.0f;
+ t->snap[1] = ED_node_grid_size() * NODE_GRID_STEPS;
+ t->snap[2] = ED_node_grid_size();
}
else {
t->snap[0] = 0.0f;
@@ -3871,8 +3993,7 @@ void initTranslation(TransInfo *t)
t->num.increment = t->snap[1];
}
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTranslation(TransInfo *t, float vec[3], char *str)
+static void headerTranslation(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
{
size_t ofs = 0;
char tvec[NUM_STR_REP_LEN * 3];
@@ -3959,7 +4080,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
}
}
-static void applyTranslation(TransInfo *t, float vec[3])
+static void applyTranslationValue(TransInfo *t, float vec[3])
{
TransData *td = t->data;
float tvec[3];
@@ -4026,7 +4147,7 @@ static void applyTranslation(TransInfo *t, float vec[3])
}
/* uses t->vec to store actual translation in */
-int Translation(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
{
char str[MAX_INFO_LEN];
@@ -4042,7 +4163,7 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
headerTranslation(t, pvec, str);
}
else {
- snapGrid(t, t->values);
+ snapGridIncrement(t, t->values);
applyNumInput(&t->num, t->values);
if (hasNumInput(&t->num)) {
removeAspectRatio(t, t->values);
@@ -4051,11 +4172,11 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
headerTranslation(t, t->values, str);
}
- applyTranslation(t, t->values);
+ applyTranslationValue(t, t->values);
/* evil hack - redo translation if clipping needed */
if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 0)) {
- applyTranslation(t, t->values);
+ applyTranslationValue(t, t->values);
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
@@ -4069,13 +4190,17 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Shrink-Fatten) */
-/* ************************** SHRINK/FATTEN *************************** */
+/** \name Transform Shrink-Fatten
+ * \{ */
-void initShrinkFatten(TransInfo *t)
+static void initShrinkFatten(TransInfo *t)
{
// If not in mesh edit mode, fallback to Resize
if (t->obedit == NULL || t->obedit->type != OB_MESH) {
@@ -4083,7 +4208,7 @@ void initShrinkFatten(TransInfo *t)
}
else {
t->mode = TFM_SHRINKFATTEN;
- t->transform = ShrinkFatten;
+ t->transform = applyShrinkFatten;
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
@@ -4100,7 +4225,7 @@ void initShrinkFatten(TransInfo *t)
}
-int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
+static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
float distance;
int i;
@@ -4110,7 +4235,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
distance = -t->values[0];
- snapGrid(t, &distance);
+ snapGridIncrement(t, &distance);
applyNumInput(&t->num, &distance);
@@ -4138,7 +4263,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
}
}
BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"),
- WM_bool_as_string(t->flag & T_ALT_TRANSFORM));
+ WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
/* done with header string */
@@ -4164,16 +4289,20 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
-/* ************************** TILT *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Tilt) */
-void initTilt(TransInfo *t)
+/** \name Transform Tilt
+ * \{ */
+
+static void initTilt(TransInfo *t)
{
t->mode = TFM_TILT;
- t->transform = Tilt;
+ t->transform = applyTilt;
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
@@ -4189,8 +4318,7 @@ void initTilt(TransInfo *t)
}
-
-int Tilt(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
int i;
@@ -4200,7 +4328,7 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
final = t->values[0];
- snapGrid(t, &final);
+ snapGridIncrement(t, &final);
if (hasNumInput(&t->num)) {
char c[NUM_STR_REP_LEN];
@@ -4235,17 +4363,20 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ******************** Curve Shrink/Fatten *************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Curve Shrink/Fatten) */
-void initCurveShrinkFatten(TransInfo *t)
+/** \name Transform Curve Shrink/Fatten
+ * \{ */
+
+static void initCurveShrinkFatten(TransInfo *t)
{
t->mode = TFM_CURVE_SHRINKFATTEN;
- t->transform = CurveShrinkFatten;
+ t->transform = applyCurveShrinkFatten;
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
@@ -4263,7 +4394,7 @@ void initCurveShrinkFatten(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
}
-int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
+static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
float ratio;
@@ -4272,7 +4403,7 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
ratio = t->values[0];
- snapGrid(t, &ratio);
+ snapGridIncrement(t, &ratio);
applyNumInput(&t->num, &ratio);
@@ -4305,15 +4436,20 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Mask Shrink/Fatten) */
+/** \name Transform Mask Shrink/Fatten
+ * \{ */
-void initMaskShrinkFatten(TransInfo *t)
+static void initMaskShrinkFatten(TransInfo *t)
{
t->mode = TFM_MASK_SHRINKFATTEN;
- t->transform = MaskShrinkFatten;
+ t->transform = applyMaskShrinkFatten;
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
@@ -4331,7 +4467,7 @@ void initMaskShrinkFatten(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
}
-int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
+static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td;
float ratio;
@@ -4340,7 +4476,7 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
ratio = t->values[0];
- snapGrid(t, &ratio);
+ snapGridIncrement(t, &ratio);
applyNumInput(&t->num, &ratio);
@@ -4394,16 +4530,20 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ************************** PUSH/PULL *************************** */
-void initPushPull(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Push/Pull) */
+
+/** \name Transform Push/Pull
+ * \{ */
+
+static void initPushPull(TransInfo *t)
{
t->mode = TFM_PUSHPULL;
- t->transform = PushPull;
+ t->transform = applyPushPull;
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
@@ -4417,7 +4557,7 @@ void initPushPull(TransInfo *t)
}
-int PushPull(TransInfo *t, const int UNUSED(mval[2]))
+static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
{
float vec[3], axis[3];
float distance;
@@ -4427,7 +4567,7 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
distance = t->values[0];
- snapGrid(t, &distance);
+ snapGridIncrement(t, &distance);
applyNumInput(&t->num, &distance);
@@ -4479,16 +4619,20 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
-/* ************************** BEVEL WEIGHT *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Bevel Weight) */
-void initBevelWeight(TransInfo *t)
+/** \name Transform Bevel Weight
+ * \{ */
+
+static void initBevelWeight(TransInfo *t)
{
t->mode = TFM_BWEIGHT;
- t->transform = BevelWeight;
+ t->transform = applyBevelWeight;
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
@@ -4503,7 +4647,7 @@ void initBevelWeight(TransInfo *t)
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
-int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
+static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
float weight;
@@ -4515,7 +4659,7 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
weight -= 1.0f;
if (weight > 1.0f) weight = 1.0f;
- snapGrid(t, &weight);
+ snapGridIncrement(t, &weight);
applyNumInput(&t->num, &weight);
@@ -4552,16 +4696,20 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Crease) */
-/* ************************** CREASE *************************** */
+/** \name Transform Crease
+ * \{ */
-void initCrease(TransInfo *t)
+static void initCrease(TransInfo *t)
{
t->mode = TFM_CREASE;
- t->transform = Crease;
+ t->transform = applyCrease;
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
@@ -4576,7 +4724,7 @@ void initCrease(TransInfo *t)
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
-int Crease(TransInfo *t, const int UNUSED(mval[2]))
+static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
float crease;
@@ -4588,7 +4736,7 @@ int Crease(TransInfo *t, const int UNUSED(mval[2]))
crease -= 1.0f;
if (crease > 1.0f) crease = 1.0f;
- snapGrid(t, &crease);
+ snapGridIncrement(t, &crease);
applyNumInput(&t->num, &crease);
@@ -4628,16 +4776,20 @@ int Crease(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (EditBone (B-bone) width scaling) */
-/* ******************** EditBone (B-bone) width scaling *************** */
+/** \name Transform B-bone width scaling
+ * \{ */
-void initBoneSize(TransInfo *t)
+static void initBoneSize(TransInfo *t)
{
t->mode = TFM_BONESIZE;
- t->transform = BoneSize;
+ t->transform = applyBoneSize;
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
@@ -4652,8 +4804,7 @@ void initBoneSize(TransInfo *t)
t->num.increment = t->snap[1];
}
-/* We assume str is MAX_INFO_LEN long. */
-static void headerBoneSize(TransInfo *t, float vec[3], char *str)
+static void headerBoneSize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
{
char tvec[NUM_STR_REP_LEN * 3];
if (hasNumInput(&t->num)) {
@@ -4699,7 +4850,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
td->loc[1] = oldy;
}
-int BoneSize(TransInfo *t, const int mval[2])
+static void applyBoneSize(TransInfo *t, const int mval[2])
{
TransData *td = t->data;
float size[3], mat[3][3];
@@ -4718,7 +4869,7 @@ int BoneSize(TransInfo *t, const int mval[2])
size[0] = size[1] = size[2] = ratio;
- snapGrid(t, size);
+ snapGridIncrement(t, size);
if (hasNumInput(&t->num)) {
applyNumInput(&t->num, size);
@@ -4748,17 +4899,20 @@ int BoneSize(TransInfo *t, const int mval[2])
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/* Transform (Bone Envelope) */
-/* ******************** EditBone envelope *************** */
+/** \name Transform Bone Envelope
+ * \{ */
-void initBoneEnvelope(TransInfo *t)
+static void initBoneEnvelope(TransInfo *t)
{
t->mode = TFM_BONE_ENVELOPE;
- t->transform = BoneEnvelope;
+ t->transform = applyBoneEnvelope;
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
@@ -4773,7 +4927,7 @@ void initBoneEnvelope(TransInfo *t)
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
-int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
+static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
float ratio;
@@ -4782,7 +4936,7 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
ratio = t->values[0];
- snapGrid(t, &ratio);
+ snapGridIncrement(t, &ratio);
applyNumInput(&t->num, &ratio);
@@ -4816,11 +4970,16 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Edge Slide) */
+
+/** \name Transform Edge Slide
+ * \{ */
-/* ******************** Edge Slide *************** */
static BMEdge *get_other_edge(BMVert *v, BMEdge *e)
{
BMIter iter;
@@ -5343,7 +5502,7 @@ static bool createEdgeSlideVerts(TransInfo *t)
use_btree_disp = (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
if (use_btree_disp) {
- btree = BKE_bmbvh_new(em, BMBVH_RESPECT_HIDDEN, NULL, false);
+ btree = BKE_bmbvh_new_from_editmesh(em, BMBVH_RESPECT_HIDDEN, NULL, false);
}
else {
btree = NULL;
@@ -5678,12 +5837,12 @@ void freeEdgeSlideVerts(TransInfo *t)
recalcData(t);
}
-void initEdgeSlide(TransInfo *t)
+static void initEdgeSlide(TransInfo *t)
{
EdgeSlideData *sld;
t->mode = TFM_EDGE_SLIDE;
- t->transform = EdgeSlide;
+ t->transform = applyEdgeSlide;
t->handleEvent = handleEventEdgeSlide;
if (!createEdgeSlideVerts(t)) {
@@ -5713,7 +5872,7 @@ void initEdgeSlide(TransInfo *t)
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
-int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
+static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
{
if (t->mode == TFM_EDGE_SLIDE) {
EdgeSlideData *sld = t->customData;
@@ -5723,7 +5882,7 @@ int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
case EKEY:
if (event->val == KM_PRESS) {
sld->is_proportional = !sld->is_proportional;
- return 1;
+ return TREDRAW_HARD;
}
break;
case FKEY:
@@ -5732,7 +5891,7 @@ int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
if (sld->is_proportional == FALSE) {
sld->flipped_vtx = !sld->flipped_vtx;
}
- return 1;
+ return TREDRAW_HARD;
}
break;
}
@@ -5757,7 +5916,7 @@ int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
}
}
}
- return 0;
+ return TREDRAW_NOTHING;
}
static void drawEdgeSlide(const struct bContext *C, TransInfo *t)
@@ -5898,7 +6057,7 @@ static int doEdgeSlide(TransInfo *t, float perc)
return 1;
}
-int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
+static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
{
char str[MAX_INFO_LEN];
float final;
@@ -5908,7 +6067,7 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
final = t->values[0];
- snapGrid(t, &final);
+ snapGridIncrement(t, &final);
/* only do this so out of range values are not displayed */
CLAMP(final, -1.0f, 1.0f);
@@ -5938,12 +6097,16 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/* Transform (Vert Slide) */
+
+/** \name Transform Vert Slide
+ * \{ */
-/* ******************** Vert Slide *************** */
static void calcVertSlideCustomPoints(struct TransInfo *t)
{
VertSlideData *sld = t->customData;
@@ -6180,12 +6343,12 @@ void freeVertSlideVerts(TransInfo *t)
recalcData(t);
}
-void initVertSlide(TransInfo *t)
+static void initVertSlide(TransInfo *t)
{
VertSlideData *sld;
t->mode = TFM_VERT_SLIDE;
- t->transform = VertSlide;
+ t->transform = applyVertSlide;
t->handleEvent = handleEventVertSlide;
if (!createVertSlideVerts(t)) {
@@ -6215,7 +6378,7 @@ void initVertSlide(TransInfo *t)
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
-int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
+static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
{
if (t->mode == TFM_VERT_SLIDE) {
VertSlideData *sld = t->customData;
@@ -6228,7 +6391,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
if (sld->flipped_vtx) {
calcVertSlideCustomPoints(t);
}
- return 1;
+ return TREDRAW_HARD;
}
break;
case FKEY:
@@ -6236,7 +6399,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
if (event->val == KM_PRESS) {
sld->flipped_vtx = !sld->flipped_vtx;
calcVertSlideCustomPoints(t);
- return 1;
+ return TREDRAW_HARD;
}
break;
}
@@ -6246,7 +6409,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
if (event->val == KM_PRESS) {
t->flag ^= T_ALT_TRANSFORM;
calcVertSlideCustomPoints(t);
- return 1;
+ return TREDRAW_HARD;
}
break;
}
@@ -6282,7 +6445,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
}
}
}
- return 0;
+ return TREDRAW_NOTHING;
}
static void drawVertSlide(const struct bContext *C, TransInfo *t)
@@ -6399,7 +6562,7 @@ static int doVertSlide(TransInfo *t, float perc)
return 1;
}
-int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
+static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
{
char str[MAX_INFO_LEN];
size_t ofs = 0;
@@ -6412,7 +6575,7 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
final = t->values[0];
- snapGrid(t, &final);
+ snapGridIncrement(t, &final);
/* only do this so out of range values are not displayed */
if (is_constrained) {
@@ -6443,17 +6606,20 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ******************** EditBone roll *************** */
+/* -------------------------------------------------------------------- */
+/* Transform (EditBone Roll) */
-void initBoneRoll(TransInfo *t)
+/** \name Transform EditBone Roll
+ * \{ */
+
+static void initBoneRoll(TransInfo *t)
{
t->mode = TFM_BONE_ROLL;
- t->transform = BoneRoll;
+ t->transform = applyBoneRoll;
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
@@ -6468,7 +6634,7 @@ void initBoneRoll(TransInfo *t)
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
-int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
+static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
int i;
@@ -6478,7 +6644,7 @@ int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
final = t->values[0];
- snapGrid(t, &final);
+ snapGridIncrement(t, &final);
if (hasNumInput(&t->num)) {
char c[NUM_STR_REP_LEN];
@@ -6509,15 +6675,19 @@ int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Bake-Time) */
-/* ************************** BAKE TIME ******************* */
+/** \name Transform Bake-Time
+ * \{ */
-void initBakeTime(TransInfo *t)
+static void initBakeTime(TransInfo *t)
{
- t->transform = BakeTime;
+ t->transform = applyBakeTime;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
t->idx_max = 0;
@@ -6529,7 +6699,7 @@ void initBakeTime(TransInfo *t)
t->num.increment = t->snap[1];
}
-int BakeTime(TransInfo *t, const int mval[2])
+static void applyBakeTime(TransInfo *t, const int mval[2])
{
TransData *td = t->data;
float time;
@@ -6547,7 +6717,7 @@ int BakeTime(TransInfo *t, const int mval[2])
time = (float)(t->center2d[0] - mval[0]) * fac;
}
- snapGrid(t, &time);
+ snapGridIncrement(t, &time);
applyNumInput(&t->num, &time);
@@ -6587,15 +6757,19 @@ int BakeTime(TransInfo *t, const int mval[2])
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ************************** MIRROR *************************** */
-void initMirror(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Mirror) */
+
+/** \name Transform Mirror
+ * \{ */
+
+static void initMirror(TransInfo *t)
{
- t->transform = Mirror;
+ t->transform = applyMirror;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
t->flag |= T_NULL_ONE;
@@ -6604,7 +6778,7 @@ void initMirror(TransInfo *t)
}
}
-int Mirror(TransInfo *t, const int UNUSED(mval[2]))
+static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td;
float size[3], mat[3][3];
@@ -6665,22 +6839,26 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2]))
else
ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y, Z)"));
}
-
- return 1;
}
+/** \} */
-/* ************************** ALIGN *************************** */
-void initAlign(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Align) */
+
+/** \name Transform Align
+ * \{ */
+
+static void initAlign(TransInfo *t)
{
t->flag |= T_NO_CONSTRAINT;
- t->transform = Align;
+ t->transform = applyAlign;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
}
-int Align(TransInfo *t, const int UNUSED(mval[2]))
+static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td = t->data;
float center[3];
@@ -6721,15 +6899,19 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
ED_area_headerprint(t->sa, IFACE_("Align"));
-
- return 1;
}
+/** \} */
+
-/* ************************** SEQ SLIDE *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Sequencer Slide) */
-void initSeqSlide(TransInfo *t)
+/** \name Transform Sequencer Slide
+ * \{ */
+
+static void initSeqSlide(TransInfo *t)
{
- t->transform = SeqSlide;
+ t->transform = applySeqSlide;
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
@@ -6744,8 +6926,7 @@ void initSeqSlide(TransInfo *t)
t->num.increment = t->snap[1];
}
-/* We assume str is MAX_INFO_LEN long. */
-static void headerSeqSlide(TransInfo *t, float val[2], char *str)
+static void headerSeqSlide(TransInfo *t, float val[2], char str[MAX_INFO_LEN])
{
char tvec[NUM_STR_REP_LEN * 3];
size_t ofs = 0;
@@ -6766,10 +6947,10 @@ static void headerSeqSlide(TransInfo *t, float val[2], char *str)
}
}
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"),
- WM_bool_as_string(t->flag & T_ALT_TRANSFORM));
+ WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
}
-static void applySeqSlide(TransInfo *t, const float val[2])
+static void applySeqSlideValue(TransInfo *t, const float val[2])
{
TransData *td = t->data;
int i;
@@ -6792,7 +6973,7 @@ static void applySeqSlide(TransInfo *t, const float val[2])
}
}
-int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
+static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2]))
{
char str[MAX_INFO_LEN];
@@ -6803,7 +6984,7 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
copy_v3_v3(t->values, tvec);
}
else {
- snapGrid(t, t->values);
+ snapGridIncrement(t, t->values);
applyNumInput(&t->num, t->values);
}
@@ -6811,19 +6992,23 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
t->values[1] = floor(t->values[1] + 0.5f);
headerSeqSlide(t, t->values, str);
- applySeqSlide(t, t->values);
+ applySeqSlideValue(t, t->values);
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ************************** ANIM EDITORS - TRANSFORM TOOLS *************************** */
-/* ---------------- Special Helpers for Various Settings ------------- */
+/* -------------------------------------------------------------------- */
+/* Animation Editors - Transform Utils
+ *
+ * Special Helpers for Various Settings
+ */
+/** \name Animation Editor Utils
+ * \{ */
/* This function returns the snapping 'mode' for Animation Editors only
* We cannot use the standard snapping due to NLA-strip scaling complexities.
@@ -6975,10 +7160,16 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
td2d->h2[0] = td2d->ih2[0] + *td->val - td->ival;
}
}
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Animation Translation) */
-/* ----------------- Translation ----------------------- */
+/** \name Transform Animation Translation
+ * \{ */
-void initTimeTranslate(TransInfo *t)
+static void initTimeTranslate(TransInfo *t)
{
/* this tool is only really available in the Action Editor... */
if (!ELEM(t->spacetype, SPACE_ACTION, SPACE_SEQ)) {
@@ -6986,7 +7177,7 @@ void initTimeTranslate(TransInfo *t)
}
t->mode = TFM_TIME_TRANSLATE;
- t->transform = TimeTranslate;
+ t->transform = applyTimeTranslate;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
@@ -7002,8 +7193,7 @@ void initTimeTranslate(TransInfo *t)
t->num.increment = t->snap[1];
}
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTimeTranslate(TransInfo *t, char *str)
+static void headerTimeTranslate(TransInfo *t, char str[MAX_INFO_LEN])
{
char tvec[NUM_STR_REP_LEN * 3];
@@ -7039,7 +7229,7 @@ static void headerTimeTranslate(TransInfo *t, char *str)
BLI_snprintf(str, MAX_INFO_LEN, IFACE_("DeltaX: %s"), &tvec[0]);
}
-static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
+static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
{
TransData *td = t->data;
TransData2D *td2d = t->data2d;
@@ -7096,7 +7286,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
}
}
-int TimeTranslate(TransInfo *t, const int mval[2])
+static void applyTimeTranslate(TransInfo *t, const int mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
@@ -7115,18 +7305,22 @@ int TimeTranslate(TransInfo *t, const int mval[2])
t->values[0] = t->vec[0];
headerTimeTranslate(t, str);
- applyTimeTranslate(t, sval[0]);
+ applyTimeTranslateValue(t, sval[0]);
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ----------------- Time Slide ----------------------- */
-void initTimeSlide(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Animation Time Slide) */
+
+/** \name Transform Animation Time Slide
+ * \{ */
+
+static void initTimeSlide(TransInfo *t)
{
/* this tool is only really available in the Action Editor... */
if (t->spacetype == SPACE_ACTION) {
@@ -7141,7 +7335,7 @@ void initTimeSlide(TransInfo *t)
t->mode = TFM_TIME_SLIDE;
- t->transform = TimeSlide;
+ t->transform = applyTimeSlide;
t->flag |= T_FREE_CUSTOMDATA;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
@@ -7158,8 +7352,7 @@ void initTimeSlide(TransInfo *t)
t->num.increment = t->snap[1];
}
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTimeSlide(TransInfo *t, float sval, char *str)
+static void headerTimeSlide(TransInfo *t, float sval, char str[MAX_INFO_LEN])
{
char tvec[NUM_STR_REP_LEN * 3];
@@ -7181,7 +7374,7 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
BLI_snprintf(str, MAX_INFO_LEN, IFACE_("TimeSlide: %s"), &tvec[0]);
}
-static void applyTimeSlide(TransInfo *t, float sval)
+static void applyTimeSlideValue(TransInfo *t, float sval)
{
TransData *td = t->data;
int i;
@@ -7228,7 +7421,7 @@ static void applyTimeSlide(TransInfo *t, float sval)
}
}
-int TimeSlide(TransInfo *t, const int mval[2])
+static void applyTimeSlide(TransInfo *t, const int mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
@@ -7250,18 +7443,22 @@ int TimeSlide(TransInfo *t, const int mval[2])
t->values[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0];
headerTimeSlide(t, sval[0], str);
- applyTimeSlide(t, sval[0]);
+ applyTimeSlideValue(t, sval[0]);
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
}
+/** \} */
-/* ----------------- Scaling ----------------------- */
-void initTimeScale(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Animation Time Scale) */
+
+/** \name Transform Animation Time Scale
+ * \{ */
+
+static void initTimeScale(TransInfo *t)
{
float center[2];
@@ -7273,7 +7470,7 @@ void initTimeScale(TransInfo *t)
}
t->mode = TFM_TIME_SCALE;
- t->transform = TimeScale;
+ t->transform = applyTimeScale;
/* recalculate center2d to use CFRA and mouse Y, since that's
* what is used in time scale */
@@ -7301,8 +7498,7 @@ void initTimeScale(TransInfo *t)
t->num.increment = t->snap[1];
}
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTimeScale(TransInfo *t, char *str)
+static void headerTimeScale(TransInfo *t, char str[MAX_INFO_LEN])
{
char tvec[NUM_STR_REP_LEN * 3];
@@ -7314,7 +7510,7 @@ static void headerTimeScale(TransInfo *t, char *str)
BLI_snprintf(str, MAX_INFO_LEN, IFACE_("ScaleX: %s"), &tvec[0]);
}
-static void applyTimeScale(TransInfo *t)
+static void applyTimeScaleValue(TransInfo *t)
{
Scene *scene = t->scene;
TransData *td = t->data;
@@ -7354,7 +7550,7 @@ static void applyTimeScale(TransInfo *t)
}
}
-int TimeScale(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
{
char str[MAX_INFO_LEN];
@@ -7364,22 +7560,13 @@ int TimeScale(TransInfo *t, const int UNUSED(mval[2]))
t->values[0] = t->vec[0];
headerTimeScale(t, str);
- applyTimeScale(t);
+ applyTimeScaleValue(t);
recalcData(t);
ED_area_headerprint(t->sa, str);
-
- return 1;
-}
-
-/* ************************************ */
-
-void BIF_TransformSetUndo(const char *UNUSED(str))
-{
- // TRANSFORM_FIX_ME
- //Trans.undostr = str;
}
+/** \} */
/* TODO, move to: transform_queries.c */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index b32ba5ad527..ab5f034c836 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -62,6 +62,13 @@ struct wmTimer;
struct ARegion;
struct ReportList;
+/* transinfo->redraw */
+typedef enum {
+ TREDRAW_NOTHING = 0,
+ TREDRAW_HARD = 1,
+ TREDRAW_SOFT = 2,
+} eRedrawFlag;
+
typedef struct TransSnapPoint {
struct TransSnapPoint *next, *prev;
float co[3];
@@ -284,9 +291,9 @@ typedef struct TransInfo {
int options; /* current context/options for transform */
float val; /* init value for some transformations (and rotation angle) */
float fac; /* factor for distance based transform */
- int (*transform)(struct TransInfo *, const int *);
+ void (*transform)(struct TransInfo *, const int[2]);
/* transform function pointer */
- int (*handleEvent)(struct TransInfo *, const struct wmEvent *);
+ eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
/* event handler function pointer RETURN 1 if redraw is needed */
int total; /* total number of transformed data */
TransData *data; /* transformed data (array) */
@@ -296,7 +303,7 @@ typedef struct TransInfo {
TransSnap tsnap;
NumInput num; /* numerical input */
MouseInput mouse; /* mouse input */
- char redraw; /* redraw flag */
+ eRedrawFlag redraw; /* redraw flag */
float prop_size; /* proportional circle radius */
char proptext[20]; /* proportional falloff text */
float center[3]; /* center of transformation */
@@ -342,7 +349,7 @@ typedef struct TransInfo {
float axis[3];
float axis_orig[3]; /* TransCon can change 'axis', store the original value here */
- short remove_on_cancel; /* remove elements if operator is cancelled */
+ short remove_on_cancel; /* remove elements if operator is canceled */
void *view;
struct bContext *context; /* Only valid (non null) during an operator called function. */
@@ -372,12 +379,6 @@ typedef struct TransInfo {
#define TRANS_CONFIRM 2
#define TRANS_CANCEL 3
-/* transinfo->redraw */
-#define TREDRAW_NOTHING 0
-#define TREDRAW_HARD 1
-#define TREDRAW_SOFT 2
-
-
/* transinfo->flag */
#define T_OBJECT (1 << 0)
#define T_EDIT (1 << 1)
@@ -494,91 +495,6 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]);
void applyAspectRatio(TransInfo *t, float *vec);
void removeAspectRatio(TransInfo *t, float *vec);
-void initWarp(TransInfo *t);
-int handleEventWarp(TransInfo *t, const struct wmEvent *event);
-int Warp(TransInfo *t, const int mval[2]);
-
-void initShear(TransInfo *t);
-int handleEventShear(TransInfo *t, const struct wmEvent *event);
-int Shear(TransInfo *t, const int mval[2]);
-
-void initResize(TransInfo *t);
-int Resize(TransInfo *t, const int mval[2]);
-
-void initSkinResize(TransInfo *t);
-int SkinResize(TransInfo *t, const int mval[2]);
-
-void initTranslation(TransInfo *t);
-int Translation(TransInfo *t, const int mval[2]);
-
-void initToSphere(TransInfo *t);
-int ToSphere(TransInfo *t, const int mval[2]);
-
-void initRotation(TransInfo *t);
-int Rotation(TransInfo *t, const int mval[2]);
-
-void initShrinkFatten(TransInfo *t);
-int ShrinkFatten(TransInfo *t, const int mval[2]);
-
-void initTilt(TransInfo *t);
-int Tilt(TransInfo *t, const int mval[2]);
-
-void initCurveShrinkFatten(TransInfo *t);
-int CurveShrinkFatten(TransInfo *t, const int mval[2]);
-
-void initMaskShrinkFatten(TransInfo *t);
-int MaskShrinkFatten(TransInfo *t, const int mval[2]);
-
-void initTrackball(TransInfo *t);
-int Trackball(TransInfo *t, const int mval[2]);
-
-void initPushPull(TransInfo *t);
-int PushPull(TransInfo *t, const int mval[2]);
-
-void initBevelWeight(TransInfo *t);
-int BevelWeight(TransInfo *t, const int mval[2]);
-
-void initCrease(TransInfo *t);
-int Crease(TransInfo *t, const int mval[2]);
-
-void initBoneSize(TransInfo *t);
-int BoneSize(TransInfo *t, const int mval[2]);
-
-void initBoneEnvelope(TransInfo *t);
-int BoneEnvelope(TransInfo *t, const int mval[2]);
-
-void initBoneRoll(TransInfo *t);
-int BoneRoll(TransInfo *t, const int mval[2]);
-
-void initEdgeSlide(TransInfo *t);
-int handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event);
-int EdgeSlide(TransInfo *t, const int mval[2]);
-
-void initVertSlide(TransInfo *t);
-int handleEventVertSlide(TransInfo *t, const struct wmEvent *event);
-int VertSlide(TransInfo *t, const int mval[2]);
-
-void initTimeTranslate(TransInfo *t);
-int TimeTranslate(TransInfo *t, const int mval[2]);
-
-void initTimeSlide(TransInfo *t);
-int TimeSlide(TransInfo *t, const int mval[2]);
-
-void initTimeScale(TransInfo *t);
-int TimeScale(TransInfo *t, const int mval[2]);
-
-void initBakeTime(TransInfo *t);
-int BakeTime(TransInfo *t, const int mval[2]);
-
-void initMirror(TransInfo *t);
-int Mirror(TransInfo *t, const int mval[2]);
-
-void initAlign(TransInfo *t);
-int Align(TransInfo *t, const int mval[2]);
-
-void initSeqSlide(TransInfo *t);
-int SeqSlide(TransInfo *t, const int mval[2]);
-
void drawPropCircle(const struct bContext *C, TransInfo *t);
struct wmKeyMap *transform_modal_keymap(struct wmKeyConfig *keyconf);
@@ -650,24 +566,25 @@ typedef enum {
SMALL_GEARS = 2
} GearsType;
-void snapGrid(TransInfo *t, float *val);
-void snapGridAction(TransInfo *t, float *val, GearsType action);
+void snapGridIncrement(TransInfo *t, float *val);
+void snapGridIncrementAction(TransInfo *t, float *val, GearsType action);
bool activeSnap(TransInfo *t);
bool validSnap(TransInfo *t);
void initSnapping(struct TransInfo *t, struct wmOperator *op);
void applyProject(TransInfo *t);
+void applyGridAbsolute(TransInfo *t);
void applySnapping(TransInfo *t, float *vec);
void resetSnapping(TransInfo *t);
-bool handleSnapping(TransInfo *t, const struct wmEvent *event);
+eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event);
void drawSnapping(const struct bContext *C, TransInfo *t);
bool usingSnappingNormal(TransInfo *t);
bool validSnappingNormal(TransInfo *t);
void getSnapPoint(TransInfo *t, float vec[3]);
void addSnapPoint(TransInfo *t);
-bool updateSelectedSnapPoint(TransInfo *t);
+eRedrawFlag updateSelectedSnapPoint(TransInfo *t);
void removeSnapPoint(TransInfo *t);
/********************** Mouse Input ******************************/
@@ -690,7 +607,7 @@ typedef enum {
void initMouseInput(TransInfo *t, MouseInput *mi, const float center[2], const int mval[2]);
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode);
-int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, const struct wmEvent *event);
+eRedrawFlag handleMouseInput(struct TransInfo *t, struct MouseInput *mi, const struct wmEvent *event);
void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]);
void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2]);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index a73bf86feb1..4ba87eb8c39 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -135,7 +135,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3])
mul_m3_v3(t->con.imtx, vec);
- snapGrid(t, vec);
+ snapGridIncrement(t, vec);
if (t->num.flag & T_NULL_ONE) {
if (!(t->con.mode & CON_AXIS0))
@@ -569,7 +569,7 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
t->con.applyVec = applyAxisConstraintVec;
t->con.applySize = applyAxisConstraintSize;
t->con.applyRot = applyAxisConstraintRot;
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
}
/* applies individual td->axismtx constraints */
@@ -590,7 +590,7 @@ void setAxisMatrixConstraint(TransInfo *t, int mode, const char text[])
t->con.applyVec = applyObjectConstraintVec;
t->con.applySize = applyObjectConstraintSize;
t->con.applyRot = applyObjectConstraintRot;
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
}
}
@@ -792,6 +792,13 @@ static void drawObjectConstraint(TransInfo *t)
float co[3];
float (*axismtx)[3];
+ if (t->flag & T_PROP_EDIT) {
+ /* we're sorted, so skip the rest */
+ if (td->factor == 0.0f) {
+ break;
+ }
+ }
+
if (t->flag & T_OBJECT) {
copy_v3_v3(co, td->ob->obmat[3]);
axismtx = td->axismtx;
@@ -904,7 +911,7 @@ void postSelectConstraint(TransInfo *t)
setNearestAxis(t);
startConstraint(t);
- t->redraw = 1;
+ t->redraw = TREDRAW_HARD;
}
static void setNearestAxis2d(TransInfo *t)
@@ -923,9 +930,9 @@ static void setNearestAxis2d(TransInfo *t)
static void setNearestAxis3d(TransInfo *t)
{
float zfac;
- float mvec[3], axis[3], proj[3];
+ float mvec[3], proj[3];
float len[3];
- int i, icoord[2];
+ int i;
/* calculate mouse movement */
mvec[0] = (float)(t->mval[0] - t->con.imval[0]);
@@ -943,15 +950,16 @@ static void setNearestAxis3d(TransInfo *t)
zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f;
for (i = 0; i < 3; i++) {
+ float axis[3], axis_2d[2];
+
copy_v3_v3(axis, t->con.mtx[i]);
mul_v3_fl(axis, zfac);
/* now we can project to get window coordinate */
add_v3_v3(axis, t->con.center);
- projectIntView(t, axis, icoord);
+ projectFloatView(t, axis, axis_2d);
- axis[0] = (float)(icoord[0] - t->center2d[0]);
- axis[1] = (float)(icoord[1] - t->center2d[1]);
+ sub_v2_v2v2(axis, axis_2d, t->center2d);
axis[2] = 0.0f;
if (normalize_v3(axis) != 0.0f) {
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index f5a12fed076..06da1edbcdc 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -2008,8 +2008,8 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, int *r
* its possible we have a selected vertex thats not in a face, for now best not crash in that case. */
fill_vn_i(vert_map, bm->totvert, -1);
- EDBM_index_arrays_ensure(em, htype);
- ele_array = (htype == BM_FACE) ? (void **)em->face_index : (void **)em->edge_index;
+ BM_mesh_elem_table_ensure(bm, htype);
+ ele_array = (htype == BM_FACE) ? (void **)bm->ftable : (void **)bm->etable;
BM_mesh_elem_index_ensure(bm, BM_VERT);
@@ -2098,9 +2098,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
}
else if (t->around == V3D_LOCAL) {
copy_v3_v3(td->center, td->loc);
-
- axis_dominant_v3_to_m3(td->axismtx, eve->no);
- invert_m3(td->axismtx);
+ createSpaceNormal(td->axismtx, eve->no);
}
else {
copy_v3_v3(td->center, td->loc);
@@ -2383,16 +2381,16 @@ void flushTransNodes(TransInfo *t)
int a;
TransData *td;
TransData2D *td2d;
-
+
+ applyGridAbsolute(t);
+
/* flush to 2d vector from internally used 3d vector */
for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
bNode *node = td->extra;
- float vec[2];
/* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
- add_v2_v2v2(vec, td2d->loc, td2d->ih1);
- node->locx = vec[0] / UI_DPI_FAC;
- node->locy = vec[1] / UI_DPI_FAC;
+ node->locx = td2d->loc[0] / UI_DPI_FAC;
+ node->locy = td2d->loc[1] / UI_DPI_FAC;
}
/* handle intersection with noodles */
@@ -2578,10 +2576,10 @@ static void createTransUVs(bContext *C, TransInfo *t)
if (propconnected) {
/* create element map with island information */
if (ts->uv_flag & UV_SYNC_SELECTION) {
- elementmap = EDBM_uv_element_map_create(em, false, true);
+ elementmap = BM_uv_element_map_create(em->bm, false, true);
}
else {
- elementmap = EDBM_uv_element_map_create(em, true, true);
+ elementmap = BM_uv_element_map_create(em->bm, true, true);
}
island_enabled = MEM_callocN(sizeof(*island_enabled) * elementmap->totalIslands, "TransIslandData(UV Editing)");
}
@@ -2600,7 +2598,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
countsel++;
if (propconnected) {
- UvElement *element = ED_uv_element_get(elementmap, efa, l);
+ UvElement *element = BM_uv_element_get(elementmap, efa, l);
island_enabled[element->island] = TRUE;
}
@@ -2636,7 +2634,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
continue;
if (propconnected) {
- UvElement *element = ED_uv_element_get(elementmap, efa, l);
+ UvElement *element = BM_uv_element_get(elementmap, efa, l);
if (!island_enabled[element->island]) {
count_rejected++;
continue;
@@ -2650,7 +2648,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
if (propconnected) {
t->total -= count_rejected;
- EDBM_uv_element_map_free(elementmap);
+ BM_uv_element_map_free(elementmap);
MEM_freeN(island_enabled);
}
@@ -3716,12 +3714,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
float mtx[3][3], smtx[3][3];
const bool use_handle = !(sipo->flag & SIPO_NOHANDLES);
const bool use_local_center = checkUseLocalCenter_GraphEdit(t);
- const short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS;
+ short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS;
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
+ anim_map_flag |= ANIM_get_normalization_flags(&ac);
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -3837,7 +3837,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
short intvals = (fcu->flag & FCURVE_INT_VALUES);
-
+ float unit_scale;
+ float scaled_mtx[3][3], scaled_smtx[3][3];
+
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
@@ -3850,8 +3852,13 @@ 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_map_flag);
-
+ unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, anim_map_flag);
+
+ copy_m3_m3(scaled_mtx, mtx);
+ copy_m3_m3(scaled_smtx, smtx);
+ mul_v3_fl(scaled_mtx[1], unit_scale);
+ mul_v3_fl(scaled_smtx[1], 1.0f / unit_scale);
+
/* 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++) {
if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
@@ -3868,7 +3875,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (!ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE) || !(sel2)) {
if (sel1) {
hdata = initTransDataCurveHandles(td, bezt);
- bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, mtx, smtx);
+ bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, scaled_mtx, scaled_smtx);
}
else {
/* h1 = 0; */ /* UNUSED */
@@ -3877,7 +3884,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (sel3) {
if (hdata == NULL)
hdata = initTransDataCurveHandles(td, bezt);
- bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx);
+ bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, scaled_mtx, scaled_smtx);
}
else {
/* h2 = 0; */ /* UNUSED */
@@ -3899,7 +3906,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
hdata = initTransDataCurveHandles(td, bezt);
}
- bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, mtx, smtx);
+ bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, scaled_mtx, scaled_smtx);
}
/* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...):
@@ -3921,13 +3928,6 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
/* Sets handles based on the selection */
testhandles_fcurve(fcu, use_handle);
-
- /* even though transform values are written back right after during transform,
- * using individual center's with rotation means the center point wont
- * be touched again see: [#34303] */
- if (use_local_center) {
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, anim_map_flag | ANIM_UNITCONV_RESTORE);
- }
}
/* cleanup temp list */
@@ -4591,7 +4591,7 @@ static void freeSeqData(TransInfo *t)
BKE_sequencer_sort(t->scene);
}
else {
- /* Cancelled, need to update the strips display */
+ /* Canceled, 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)) {
@@ -4715,13 +4715,12 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) {
/* (affirmative) returns for specific constraints here... */
/* constraints that require this regardless */
- if (ELEM6(con->type,
+ if (ELEM5(con->type,
CONSTRAINT_TYPE_CHILDOF,
CONSTRAINT_TYPE_FOLLOWPATH,
CONSTRAINT_TYPE_CLAMPTO,
CONSTRAINT_TYPE_OBJECTSOLVER,
- CONSTRAINT_TYPE_FOLLOWTRACK,
- CONSTRAINT_TYPE_TRANSFORM))
+ CONSTRAINT_TYPE_FOLLOWTRACK))
{
return true;
}
@@ -4734,6 +4733,15 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION))
return true;
}
+ else if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
+ /* Transform constraint needs it for rotation at least (r.57309),
+ * but doing so when translating may also mess things up [#36203]
+ */
+
+ if (t->mode == TFM_ROTATION)
+ return true;
+ /* ??? (t->mode == TFM_SCALE) ? */
+ }
}
}
}
@@ -5863,6 +5871,9 @@ int special_transform_moving(TransInfo *t)
if (t->spacetype == SPACE_SEQ) {
return G_TRANSFORM_SEQ;
}
+ else if (t->spacetype == SPACE_IPO) {
+ return G_TRANSFORM_FCURVES;
+ }
else if (t->obedit || ((t->flag & T_POSE) && (t->poseobj))) {
return G_TRANSFORM_EDIT;
}
@@ -5951,12 +5962,10 @@ static void createTransObject(bContext *C, TransInfo *t)
/* transcribe given node into TransData2D for Transforming */
static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
{
- /* hold original location */
- float locxy[2] = {BLI_rctf_cent_x(&node->totr),
- BLI_rctf_cent_y(&node->totr)};
- float nodeloc[2];
-
- copy_v2_v2(td2d->loc, locxy);
+ /* use top-left corner as the transform origin for nodes */
+ /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
+ td2d->loc[0] = UI_DPI_FAC * node->locx;
+ td2d->loc[1] = UI_DPI_FAC * node->locy;
td2d->loc[2] = 0.0f;
td2d->loc2d = td2d->loc; /* current location */
@@ -5965,8 +5974,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
td->loc = td2d->loc;
copy_v3_v3(td->iloc, td->loc);
/* use node center instead of origin (top-left corner) */
- td->center[0] = locxy[0];
- td->center[1] = locxy[1];
+ td->center[0] = td2d->loc[0] + BLI_rctf_size_x(&node->totr);
+ td->center[1] = td2d->loc[1] + BLI_rctf_size_y(&node->totr);
td->center[2] = 0.0f;
memset(td->axismtx, 0, sizeof(td->axismtx));
@@ -5980,11 +5989,6 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
unit_m3(td->mtx);
unit_m3(td->smtx);
- /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
- nodeloc[0] = UI_DPI_FAC * node->locx;
- nodeloc[1] = UI_DPI_FAC * node->locy;
- sub_v2_v2v2(td2d->ih1, nodeloc, locxy);
-
td->extra = node;
}
@@ -6821,8 +6825,11 @@ void flushTransMasking(TransInfo *t)
td->loc2d[1] = td->loc[1] * inv[1];
mul_m3_v2(tdm->parent_inverse_matrix, td->loc2d);
- if (tdm->is_handle)
- BKE_mask_point_set_handle(tdm->point, td->loc2d, t->flag & T_ALT_TRANSFORM, tdm->orig_handle, tdm->vec);
+ if (tdm->is_handle) {
+ BKE_mask_point_set_handle(tdm->point, td->loc2d,
+ (t->flag & T_ALT_TRANSFORM) != 0,
+ tdm->orig_handle, tdm->vec);
+ }
}
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 94f481d8dfc..95b6067f2c4 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -381,9 +381,6 @@ static void recalcData_graphedit(TransInfo *t)
bAnimListElem *ale;
int dosort = 0;
- const bool use_local_center = checkUseLocalCenter_GraphEdit(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;
@@ -411,11 +408,6 @@ static void recalcData_graphedit(TransInfo *t)
if (!fcu_test_selected(fcu))
continue;
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data,
- ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS | ANIM_UNITCONV_RESTORE |
- (use_local_center ? ANIM_UNITCONV_SKIPKNOTS : 0));
-
-
/* watch it: if the time is wrong: do not correct handles yet */
if (test_time_fcurve(fcu))
dosort++;
@@ -1066,7 +1058,7 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
t->flag = 0;
- t->redraw = 1; /* redraw first time */
+ t->redraw = TREDRAW_HARD; /* redraw first time */
if (event) {
copy_v2_v2_int(t->imval, event->mval);
@@ -1145,8 +1137,8 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
t->around = v3d->around;
- /* warp always uses the cursor */
- if (t->mode == TFM_WARP) {
+ /* bend always uses the cursor */
+ if (t->mode == TFM_BEND) {
t->around = V3D_CURSOR;
}
@@ -1500,7 +1492,7 @@ void calculateCenterCursor(TransInfo *t)
{
const float *cursor;
- cursor = give_cursor(t->scene, t->view);
+ cursor = ED_view3d_cursor3d_get(t->scene, t->view);
copy_v3_v3(t->center, cursor);
/* If edit or pose mode, move cursor in local space */
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index ee993129303..39c7b4b5c1c 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -407,9 +407,9 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp
}
}
-int handleMouseInput(TransInfo *t, MouseInput *mi, const wmEvent *event)
+eRedrawFlag handleMouseInput(TransInfo *t, MouseInput *mi, const wmEvent *event)
{
- int redraw = TREDRAW_NOTHING;
+ eRedrawFlag redraw = TREDRAW_NOTHING;
switch (event->type) {
case LEFTSHIFTKEY:
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index f667a98812b..132a46441e6 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1635,7 +1635,7 @@ void BIF_draw_manipulator(const bContext *C)
copy_v3_v3(rv3d->twmat[3], scene->twcent);
break;
case V3D_CURSOR:
- copy_v3_v3(rv3d->twmat[3], give_cursor(scene, v3d));
+ copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d));
break;
}
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 2904b37c2e5..106024cd3e2 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -68,7 +68,7 @@ static char OP_TOSPHERE[] = "TRANSFORM_OT_tosphere";
static char OP_RESIZE[] = "TRANSFORM_OT_resize";
static char OP_SKIN_RESIZE[] = "TRANSFORM_OT_skin_resize";
static char OP_SHEAR[] = "TRANSFORM_OT_shear";
-static char OP_WARP[] = "TRANSFORM_OT_warp";
+static char OP_BEND[] = "TRANSFORM_OT_bend";
static char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten";
static char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull";
static char OP_TILT[] = "TRANSFORM_OT_tilt";
@@ -86,7 +86,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot);
static void TRANSFORM_OT_resize(struct wmOperatorType *ot);
static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot);
static void TRANSFORM_OT_shear(struct wmOperatorType *ot);
-static void TRANSFORM_OT_warp(struct wmOperatorType *ot);
+static void TRANSFORM_OT_bend(struct wmOperatorType *ot);
static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot);
static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot);
static void TRANSFORM_OT_tilt(struct wmOperatorType *ot);
@@ -106,7 +106,7 @@ static TransformModeItem transform_modes[] =
{OP_RESIZE, TFM_RESIZE, TRANSFORM_OT_resize},
{OP_SKIN_RESIZE, TFM_SKIN_RESIZE, TRANSFORM_OT_skin_resize},
{OP_SHEAR, TFM_SHEAR, TRANSFORM_OT_shear},
- {OP_WARP, TFM_WARP, TRANSFORM_OT_warp},
+ {OP_BEND, TFM_BEND, TRANSFORM_OT_bend},
{OP_SHRINK_FATTEN, TFM_SHRINKFATTEN, TRANSFORM_OT_shrink_fatten},
{OP_PUSH_PULL, TFM_PUSHPULL, TRANSFORM_OT_push_pull},
{OP_TILT, TFM_TILT, TRANSFORM_OT_tilt},
@@ -130,7 +130,7 @@ EnumPropertyItem transform_mode_types[] =
{TFM_SKIN_RESIZE, "SKIN_RESIZE", 0, "Skin Resize", ""},
{TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""},
{TFM_SHEAR, "SHEAR", 0, "Shear", ""},
- {TFM_WARP, "WARP", 0, "Warp", ""},
+ {TFM_BEND, "BEND", 0, "Bend", ""},
{TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""},
{TFM_TILT, "TILT", 0, "Tilt", ""},
{TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""},
@@ -426,15 +426,13 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
return exit_code;
}
-static int transform_cancel(bContext *C, wmOperator *op)
+static void transform_cancel(bContext *C, wmOperator *op)
{
TransInfo *t = op->customdata;
t->state = TRANS_CANCEL;
transformEnd(C, t);
transformops_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
static int transform_exec(bContext *C, wmOperator *op)
@@ -695,12 +693,12 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
-static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
+static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Warp";
- ot->description = "Warp selected items around the cursor";
- ot->idname = OP_WARP;
+ ot->name = "Bend";
+ ot->description = "Bend selected items between the 3D cursor and the mouse";
+ ot->idname = OP_BEND;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
@@ -708,12 +706,11 @@ static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_screenactive;
+ ot->poll = ED_operator_region_view3d_active;
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);
- // XXX Warp axis?
}
static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
@@ -984,7 +981,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_WARP, WKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, OP_BEND, WKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, OP_TOSPHERE, SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 04bccac2a15..4cda56028ca 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -37,6 +37,7 @@
#include "PIL_time.h"
#include "DNA_armature_types.h"
+#include "DNA_curve_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
@@ -117,7 +118,7 @@ int BIF_snappingSupported(Object *obedit)
{
int status = 0;
- if (obedit == NULL || ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) /* only support object mesh, armature, curves */
+ if (obedit == NULL || ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) /* only support object mesh, armature, curves */
{
status = 1;
}
@@ -267,16 +268,16 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
}
}
-bool handleSnapping(TransInfo *t, const wmEvent *event)
+eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
{
- bool status = false;
+ eRedrawFlag status = TREDRAW_NOTHING;
#if 0 // XXX need a proper selector for all snap mode
if (BIF_snappingSupported(t->obedit) && event->type == TABKEY && event->shift) {
/* toggle snap and reinit */
t->settings->snap_flag ^= SCE_SNAP;
initSnapping(t, NULL);
- status = 1;
+ status = TREDRAW_HARD;
}
#endif
if (event->type == MOUSEMOVE) {
@@ -344,6 +345,70 @@ void applyProject(TransInfo *t)
}
}
+void applyGridAbsolute(TransInfo *t)
+{
+ float grid_size = 0.0f;
+ GearsType grid_action;
+ TransData *td;
+ float imat[4][4];
+ int i;
+
+ if (!(activeSnap(t) && (t->tsnap.mode == SCE_SNAP_MODE_GRID)))
+ return;
+
+ grid_action = BIG_GEARS;
+ if (t->modifiers & MOD_PRECISION)
+ grid_action = SMALL_GEARS;
+
+ switch (grid_action) {
+ case NO_GEARS: grid_size = t->snap[0]; break;
+ case BIG_GEARS: grid_size = t->snap[1]; break;
+ case SMALL_GEARS: grid_size = t->snap[2]; break;
+ }
+ /* early exit on unusable grid size */
+ if (grid_size == 0.0f)
+ return;
+
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = t->obedit ? t->obedit : t->poseobj;
+ invert_m4_m4(imat, ob->obmat);
+ }
+
+ for (i = 0, td = t->data; i < t->total; i++, td++) {
+ float iloc[3], loc[3], tvec[3];
+
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
+ continue;
+
+ copy_v3_v3(iloc, td->loc);
+ 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;
+ BKE_object_handle_update(t->scene, td->ob);
+ copy_v3_v3(iloc, td->ob->obmat[3]);
+ }
+
+ mul_v3_v3fl(loc, iloc, 1.0f / grid_size);
+ loc[0] = floorf(loc[0]);
+ loc[1] = floorf(loc[1]);
+ loc[2] = floorf(loc[2]);
+ mul_v3_fl(loc, grid_size);
+
+ sub_v3_v3v3(tvec, loc, iloc);
+ mul_m3_v3(td->smtx, tvec);
+ add_v3_v3(td->loc, tvec);
+ }
+}
+
void applySnapping(TransInfo *t, float *vec)
{
/* project is not applied this way */
@@ -440,7 +505,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 && ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs
{
/* Exclude editmesh if using proportional edit */
if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) {
@@ -606,9 +671,10 @@ void addSnapPoint(TransInfo *t)
}
}
-bool updateSelectedSnapPoint(TransInfo *t)
+eRedrawFlag updateSelectedSnapPoint(TransInfo *t)
{
- bool status = false;
+ eRedrawFlag status = TREDRAW_NOTHING;
+
if (t->tsnap.status & MULTI_POINTS) {
TransSnapPoint *p, *closest_p = NULL;
float closest_dist = TRANSFORM_SNAP_MAX_PX;
@@ -631,7 +697,10 @@ bool updateSelectedSnapPoint(TransInfo *t)
}
if (closest_p) {
- status = (t->tsnap.selectedPoint != closest_p);
+ if (t->tsnap.selectedPoint != closest_p) {
+ status = TREDRAW_HARD;
+ }
+
t->tsnap.selectedPoint = closest_p;
}
}
@@ -814,7 +883,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
static void UNUSED_FUNCTION(CalcSnapGrid) (TransInfo *t, float *UNUSED(vec))
{
- snapGridAction(t, t->tsnap.snapPoint, BIG_GEARS);
+ snapGridIncrementAction(t, t->tsnap.snapPoint, BIG_GEARS);
}
static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
@@ -1347,6 +1416,79 @@ static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *ar
return retval;
}
+static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float obmat[4][4],
+ const float ray_start[3], const float ray_normal[3], const float mval[2],
+ float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth)
+{
+ float imat[4][4];
+ float ray_start_local[3], ray_normal_local[3];
+ bool retval = false;
+ int u;
+
+ Nurb *nu;
+
+ /* only vertex snapping mode (eg control points and handles) supported for now) */
+ if (snap_mode != SCE_SNAP_MODE_VERTEX) {
+ return retval;
+ }
+
+ invert_m4_m4(imat, obmat);
+
+ copy_v3_v3(ray_start_local, ray_start);
+ copy_v3_v3(ray_normal_local, ray_normal);
+
+ mul_m4_v3(imat, ray_start_local);
+ mul_mat3_m4_v3(imat, ray_normal_local);
+
+ for (nu = (ob->mode == OB_MODE_EDIT ? cu->editnurb->nurbs.first : cu->nurb.first); nu; nu = nu->next) {
+ for (u = 0; u < nu->pntsu; u++) {
+ switch (snap_mode) {
+ case SCE_SNAP_MODE_VERTEX:
+ {
+ if (ob->mode == OB_MODE_EDIT) {
+ if (nu->bezt) {
+ /* don't snap to selected (moving) or hidden */
+ if (nu->bezt[u].f2 & SELECT || nu->bezt[u].hide != 0) {
+ break;
+ }
+ retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ /* don't snap if handle is selected (moving), or if it is aligning to a moving handle */
+ if (!(nu->bezt[u].f1 & SELECT) && !(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) {
+ retval |= snapVertex(ar, nu->bezt[u].vec[0], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ }
+ if (!(nu->bezt[u].f3 & SELECT) && !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) {
+ retval |= snapVertex(ar, nu->bezt[u].vec[2], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ }
+ }
+ else {
+ /* don't snap to selected (moving) or hidden */
+ if (nu->bp[u].f1 & SELECT || nu->bp[u].hide != 0) {
+ break;
+ }
+ retval |= snapVertex(ar, nu->bp[u].vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ }
+ }
+ else {
+ /* curve is not visible outside editmode if nurb length less than two */
+ if (nu->pntsu > 1) {
+ if (nu->bezt) {
+ retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ }
+ else {
+ retval |= snapVertex(ar, nu->bp[u].vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ }
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ return retval;
+}
+
static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4],
const float ray_start[3], const float ray_normal[3], const float mval[2],
float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
@@ -1425,7 +1567,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
if (em != NULL) {
index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
- EDBM_index_arrays_ensure(em, BM_VERT);
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT);
}
for (i = 0; i < totvert; i++) {
@@ -1446,7 +1588,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
test = 0;
}
else {
- eve = EDBM_vert_at_index(em, index);
+ eve = BM_vert_at_index(em->bm, index);
if ((BM_elem_flag_test(eve, BM_ELEM_HIDDEN) ||
BM_elem_flag_test(eve, BM_ELEM_SELECT)))
@@ -1475,7 +1617,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
if (em != NULL) {
index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
- EDBM_index_arrays_ensure(em, BM_EDGE);
+ BM_mesh_elem_table_ensure(em->bm, BM_EDGE);
}
for (i = 0; i < totedge; i++) {
@@ -1495,7 +1637,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
test = 0;
}
else {
- BMEdge *eed = EDBM_edge_at_index(em, index);
+ BMEdge *eed = BM_edge_at_index(em->bm, index);
if ((BM_elem_flag_test(eed, BM_ELEM_HIDDEN) ||
BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
@@ -1670,6 +1812,9 @@ static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, f
else if (ob->type == OB_ARMATURE) {
retval = snapArmature(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
}
+ else if (ob->type == OB_CURVE) {
+ retval = snapCurve(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
+ }
else if (ob->type == OB_EMPTY) {
retval = snapEmpty(snap_mode, ar, ob, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
}
@@ -2165,10 +2310,10 @@ bool snapNodesContext(bContext *C, const int mval[2], float *r_dist_px, float r_
/*================================================================*/
-static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action);
+static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action);
-void snapGridAction(TransInfo *t, float *val, GearsType action)
+void snapGridIncrementAction(TransInfo *t, float *val, GearsType action)
{
float fac[3];
@@ -2176,11 +2321,11 @@ void snapGridAction(TransInfo *t, float *val, GearsType action)
fac[BIG_GEARS] = t->snap[1];
fac[SMALL_GEARS] = t->snap[2];
- applyGrid(t, val, t->idx_max, fac, action);
+ applyGridIncrement(t, val, t->idx_max, fac, action);
}
-void snapGrid(TransInfo *t, float *val)
+void snapGridIncrement(TransInfo *t, float *val)
{
GearsType action;
@@ -2194,17 +2339,17 @@ void snapGrid(TransInfo *t, float *val)
action = SMALL_GEARS;
}
- snapGridAction(t, val, action);
+ snapGridIncrementAction(t, val, action);
}
-static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action)
+static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action)
{
int i;
float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3)
if (max_index > 2) {
- printf("applyGrid: invalid index %d, clamping\n", max_index);
+ printf("applyGridIncrement: invalid index %d, clamping\n", max_index);
max_index = 2;
}
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index e72385b311d..6c0bf92a484 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -35,6 +35,7 @@ set(INC_SYS
)
set(SRC
+ ed_transverts.c
ed_util.c
editmode_undo.c
numinput.c
@@ -79,6 +80,7 @@ set(SRC
../include/ED_space_api.h
../include/ED_text.h
../include/ED_transform.h
+ ../include/ED_transverts.h
../include/ED_types.h
../include/ED_util.h
../include/ED_uvedit.h
diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c
new file mode 100644
index 00000000000..4123132ad03
--- /dev/null
+++ b/source/blender/editors/util/ed_transverts.c
@@ -0,0 +1,462 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/ed_transverts.c
+ * \ingroup edutil
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_armature_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_meta_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
+#include "BKE_curve.h"
+#include "BKE_depsgraph.h"
+#include "BKE_lattice.h"
+#include "BKE_editmesh.h"
+#include "BKE_DerivedMesh.h"
+
+#include "ED_armature.h"
+
+#include "ED_transverts.h" /* own include */
+
+
+/* copied from editobject.c, now uses (almost) proper depgraph */
+void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
+{
+ BLI_assert(ED_transverts_check_obedit(obedit) == true);
+
+ DAG_id_tag_update(obedit->data, 0);
+
+ if (obedit->type == OB_MESH) {
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BM_mesh_normals_update(em->bm);
+ }
+ else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
+ Curve *cu = obedit->data;
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+ Nurb *nu = nurbs->first;
+
+ while (nu) {
+ /* keep handles' vectors unchanged */
+ if (nu->bezt) {
+ int a = nu->pntsu;
+ TransVert *tv = tvs->transverts;
+ BezTriple *bezt = nu->bezt;
+
+ while (a--) {
+ if (bezt->f1 & SELECT) tv++;
+
+ if (bezt->f2 & SELECT) {
+ float v[3];
+
+ if (bezt->f1 & SELECT) {
+ sub_v3_v3v3(v, (tv - 1)->oldloc, tv->oldloc);
+ add_v3_v3v3(bezt->vec[0], bezt->vec[1], v);
+ }
+
+ if (bezt->f3 & SELECT) {
+ sub_v3_v3v3(v, (tv + 1)->oldloc, tv->oldloc);
+ add_v3_v3v3(bezt->vec[2], bezt->vec[1], v);
+ }
+
+ tv++;
+ }
+
+ if (bezt->f3 & SELECT) tv++;
+
+ bezt++;
+ }
+ }
+
+ BKE_nurb_test2D(nu);
+ BKE_nurb_handles_test(nu, true); /* test for bezier too */
+ nu = nu->next;
+ }
+ }
+ else if (obedit->type == OB_ARMATURE) {
+ bArmature *arm = obedit->data;
+ EditBone *ebo;
+ TransVert *tv = tvs->transverts;
+ int a = 0;
+
+ /* Ensure all bone tails are correctly adjusted */
+ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ /* adjust tip if both ends selected */
+ if ((ebo->flag & BONE_ROOTSEL) && (ebo->flag & BONE_TIPSEL)) {
+ if (tv) {
+ float diffvec[3];
+
+ sub_v3_v3v3(diffvec, tv->loc, tv->oldloc);
+ add_v3_v3(ebo->tail, diffvec);
+
+ a++;
+ if (a < tvs->transverts_tot) tv++;
+ }
+ }
+ }
+
+ /* Ensure all bones are correctly adjusted */
+ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ 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 this bone has a parent tip that has NOT been moved */
+ else {
+ copy_v3_v3(ebo->parent->tail, ebo->head);
+ }
+ }
+ }
+ if (arm->flag & ARM_MIRROR_EDIT)
+ transform_armature_mirror_update(obedit);
+ }
+ else if (obedit->type == OB_LATTICE) {
+ Lattice *lt = obedit->data;
+
+ if (lt->editlatt->latt->flag & LT_OUTSIDE)
+ outside_lattice(lt->editlatt->latt);
+ }
+}
+
+static void set_mapped_co(void *vuserdata, int index, const float co[3],
+ const float UNUSED(no[3]), const short UNUSED(no_s[3]))
+{
+ void **userdata = vuserdata;
+ BMEditMesh *em = userdata[0];
+ TransVert *tv = userdata[1];
+ BMVert *eve = BM_vert_at_index(em->bm, index);
+
+ if (BM_elem_index_get(eve) != TM_INDEX_SKIP) {
+ tv = &tv[BM_elem_index_get(eve)];
+
+ /* be clever, get the closest vertex to the original,
+ * behaves most logically when the mirror modifier is used for eg [#33051]*/
+ if ((tv->flag & TX_VERT_USE_MAPLOC) == 0) {
+ /* first time */
+ copy_v3_v3(tv->maploc, co);
+ tv->flag |= TX_VERT_USE_MAPLOC;
+ }
+ else {
+ /* find best location to use */
+ if (len_squared_v3v3(eve->co, co) < len_squared_v3v3(eve->co, tv->maploc)) {
+ copy_v3_v3(tv->maploc, co);
+ }
+ }
+ }
+}
+
+bool ED_transverts_check_obedit(Object *obedit)
+{
+ return (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL));
+}
+
+void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const int mode)
+{
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ TransVert *tv = NULL;
+ MetaElem *ml;
+ BMVert *eve;
+ EditBone *ebo;
+ int a;
+
+ tvs->transverts_tot = 0;
+
+ if (obedit->type == OB_MESH) {
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ BMIter iter;
+ void *userdata[2] = {em, NULL};
+ /*int proptrans = 0; */ /*UNUSED*/
+
+ /* abuses vertex index all over, set, just set dirty here,
+ * perhaps this could use its own array instead? - campbell */
+
+ /* transform now requires awareness for select mode, so we tag the f1 flags in verts */
+ tvs->transverts_tot = 0;
+ if (em->selectmode & SCE_SELECT_VERTEX) {
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ BM_elem_index_set(eve, TM_INDEX_ON); /* set_dirty! */
+ tvs->transverts_tot++;
+ }
+ else {
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
+ }
+ }
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
+ BMEdge *eed;
+
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
+ }
+
+ BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+ BM_elem_index_set(eed->v1, TM_INDEX_ON); /* set_dirty! */
+ BM_elem_index_set(eed->v2, TM_INDEX_ON); /* set_dirty! */
+ }
+ }
+
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) tvs->transverts_tot++;
+ }
+ }
+ else {
+ BMFace *efa;
+
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
+ }
+
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
+ BMIter liter;
+ BMLoop *l;
+
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ BM_elem_index_set(l->v, TM_INDEX_ON); /* set_dirty! */
+ }
+ }
+ }
+
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) tvs->transverts_tot++;
+ }
+ }
+ /* for any of the 3 loops above which all dirty the indices */
+ bm->elem_index_dirty |= BM_VERT;
+
+ /* and now make transverts */
+ if (tvs->transverts_tot) {
+ tv = tvs->transverts = MEM_callocN(tvs->transverts_tot * sizeof(TransVert), __func__);
+
+ a = 0;
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_index_get(eve)) {
+ BM_elem_index_set(eve, a); /* set_dirty! */
+ copy_v3_v3(tv->oldloc, eve->co);
+ tv->loc = eve->co;
+ tv->flag = (BM_elem_index_get(eve) == TM_INDEX_ON) ? SELECT : 0;
+ tv++;
+ a++;
+ }
+ else {
+ BM_elem_index_set(eve, TM_INDEX_SKIP); /* set_dirty! */
+ }
+ }
+ /* set dirty already, above */
+
+ userdata[1] = tvs->transverts;
+ }
+
+ if (tvs->transverts && em->derivedCage) {
+ BM_mesh_elem_table_ensure(bm, BM_VERT);
+ em->derivedCage->foreachMappedVert(em->derivedCage, set_mapped_co, userdata, DM_FOREACH_NOP);
+ }
+ }
+ else if (obedit->type == OB_ARMATURE) {
+ bArmature *arm = obedit->data;
+ int totmalloc = BLI_countlist(arm->edbo);
+
+ totmalloc *= 2; /* probably overkill but bones can have 2 trans verts each */
+
+ tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__);
+
+ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ if (ebo->layer & arm->layer) {
+ short tipsel = (ebo->flag & BONE_TIPSEL);
+ short rootsel = (ebo->flag & BONE_ROOTSEL);
+ short rootok = (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && (ebo->parent->flag & BONE_TIPSEL)));
+
+ if ((tipsel && rootsel) || (rootsel)) {
+ /* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints),
+ * otherwise we get zero-length bones as tips will snap to the same
+ * location as heads.
+ */
+ if (rootok) {
+ copy_v3_v3(tv->oldloc, ebo->head);
+ tv->loc = ebo->head;
+ tv->flag = SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+
+ if ((mode & TM_ALL_JOINTS) && (tipsel)) {
+ copy_v3_v3(tv->oldloc, ebo->tail);
+ tv->loc = ebo->tail;
+ tv->flag = SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ }
+ else if (tipsel) {
+ copy_v3_v3(tv->oldloc, ebo->tail);
+ tv->loc = ebo->tail;
+ tv->flag = SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ }
+ }
+ }
+ else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
+ Curve *cu = obedit->data;
+ int totmalloc = 0;
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+
+ for (nu = nurbs->first; nu; nu = nu->next) {
+ if (nu->type == CU_BEZIER)
+ totmalloc += 3 * nu->pntsu;
+ else
+ totmalloc += nu->pntsu * nu->pntsv;
+ }
+ tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__);
+
+ nu = nurbs->first;
+ while (nu) {
+ if (nu->type == CU_BEZIER) {
+ a = nu->pntsu;
+ bezt = nu->bezt;
+ while (a--) {
+ if (bezt->hide == 0) {
+ int skip_handle = 0;
+ if (bezt->f2 & SELECT)
+ skip_handle = mode & TM_SKIP_HANDLES;
+
+ if ((bezt->f1 & SELECT) && !skip_handle) {
+ copy_v3_v3(tv->oldloc, bezt->vec[0]);
+ tv->loc = bezt->vec[0];
+ tv->flag = bezt->f1 & SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ if (bezt->f2 & SELECT) {
+ copy_v3_v3(tv->oldloc, bezt->vec[1]);
+ tv->loc = bezt->vec[1];
+ tv->val = &(bezt->alfa);
+ tv->oldval = bezt->alfa;
+ tv->flag = bezt->f2 & SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ if ((bezt->f3 & SELECT) && !skip_handle) {
+ copy_v3_v3(tv->oldloc, bezt->vec[2]);
+ tv->loc = bezt->vec[2];
+ tv->flag = bezt->f3 & SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ }
+ bezt++;
+ }
+ }
+ else {
+ a = nu->pntsu * nu->pntsv;
+ bp = nu->bp;
+ while (a--) {
+ if (bp->hide == 0) {
+ if (bp->f1 & SELECT) {
+ copy_v3_v3(tv->oldloc, bp->vec);
+ tv->loc = bp->vec;
+ tv->val = &(bp->alfa);
+ tv->oldval = bp->alfa;
+ tv->flag = bp->f1 & SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ }
+ bp++;
+ }
+ }
+ nu = nu->next;
+ }
+ }
+ else if (obedit->type == OB_MBALL) {
+ MetaBall *mb = obedit->data;
+ int totmalloc = BLI_countlist(mb->editelems);
+
+ tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__);
+
+ ml = mb->editelems->first;
+ while (ml) {
+ if (ml->flag & SELECT) {
+ tv->loc = &ml->x;
+ copy_v3_v3(tv->oldloc, tv->loc);
+ tv->val = &(ml->rad);
+ tv->oldval = ml->rad;
+ tv->flag = SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ ml = ml->next;
+ }
+ }
+ else if (obedit->type == OB_LATTICE) {
+ Lattice *lt = obedit->data;
+
+ bp = lt->editlatt->latt->def;
+
+ a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+
+ tv = tvs->transverts = MEM_callocN(a * sizeof(TransVert), __func__);
+
+ while (a--) {
+ if (bp->f1 & SELECT) {
+ if (bp->hide == 0) {
+ copy_v3_v3(tv->oldloc, bp->vec);
+ tv->loc = bp->vec;
+ tv->flag = bp->f1 & SELECT;
+ tv++;
+ tvs->transverts_tot++;
+ }
+ }
+ bp++;
+ }
+ }
+
+ if (!tvs->transverts_tot && tvs->transverts) {
+ /* prevent memory leak. happens for curves/latticies due to */
+ /* difficult condition of adding points to trans data */
+ MEM_freeN(tvs->transverts);
+ tvs->transverts = NULL;
+ }
+}
+
+void ED_transverts_free(TransVertStore *tvs)
+{
+ MEM_SAFE_FREE(tvs->transverts);
+ tvs->transverts_tot = 0;
+}
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 3e5f879aa3c..0feaf936172 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -114,16 +114,16 @@ void outputNumInput(NumInput *n, char *str)
}
}
-short hasNumInput(NumInput *n)
+bool hasNumInput(const NumInput *n)
{
short i;
for (i = 0; i <= n->idx_max; i++) {
if (n->ctrl[i])
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/**
@@ -159,7 +159,7 @@ void applyNumInput(NumInput *n, float *vec)
}
}
-char handleNumInput(NumInput *n, const wmEvent *event)
+bool handleNumInput(NumInput *n, const wmEvent *event)
{
float Val = 0;
short idx = n->idx, idx_max = n->idx_max;
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 8c299cccbc2..474348e84bc 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -924,7 +924,7 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first)
static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa, BMLoop *l)
{
UvMapVert *iterv, *first;
- first = EDBM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
+ first = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
for (iterv = first; iterv; iterv = iterv->next) {
if (iterv->separate)
@@ -953,7 +953,7 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1,
if (iterv1->f == iterv2->f) {
/* if face already tagged, don't do this edge */
- efa = EDBM_face_at_index(em, iterv1->f);
+ efa = BM_face_at_index(em->bm, iterv1->f);
if (BM_elem_flag_test(efa, BM_ELEM_TAG))
return false;
@@ -978,7 +978,7 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1,
break;
if (iterv1->f == iterv2->f) {
- efa = EDBM_face_at_index(em, iterv1->f);
+ efa = BM_face_at_index(em->bm, iterv1->f);
BM_elem_flag_enable(efa, BM_ELEM_TAG);
break;
}
@@ -1005,8 +1005,8 @@ static int uv_select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestH
const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
/* setup */
- EDBM_index_arrays_ensure(em, BM_FACE);
- vmap = EDBM_uv_vert_map_create(em, 0, limit);
+ BM_mesh_elem_table_ensure(em->bm, BM_FACE);
+ vmap = BM_uv_vert_map_create(em->bm, 0, limit);
BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
@@ -1085,7 +1085,7 @@ static int uv_select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestH
}
/* cleanup */
- EDBM_uv_vert_map_free(vmap);
+ BM_uv_vert_map_free(vmap);
return (select) ? 1 : -1;
}
@@ -1108,8 +1108,8 @@ static void uv_select_linked(Scene *scene, Image *ima, BMEditMesh *em, const flo
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
- EDBM_index_arrays_ensure(em, BM_FACE); /* we can use this too */
- vmap = EDBM_uv_vert_map_create(em, 1, limit);
+ BM_mesh_elem_table_ensure(em->bm, BM_FACE); /* we can use this too */
+ vmap = BM_uv_vert_map_create(em->bm, 1, limit);
if (vmap == NULL)
return;
@@ -1152,12 +1152,12 @@ static void uv_select_linked(Scene *scene, Image *ima, BMEditMesh *em, const flo
stacksize--;
a = stack[stacksize];
- efa = EDBM_face_at_index(em, a);
+ efa = BM_face_at_index(em->bm, a);
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
/* make_uv_vert_map_EM sets verts tmp.l to the indices */
- vlist = EDBM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
+ vlist = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
startv = vlist;
@@ -1241,7 +1241,7 @@ static void uv_select_linked(Scene *scene, Image *ima, BMEditMesh *em, const flo
MEM_freeN(stack);
MEM_freeN(flag);
- EDBM_uv_vert_map_free(vmap);
+ BM_uv_vert_map_free(vmap);
}
/* WATCH IT: this returns first selected UV,
@@ -2567,7 +2567,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, BMEditMes
uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
- vlist_iter = EDBM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
+ vlist_iter = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
while (vlist_iter) {
if (vlist_iter->separate)
@@ -2587,7 +2587,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, BMEditMes
if (efa_index != vlist_iter->f) {
BMLoop *l_other;
- efa_vlist = EDBM_face_at_index(em, vlist_iter->f);
+ efa_vlist = BM_face_at_index(em->bm, vlist_iter->f);
/* tf_vlist = BM_ELEM_CD_GET_VOID_P(efa_vlist, cd_poly_tex_offset); */ /* UNUSED */
l_other = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex);
@@ -2657,8 +2657,8 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object
uvedit_pixel_to_float(sima, limit, 0.05);
- EDBM_index_arrays_ensure(em, BM_FACE);
- vmap = EDBM_uv_vert_map_create(em, 0, limit);
+ BM_mesh_elem_table_ensure(em->bm, BM_FACE);
+ vmap = BM_uv_vert_map_create(em->bm, 0, limit);
if (vmap == NULL) {
return;
}
@@ -2673,7 +2673,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object
}
}
}
- EDBM_uv_vert_map_free(vmap);
+ BM_uv_vert_map_free(vmap);
}
else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */
@@ -2748,8 +2748,8 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object
uvedit_pixel_to_float(sima, limit, 0.05);
- EDBM_index_arrays_ensure(em, BM_FACE);
- vmap = EDBM_uv_vert_map_create(em, 0, limit);
+ BM_mesh_elem_table_ensure(em->bm, BM_FACE);
+ vmap = BM_uv_vert_map_create(em->bm, 0, limit);
if (vmap == NULL) {
return;
}
@@ -2764,7 +2764,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object
}
}
}
- EDBM_uv_vert_map_free(vmap);
+ BM_uv_vert_map_free(vmap);
}
else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */
@@ -3963,8 +3963,8 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
}
/* This code sets editvert->tmp.l to the index. This will be useful later on. */
- EDBM_index_arrays_ensure(em, BM_FACE);
- vmap = EDBM_uv_vert_map_create(em, 0, limit);
+ BM_mesh_elem_table_ensure(bm, BM_FACE);
+ vmap = BM_uv_vert_map_create(bm, 0, limit);
BM_ITER_MESH (editedge, &iter, bm, BM_EDGES_OF_MESH) {
/* flags to determine if we uv is separated from first editface match */
@@ -3992,14 +3992,14 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
v1coincident = 0;
separated2 = 0;
- efa1 = EDBM_face_at_index(em, mv1->f);
+ efa1 = BM_face_at_index(bm, mv1->f);
mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)];
for (mv2 = mvinit2; mv2; mv2 = mv2->next) {
if (mv2->separate)
mv2sep = mv2;
- efa2 = EDBM_face_at_index(em, mv2->f);
+ efa2 = BM_face_at_index(bm, mv2->f);
if (efa1 == efa2) {
/* if v1 is not coincident no point in comparing */
if (v1coincident) {
@@ -4042,7 +4042,7 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
me->drawflag |= ME_DRAWSEAMS;
- EDBM_uv_vert_map_free(vmap);
+ BM_uv_vert_map_free(vmap);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index f788c6a772c..28e28238ca9 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -600,7 +600,7 @@ static void state_delete(StitchState *state)
{
if (state) {
if (state->element_map) {
- EDBM_uv_element_map_free(state->element_map);
+ BM_uv_element_map_free(state->element_map);
}
if (state->uvs) {
MEM_freeN(state->uvs);
@@ -661,9 +661,9 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *
/* check to see if other vertex of edge belongs to same vertex as */
if (BM_elem_index_get(iter1->l->next->v) == elemindex2)
- iter2 = ED_uv_element_get(element_map, iter1->l->f, iter1->l->next);
+ iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->next);
else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2)
- iter2 = ED_uv_element_get(element_map, iter1->l->f, iter1->l->prev);
+ iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->prev);
if (iter2) {
int index1 = map[iter1 - first_element];
@@ -1017,7 +1017,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
/* copy data from MLoopUVs to the preview display buffers */
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
/* just to test if face was added for processing. uvs of inselected vertices will return NULL */
- UvElement *element = ED_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa));
+ UvElement *element = BM_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa));
if (element) {
int numoftris = efa->len - 2;
@@ -1568,8 +1568,8 @@ static UvEdge *uv_edge_get(BMLoop *l, StitchState *state)
{
UvEdge tmp_edge;
- UvElement *element1 = ED_uv_element_get(state->element_map, l->f, l);
- UvElement *element2 = ED_uv_element_get(state->element_map, l->f, l->next);
+ UvElement *element1 = BM_uv_element_get(state->element_map, l->f, l);
+ UvElement *element2 = BM_uv_element_get(state->element_map, l->f, l->next);
int uv1 = state->map[element1 - state->element_map->buf];
int uv2 = state->map[element2 - state->element_map->buf];
@@ -1613,10 +1613,7 @@ static int stitch_init(bContext *C, wmOperator *op)
if (!ar)
return 0;
- state = MEM_mallocN(sizeof(StitchState), "stitch state");
-
- if (!state)
- return 0;
+ state = MEM_callocN(sizeof(StitchState), "stitch state");
op->customdata = state;
@@ -1648,13 +1645,12 @@ static int stitch_init(bContext *C, wmOperator *op)
}
}
- state->draw_handle = ED_region_draw_cb_activate(ar->type, stitch_draw, state, REGION_DRAW_POST_VIEW);
/* in uv synch selection, all uv's are visible */
if (ts->uv_flag & UV_SYNC_SELECTION) {
- state->element_map = EDBM_uv_element_map_create(state->em, FALSE, TRUE);
+ state->element_map = BM_uv_element_map_create(state->em->bm, false, true);
}
else {
- state->element_map = EDBM_uv_element_map_create(state->em, TRUE, TRUE);
+ state->element_map = BM_uv_element_map_create(state->em->bm, true, true);
}
if (!state->element_map) {
state_delete(state);
@@ -1715,9 +1711,9 @@ static int stitch_init(bContext *C, wmOperator *op)
continue;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- UvElement *element = ED_uv_element_get(state->element_map, efa, l);
+ UvElement *element = BM_uv_element_get(state->element_map, efa, l);
int offset1, itmp1 = element - state->element_map->buf;
- int offset2, itmp2 = ED_uv_element_get(state->element_map, efa, l->next) - state->element_map->buf;
+ int offset2, itmp2 = BM_uv_element_get(state->element_map, efa, l->next) - state->element_map->buf;
UvEdge *edge;
offset1 = map[itmp1];
@@ -1814,7 +1810,7 @@ static int stitch_init(bContext *C, wmOperator *op)
UvElement *element;
enum StitchModes stored_mode = RNA_enum_get(op->ptr, "stored_mode");
- EDBM_index_arrays_ensure(em, BM_FACE);
+ BM_mesh_elem_table_ensure(em->bm, BM_FACE);
if (stored_mode == STITCH_VERT) {
state->selection_stack = MEM_mallocN(sizeof(*state->selection_stack) * state->total_separate_uvs, "uv_stitch_selection_stack");
@@ -1823,8 +1819,8 @@ static int stitch_init(bContext *C, wmOperator *op)
{
faceIndex = RNA_int_get(&itemptr, "face_index");
elementIndex = RNA_int_get(&itemptr, "element_index");
- efa = EDBM_face_at_index(em, faceIndex);
- element = ED_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex));
+ efa = BM_face_at_index(em->bm, faceIndex);
+ element = BM_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex));
stitch_select_uv(element, state, 1);
}
RNA_END;
@@ -1838,11 +1834,11 @@ static int stitch_init(bContext *C, wmOperator *op)
int uv1, uv2;
faceIndex = RNA_int_get(&itemptr, "face_index");
elementIndex = RNA_int_get(&itemptr, "element_index");
- efa = EDBM_face_at_index(em, faceIndex);
- element = ED_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex));
+ efa = BM_face_at_index(em->bm, faceIndex);
+ element = BM_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex));
uv1 = map[element - state->element_map->buf];
- element = ED_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, (elementIndex + 1) % efa->len));
+ element = BM_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, (elementIndex + 1) % efa->len));
uv2 = map[element - state->element_map->buf];
if (uv1 < uv2) {
@@ -1877,7 +1873,7 @@ static int stitch_init(bContext *C, wmOperator *op)
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
- UvElement *element = ED_uv_element_get(state->element_map, efa, l);
+ UvElement *element = BM_uv_element_get(state->element_map, efa, l);
if (element) {
stitch_select_uv(element, state, 1);
}
@@ -1913,7 +1909,7 @@ static int stitch_init(bContext *C, wmOperator *op)
}
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- UvElement *element = ED_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa));
+ UvElement *element = BM_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa));
if (element) {
state->tris_per_island[element->island] += (efa->len > 2) ? efa->len - 2 : 0;
@@ -1926,6 +1922,8 @@ static int stitch_init(bContext *C, wmOperator *op)
return 0;
}
+ state->draw_handle = ED_region_draw_cb_activate(ar->type, stitch_draw, state, REGION_DRAW_POST_VIEW);
+
stitch_update_header(state, C);
return 1;
}
@@ -1998,10 +1996,9 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
}
-static int stitch_cancel(bContext *C, wmOperator *op)
+static void stitch_cancel(bContext *C, wmOperator *op)
{
stitch_exit(C, op, 0);
- return OPERATOR_CANCELLED;
}
@@ -2016,7 +2013,8 @@ static int stitch_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
}
@@ -2039,7 +2037,7 @@ static void stitch_select(bContext *C, Scene *scene, const wmEvent *event, Stitc
* you can do stuff like deselect the opposite stitchable vertex and the initial still gets deselected */
/* This works due to setting of tmp in find nearest uv vert */
- UvElement *element = ED_uv_element_get(state->element_map, hit.efa, hit.l);
+ UvElement *element = BM_uv_element_get(state->element_map, hit.efa, hit.l);
stitch_select_uv(element, state, FALSE);
}
@@ -2067,8 +2065,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Cancel */
case ESCKEY:
- return stitch_cancel(C, op);
-
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
case LEFTMOUSE:
if (event->shift && (U.flag & USER_LMOUSESELECT)) {
@@ -2076,7 +2074,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
stitch_select(C, scene, event, state);
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
}
break;
@@ -2089,7 +2088,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
else {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
}
else {
@@ -2101,7 +2101,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS && event->alt) {
state->limit_dist += 0.01f;
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
break;
}
@@ -2115,7 +2116,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
state->limit_dist -= 0.01f;
state->limit_dist = MAX2(0.01f, state->limit_dist);
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
break;
}
@@ -2128,7 +2130,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
state->use_limit = !state->use_limit;
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
break;
}
@@ -2140,7 +2143,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
state->static_island %= state->element_map->totalIslands;
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
break;
}
@@ -2150,7 +2154,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
state->midpoints = !state->midpoints;
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
}
break;
@@ -2158,13 +2163,15 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Select geometry*/
case RIGHTMOUSE:
if (!event->shift) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
if (event->val == KM_PRESS && !(U.flag & USER_LMOUSESELECT)) {
stitch_select(C, scene, event, state);
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
break;
}
@@ -2175,7 +2182,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
state->snap_islands = !state->snap_islands;
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
break;
}
@@ -2189,7 +2197,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event)
stitch_switch_selection_mode(state);
if (!stitch_process_data(state, scene, FALSE)) {
- return stitch_cancel(C, op);
+ stitch_cancel(C, op);
+ return OPERATOR_CANCELLED;
}
}
break;
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 87cc42001d6..d6bd6f466b9 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -421,11 +421,11 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
faceMap = MEM_mallocN(numOfFaces * sizeof(BMFace *), "unwrap_edit_face_map");
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
- EDBM_index_arrays_ensure(em, BM_EDGE | BM_FACE);
+ BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_FACE);
/* map subsurfed faces to original editFaces */
for (i = 0; i < numOfFaces; i++)
- faceMap[i] = EDBM_face_at_index(em, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i));
+ faceMap[i] = BM_face_at_index(em->bm, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i));
edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map");
@@ -433,7 +433,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
for (i = 0; i < numOfEdges; i++) {
/* not all edges correspond to an old edge */
edgeMap[i] = (origEdgeIndices[i] != ORIGINDEX_NONE) ?
- EDBM_edge_at_index(em, origEdgeIndices[i]) : NULL;
+ BM_edge_at_index(em->bm, origEdgeIndices[i]) : NULL;
}
/* Prepare and feed faces to the solver */
@@ -542,7 +542,7 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op)
return true;
}
-static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interactive)
+static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interactive)
{
MinStretch *ms = op->customdata;
ScrArea *sa = CTX_wm_area(C);
@@ -570,7 +570,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact
}
}
-static void minimize_stretch_exit(bContext *C, wmOperator *op, int cancel)
+static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
{
MinStretch *ms = op->customdata;
ScrArea *sa = CTX_wm_area(C);
@@ -604,8 +604,8 @@ static int minimize_stretch_exec(bContext *C, wmOperator *op)
iterations = RNA_int_get(op->ptr, "iterations");
for (i = 0; i < iterations; i++)
- minimize_stretch_iteration(C, op, 0);
- minimize_stretch_exit(C, op, 0);
+ minimize_stretch_iteration(C, op, false);
+ minimize_stretch_exit(C, op, false);
return OPERATOR_FINISHED;
}
@@ -617,7 +617,7 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, const wmEvent *U
if (!minimize_stretch_init(C, op))
return OPERATOR_CANCELLED;
- minimize_stretch_iteration(C, op, 1);
+ minimize_stretch_iteration(C, op, true);
ms = op->customdata;
WM_event_add_modal_handler(C, op);
@@ -633,12 +633,12 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
- minimize_stretch_exit(C, op, 1);
+ minimize_stretch_exit(C, op, true);
return OPERATOR_CANCELLED;
case RETKEY:
case PADENTER:
case LEFTMOUSE:
- minimize_stretch_exit(C, op, 0);
+ minimize_stretch_exit(C, op, false);
return OPERATOR_FINISHED;
case PADPLUSKEY:
case WHEELUPMOUSE:
@@ -647,7 +647,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev
ms->blend += 0.1f;
ms->lasttime = 0.0f;
RNA_float_set(op->ptr, "blend", ms->blend);
- minimize_stretch_iteration(C, op, 1);
+ minimize_stretch_iteration(C, op, true);
}
}
break;
@@ -658,7 +658,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev
ms->blend -= 0.1f;
ms->lasttime = 0.0f;
RNA_float_set(op->ptr, "blend", ms->blend);
- minimize_stretch_iteration(C, op, 1);
+ minimize_stretch_iteration(C, op, true);
}
}
break;
@@ -667,25 +667,23 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev
double start = PIL_check_seconds_timer();
do {
- minimize_stretch_iteration(C, op, 1);
+ minimize_stretch_iteration(C, op, true);
} while (PIL_check_seconds_timer() - start < 0.01);
}
break;
}
if (ms->iterations && ms->i >= ms->iterations) {
- minimize_stretch_exit(C, op, 0);
+ minimize_stretch_exit(C, op, false);
return OPERATOR_FINISHED;
}
return OPERATOR_RUNNING_MODAL;
}
-static int minimize_stretch_cancel(bContext *C, wmOperator *op)
+static void minimize_stretch_cancel(bContext *C, wmOperator *op)
{
- minimize_stretch_exit(C, op, 1);
-
- return OPERATOR_CANCELLED;
+ minimize_stretch_exit(C, op, true);
}
void UV_OT_minimize_stretch(wmOperatorType *ot)
@@ -890,7 +888,7 @@ static void uv_map_transform_center(Scene *scene, View3D *v3d, float *result,
}
case V3D_CURSOR: /* cursor center */
{
- const float *curs = give_cursor(scene, v3d);
+ const float *curs = ED_view3d_cursor3d_get(scene, v3d);
/* shift to objects world */
sub_v3_v3v3(result, curs, ob->obmat[3]);
break;
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index c61f72295d2..81034c1502c 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -204,7 +204,6 @@ void Controller::setPassZ(float *buf, int width, int height)
void Controller::setContext(bContext *C)
{
PythonInterpreter *py_inter = dynamic_cast<PythonInterpreter*>(_inter);
- assert(py_inter != 0);
py_inter->setContext(C);
}
diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h
index a1368f1ea21..070bee047a9 100644
--- a/source/blender/freestyle/intern/geometry/Grid.h
+++ b/source/blender/freestyle/intern/geometry/Grid.h
@@ -261,7 +261,7 @@ public:
/*! inserts a convex polygon occluder
* This method is quite coarse insofar as it adds all cells intersecting the polygon bounding box
* convex_poly
- * The list of 3D points constituing a convex polygon
+ * The list of 3D points constituting a convex polygon
*/
void insertOccluder(Polygon3r *convex_poly);
diff --git a/source/blender/freestyle/intern/geometry/Noise.cpp b/source/blender/freestyle/intern/geometry/Noise.cpp
index b21ded9dd95..8ec56e84f95 100644
--- a/source/blender/freestyle/intern/geometry/Noise.cpp
+++ b/source/blender/freestyle/intern/geometry/Noise.cpp
@@ -62,10 +62,10 @@ namespace Freestyle {
#define SETUP(i, b0, b1, r0, r1) \
{ \
(t) = (i) + (N); \
- (b0) = ((int)(t)) & BM; \
- (b1) = ((b0) + 1) & BM; \
- (r0) = (t) - (int)(t); \
+ (r0) = modff((t), &(u)); \
(r1) = (r0) - 1.0; \
+ (b0) = ((int)(u)) & BM; \
+ (b1) = ((b0) + 1) & BM; \
} (void)0
static void normalize2(float v[2])
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 3b1232c51af..56c096a1eae 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -512,93 +512,100 @@ Nature::EdgeNature EdgeNature_from_BPy_Nature(PyObject *obj)
return static_cast<Nature::EdgeNature>(PyLong_AsLong(obj));
}
-Vec2f *Vec2f_ptr_from_PyObject(PyObject *obj)
-{
- Vec2f *v;
- if ((v = Vec2f_ptr_from_Vector(obj)))
- return v;
- if ((v = Vec2f_ptr_from_PyList(obj)))
- return v;
- if ((v = Vec2f_ptr_from_PyTuple(obj)))
- return v;
- return NULL;
+bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f *vec)
+{
+ if (Vec2f_ptr_from_Vector(obj, vec))
+ return true;
+ if (Vec2f_ptr_from_PyList(obj, vec))
+ return true;
+ if (Vec2f_ptr_from_PyTuple(obj, vec))
+ return true;
+ return false;
}
-Vec3f *Vec3f_ptr_from_PyObject(PyObject *obj)
+bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f *vec)
{
- Vec3f *v;
- if ((v = Vec3f_ptr_from_Vector(obj)))
- return v;
- if ((v = Vec3f_ptr_from_Color(obj)))
- return v;
- if ((v = Vec3f_ptr_from_PyList(obj)))
- return v;
- if ((v = Vec3f_ptr_from_PyTuple(obj)))
- return v;
- return NULL;
+ if (Vec3f_ptr_from_Vector(obj, vec))
+ return true;
+ if (Vec3f_ptr_from_Color(obj, vec))
+ return true;
+ if (Vec3f_ptr_from_PyList(obj, vec))
+ return true;
+ if (Vec3f_ptr_from_PyTuple(obj, vec))
+ return true;
+ return false;
}
-Vec3r *Vec3r_ptr_from_PyObject(PyObject *obj)
+bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r *vec)
{
- Vec3r *v;
- if ((v = Vec3r_ptr_from_Vector(obj)))
- return v;
- if ((v = Vec3r_ptr_from_Color(obj)))
- return v;
- if ((v = Vec3r_ptr_from_PyList(obj)))
- return v;
- if ((v = Vec3r_ptr_from_PyTuple(obj)))
- return v;
- return NULL;
+ if (Vec3r_ptr_from_Vector(obj, vec))
+ return true;
+ if (Vec3r_ptr_from_Color(obj, vec))
+ return true;
+ if (Vec3r_ptr_from_PyList(obj, vec))
+ return true;
+ if (Vec3r_ptr_from_PyTuple(obj, vec))
+ return true;
+ return false;
}
-Vec2f *Vec2f_ptr_from_Vector(PyObject *obj)
+bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f *vec)
{
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2)
- return NULL;
- float x = ((VectorObject *)obj)->vec[0];
- float y = ((VectorObject *)obj)->vec[1];
- return new Vec2f(x, y);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((VectorObject *)obj)->vec[0];
+ vec[1] = ((VectorObject *)obj)->vec[1];
+ return true;
}
-Vec3f *Vec3f_ptr_from_Vector(PyObject *obj)
+bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f *vec)
{
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
- return NULL;
- float x = ((VectorObject *)obj)->vec[0];
- float y = ((VectorObject *)obj)->vec[1];
- float z = ((VectorObject *)obj)->vec[2];
- return new Vec3f(x, y, z);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((VectorObject *)obj)->vec[0];
+ vec[1] = ((VectorObject *)obj)->vec[1];
+ vec[2] = ((VectorObject *)obj)->vec[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_Vector(PyObject *obj)
+bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r *vec)
{
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
- return NULL;
- real x = ((VectorObject *)obj)->vec[0];
- real y = ((VectorObject *)obj)->vec[1];
- real z = ((VectorObject *)obj)->vec[2];
- return new Vec3r(x, y, z);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((VectorObject *)obj)->vec[0];
+ vec[1] = ((VectorObject *)obj)->vec[1];
+ vec[2] = ((VectorObject *)obj)->vec[2];
+ return true;
}
-Vec3f *Vec3f_ptr_from_Color(PyObject *obj)
+bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f *vec)
{
if (!ColorObject_Check(obj))
- return NULL;
- float r = ((ColorObject *)obj)->col[0];
- float g = ((ColorObject *)obj)->col[1];
- float b = ((ColorObject *)obj)->col[2];
- return new Vec3f(r, g, b);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((ColorObject *)obj)->col[0];
+ vec[1] = ((ColorObject *)obj)->col[1];
+ vec[2] = ((ColorObject *)obj)->col[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_Color(PyObject *obj)
+bool Vec3r_ptr_from_Color(PyObject *obj, Vec3r *vec)
{
if (!ColorObject_Check(obj))
- return NULL;
- real r = ((ColorObject *)obj)->col[0];
- real g = ((ColorObject *)obj)->col[1];
- real b = ((ColorObject *)obj)->col[2];
- return new Vec3r(r, g, b);
+ return false;
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return false;
+ vec[0] = ((ColorObject *)obj)->col[0];
+ vec[1] = ((ColorObject *)obj)->col[1];
+ vec[2] = ((ColorObject *)obj)->col[2];
+ return true;
}
static int float_array_from_PyList(PyObject *obj, float *v, int n)
@@ -613,37 +620,45 @@ static int float_array_from_PyList(PyObject *obj, float *v, int n)
return 1;
}
-Vec2f *Vec2f_ptr_from_PyList(PyObject *obj)
+bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f *vec)
{
float v[2];
if (!PyList_Check(obj) || PyList_Size(obj) != 2)
- return NULL;
+ return false;
if (!float_array_from_PyList(obj, v, 2))
- return NULL;
- return new Vec2f(v[0], v[1]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ return true;
}
-Vec3f *Vec3f_ptr_from_PyList(PyObject *obj)
+bool Vec3f_ptr_from_PyList(PyObject *obj, Vec3f *vec)
{
float v[3];
if (!PyList_Check(obj) || PyList_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyList(obj, v, 3))
- return NULL;
- return new Vec3f(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_PyList(PyObject *obj)
+bool Vec3r_ptr_from_PyList(PyObject *obj, Vec3r *vec)
{
float v[3];
if (!PyList_Check(obj) || PyList_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyList(obj, v, 3))
- return NULL;
- return new Vec3r(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
static int float_array_from_PyTuple(PyObject *obj, float *v, int n)
@@ -658,37 +673,45 @@ static int float_array_from_PyTuple(PyObject *obj, float *v, int n)
return 1;
}
-Vec2f *Vec2f_ptr_from_PyTuple(PyObject *obj)
+bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f *vec)
{
float v[2];
if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 2)
- return NULL;
+ return false;
if (!float_array_from_PyTuple(obj, v, 2))
- return NULL;
- return new Vec2f(v[0], v[1]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ return true;
}
-Vec3f *Vec3f_ptr_from_PyTuple(PyObject *obj)
+bool Vec3f_ptr_from_PyTuple(PyObject *obj, Vec3f *vec)
{
float v[3];
if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyTuple(obj, v, 3))
- return NULL;
- return new Vec3f(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
-Vec3r *Vec3r_ptr_from_PyTuple(PyObject *obj)
+bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r *vec)
{
float v[3];
if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3)
- return NULL;
+ return false;
if (!float_array_from_PyTuple(obj, v, 3))
- return NULL;
- return new Vec3r(v[0], v[1], v[2]);
+ return false;
+ vec[0] = v[0];
+ vec[1] = v[1];
+ vec[2] = v[2];
+ return true;
}
// helper for argument parsing
@@ -696,10 +719,19 @@ Vec3r *Vec3r_ptr_from_PyTuple(PyObject *obj)
int float_array_from_PyObject(PyObject *obj, float *v, int n)
{
if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) {
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return 0;
for (int i = 0; i < n; i++)
v[i] = ((VectorObject *)obj)->vec[i];
return 1;
}
+ else if (ColorObject_Check(obj) && n == 3) {
+ if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
+ return 0;
+ for (int i = 0; i < n; i++)
+ v[i] = ((ColorObject *)obj)->col[i];
+ return 1;
+ }
else if (PyList_Check(obj) && PyList_Size(obj) == n) {
return float_array_from_PyList(obj, v, n);
}
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h
index 1df4901757b..a8bc7eaa306 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.h
+++ b/source/blender/freestyle/intern/python/BPy_Convert.h
@@ -150,20 +150,20 @@ bool bool_from_PyBool(PyObject *b);
IntegrationType IntegrationType_from_BPy_IntegrationType(PyObject *obj);
Stroke::MediumType MediumType_from_BPy_MediumType(PyObject *obj);
Nature::EdgeNature EdgeNature_from_BPy_Nature(PyObject *obj);
-Vec2f * Vec2f_ptr_from_PyObject(PyObject *obj);
-Vec3f * Vec3f_ptr_from_PyObject(PyObject *obj);
-Vec3r * Vec3r_ptr_from_PyObject(PyObject *obj);
-Vec2f * Vec2f_ptr_from_Vector(PyObject *obj);
-Vec3f * Vec3f_ptr_from_Vector(PyObject *obj);
-Vec3r * Vec3r_ptr_from_Vector(PyObject *obj);
-Vec3f * Vec3f_ptr_from_Color(PyObject *obj);
-Vec3r * Vec3r_ptr_from_Color(PyObject *obj);
-Vec2f * Vec2f_ptr_from_PyList(PyObject *obj);
-Vec3f * Vec3f_ptr_from_PyList(PyObject *obj);
-Vec3r * Vec3r_ptr_from_PyList(PyObject *obj);
-Vec2f * Vec2f_ptr_from_PyTuple(PyObject *obj);
-Vec3f * Vec3f_ptr_from_PyTuple(PyObject *obj);
-Vec3r * Vec3r_ptr_from_PyTuple(PyObject *obj);
+bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f *vec);
+bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f *vec);
+bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r *vec);
+bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f *vec);
+bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f *vec);
+bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r *vec);
+bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f *vec);
+bool Vec3r_ptr_from_Color(PyObject *obj, Vec3r *vec);
+bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f *vec);
+bool Vec3f_ptr_from_PyList(PyObject *obj, Vec3f *vec);
+bool Vec3r_ptr_from_PyList(PyObject *obj, Vec3r *vec);
+bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f *vec);
+bool Vec3f_ptr_from_PyTuple(PyObject *obj, Vec3f *vec);
+bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r *vec);
int float_array_from_PyObject(PyObject *obj, float *v, int n);
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
index 680f399cc77..fb678d7ea66 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
@@ -101,8 +101,8 @@ static int ramp_blend_type(const char *type)
if (!strcmp(type, "SATURATION")) return MA_RAMP_SAT;
if (!strcmp(type, "VALUE")) return MA_RAMP_VAL;
if (!strcmp(type, "COLOR")) return MA_RAMP_COLOR;
- if (!strcmp(type, "SOFT LIGHT")) return MA_RAMP_SOFT;
- if (!strcmp(type, "LINEAR LIGHT")) return MA_RAMP_LINEAR;
+ if (!strcmp(type, "SOFT_LIGHT")) return MA_RAMP_SOFT;
+ if (!strcmp(type, "LINEAR_LIGHT")) return MA_RAMP_LINEAR;
return -1;
}
@@ -129,7 +129,6 @@ static PyObject *Freestyle_blendRamp(PyObject *self, PyObject *args)
PyObject *obj1, *obj2;
char *s;
int type;
- Vec3f *v1 = NULL, *v2 = NULL;
float a[3], fac, b[3];
if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2))
@@ -137,32 +136,20 @@ static PyObject *Freestyle_blendRamp(PyObject *self, PyObject *args)
type = ramp_blend_type(s);
if (type < 0) {
PyErr_SetString(PyExc_TypeError, "argument 1 is an unknown ramp blend type");
- goto error;
+ return NULL;
}
- v1 = Vec3f_ptr_from_PyObject(obj1);
- if (!v1) {
+ if (!float_array_from_PyObject(obj1, a, 3)) {
PyErr_SetString(PyExc_TypeError,
"argument 2 must be a 3D vector (either a tuple/list of 3 elements or Vector)");
- goto error;
+ return NULL;
}
- v2 = Vec3f_ptr_from_PyObject(obj2);
- if (!v2) {
+ if (!float_array_from_PyObject(obj2, b, 3)) {
PyErr_SetString(PyExc_TypeError,
"argument 4 must be a 3D vector (either a tuple/list of 3 elements or Vector)");
- goto error;
+ return NULL;
}
- a[0] = v1->x(); b[0] = v2->x();
- a[1] = v1->y(); b[1] = v2->y();
- a[2] = v1->z(); b[2] = v2->z();
ramp_blend(type, a, fac, b);
- delete v1;
- delete v2;
return Vector_CreatePyObject(a, 3, Py_NEW, NULL);
-
-error:
- if (v1) delete v1;
- if (v2) delete v2;
- return NULL;
}
#include "BKE_texture.h" /* do_colorband() */
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
index abdcbaff6e1..2575b16b27a 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
@@ -132,16 +132,15 @@ static PyObject *FrsNoise_turbulence2(BPy_FrsNoise *self, PyObject *args, PyObje
PyObject *obj1;
float f2, f3;
unsigned int i = 4;
+ Vec2f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i))
return NULL;
- Vec2f *v = Vec2f_ptr_from_PyObject(obj1);
- if (!v) {
+ if (!Vec2f_ptr_from_PyObject(obj1, &vec)) {
PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
return NULL;
}
- float t = self->n->turbulence2(*v, f2, f3, i);
- delete v;
+ float t = self->n->turbulence2(vec, f2, f3, i);
return PyFloat_FromDouble(t);
}
@@ -167,16 +166,15 @@ static PyObject *FrsNoise_turbulence3(BPy_FrsNoise *self, PyObject *args, PyObje
PyObject *obj1;
float f2, f3;
unsigned int i = 4;
+ Vec3f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i))
return NULL;
- Vec3f *v = Vec3f_ptr_from_PyObject(obj1);
- if (!v) {
+ if (!Vec3f_ptr_from_PyObject(obj1, &vec)) {
PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
return NULL;
}
- float t = self->n->turbulence3(*v, f2, f3, i);
- delete v;
+ float t = self->n->turbulence3(vec, f2, f3, i);
return PyFloat_FromDouble(t);
}
@@ -214,16 +212,15 @@ static PyObject *FrsNoise_smoothNoise2(BPy_FrsNoise *self, PyObject *args, PyObj
{
static const char *kwlist[] = {"v", NULL};
PyObject *obj;
+ Vec2f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj))
return NULL;
- Vec2f *v = Vec2f_ptr_from_PyObject(obj);
- if (!v) {
+ if (!Vec2f_ptr_from_PyObject(obj, &vec)) {
PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
return NULL;
}
- float t = self->n->smoothNoise2(*v);
- delete v;
+ float t = self->n->smoothNoise2(vec);
return PyFloat_FromDouble(t);
}
@@ -241,16 +238,15 @@ static PyObject *FrsNoise_smoothNoise3(BPy_FrsNoise *self, PyObject *args, PyObj
{
static const char *kwlist[] = {"v", NULL};
PyObject *obj;
+ Vec3f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj))
return NULL;
- Vec3f *v = Vec3f_ptr_from_PyObject(obj);
- if (!v) {
+ if (!Vec3f_ptr_from_PyObject(obj, &vec)) {
PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
return NULL;
}
- float t = self->n->smoothNoise3(*v);
- delete v;
+ float t = self->n->smoothNoise3(vec);
return PyFloat_FromDouble(t);
}
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index e17f16a2fa7..b08fcfa8dba 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -311,16 +311,15 @@ static PyObject * StrokeAttribute_set_attribute_vec2(BPy_StrokeAttribute *self,
static const char *kwlist[] = {"name", "value", NULL};
char *s;
PyObject *obj = 0;
+ Vec2f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj))
return NULL;
- Vec2f *v = Vec2f_ptr_from_PyObject(obj);
- if (!v) {
+ if (!Vec2f_ptr_from_PyObject(obj, &vec)) {
PyErr_SetString(PyExc_TypeError, "argument 2 must be a 2D vector (either a list of 2 elements or Vector)");
return NULL;
}
- self->sa->setAttributeVec2f(s, *v);
- delete v;
+ self->sa->setAttributeVec2f(s, vec);
Py_RETURN_NONE;
}
@@ -341,16 +340,15 @@ static PyObject * StrokeAttribute_set_attribute_vec3(BPy_StrokeAttribute *self,
static const char *kwlist[] = {"name", "value", NULL};
char *s;
PyObject *obj = 0;
+ Vec3f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj))
return NULL;
- Vec3f *v = Vec3f_ptr_from_PyObject(obj);
- if (!v) {
+ if (!Vec3f_ptr_from_PyObject(obj, &vec)) {
PyErr_SetString(PyExc_TypeError, "argument 2 must be a 3D vector (either a list of 3 elements or Vector)");
return NULL;
}
- self->sa->setAttributeVec3f(s, *v);
- delete v;
+ self->sa->setAttributeVec3f(s, vec);
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp
index cd6f9da3e05..011609bb343 100644
--- a/source/blender/freestyle/intern/python/Director.cpp
+++ b/source/blender/freestyle/intern/python/Director.cpp
@@ -251,14 +251,16 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0D
((UnaryFunction0D<unsigned> *)uf0D)->result = PyLong_AsLong(result);
}
else if (BPy_UnaryFunction0DVec2f_Check(obj)) {
- Vec2f *v = Vec2f_ptr_from_Vector(result);
- ((UnaryFunction0D<Vec2f> *)uf0D)->result = *v;
- delete v;
+ Vec2f vec;
+ if (!Vec2f_ptr_from_Vector(result, &vec))
+ return -1;
+ ((UnaryFunction0D<Vec2f> *)uf0D)->result = vec;
}
else if (BPy_UnaryFunction0DVec3f_Check(obj)) {
- Vec3f *v = Vec3f_ptr_from_Vector(result);
- ((UnaryFunction0D<Vec3f> *)uf0D)->result = *v;
- delete v;
+ Vec3f vec;
+ if (!Vec3f_ptr_from_Vector(result, &vec))
+ return -1;
+ ((UnaryFunction0D<Vec3f> *)uf0D)->result = vec;
}
else if (BPy_UnaryFunction0DVectorViewShape_Check(obj)) {
vector<ViewShape*> vec;
@@ -301,14 +303,16 @@ int Director_BPy_UnaryFunction1D___call__(void *uf1D, PyObject *obj, Interface1D
((UnaryFunction1D<unsigned> *)uf1D)->result = PyLong_AsLong(result);
}
else if (BPy_UnaryFunction1DVec2f_Check(obj)) {
- Vec2f *v = Vec2f_ptr_from_Vector(result);
- ((UnaryFunction1D<Vec2f> *)uf1D)->result = *v;
- delete v;
+ Vec2f vec;
+ if (!Vec2f_ptr_from_Vector(result, &vec))
+ return -1;
+ ((UnaryFunction1D<Vec2f> *)uf1D)->result = vec;
}
else if (BPy_UnaryFunction1DVec3f_Check(obj)) {
- Vec3f *v = Vec3f_ptr_from_Vector(result);
- ((UnaryFunction1D<Vec3f> *)uf1D)->result = *v;
- delete v;
+ Vec3f vec;
+ if (!Vec3f_ptr_from_Vector(result, &vec))
+ return -1;
+ ((UnaryFunction1D<Vec3f> *)uf1D)->result = vec;
}
else if (BPy_UnaryFunction1DVectorViewShape_Check(obj)) {
vector<ViewShape*> vec;
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
index 3205a3a3d7e..d2dd1657770 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
@@ -107,17 +107,15 @@ static PyObject *SVertex_add_normal(BPy_SVertex *self, PyObject *args, PyObject
{
static const char *kwlist[] = {"normal", NULL};
PyObject *py_normal;
+ Vec3r n;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_normal))
return NULL;
- Vec3r *n = Vec3r_ptr_from_PyObject(py_normal);
- if (!n) {
+ if (!Vec3r_ptr_from_PyObject(py_normal, &n)) {
PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
return NULL;
}
- self->sv->AddNormal(*n);
- delete n;
-
+ self->sv->AddNormal(n);
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
index 50d54df2ead..9bbb0405e49 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
@@ -167,7 +167,7 @@ static PyObject *FrsCurve_is_empty_get(BPy_FrsCurve *self, void *UNUSED(closure)
}
PyDoc_STRVAR(FrsCurve_segments_size_doc,
-"The number of segments in the polyline constituing the Curve.\n"
+"The number of segments in the polyline constituting the Curve.\n"
"\n"
":type: int");
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
index 3e4e7e3aef3..80765e794fb 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
@@ -283,7 +283,7 @@ static PyObject *Stroke_stroke_vertices_end(BPy_Stroke *self)
PyDoc_STRVAR(Stroke_stroke_vertices_size_doc,
".. method:: stroke_vertices_size()\n"
"\n"
-" Returns the number of StrokeVertex constituing the Stroke.\n"
+" Returns the number of StrokeVertex constituting the Stroke.\n"
"\n"
" :return: The number of stroke vertices.\n"
" :rtype: int");
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
index 510875ebb2f..292729782ec 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
@@ -115,6 +115,10 @@ PyDoc_STRVAR(AdjacencyIterator_object_doc,
static PyObject *AdjacencyIterator_object_get(BPy_AdjacencyIterator *self, void *UNUSED(closure))
{
+ if (self->a_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
ViewEdge *ve = self->a_it->operator*();
if (ve)
return BPy_ViewEdge_from_ViewEdge(*ve);
@@ -129,6 +133,10 @@ PyDoc_STRVAR(AdjacencyIterator_is_incoming_doc,
static PyObject *AdjacencyIterator_is_incoming_get(BPy_AdjacencyIterator *self, void *UNUSED(closure))
{
+ if (self->a_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
return PyBool_from_bool(self->a_it->isIncoming());
}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
index 2b8b4eec4dd..99ac72db028 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
@@ -104,7 +104,7 @@ PyDoc_STRVAR(ChainPredicateIterator_doc,
static int check_begin(PyObject *obj, void *v)
{
- if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj))
+ if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj))
return 0;
*((PyObject **)v) = obj;
return 1;
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
index b723631f365..1a082ac93bb 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
@@ -74,7 +74,7 @@ PyDoc_STRVAR(ChainSilhouetteIterator_doc,
static int check_begin(PyObject *obj, void *v)
{
- if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj))
+ if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj))
return 0;
*((PyObject **)v) = obj;
return 1;
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
index 3e2f0102dc3..1dadfbced03 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
@@ -75,7 +75,7 @@ PyDoc_STRVAR(ChainingIterator_doc,
static int check_begin(PyObject *obj, void *v)
{
- if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj))
+ if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj))
return 0;
*((PyObject **)v) = obj;
return 1;
@@ -175,6 +175,10 @@ PyDoc_STRVAR(ChainingIterator_object_doc,
static PyObject *ChainingIterator_object_get(BPy_ChainingIterator *self, void *UNUSED(closure))
{
+ if (self->c_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
ViewEdge *ve = self->c_it->operator*();
if (ve)
return BPy_ViewEdge_from_ViewEdge(*ve);
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
index 3e45ef17c1b..0329aa99acc 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
@@ -97,6 +97,10 @@ PyDoc_STRVAR(CurvePointIterator_object_doc,
static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, void *UNUSED(closure))
{
+ if (self->cp_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*());
}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index 3a537eb672a..3a246263efa 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -123,6 +123,10 @@ PyDoc_STRVAR(Interface0DIterator_object_doc,
static PyObject *Interface0DIterator_object_get(BPy_Interface0DIterator *self, void *UNUSED(closure))
{
+ if (self->if0D_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
return Any_BPy_Interface0D_from_Interface0D(self->if0D_it->operator*());
}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
index d493b6c158b..ccf52c64757 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
@@ -115,6 +115,10 @@ PyDoc_STRVAR(SVertexIterator_object_doc,
static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void *UNUSED(closure))
{
+ if (self->sv_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
SVertex *sv = self->sv_it->operator->();
if (sv)
return BPy_SVertex_from_SVertex(*sv);
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
index 3174980b7d9..8287e280186 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -109,8 +109,10 @@ PyDoc_STRVAR(StrokeVertexIterator_object_doc,
static PyObject *StrokeVertexIterator_object_get(BPy_StrokeVertexIterator *self, void *UNUSED(closure))
{
- if (!self->reversed && self->sv_it->isEnd())
- Py_RETURN_NONE;
+ if (!self->reversed && self->sv_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
StrokeVertex *sv = self->sv_it->operator->();
if (sv)
return BPy_StrokeVertex_from_StrokeVertex(*sv);
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
index f30621f01e3..4a45be8caa5 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
@@ -65,7 +65,7 @@ PyDoc_STRVAR(ViewEdgeIterator_doc,
static int check_begin(PyObject *obj, void *v)
{
- if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj))
+ if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj))
return 0;
*((PyObject **)v) = obj;
return 1;
@@ -122,6 +122,10 @@ PyDoc_STRVAR(ViewEdgeIterator_object_doc,
static PyObject *ViewEdgeIterator_object_get(BPy_ViewEdgeIterator *self, void *UNUSED(closure))
{
+ if (!self->ve_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
ViewEdge *ve = self->ve_it->operator*();
if (ve)
return BPy_ViewEdge_from_ViewEdge(*ve);
@@ -138,7 +142,8 @@ static PyObject *ViewEdgeIterator_current_edge_get(BPy_ViewEdgeIterator *self, v
ViewEdge *ve = self->ve_it->getCurrentEdge();
if (ve)
return BPy_ViewEdge_from_ViewEdge(*ve);
- Py_RETURN_NONE;}
+ Py_RETURN_NONE;
+}
static int ViewEdgeIterator_current_edge_set(BPy_ViewEdgeIterator *self, PyObject *value, void *UNUSED(closure))
{
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
index f2b0e604c22..12ca3d6cc4a 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
@@ -103,6 +103,10 @@ PyDoc_STRVAR(orientedViewEdgeIterator_object_doc,
static PyObject *orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterator *self, void *UNUSED(closure))
{
+ if (self->ove_it->isEnd()) {
+ PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
+ return NULL;
+ }
return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*());
}
diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h
index 68da744d7b3..7e3b6732bff 100644
--- a/source/blender/freestyle/intern/stroke/Curve.h
+++ b/source/blender/freestyle/intern/stroke/Curve.h
@@ -491,7 +491,7 @@ public:
return _Id;
}
- /*! Returns the number of segments in the polyline constituing the Curve. */
+ /*! Returns the number of segments in the polyline constituting the Curve. */
inline unsigned int nSegments() const
{
return _nSegments;
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index e7a75728985..d116edc6ace 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -774,7 +774,7 @@ public:
const_vertex_iterator vertices_end() const;
vertex_iterator vertices_end();
- /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specifly a sampling
+ /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specify a sampling
* value to resample the Stroke on the fly if needed.
* \param t
* The resampling value with which we want our Stroke to be resampled.
@@ -785,7 +785,7 @@ public:
/*! Returns a StrokeVertexIterator pointing after the last StrokeVertex of the Stroke. */
StrokeInternal::StrokeVertexIterator strokeVerticesEnd();
- /*! Returns the number of StrokeVertex constituing the Stroke. */
+ /*! Returns the number of StrokeVertex constituting the Stroke. */
inline unsigned int strokeVerticesSize() const
{
return _Vertices.size();
diff --git a/source/blender/freestyle/intern/system/Id.h b/source/blender/freestyle/intern/system/Id.h
index 9cd45646f1c..8b028cdb3da 100644
--- a/source/blender/freestyle/intern/system/Id.h
+++ b/source/blender/freestyle/intern/system/Id.h
@@ -92,13 +92,13 @@ public:
return _second;
}
- /*! Sets the first number constituing the Id */
+ /*! Sets the first number constituting the Id */
void setFirst(id_type first)
{
_first = first;
}
- /*! Sets the second number constituing the Id */
+ /*! Sets the second number constituting the Id */
void setSecond(id_type second)
{
_second = second;
diff --git a/source/blender/freestyle/intern/system/TimeUtils.h b/source/blender/freestyle/intern/system/TimeUtils.h
index bbf4c5a1edb..6fe8b0e7431 100644
--- a/source/blender/freestyle/intern/system/TimeUtils.h
+++ b/source/blender/freestyle/intern/system/TimeUtils.h
@@ -23,7 +23,7 @@
/** \file blender/freestyle/intern/system/TimeUtils.h
* \ingroup freestyle
- * \brief Class to measure ellapsed time
+ * \brief Class to measure elapsed time
* \author Stephane Grabli
* \date 10/04/2002
*/
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.h b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
index 581155fa6e8..d6af7384fb8 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.h
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
@@ -95,7 +95,7 @@ public:
/*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations+1 base images of the steerable viewmap.
* \param steerableBases
- * The _nbOrientations+1 images constituing the basis for the steerable pyramid.
+ * The _nbOrientations+1 images constituting the basis for the steerable pyramid.
* \param copy
* If false, the data is not duplicated, and Canvas deals with the memory management of these
* _nbOrientations+1 images. If true, data is copied, and it's up to the caller to delete the images.
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
index 91d077278fb..b5d73640c11 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
@@ -39,7 +39,7 @@ namespace Freestyle {
void ViewEdgeXBuilder::Init(ViewShape *oVShape)
{
- if (0 == oVShape)
+ if (NULL == oVShape)
return;
// for design conveniance, we store the current SShape.
@@ -527,7 +527,7 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer&
bool ViewEdgeXBuilder::stopSmoothViewEdge(WXFaceLayer *iFaceLayer)
{
- if (0 == iFaceLayer)
+ if (NULL == iFaceLayer)
return true;
if (iFaceLayer->userdata == 0)
return false;
@@ -698,7 +698,7 @@ FEdge *ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge& iwe)
bool ViewEdgeXBuilder::stopSharpViewEdge(WXEdge *iEdge)
{
- if (0 == iEdge)
+ if (NULL == iEdge)
return true;
if (iEdge->userdata == 0)
return false;
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h
index 0ab089b7d7a..2c9672be53b 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.h
+++ b/source/blender/freestyle/intern/view_map/ViewMap.h
@@ -1352,12 +1352,12 @@ public:
vertex_iterator vertices_end();
// Iterator access (Interface1D)
- /*! Returns an Interface0DIterator to iterate over the SVertex constituing the embedding of this ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge.
* The returned Interface0DIterator points to the first SVertex of the ViewEdge.
*/
virtual Interface0DIterator verticesBegin();
- /*! Returns an Interface0DIterator to iterate over the SVertex constituing the embedding of this ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge.
* The returned Interface0DIterator points after the last SVertex of the ViewEdge.
*/
virtual Interface0DIterator verticesEnd();
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index d7919125fee..8e0d0e55709 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -65,7 +65,7 @@ static char *glsl_material_library = NULL;
/* structs and defines */
-static const char* GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4",
+static const char *GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4",
NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4"};
#define LINK_IMAGE_BLENDER 1
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 633112095a7..f5881cdc923 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -393,11 +393,21 @@ void set_rgb_zero(out vec3 outval)
outval = vec3(0.0);
}
+void set_rgb_one(out vec3 outval)
+{
+ outval = vec3(1.0);
+}
+
void set_rgba_zero(out vec4 outval)
{
outval = vec4(0.0);
}
+void set_rgba_one(out vec4 outval)
+{
+ outval = vec4(1.0);
+}
+
void brightness_contrast(vec4 col, float brightness, float contrast, out vec4 outcol)
{
float a = 1.0 + contrast;
@@ -725,6 +735,21 @@ void combine_rgb(float r, float g, float b, out vec4 col)
col = vec4(r, g, b, 1.0);
}
+void separate_hsv(vec4 col, out float h, out float s, out float v)
+{
+ vec4 hsv;
+
+ rgb_to_hsv(col, hsv);
+ h = hsv[0];
+ s = hsv[1];
+ v = hsv[2];
+}
+
+void combine_hsv(float h, float s, float v, out vec4 col)
+{
+ hsv_to_rgb(vec4(h, s, v, 1.0), col);
+}
+
void output_node(vec4 rgb, float alpha, out vec4 outrgb)
{
outrgb = vec4(rgb.rgb, alpha);
@@ -2131,7 +2156,25 @@ void node_add_shader(vec4 shader1, vec4 shader2, out vec4 shader)
void node_fresnel(float ior, vec3 N, vec3 I, out float result)
{
float eta = max(ior, 0.00001);
- result = fresnel_dielectric(I, N, (gl_FrontFacing)? eta: 1.0/eta);
+ result = fresnel_dielectric(normalize(I), N, (gl_FrontFacing)? eta: 1.0/eta);
+}
+
+/* layer_weight */
+
+void node_layer_weight(float blend, vec3 N, vec3 I, out float fresnel, out float facing)
+{
+ /* fresnel */
+ float eta = max(1.0 - blend, 0.00001);
+ fresnel = fresnel_dielectric(normalize(I), N, (gl_FrontFacing)? 1.0/eta : eta );
+
+ /* facing */
+ facing = abs(dot(normalize(I), N));
+ if(blend != 0.5) {
+ blend = clamp(blend, 0.0, 0.99999);
+ blend = (blend < 0.5)? 2.0*blend: 0.5/(1.0 - blend);
+ facing = pow(facing, blend);
+ }
+ facing = 1.0 - facing;
}
/* gamma */
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 63790cf7d25..271e52da1d4 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -477,7 +477,7 @@ static int startffmpeg(struct anim *anim)
const int *inv_table;
#endif
- if (anim == 0) return(-1);
+ if (anim == NULL) return(-1);
streamcount = anim->streamindex;
@@ -960,7 +960,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position,
int new_frame_index = 0; /* To quiet gcc barking... */
int old_frame_index = 0; /* To quiet gcc barking... */
- if (anim == 0) return (0);
+ if (anim == NULL) return (0);
av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: pos=%d\n", position);
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index 1481b2aaa66..fddfa2618c2 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -277,10 +277,10 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
return NULL;
}
- if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refLowData))
+ if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32)
cineon->element[i].refLowData = 0;
- if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refHighData))
+ if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32)
cineon->element[i].refHighData = (unsigned int)cineon->element[i].maxValue;
if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 || isnan(cineon->element[i].refLowQuantity))
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 5a4371d84ba..e839c2fce90 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -300,10 +300,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
case descriptor_RGB:
case descriptor_RGBA:
case descriptor_ABGR:
- if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData))
+ if (dpx->element[i].refLowData == DPX_UNDEFINED_U32)
dpx->element[i].refLowData = 0;
- if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData))
+ if (dpx->element[i].refHighData == DPX_UNDEFINED_U32)
dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue;
if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
@@ -324,10 +324,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
case descriptor_CbYCr:
case descriptor_CbYACrYA:
case descriptor_CbYCrA:
- if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData))
+ if (dpx->element[i].refLowData == DPX_UNDEFINED_U32)
dpx->element[i].refLowData = 16.0f / 255.0f * dpx->element[i].maxValue;
- if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData))
+ if (dpx->element[i].refHighData == DPX_UNDEFINED_U32)
dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue;
if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 93324b94cdc..49a40c461ac 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -656,7 +656,6 @@ static int add_to_proxy_output_ffmpeg(
static void free_proxy_output_ffmpeg(struct proxy_output_ctx *ctx,
int rollback)
{
- int i;
char fname[FILE_MAX];
char fname_tmp[FILE_MAX];
@@ -674,18 +673,12 @@ static void free_proxy_output_ffmpeg(struct proxy_output_ctx *ctx,
avcodec_close(ctx->c);
- for (i = 0; i < ctx->of->nb_streams; i++) {
- if (&ctx->of->streams[i]) {
- av_freep(&ctx->of->streams[i]);
- }
- }
-
if (ctx->of->oformat) {
if (!(ctx->of->oformat->flags & AVFMT_NOFILE)) {
avio_close(ctx->of->pb);
}
}
- av_free(ctx->of);
+ avformat_free_context(ctx->of);
MEM_freeN(ctx->video_buffer);
@@ -854,6 +847,9 @@ static void index_rebuild_ffmpeg_finish(FFmpegIndexBuilderContext *context, int
}
}
+ avcodec_close(context->iCodecCtx);
+ avformat_close_input(&context->iFormatCtx);
+
MEM_freeN(context);
}
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index 838343dce35..fe74b8f7cce 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -98,11 +98,20 @@ static ImBuf *imb_oiio_load_image(ImageInput *in, int width, int height, int com
try
{
- in->read_image(TypeDesc::UINT8,
- (uchar *)ibuf->rect + (height - 1) * scanlinesize,
- AutoStride,
- -scanlinesize,
- AutoStride);
+ if (!in->read_image(TypeDesc::UINT8,
+ (uchar *)ibuf->rect + (height - 1) * scanlinesize,
+ AutoStride,
+ -scanlinesize,
+ AutoStride))
+ {
+ std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl
+ << in->geterror() << std::endl;
+
+ if (ibuf)
+ IMB_freeImBuf(ibuf);
+
+ return NULL;
+ }
}
catch (const std::exception &exc)
{
@@ -128,11 +137,20 @@ static ImBuf *imb_oiio_load_image_float(ImageInput *in, int width, int height, i
try
{
- in->read_image(TypeDesc::FLOAT,
- (uchar *)ibuf->rect_float + (height - 1) * scanlinesize,
- AutoStride,
- -scanlinesize,
- AutoStride);
+ if (!in->read_image(TypeDesc::FLOAT,
+ (uchar *)ibuf->rect_float + (height - 1) * scanlinesize,
+ AutoStride,
+ -scanlinesize,
+ AutoStride))
+ {
+ std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl
+ << in->geterror() << std::endl;
+
+ if (ibuf)
+ IMB_freeImBuf(ibuf);
+
+ return NULL;
+ }
}
catch (const std::exception &exc)
{
@@ -191,12 +209,18 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
in = ImageInput::create(filename);
- if (!in) return NULL;
+ if (!in) {
+ std::cerr << __func__ << ": ImageInput::create() failed:" << std::endl
+ << OpenImageIO::geterror() << std::endl;
+ return NULL;
+ }
ImageSpec spec, config;
config.attribute("oiio:UnassociatedAlpha", (int) 1);
if (!in->open(filename, spec, config)) {
+ std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl
+ << in->geterror() << std::endl;
delete in;
return NULL;
}
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index ecf6458ac57..9d1ff79960c 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -120,6 +120,17 @@ const char *imb_ext_image_qt[] = {
NULL
};
+const char *imb_ext_movie_qt[] = {
+ ".avi",
+ ".flc",
+ ".dv",
+ ".r3d",
+ ".mov",
+ ".movie",
+ ".mv",
+ NULL
+};
+
const char *imb_ext_movie[] = {
".avi",
".flc",
@@ -131,10 +142,13 @@ const char *imb_ext_movie[] = {
".m2t",
".m2ts",
".mts",
+ ".ts",
".mv",
".avs",
".wmv",
".ogv",
+ ".ogg",
+ ".r3d",
".dv",
".mpeg",
".mpg",
@@ -145,6 +159,7 @@ const char *imb_ext_movie[] = {
".divx",
".xvid",
".mxf",
+ ".webm",
NULL
};
@@ -448,14 +463,7 @@ int IMB_isanim(const char *filename)
if (U.uiflag & USER_FILTERFILEEXTS) {
if (G.have_quicktime) {
- if (BLI_testextensie(filename, ".avi") ||
- BLI_testextensie(filename, ".flc") ||
- BLI_testextensie(filename, ".dv") ||
- BLI_testextensie(filename, ".r3d") ||
- BLI_testextensie(filename, ".mov") ||
- BLI_testextensie(filename, ".movie") ||
- BLI_testextensie(filename, ".mv"))
- {
+ if (BLI_testextensie_array(filename, imb_ext_movie_qt)) {
type = imb_get_anim_type(filename);
}
else {
@@ -463,11 +471,7 @@ int IMB_isanim(const char *filename)
}
}
else { /* no quicktime */
- if (BLI_testextensie(filename, ".avi") ||
- BLI_testextensie(filename, ".dv") ||
- BLI_testextensie(filename, ".r3d") ||
- BLI_testextensie(filename, ".mv"))
- {
+ if (BLI_testextensie_array(filename, imb_ext_movie)) {
type = imb_get_anim_type(filename);
}
else {
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index fc0dd54a8e7..7a7e08138b0 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -459,6 +459,8 @@ typedef struct FCurve {
/* curve coloring (for editor) */
int color_mode; /* coloring method to use (eFCurve_Coloring) */
float color[3]; /* the last-color this curve took */
+
+ float prev_norm_factor, pad;
} FCurve;
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 4780b2e85de..e751966c34d 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -88,7 +88,7 @@ typedef struct bArmature {
* - from the user perspective active == last selected
* - active should be ignored when not visible (hidden layer) */
- Bone *act_bone; /* active bone (when not in editmode) */
+ Bone *act_bone; /* active bone */
struct EditBone *act_edbone; /* active editbone (in editmode) */
void *sketch; /* sketch struct for etch-a-ton */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 2cfbbbd516b..0141c4b61db 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -223,7 +223,7 @@ typedef struct Curve {
float linewidth;
char *str;
- struct SelBox *selboxes;
+ struct SelBox *selboxes; /* runtime variable for drawing selections (editmode data) */
struct EditFont *editfont;
char family[24];
@@ -364,6 +364,8 @@ typedef enum eBezTriple_KeyframeType {
/* mixed with KEY_LINEAR but define here since only curve supports */
#define KEY_CU_EASE 3
+/* indicates point has been seen during surface duplication */
+#define SURF_SEEN 4
#endif
diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h
index 7e81041fe4a..040b55d9eb6 100644
--- a/source/blender/makesdna/DNA_fileglobal_types.h
+++ b/source/blender/makesdna/DNA_fileglobal_types.h
@@ -48,8 +48,8 @@ typedef struct FileGlobal {
struct Scene *curscene;
int fileflags;
int globalf;
- int revision; /* svn revision from buildinfo */
- int pad;
+ uint64_t build_commit_timestamp; /* commit timestamp from buildinfo */
+ char build_hash[16]; /* hash from buildinfo */
/* file path where this was saved, for recover */
char filename[1024]; /* 1024 = FILE_MAX */
} FileGlobal;
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index 2699c6e576e..b4088cc5a5d 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -308,6 +308,7 @@ typedef struct Ipo {
#define WO_MISTSTA 10
#define WO_MISTHI 11
+/* Stars are deprecated */
#define WO_STAR_R 12
#define WO_STAR_G 13
#define WO_STAR_B 14
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 799968335b7..11bdf707c45 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -822,12 +822,13 @@ typedef struct ScrewModifierData {
ModifierData modifier;
struct Object *ob_axis;
- int steps;
- int render_steps;
- int iter;
+ unsigned int steps;
+ unsigned int render_steps;
+ unsigned int iter;
float screw_ofs;
float angle;
- short axis;
+ char axis;
+ char pad;
short flag;
} ScrewModifierData;
@@ -1177,11 +1178,27 @@ typedef struct TriangulateModifierData {
ModifierData modifier;
int flag;
+ int quad_method;
+ int ngon_method;
int pad;
} TriangulateModifierData;
enum {
- MOD_TRIANGULATE_BEAUTY = (1 << 0),
+ MOD_TRIANGULATE_BEAUTY = (1 << 0), /* deprecated */
+};
+
+/* Triangulate methods - NGons */
+enum {
+ MOD_TRIANGULATE_NGON_BEAUTY = 0,
+ MOD_TRIANGULATE_NGON_SCANFILL,
+};
+
+/* Triangulate methods - Quads */
+enum {
+ MOD_TRIANGULATE_QUAD_BEAUTY = 0,
+ MOD_TRIANGULATE_QUAD_FIXED,
+ MOD_TRIANGULATE_QUAD_ALTERNATE,
+ MOD_TRIANGULATE_QUAD_SHORTEDGE
};
typedef struct LaplacianSmoothModifierData {
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 75b9540f736..a4510dd23fd 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -402,6 +402,7 @@ typedef struct bNodeTree {
#define NTREE_TWO_PASS 4 /* two pass */
#define NTREE_COM_GROUPNODE_BUFFER 8 /* use groupnode buffers */
#define NTREE_VIEWER_BORDER 16 /* use a border for viewer nodes */
+#define NTREE_IS_LOCALIZED 32 /* tree is localized copy, free when deleting node groups */
/* XXX not nice, but needed as a temporary flags
* for group updates after library linking.
@@ -676,19 +677,15 @@ typedef struct NodeLensDist {
} NodeLensDist;
typedef struct NodeColorBalance {
- /* for processing */
+ /* ASC CDL parameters */
float slope[3];
float offset[3];
float power[3];
- /* for ui representation */
+ /* LGG parameters */
float lift[3];
float gamma[3];
float gain[3];
-
- /* temp storage for inverted lift */
- float lift_lgg[3];
- float gamma_inv[3];
} NodeColorBalance;
typedef struct NodeColorspill {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 232fe62df31..7aabad86809 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -196,7 +196,7 @@ typedef struct SceneRenderLayer {
#define SCE_LAY_SOLID 1
#define SCE_LAY_ZTRA 2
#define SCE_LAY_HALO 4
-#define SCE_LAY_EDGE 8
+#define SCE_LAY_EDGE 8 /* deprecated */
#define SCE_LAY_SKY 16
#define SCE_LAY_STRAND 32
#define SCE_LAY_FRS 64
@@ -378,7 +378,7 @@ typedef struct RenderData {
float framelen, blurfac;
/** For UR edge rendering: give the edges this color */
- float edgeR, edgeG, edgeB;
+ float edgeR DNA_DEPRECATED, edgeG DNA_DEPRECATED, edgeB DNA_DEPRECATED;
/* standalone player */ // XXX deprecated since 2.5
@@ -725,7 +725,7 @@ typedef struct GameData {
#define GAME_PLAYER_DESKTOP_RESOLUTION (1 << 1)
/* GameData.matmode */
-#define GAME_MAT_TEXFACE 0
+#define GAME_MAT_TEXFACE 0 /* deprecated */
#define GAME_MAT_MULTITEX 1
#define GAME_MAT_GLSL 2
@@ -1212,6 +1212,7 @@ typedef struct Scene {
/* flag */
/* use preview range */
#define SCER_PRV_RANGE (1<<0)
+#define SCER_LOCK_FRAME_SELECTION (1<<1)
/* mode (int now) */
#define R_OSA 0x0001
@@ -1219,7 +1220,7 @@ typedef struct Scene {
#define R_GAMMA 0x0004
#define R_ORTHO 0x0008
#define R_ENVMAP 0x0010
-#define R_EDGE 0x0020
+#define R_EDGE 0x0020 /* deprecated */
#define R_FIELDS 0x0040
#define R_FIELDSTILL 0x0080
/*#define R_RADIO 0x0100 */ /* deprecated */
@@ -1456,6 +1457,7 @@ typedef struct Scene {
#define SCE_SNAP_MODE_NODE_X 5
#define SCE_SNAP_MODE_NODE_Y 6
#define SCE_SNAP_MODE_NODE_XY 7
+#define SCE_SNAP_MODE_GRID 8
/* toolsettings->selectmode */
#define SCE_SELECT_VERTEX 1 /* for mesh */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 5befaa87e7f..4ebfe349a9f 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -286,11 +286,11 @@ typedef enum eSpaceOutliner_Mode {
SO_GROUPS = 6,
SO_LIBRARIES = 7,
/* SO_VERSE_SESSION = 8, */ /* deprecated! */
- /* SO_VERSE_MS = 9, */ /* deprecated!*/
+ /* SO_VERSE_MS = 9, */ /* deprecated! */
SO_SEQUENCE = 10,
SO_DATABLOCKS = 11,
SO_USERDEF = 12,
- SO_KEYMAP = 13,
+ /* SO_KEYMAP = 13, */ /* deprecated! */
} eSpaceOutliner_Mode;
/* SpaceOops->storeflag */
@@ -366,6 +366,9 @@ typedef enum eGraphEdit_Flag {
SIPO_BEAUTYDRAW_OFF = (1 << 12),
/* draw grouped channels with colors set in group */
SIPO_NODRAWGCOLORS = (1 << 13),
+ /* normalize curves on display */
+ SIPO_NORMALIZE = (1 << 14),
+ SIPO_NORMALIZE_FREEZE = (1 << 15),
} eGraphEdit_Flag;
/* SpaceIpo->mode (Graph Editor Mode) */
@@ -690,6 +693,7 @@ typedef enum eFileSel_File_Types {
BTXFILE = (1 << 12),
COLLADAFILE = (1 << 13),
OPERATORFILE = (1 << 14), /* from filter_glob operator property */
+ APPLICATIONBUNDLE = (1 << 15),
} eFileSel_File_Types;
/* Selection Flags in filesel: struct direntry, unsigned char selflag */
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 49c1e3ed35d..ad9a2ea169c 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -142,6 +142,17 @@ typedef struct MovieTrackingTrack {
float minimum_correlation; /* minimal correlation which is still treated as successful tracking */
struct bGPdata *gpd; /* grease-pencil data */
+
+ /* Weight of this track.
+ *
+ * Weight defines how much the track affects on the final reconstruction,
+ * usually gets animated in a way so when track has just appeared it's
+ * weight is zero and then it gets faded up.
+ *
+ * Used to prevent jumps of the camera when tracks are appearing or
+ * disappearing.
+ */
+ float weight, pad;
} MovieTrackingTrack;
typedef struct MovieTrackingPlaneMarker {
@@ -207,8 +218,7 @@ typedef struct MovieTrackingSettings {
* were moved to per-tracking object settings
*/
- float reconstruction_success_threshold;
- int reconstruction_flag;
+ int reconstruction_flag, pad;
/* which camera intrinsics to refine. uses on the REFINE_* flags */
short refine_camera_intrinsics, pad2;
@@ -409,7 +419,7 @@ enum {
/* MovieTrackingSettings->reconstruction_flag */
enum {
- TRACKING_USE_FALLBACK_RECONSTRUCTION = (1 << 0),
+ /* TRACKING_USE_FALLBACK_RECONSTRUCTION = (1 << 0), */ /* DEPRECATED */
TRACKING_USE_KEYFRAME_SELECTION = (1 << 1)
};
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 1621f7c6cb6..37d5f313dfb 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -474,6 +474,7 @@ typedef struct UserDef {
struct ColorBand coba_weight; /* from texture.h */
float sculpt_paint_overlay_col[3];
+ float gpencil_new_layer_col[4]; /* default color for newly created Grease Pencil layers */
short tweak_threshold;
short pad3;
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 155f41b2c6e..5eba8503c2a 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -280,7 +280,8 @@ typedef struct View3D {
#define V3D_SOLID_MATCAP 4096 /* user flag */
#define V3D_SHOW_SOLID_MATCAP 8192 /* runtime flag */
#define V3D_OCCLUDE_WIRE 16384
-#define V3D_NO_PHYSICS 32768
+#define V3D_SHADELESS_TEX 32768
+#define V3D_NO_PHYSICS 32768 // RB_FIXME need new drawing flag
/* View3D->around */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 07a679be571..ff43cc31b9a 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -60,42 +60,44 @@ struct ReportList;
struct Report;
struct uiLayout;
-#define OP_MAX_TYPENAME 64
-#define KMAP_MAX_NAME 64
+#define OP_MAX_TYPENAME 64
+#define KMAP_MAX_NAME 64
/* keep in sync with 'wm_report_items' in wm_rna.c */
typedef enum ReportType {
- RPT_DEBUG = 1 << 0,
- RPT_INFO = 1 << 1,
- RPT_OPERATOR = 1 << 2,
- RPT_PROPERTY = 1 << 3,
- RPT_WARNING = 1 << 4,
- RPT_ERROR = 1 << 5,
- RPT_ERROR_INVALID_INPUT = 1 << 6,
- RPT_ERROR_INVALID_CONTEXT = 1 << 7,
- RPT_ERROR_OUT_OF_MEMORY = 1 << 8
+ RPT_DEBUG = (1 << 0),
+ RPT_INFO = (1 << 1),
+ RPT_OPERATOR = (1 << 2),
+ RPT_PROPERTY = (1 << 3),
+ RPT_WARNING = (1 << 4),
+ RPT_ERROR = (1 << 5),
+ RPT_ERROR_INVALID_INPUT = (1 << 6),
+ RPT_ERROR_INVALID_CONTEXT = (1 << 7),
+ RPT_ERROR_OUT_OF_MEMORY = (1 << 8),
} ReportType;
-#define RPT_DEBUG_ALL (RPT_DEBUG)
-#define RPT_INFO_ALL (RPT_INFO)
-#define RPT_OPERATOR_ALL (RPT_OPERATOR)
-#define RPT_PROPERTY_ALL (RPT_PROPERTY)
-#define RPT_WARNING_ALL (RPT_WARNING)
-#define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
+#define RPT_DEBUG_ALL (RPT_DEBUG)
+#define RPT_INFO_ALL (RPT_INFO)
+#define RPT_OPERATOR_ALL (RPT_OPERATOR)
+#define RPT_PROPERTY_ALL (RPT_PROPERTY)
+#define RPT_WARNING_ALL (RPT_WARNING)
+#define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
enum ReportListFlags {
- RPT_PRINT = 1,
- RPT_STORE = 2,
- RPT_FREE = 4,
- RPT_OP_HOLD = 8 /* don't move them into the operator global list (caller will use) */
+ RPT_PRINT = (1 << 0),
+ RPT_STORE = (1 << 1),
+ RPT_FREE = (1 << 2),
+ RPT_OP_HOLD = (1 << 3), /* don't move them into the operator global list (caller will use) */
};
+
+/* These two Lines with # tell makesdna this struct can be excluded. */
#
#
typedef struct Report {
struct Report *next, *prev;
- short type; /* ReportType */
+ short type; /* ReportType */
short flag;
- int len; /* strlen(message), saves some time calculating the word wrap */
+ int len; /* strlen(message), saves some time calculating the word wrap */
const char *typestr;
const char *message;
} Report;
@@ -103,13 +105,14 @@ typedef struct Report {
/* saved in the wm, don't remove */
typedef struct ReportList {
ListBase list;
- int printlevel; /* ReportType */
- int storelevel; /* ReportType */
+ int printlevel; /* ReportType */
+ int storelevel; /* ReportType */
int flag, pad;
struct wmTimer *reporttimer;
} ReportList;
/* timer customdata to control reports display */
+/* These two Lines with # tell makesdna this struct can be excluded. */
#
#
typedef struct ReportTimerInfo {
@@ -124,84 +127,86 @@ typedef struct ReportTimerInfo {
/* windowmanager is saved, tag WMAN */
typedef struct wmWindowManager {
ID id;
-
- struct wmWindow *windrawable, *winactive; /* separate active from drawable */
+
+ struct wmWindow *windrawable, *winactive; /* separate active from drawable */
ListBase windows;
-
- int initialized; /* set on file read */
- short file_saved; /* indicator whether data was saved */
- short op_undo_depth; /* operator stack depth to avoid nested undo pushes */
-
- ListBase operators; /* operator registry */
-
- ListBase queue; /* refresh/redraw wmNotifier structs */
-
- struct ReportList reports; /* information and error reports */
-
- ListBase jobs; /* threaded jobs manager */
-
- ListBase paintcursors; /* extra overlay cursors to draw, like circles */
-
- ListBase drags; /* active dragged items */
-
- ListBase keyconfigs; /* known key configurations */
- struct wmKeyConfig *defaultconf; /* default configuration */
- struct wmKeyConfig *addonconf; /* addon configuration */
- struct wmKeyConfig *userconf; /* user configuration */
-
- ListBase timers; /* active timers */
- struct wmTimer *autosavetimer; /* timer for auto save */
+
+ int initialized; /* set on file read */
+ short file_saved; /* indicator whether data was saved */
+ short op_undo_depth; /* operator stack depth to avoid nested undo pushes */
+
+ ListBase operators; /* operator registry */
+
+ ListBase queue; /* refresh/redraw wmNotifier structs */
+
+ struct ReportList reports; /* information and error reports */
+
+ ListBase jobs; /* threaded jobs manager */
+
+ ListBase paintcursors; /* extra overlay cursors to draw, like circles */
+
+ ListBase drags; /* active dragged items */
+
+ ListBase keyconfigs; /* known key configurations */
+ struct wmKeyConfig *defaultconf; /* default configuration */
+ struct wmKeyConfig *addonconf; /* addon configuration */
+ struct wmKeyConfig *userconf; /* user configuration */
+
+ ListBase timers; /* active timers */
+ struct wmTimer *autosavetimer; /* timer for auto save */
} wmWindowManager;
/* wmWindowManager.initialized */
-#define WM_INIT_WINDOW (1<<0)
-#define WM_INIT_KEYMAP (1<<1)
+enum {
+ WM_INIT_WINDOW = (1<<0),
+ WM_INIT_KEYMAP = (1<<1),
+};
/* the savable part, rest of data is local in ghostwinlay */
typedef struct wmWindow {
struct wmWindow *next, *prev;
-
- void *ghostwin; /* don't want to include ghost.h stuff */
-
- int winid; /* winid also in screens, is for retrieving this window after read */
- short grabcursor; /* cursor grab mode */
+ void *ghostwin; /* don't want to include ghost.h stuff */
+
+ int winid; /* winid also in screens, is for retrieving this window after read */
+
+ short grabcursor; /* cursor grab mode */
short pad;
-
- struct bScreen *screen; /* active screen */
- struct bScreen *newscreen; /* temporary when switching */
- char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */
-
- short posx, posy, sizex, sizey; /* window coords */
- short windowstate; /* borderless, full */
- short monitor; /* multiscreen... no idea how to store yet */
- short active; /* set to 1 if an active window, for quick rejects */
- short cursor; /* current mouse cursor type */
- short lastcursor; /* previous cursor when setting modal one */
- short modalcursor; /* the current modal cursor */
- short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
+
+ struct bScreen *screen; /* active screen */
+ struct bScreen *newscreen; /* temporary when switching */
+ char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */
+
+ short posx, posy, sizex, sizey; /* window coords */
+ short windowstate; /* borderless, full */
+ short monitor; /* multiscreen... no idea how to store yet */
+ short active; /* set to 1 if an active window, for quick rejects */
+ short cursor; /* current mouse cursor type */
+ short lastcursor; /* previous cursor when setting modal one */
+ short modalcursor; /* the current modal cursor */
+ short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
short pad2;
- struct wmEvent *eventstate; /* storage for event system */
-
- struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
-
- struct wmGesture *tweak; /* internal for wm_operators.c */
-
- int drawmethod, drawfail; /* internal for wm_draw.c only */
- void *drawdata; /* internal for wm_draw.c only */
-
- ListBase queue; /* all events (ghost level events were handled) */
- ListBase handlers; /* window+screen handlers, handled last */
- ListBase modalhandlers; /* priority handlers, handled first */
-
- ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
- ListBase gesture; /* gesture stuff */
+ struct wmEvent *eventstate; /* storage for event system */
+
+ struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
+
+ struct wmGesture *tweak; /* internal for wm_operators.c */
+
+ int drawmethod, drawfail; /* internal for wm_draw.c only */
+ void *drawdata; /* internal for wm_draw.c only */
+
+ ListBase queue; /* all events (ghost level events were handled) */
+ ListBase handlers; /* window+screen handlers, handled last */
+ ListBase modalhandlers; /* priority handlers, handled first */
+
+ ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
+ ListBase gesture; /* gesture stuff */
} wmWindow;
+/* These two Lines with # tell makesdna this struct can be excluded. */
/* should be something like DNA_EXCLUDE
* but the preprocessor first removes all comments, spaces etc */
-
#
#
typedef struct wmOperatorTypeMacro {
@@ -210,37 +215,36 @@ typedef struct wmOperatorTypeMacro {
/* operator id */
char idname[64];
/* rna pointer to access properties, like keymap */
- struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
+ struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
struct PointerRNA *ptr;
-
} wmOperatorTypeMacro;
/* partial copy of the event, for matching by eventhandler */
typedef struct wmKeyMapItem {
struct wmKeyMapItem *next, *prev;
-
+
/* operator */
- char idname[64]; /* used to retrieve operator type pointer */
- IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
-
+ char idname[64]; /* used to retrieve operator type pointer */
+ IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
+
/* modal */
- char propvalue_str[64]; /* runtime temporary storage for loading */
- short propvalue; /* if used, the item is from modal map */
+ char propvalue_str[64]; /* runtime temporary storage for loading */
+ short propvalue; /* if used, the item is from modal map */
/* event */
- short type; /* event code itself */
- short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */
- short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
- short keymodifier; /* rawkey modifier */
-
+ short type; /* event code itself */
+ short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */
+ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
+ short keymodifier; /* rawkey modifier */
+
/* flag: inactive, expanded */
short flag;
/* runtime */
- short maptype; /* keymap editor */
- short id; /* unique identifier. Positive for kmi that override builtins, negative otherwise */
+ short maptype; /* keymap editor */
+ short id; /* unique identifier. Positive for kmi that override builtins, negative otherwise */
short pad;
- struct PointerRNA *ptr; /* rna pointer to access properties */
+ struct PointerRNA *ptr; /* rna pointer to access properties */
} wmKeyMapItem;
/* used instead of wmKeyMapItem for diff keymaps */
@@ -252,52 +256,68 @@ typedef struct wmKeyMapDiffItem {
} wmKeyMapDiffItem;
/* wmKeyMapItem.flag */
-#define KMI_INACTIVE 1
-#define KMI_EXPANDED 2
-#define KMI_USER_MODIFIED 4
-#define KMI_UPDATE 8
+enum {
+ KMI_INACTIVE = (1 << 0),
+ KMI_EXPANDED = (1 << 1),
+ KMI_USER_MODIFIED = (1 << 2),
+ KMI_UPDATE = (1 << 3),
+};
+
+/* wmKeyMapItem.maptype */
+enum {
+ KMI_TYPE_KEYBOARD = 0,
+ KMI_TYPE_MOUSE = 1,
+ KMI_TYPE_TWEAK = 2,
+ KMI_TYPE_TEXTINPUT = 3,
+ KMI_TYPE_TIMER = 4,
+ KMI_TYPE_NDOF = 5,
+};
/* stored in WM, the actively used keymaps */
typedef struct wmKeyMap {
struct wmKeyMap *next, *prev;
-
+
ListBase items;
ListBase diff_items;
-
- char idname[64]; /* global editor keymaps, or for more per space/region */
- short spaceid; /* same IDs as in DNA_space_types.h */
- short regionid; /* see above */
-
- short flag; /* general flags */
- short kmi_id; /* last kmi id */
-
+
+ char idname[64]; /* global editor keymaps, or for more per space/region */
+ short spaceid; /* same IDs as in DNA_space_types.h */
+ short regionid; /* see above */
+
+ short flag; /* general flags */
+ short kmi_id; /* last kmi id */
+
/* runtime */
- int (*poll)(struct bContext *); /* verify if enabled in the current context */
- void *modal_items; /* for modal, EnumPropertyItem for now */
+ int (*poll)(struct bContext *); /* verify if enabled in the current context */
+ void *modal_items; /* for modal, EnumPropertyItem for now */
} wmKeyMap;
/* wmKeyMap.flag */
-#define KEYMAP_MODAL 1 /* modal map, not using operatornames */
-#define KEYMAP_USER 2 /* user keymap */
-#define KEYMAP_EXPANDED 4
-#define KEYMAP_CHILDREN_EXPANDED 8
-#define KEYMAP_DIFF 16 /* diff keymap for user preferences */
-#define KEYMAP_USER_MODIFIED 32 /* keymap has user modifications */
-#define KEYMAP_UPDATE 64
+enum {
+ KEYMAP_MODAL = (1 << 0), /* modal map, not using operatornames */
+ KEYMAP_USER = (1 << 1), /* user keymap */
+ KEYMAP_EXPANDED = (1 << 2),
+ KEYMAP_CHILDREN_EXPANDED = (1 << 3),
+ KEYMAP_DIFF = (1 << 4), /* diff keymap for user preferences */
+ KEYMAP_USER_MODIFIED = (1 << 5), /* keymap has user modifications */
+ KEYMAP_UPDATE = (1 << 6),
+};
typedef struct wmKeyConfig {
struct wmKeyConfig *next, *prev;
- char idname[64]; /* unique name */
- char basename[64]; /* idname of configuration this is derives from, "" if none */
-
+ char idname[64]; /* unique name */
+ char basename[64]; /* idname of configuration this is derives from, "" if none */
+
ListBase keymaps;
int actkeymap, flag;
} wmKeyConfig;
/* wmKeyConfig.flag */
-#define KEYCONF_USER (1 << 1)
-#define KEYCONF_INIT_DEFAULT (1 << 2)
+enum {
+ KEYCONF_USER = (1 << 1), /* And what about (1 << 0)? */
+ KEYCONF_INIT_DEFAULT = (1 << 2),
+};
/* this one is the operator itself, stored in files for macros etc */
/* operator + operatortype should be able to redo entirely, but for different contextes */
@@ -305,46 +325,46 @@ typedef struct wmOperator {
struct wmOperator *next, *prev;
/* saved */
- char idname[64];/* used to retrieve type pointer */
- IDProperty *properties; /* saved, user-settable properties */
+ char idname[64]; /* used to retrieve type pointer */
+ IDProperty *properties; /* saved, user-settable properties */
/* runtime */
- struct wmOperatorType *type;/* operator type definition from idname */
- void *customdata; /* custom storage, only while operator runs */
- void *py_instance; /* python stores the class instance here */
+ struct wmOperatorType *type; /* operator type definition from idname */
+ void *customdata; /* custom storage, only while operator runs */
+ void *py_instance; /* python stores the class instance here */
- struct PointerRNA *ptr; /* rna pointer to access properties */
- struct ReportList *reports; /* errors and warnings storage */
+ struct PointerRNA *ptr; /* rna pointer to access properties */
+ struct ReportList *reports; /* errors and warnings storage */
- ListBase macro; /* list of operators, can be a tree */
- struct wmOperator *opm; /* current running macro, not saved */
- struct uiLayout *layout; /* runtime for drawing */
+ ListBase macro; /* list of operators, can be a tree */
+ struct wmOperator *opm; /* current running macro, not saved */
+ struct uiLayout *layout; /* runtime for drawing */
short flag, pad[3];
} wmOperator;
-
/* operator type return flags: exec(), invoke() modal(), return values */
-#define OPERATOR_RUNNING_MODAL (1<<0)
-#define OPERATOR_CANCELLED (1<<1)
-#define OPERATOR_FINISHED (1<<2)
+enum {
+ OPERATOR_RUNNING_MODAL = (1 << 0),
+ OPERATOR_CANCELLED = (1 << 1),
+ OPERATOR_FINISHED = (1 << 2),
/* add this flag if the event should pass through */
-#define OPERATOR_PASS_THROUGH (1<<3)
+ OPERATOR_PASS_THROUGH = (1 << 3),
/* in case operator got executed outside WM code... like via fileselect */
-#define OPERATOR_HANDLED (1<<4)
-
-#define OPERATOR_FLAGS_ALL ((1<<5)-1)
+ OPERATOR_HANDLED = (1 << 4),
+};
+#define OPERATOR_FLAGS_ALL (OPERATOR_RUNNING_MODAL | OPERATOR_CANCELLED | OPERATOR_FINISHED | \
+ OPERATOR_PASS_THROUGH | OPERATOR_HANDLED)
/* sanity checks for debug mode only */
#define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)
/* wmOperator flag */
enum {
- OP_GRAB_POINTER = (1 << 0),
-
+ OP_GRAB_POINTER = (1 << 0),
/* low level flag so exec() operators can tell if they were invoked, use with care.
* typically this shouldn't make any difference, but it rare cases its needed (see smooth-view) */
- OP_IS_INVOKE = (1 << 1),
+ OP_IS_INVOKE = (1 << 1),
};
#endif /* __DNA_WINDOWMANAGER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index a0863b18cca..3e01e159d6c 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -47,7 +47,7 @@ struct MTex;
/**
* World defines general modeling data such as a background fill,
- * gravity, color model, stars, etc. It mixes game-data, rendering
+ * gravity, color model etc. It mixes game-data, rendering
* data and modeling data. */
typedef struct World {
ID id;
@@ -96,8 +96,8 @@ typedef struct World {
float misi, miststa, mistdist, misthi;
float starr DNA_DEPRECATED, starg DNA_DEPRECATED, starb DNA_DEPRECATED, stark DNA_DEPRECATED; /* Deprecated */
- float starsize, starmindist;
- float stardist, starcolnoise;
+ float starsize DNA_DEPRECATED, starmindist DNA_DEPRECATED;
+ float stardist DNA_DEPRECATED, starcolnoise DNA_DEPRECATED;
/* unused now: DOF */
short dofsta, dofend, dofmin, dofmax;
@@ -142,7 +142,7 @@ typedef struct World {
/* mode */
#define WO_MIST 1
-#define WO_STARS 2
+#define WO_STARS 2 /* deprecated */
/*#define WO_DOF 4*/
#define WO_ACTIVITY_CULLING 8
#define WO_ENV_LIGHT 16
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index b4b79059f93..d82bae1ce57 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -660,7 +660,6 @@ extern StructRNA RNA_World;
extern StructRNA RNA_WorldAmbientOcclusion;
extern StructRNA RNA_WorldLighting;
extern StructRNA RNA_WorldMistSettings;
-extern StructRNA RNA_WorldStarsSettings;
extern StructRNA RNA_WorldTextureSlot;
extern StructRNA RNA_XnorController;
extern StructRNA RNA_XorController;
@@ -1034,6 +1033,7 @@ void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier);
/* python compatible string representation of this property, (must be freed!) */
char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length);
+char *RNA_pointer_as_string_id(struct bContext *C, PointerRNA *ptr);
char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop);
char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr,
const bool skip_optional_value, const bool all_args,
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index d33d3df8a5e..f1881c8beba 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -60,6 +60,9 @@ extern EnumPropertyItem constraint_type_items[];
extern EnumPropertyItem boidrule_type_items[];
extern EnumPropertyItem sequence_modifier_type_items[];
+extern EnumPropertyItem modifier_triangulate_quad_method_items[];
+extern EnumPropertyItem modifier_triangulate_ngon_method_items[];
+
extern EnumPropertyItem image_type_items[];
extern EnumPropertyItem image_color_mode_items[];
extern EnumPropertyItem image_depth_mode_items[];
@@ -68,7 +71,6 @@ extern EnumPropertyItem image_generated_type_items[];
extern EnumPropertyItem color_sets_items[];
extern EnumPropertyItem beztriple_keyframe_type_items[];
-extern EnumPropertyItem beztriple_handle_type_items[];
extern EnumPropertyItem beztriple_interpolation_mode_items[];
extern EnumPropertyItem keyframe_handle_type_items[];
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 8a4022de104..1cb9eb8e9ae 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1555,7 +1555,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
}
else if (prop->arraydimension && prop->totarraylength) {
fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength);
- fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->totarraylength);
+ fprintf(f, "void %sset(PointerRNA *ptr, const int values[%u]);\n", func, prop->totarraylength);
}
else {
fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func);
@@ -1571,7 +1571,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
}
else if (prop->arraydimension && prop->totarraylength) {
fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength);
- fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->totarraylength);
+ fprintf(f, "void %sset(PointerRNA *ptr, const float values[%u]);\n", func, prop->totarraylength);
}
else {
fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func);
@@ -3446,7 +3446,7 @@ static const char *cpp_classes = ""
" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
"\n"
"#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-" inline Array<int,size> sname::identifier(void) \\\n"
+" inline Array<int, size> sname::identifier(void) \\\n"
" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
" inline void sname::identifier(int values[size]) \\\n"
" { sname##_##identifier##_set(&ptr, values); } \\\n"
@@ -3466,7 +3466,7 @@ static const char *cpp_classes = ""
" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
"\n"
"#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-" inline Array<int,size> sname::identifier(void) \\\n"
+" inline Array<int, size> sname::identifier(void) \\\n"
" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
" inline void sname::identifier(int values[size]) \\\n"
" { sname##_##identifier##_set(&ptr, values); } \\\n"
@@ -3486,7 +3486,7 @@ static const char *cpp_classes = ""
" inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n"
"\n"
"#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-" inline Array<float,size> sname::identifier(void) \\\n"
+" inline Array<float, size> sname::identifier(void) \\\n"
" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
" inline void sname::identifier(float values[size]) \\\n"
" { sname##_##identifier##_set(&ptr, values); } \\\n"
@@ -3695,7 +3695,7 @@ static const char *cpp_classes = ""
" typename Tcollection_funcs>\n"
"class Collection : public Tcollection_funcs {\n"
"public:\n"
-" Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n"
+" Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n"
"\n"
" void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n"
" { iter.begin(ptr); }\n"
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 341ba02fd47..6c216936190 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -290,9 +290,7 @@ static void rna_idproperty_free(PointerRNA *ptr, const char *name)
if (group) {
IDProperty *idprop = IDP_GetPropertyFromGroup(group, name);
if (idprop) {
- IDP_RemFromGroup(group, idprop);
- IDP_FreeProperty(idprop);
- MEM_freeN(idprop);
+ IDP_FreeFromGroup(group, idprop);
}
}
}
@@ -423,9 +421,7 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr)
if (idprop && !rna_idproperty_verify_valid(ptr, *prop, idprop)) {
IDProperty *group = RNA_struct_idprops(ptr, 0);
- IDP_RemFromGroup(group, idprop);
- IDP_FreeProperty(idprop);
- MEM_freeN(idprop);
+ IDP_FreeFromGroup(group, idprop);
return NULL;
}
@@ -596,9 +592,7 @@ bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier)
if (group) {
IDProperty *idp = IDP_GetPropertyFromGroup(group, identifier);
if (idp) {
- IDP_RemFromGroup(group, idp);
- IDP_FreeProperty(idp);
- MEM_freeN(idp);
+ IDP_FreeFromGroup(group, idp);
return true;
}
@@ -2771,9 +2765,7 @@ void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop)
group = RNA_struct_idprops(ptr, 0);
if (group) {
- IDP_RemFromGroup(group, idprop);
- IDP_FreeProperty(idprop);
- MEM_freeN(idprop);
+ IDP_FreeFromGroup(group, idprop);
}
}
else
@@ -4901,6 +4893,7 @@ int RNA_collection_length(PointerRNA *ptr, const char *name)
bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
{
+ prop = rna_ensure_property(prop);
if (prop->flag & PROP_IDPROPERTY) {
IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier);
return ((idprop != NULL) && (use_ghost == false || !(idprop->flag & IDP_FLAG_GHOST)));
@@ -4912,6 +4905,7 @@ bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
{
+ prop = rna_ensure_property(prop);
if (prop->flag & PROP_IDPROPERTY) {
IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier);
return ((idprop != NULL) && !(idprop->flag & IDP_FLAG_GHOST));
@@ -4923,6 +4917,7 @@ bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
{
+ prop = rna_ensure_property(prop);
if (prop->flag & PROP_IDPROPERTY) {
rna_idproperty_free(ptr, prop->identifier);
}
@@ -4985,7 +4980,7 @@ bool RNA_property_is_unlink(PropertyRNA *prop)
/* string representation of a property, python
* compatible but can be used for display too,
* context may be NULL */
-static char *rna_pointer_as_string__idprop(bContext *C, PointerRNA *ptr)
+char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr)
{
DynStr *dynstr = BLI_dynstr_new();
char *cstring;
@@ -5036,7 +5031,7 @@ static char *rna_pointer_as_string__bldata(PointerRNA *ptr)
char *RNA_pointer_as_string(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *prop_ptr, PointerRNA *ptr_prop)
{
if (RNA_property_flag(prop_ptr) & PROP_IDPROPERTY) {
- return rna_pointer_as_string__idprop(C, ptr_prop);
+ return RNA_pointer_as_string_id(C, ptr_prop);
}
else {
return rna_pointer_as_string__bldata(ptr_prop);
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index bd4b8dd76b1..74fe3c145f1 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -38,6 +38,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "rna_internal.h"
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index e13ec1f09a4..2a008a44b55 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -470,7 +470,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "start_frame");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_range(prop, 1.0, 9999.0);
+ RNA_def_property_range(prop, 1.0, MAXFRAMEF);
RNA_def_property_ui_range(prop, 1.0, 9999, 1, -1);
RNA_def_property_ui_text(prop, "Start Frame", "Simulation start frame");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
@@ -478,7 +478,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "end_frame");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_range(prop, 1.0, 9999.0);
+ RNA_def_property_range(prop, 1.0, MAXFRAMEF);
RNA_def_property_ui_range(prop, 1.0, 9999.0, 1, -1);
RNA_def_property_ui_text(prop, "End Frame", "Simulation end frame");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 4b50127d999..2036257e5d7 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -453,28 +453,66 @@ static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, Pointe
static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value))
{
- FModifier *fm = (FModifier *)ptr->data;
+ FModifier *fcm = (FModifier *)ptr->data;
/* don't toggle, always switch on */
- fm->flag |= FMODIFIER_FLAG_ACTIVE;
+ fcm->flag |= FMODIFIER_FLAG_ACTIVE;
}
-static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float *max,
- float *UNUSED(softmin), float *UNUSED(softmax))
+static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
- *min = MINAFRAMEF;
- *max = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->efra : MAXFRAMEF;
+ CLAMP(value, MINAFRAMEF, MAXFRAMEF);
+ fcm->sfra = value;
+
+ /* XXX: maintain old offset? */
+ if (fcm->sfra >= fcm->efra) {
+ fcm->efra = fcm->sfra;
+ }
}
-static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float *max,
- float *UNUSED(softmin), float *UNUSED(softmax))
+static void rna_FModifer_end_frame_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
+
+ CLAMP(value, MINAFRAMEF, MAXFRAMEF);
+ fcm->efra = value;
+
+ /* XXX: maintain old offset? */
+ if (fcm->efra <= fcm->sfra) {
+ fcm->sfra = fcm->efra;
+ }
+}
- *min = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF;
- *max = MAXFRAMEF;
+static void rna_FModifier_start_frame_range(PointerRNA *UNUSED(ptr), float *min, float *max,
+ float *UNUSED(softmin), float *UNUSED(softmax))
+{
+ // FModifier *fcm = (FModifier *)ptr->data;
+
+ /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
+ * or else it becomes tricky to adjust the range... [#36844]
+ *
+ * NOTE: we do not set soft-limits on lower bounds, as it's too confusing when you
+ * can't easily use the slider to set things here
+ */
+ *min = MINAFRAMEF;
+ *max = MAXFRAMEF;
+}
+
+static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float *max,
+ float *softmin, float *softmax)
+{
+ FModifier *fcm = (FModifier *)ptr->data;
+
+ /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
+ * or else it becomes tricky to adjust the range... [#36844]
+ */
+ *min = MINAFRAMEF;
+ *softmin = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF;
+
+ *softmax = MAXFRAMEF;
+ *max = MAXFRAMEF;
}
static void rna_FModifier_blending_range(PointerRNA *ptr, float *min, float *max,
@@ -527,44 +565,101 @@ static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float
memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
}
-static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max,
- float *UNUSED(softmin), float *UNUSED(softmax))
+
+static void rna_FModifierLimits_minx_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
+
+ data->rect.xmin = value;
+
+ if (data->rect.xmin >= data->rect.xmax) {
+ data->rect.xmax = data->rect.xmin;
+ }
+}
- *min = MINAFRAMEF;
- *max = (data->flag & FCM_LIMIT_XMAX) ? data->rect.xmax : MAXFRAMEF;
+static void rna_FModifierLimits_maxx_set(PointerRNA *ptr, float value)
+{
+ FModifier *fcm = (FModifier *)ptr->data;
+ FMod_Limits *data = fcm->data;
+
+ data->rect.xmax = value;
+
+ if (data->rect.xmax <= data->rect.xmin) {
+ data->rect.xmin = data->rect.xmax;
+ }
}
-static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max,
- float *UNUSED(softmin), float *UNUSED(softmax))
+static void rna_FModifierLimits_miny_set(PointerRNA *ptr, float value)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
+
+ data->rect.ymin = value;
+
+ if (data->rect.ymin >= data->rect.ymax) {
+ data->rect.ymax = data->rect.ymin;
+ }
+}
- *min = (data->flag & FCM_LIMIT_XMIN) ? data->rect.xmin : MINAFRAMEF;
- *max = MAXFRAMEF;
+static void rna_FModifierLimits_maxy_set(PointerRNA *ptr, float value)
+{
+ FModifier *fcm = (FModifier *)ptr->data;
+ FMod_Limits *data = fcm->data;
+
+ data->rect.ymax = value;
+
+ if (data->rect.ymax <= data->rect.ymin) {
+ data->rect.ymin = data->rect.ymax;
+ }
}
-static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max,
+static void rna_FModifierLimits_minx_range(PointerRNA *UNUSED(ptr), float *min, float *max,
float *UNUSED(softmin), float *UNUSED(softmax))
{
+ // FModifier *fcm = (FModifier *)ptr->data;
+ // FMod_Limits *data = fcm->data;
+
+ /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */
+ *min = MINAFRAMEF;
+ *max = MAXFRAMEF;
+}
+
+static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max,
+ float *softmin, float *softmax)
+{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
+
+ *min = MINAFRAMEF;
+ *softmin = (data->flag & FCM_LIMIT_XMIN) ? data->rect.xmin : MINAFRAMEF;
+
+ *softmax = MAXFRAMEF;
+ *max = MAXFRAMEF;
+}
- *min = -FLT_MAX;
- *max = (data->flag & FCM_LIMIT_YMAX) ? data->rect.ymax : FLT_MAX;
+static void rna_FModifierLimits_miny_range(PointerRNA *UNUSED(ptr), float *min, float *max,
+ float *UNUSED(softmin), float *UNUSED(softmax))
+{
+ // FModifier *fcm = (FModifier *)ptr->data;
+ // FMod_Limits *data = fcm->data;
+
+ /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */
+ *min = -FLT_MAX;
+ *max = FLT_MAX;
}
static void rna_FModifierLimits_maxy_range(PointerRNA *ptr, float *min, float *max,
- float *UNUSED(softmin), float *UNUSED(softmax))
+ float *softmin, float *softmax)
{
FModifier *fcm = (FModifier *)ptr->data;
FMod_Limits *data = fcm->data;
-
- *min = (data->flag & FCM_LIMIT_YMIN) ? data->rect.ymin : -FLT_MAX;
- *max = FLT_MAX;
+
+ *min = -FLT_MAX;
+ *softmin = (data->flag & FCM_LIMIT_YMIN) ? data->rect.ymin : -FLT_MAX;
+
+ *softmax = FLT_MAX;
+ *max = FLT_MAX;
}
@@ -1008,25 +1103,25 @@ static void rna_def_fmodifier_limits(BlenderRNA *brna)
prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.xmin");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_minx_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_minx_set", "rna_FModifierLimits_minx_range");
RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.ymin");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_miny_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_miny_set", "rna_FModifierLimits_miny_range");
RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.xmax");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxx_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_maxx_set", "rna_FModifierLimits_maxx_range");
RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "rect.ymax");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxy_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_maxy_set", "rna_FModifierLimits_maxy_range");
RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
@@ -1191,14 +1286,14 @@ static void rna_def_fmodifier(BlenderRNA *brna)
prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sfra");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_start_frame_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifier_start_frame_set", "rna_FModifier_start_frame_range");
RNA_def_property_ui_text(prop, "Start Frame",
"Frame that modifier's influence starts (if Restrict Frame Range is in use)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "efra");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_end_frame_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifer_end_frame_set", "rna_FModifier_end_frame_range");
RNA_def_property_ui_text(prop, "End Frame",
"Frame that modifier's influence ends (if Restrict Frame Range is in use)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index b18c21d53f1..9007baa9dad 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -122,7 +122,7 @@ static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA
Object *ob = (Object *)ptr->id.data;
FluidsimModifierData *fluidmd;
ParticleSystemModifierData *psmd;
- ParticleSystem *psys;
+ ParticleSystem *psys, *next_psys;
ParticleSettings *part;
fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
@@ -155,7 +155,8 @@ static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA
}
}
else {
- for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+ for (psys = ob->particlesystem.first; psys; psys = next_psys) {
+ next_psys = psys->next;
if (psys->part->type == PART_FLUID) {
/* clear modifier */
psmd = psys_get_modifier(ob, psys);
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index a20cb73b3aa..6d6f516ecac 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -405,7 +405,7 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
}
/* determine where end of array is
- * - elemsize is in bytes, so use char* cast to get array in terms of bytes
+ * - elemsize is in bytes, so use (char *) cast to get array in terms of bytes
*/
end = (float *)((char *)start + (key->elemsize * kb->totelem));
@@ -422,7 +422,7 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point)
{
- /* if we frame the data array and point pointers as char*, then the difference between
+ /* if we frame the data array and point pointers as (char *), then the difference between
* them will be in bytes. Thus, dividing through by key->elemsize (number of bytes per point)
* gives us the offset of point from start of array.
*/
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 77d593b67b6..670df017038 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -446,7 +446,7 @@ static void rna_MaskSpline_points_add(ID *id, MaskSpline *spline, int count)
BKE_mask_parent_init(&new_point->parent);
/* Not efficient, but there's no other way for now */
- BKE_mask_layer_shape_changed_add(layer, spline_shape_index + point_index, TRUE, TRUE);
+ BKE_mask_layer_shape_changed_add(layer, spline_shape_index + point_index, true, true);
}
WM_main_add_notifier(NC_MASK | ND_DATA, mask);
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 34f138cd7c5..eee7692e2ed 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -109,6 +109,22 @@ EnumPropertyItem modifier_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
+EnumPropertyItem modifier_triangulate_quad_method_items[] = {
+ {MOD_TRIANGULATE_QUAD_BEAUTY, "BEAUTY", 0, "Beauty ", "Split the quads in nice triangles, slower method"},
+ {MOD_TRIANGULATE_QUAD_FIXED, "FIXED", 0, "Fixed", "Split the quads on the first and third vertices"},
+ {MOD_TRIANGULATE_QUAD_ALTERNATE, "FIXED_ALTERNATE", 0, "Fixed Alternate",
+ "Split the quads on the 2nd and 4th vertices"},
+ {MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORTEST_DIAGONAL", 0, "Shortest Diagonal",
+ "Split the quads based on the distance between the vertices"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem modifier_triangulate_ngon_method_items[] = {
+ {MOD_TRIANGULATE_NGON_SCANFILL, "SCANFILL", 0, "Scanfill", "Split the polygons using a scanfill algorithm"},
+ {MOD_TRIANGULATE_NGON_BEAUTY, "BEAUTY", 0, "Beauty", "Arrange the new triangles nicely, slower method"},
+ {0, NULL, 0, NULL, NULL}
+};
+
#ifdef RNA_RUNTIME
#include "DNA_particle_types.h"
@@ -118,6 +134,7 @@ EnumPropertyItem modifier_type_items[] = {
#include "BKE_depsgraph.h"
#include "BKE_library.h"
#include "BKE_modifier.h"
+#include "BKE_object.h"
#include "BKE_particle.h"
static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -536,6 +553,14 @@ static int rna_MultiresModifier_filepath_length(PointerRNA *ptr)
return strlen((external) ? external->filename : "");
}
+static void rna_HookModifier_object_set(PointerRNA *ptr, PointerRNA value)
+{
+ HookModifierData *hmd = ptr->data;
+
+ hmd->object = (Object *)value.data;
+ BKE_object_modifier_hook_reset((Object *)ptr->id.data, hmd);
+}
+
static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRNA value)
{
Object *ob = value.data;
@@ -1434,6 +1459,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna)
prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Object", "Parent Object for hook, also recalculates and clears offset");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_HookModifier_object_set", NULL, NULL);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
@@ -3490,9 +3516,16 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "TriangulateModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE);
- prop = RNA_def_property(srna, "use_beauty", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_TRIANGULATE_BEAUTY);
- RNA_def_property_ui_text(prop, "Beauty Subdivide", "Subdivide across shortest diagonal");
+ prop = RNA_def_property(srna, "quad_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "quad_method");
+ RNA_def_property_enum_items(prop, modifier_triangulate_quad_method_items);
+ RNA_def_property_ui_text(prop, "Quad Method", "Method for splitting the quads into triangles");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "ngon_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "ngon_method");
+ RNA_def_property_enum_items(prop, modifier_triangulate_ngon_method_items);
+ RNA_def_property_ui_text(prop, "Polygon Method", "Method for splitting the polygons into triangles");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index bb8e8d87252..6b5bced75bd 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1280,6 +1280,29 @@ static void rna_Node_draw_buttons_ext(struct uiLayout *layout, bContext *C, Poin
RNA_parameter_list_free(&list);
}
+static void rna_Node_draw_label(bNodeTree *ntree, bNode *node, char *label, int maxlen)
+{
+ extern FunctionRNA rna_Node_draw_label_func;
+
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ void *ret;
+ char *rlabel;
+
+ func = &rna_Node_draw_label_func; /* RNA_struct_find_function(&ptr, "draw_label"); */
+
+ RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
+ RNA_parameter_list_create(&list, &ptr, func);
+ node->typeinfo->ext.call(NULL, &ptr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "label", &ret);
+ rlabel = *(char **)ret;
+ BLI_strncpy(label, rlabel != NULL ? rlabel : "", maxlen);
+
+ RNA_parameter_list_free(&list);
+}
+
static int rna_Node_is_registered_node_type(StructRNA *type)
{
return (RNA_struct_blender_type_get(type) != NULL);
@@ -1321,7 +1344,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
PointerRNA dummyptr;
FunctionRNA *func;
PropertyRNA *parm;
- int have_function[8];
+ int have_function[9];
/* setup dummy node & node type to store static properties in */
memset(&dummynt, 0, sizeof(bNodeType));
@@ -1379,6 +1402,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
nt->freefunc_api = (have_function[5]) ? rna_Node_free : NULL;
nt->draw_buttons = (have_function[6]) ? rna_Node_draw_buttons : NULL;
nt->draw_buttons_ex = (have_function[7]) ? rna_Node_draw_buttons_ext : NULL;
+ nt->labelfunc = (have_function[8]) ? rna_Node_draw_label : NULL;
/* sanitize size values in case not all have been registered */
if (nt->maxwidth < nt->minwidth)
@@ -2693,6 +2717,18 @@ static PointerRNA rna_NodeOutputFile_slot_file_get(CollectionPropertyIterator *i
return ptr;
}
+static void rna_NodeColorBalance_update_lgg(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ ntreeCompositColorBalanceSyncFromLGG(ptr->id.data, ptr->data);
+ rna_Node_update(bmain, scene, ptr);
+}
+
+static void rna_NodeColorBalance_update_cdl(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ ntreeCompositColorBalanceSyncFromCDL(ptr->id.data, ptr->data);
+ rna_Node_update(bmain, scene, ptr);
+}
+
/* ******** Node Socket Types ******** */
static PointerRNA rna_NodeOutputFile_slot_layer_get(CollectionPropertyIterator *iter)
@@ -3256,6 +3292,7 @@ static void def_sh_tex_sky(StructRNA *srna)
{SHD_SKY_NEW, "HOSEK_WILKIE", 0, "Hosek / Wilkie", ""},
{0, NULL, 0, NULL, NULL}
};
+ static float default_dir[3] = {0.0f, 0.0f, 1.0f};
PropertyRNA *prop;
@@ -3270,6 +3307,8 @@ static void def_sh_tex_sky(StructRNA *srna)
prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_array_default(prop, default_dir);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "turbidity", PROP_FLOAT, PROP_NONE);
@@ -4343,7 +4382,7 @@ static void def_cmp_despeckle(StructRNA *srna)
RNA_def_property_ui_text(prop, "Threshold", "Threshold for detecting pixels to despeckle");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
- prop = RNA_def_property(srna, "threshold_neighbour", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "threshold_neighbor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "custom4");
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_property_ui_text(prop, "Neighbor", "Threshold for the number of neighbor pixels that must match");
@@ -5233,7 +5272,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Lift", "Correction for Shadows");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gamma");
@@ -5241,7 +5280,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Gamma", "Correction for Midtones");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gain");
@@ -5249,33 +5288,33 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Gain", "Correction for Highlights");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "lift");
+ RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
RNA_def_property_ui_text(prop, "Offset", "Correction for Shadows");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
prop = RNA_def_property(srna, "power", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "gamma");
+ RNA_def_property_float_sdna(prop, NULL, "power");
RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_range(prop, 0.f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Power", "Correction for Midtones");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
prop = RNA_def_property(srna, "slope", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "gain");
+ RNA_def_property_float_sdna(prop, NULL, "slope");
RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_range(prop, 0.f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Slope", "Correction for Highlights");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
}
static void def_cmp_huecorrect(StructRNA *srna)
@@ -7134,6 +7173,14 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_struct_type(parm, "UILayout");
RNA_def_property_ui_text(parm, "Layout", "Layout in the UI");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+
+ /* dynamic label */
+ func = RNA_def_function(srna, "draw_label", NULL);
+ RNA_def_function_ui_description(func, "Returns a dynamic label string");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_string(func, "label", "", MAX_NAME, "Label", "");
+ RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
+ RNA_def_function_output(func, parm);
}
static void rna_def_node_link(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 33ae256c042..2a93925a8e5 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -517,21 +517,9 @@ static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA
{
if (!particle_id_check(ptr)) {
Object *ob = (Object *)ptr->id.data;
- PartDeflect *pd = ob->pd;
- ModifierData *md = modifiers_findByType(ob, eModifierType_Surface);
-
- /* add/remove modifier as needed */
- if (!md) {
- if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && ELEM(pd->forcefield, PFIELD_GUIDE, PFIELD_TEXTURE) == 0)
- if (ELEM4(ob->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE))
- ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Surface);
- }
- else {
- if (!pd || pd->shape != PFIELD_SHAPE_SURFACE)
- ED_object_modifier_remove(NULL, bmain, ob, md);
- }
-
+ ED_object_check_force_modifiers(bmain, scene, ob);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
+ WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
}
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 8dafe54e678..5151310cd64 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -2718,7 +2718,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "brownfac");
RNA_def_property_range(prop, 0.0f, 200.0f);
RNA_def_property_ui_range(prop, 0, 20, 1, 3);
- RNA_def_property_ui_text(prop, "Brownian", "Amount of Brownian motion");
+ RNA_def_property_ui_text(prop, "Brownian", "Amount of random, erratic particle movement");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 7ebbcf7b39b..1cd27e27f01 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -395,7 +395,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results");
func = RNA_def_function(srna, "test_break", "RE_engine_test_break");
- RNA_def_function_ui_description(func, "Test if the render operation should been cancelled, this is a fast call that should be used regularly for responsiveness");
+ RNA_def_function_ui_description(func, "Test if the render operation should been canceled, this is a fast call that should be used regularly for responsiveness");
prop = RNA_def_boolean(func, "do_break", 0, "Break", "");
RNA_def_function_return(func, prop);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 4d35acc84a0..686672e1629 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -145,7 +145,7 @@ EnumPropertyItem snap_element_items[] = {
};
EnumPropertyItem snap_node_element_items[] = {
- {SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"},
+ {SCE_SNAP_MODE_GRID, "GRID", ICON_SNAP_INCREMENT, "Grid", "Snap to grid"},
{SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_SNAP_EDGE, "Node X", "Snap to left/right node border"},
{SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_SNAP_EDGE, "Node Y", "Snap to top/bottom node border"},
{SCE_SNAP_MODE_NODE_XY, "NODE_XY", ICON_SNAP_EDGE, "Node X / Y", "Snap to any node border"},
@@ -159,7 +159,7 @@ EnumPropertyItem snap_uv_element_items[] = {
};
/* workaround for duplicate enums,
- * have each enum line as a defne then conditionally set it or not
+ * have each enum line as a define then conditionally set it or not
*/
#define R_IMF_ENUM_BMP {R_IMF_IMTYPE_BMP, "BMP", ICON_FILE_IMAGE, "BMP", "Output image in bitmap format"},
@@ -219,14 +219,6 @@ EnumPropertyItem snap_uv_element_items[] = {
# define R_IMF_ENUM_TIFF
#endif
-#ifdef WITH_OPENIMAGEIO
-# define R_IMF_ENUM_PSD {R_IMF_IMTYPE_PSD, "PSD", ICON_FILE_IMAGE, "Photosp PSD", \
- "Output image in Photoshop PSD format"},
-#else
-# define R_IMF_ENUM_PSD
-#endif
-
-
#define IMAGE_TYPE_ITEMS_IMAGE_ONLY \
R_IMF_ENUM_BMP \
/* DDS save not supported yet R_IMF_ENUM_DDS */ \
@@ -243,7 +235,6 @@ EnumPropertyItem snap_uv_element_items[] = {
R_IMF_ENUM_EXR \
R_IMF_ENUM_HDR \
R_IMF_ENUM_TIFF \
- R_IMF_ENUM_PSD \
EnumPropertyItem image_only_type_items[] = {
@@ -270,11 +261,7 @@ EnumPropertyItem image_type_items[] = {
{R_IMF_IMTYPE_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", "Output video in Ogg format"},
#endif
#ifdef WITH_QUICKTIME
-# ifdef USE_QTKIT
- {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"},
-# else
- {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"},
-# endif
+ {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"},
#endif
#ifdef WITH_FFMPEG
{R_IMF_IMTYPE_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", "Output video in Xvid format"},
@@ -964,7 +951,6 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_codecType_itemf(bCon
return item;
}
-#ifdef USE_QTKIT
static int rna_RenderSettings_qtcodecsettings_audiocodecType_get(PointerRNA *ptr)
{
QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data;
@@ -1003,7 +989,6 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_audiocodecType_itemf
return item;
}
#endif
-#endif
#ifdef WITH_FFMPEG
static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value)
@@ -1452,6 +1437,12 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons
}
}
+static void rna_UnifiedPaintSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+{
+ Brush *br = BKE_paint_brush(BKE_paint_get_active(scene));
+ WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
+}
+
static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value)
{
UnifiedPaintSettings *ups = ptr->data;
@@ -1471,10 +1462,11 @@ static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, flo
ups->unprojected_radius = value;
}
-static void rna_UnifiedPaintSettings_radius_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void rna_UnifiedPaintSettings_radius_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- /* changing the unified size should invalidate */
+ /* changing the unified size should invalidate the overlay but also update the brush */
BKE_paint_invalidate_overlay_all();
+ rna_UnifiedPaintSettings_update(bmain, scene, ptr);
}
static char *rna_UnifiedPaintSettings_path(PointerRNA *UNUSED(ptr))
@@ -2045,6 +2037,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
RNA_def_property_ui_text(prop, "Strength", "How powerful the effect of the brush is when applied");
+ RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "weight");
@@ -2052,6 +2045,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
RNA_def_property_ui_text(prop, "Weight", "Weight to assign in vertex groups");
+ RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
prop = RNA_def_property(srna, "use_pressure_size", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_SIZE_PRESSURE);
@@ -2329,12 +2323,6 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_EDGE);
- RNA_def_property_ui_text(prop, "Edge", "Render Edge-enhance in this Layer (only works for Solid faces)");
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
prop = RNA_def_property(srna, "use_strand", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_STRAND);
RNA_def_property_ui_text(prop, "Strand", "Render Strands in this Layer");
@@ -3143,7 +3131,6 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
};
static EnumPropertyItem material_items[] = {
- {GAME_MAT_TEXFACE, "SINGLETEXTURE", 0, "Singletexture", "Singletexture face materials"},
{GAME_MAT_MULTITEX, "MULTITEXTURE", 0, "Multitexture", "Multitexture materials"},
{GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language shaders"},
{0, NULL, 0, NULL, NULL}
@@ -3435,7 +3422,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_frame_rate", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES);
RNA_def_property_ui_text(prop, "Use Frame Rate",
- "Respect the frame rate rather than rendering as many frames as possible");
+ "Respect the frame rate from the Physics panel in the world properties "
+ "rather than rendering as many frames as possible");
prop = RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS);
@@ -3783,8 +3771,6 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
{FFMPEG_OGG, "OGG", 0, "Ogg", ""},
{FFMPEG_MKV, "MKV", 0, "Matroska", ""},
{FFMPEG_FLV, "FLASH", 0, "Flash", ""},
- {FFMPEG_WAV, "WAV", 0, "Wav", ""},
- {FFMPEG_MP3, "MP3", 0, "Mp3", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -3955,7 +3941,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
-#ifdef USE_QTKIT
static EnumPropertyItem quicktime_audio_samplerate_items[] = {
{22050, "22050", 0, "22kHz", ""},
{44100, "44100", 0, "44.1kHz", ""},
@@ -3985,7 +3970,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna)
{320000, "320000", 0, "320kbps", ""},
{0, NULL, 0, NULL, NULL}
};
-#endif
/* QuickTime */
srna = RNA_def_struct(brna, "QuickTimeSettings", NULL);
@@ -4007,7 +3991,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Spatial quality", "Intra-frame spatial quality level");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-#ifdef USE_QTKIT
prop = RNA_def_property(srna, "audiocodec_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "audiocodecType");
RNA_def_property_enum_items(prop, quicktime_codec_type_items);
@@ -4044,7 +4027,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, quicktime_audio_bitrate_items);
RNA_def_property_ui_text(prop, "Bitrate", "Compressed audio bitrate");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-#endif
}
#endif
@@ -4384,23 +4366,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Textures", "Use textures to affect material properties");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE);
- RNA_def_property_ui_text(prop, "Edge", "Create a toon outline around the edges of geometry");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "edge_threshold", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "edgeint");
- RNA_def_property_range(prop, 0, 255);
- RNA_def_property_ui_text(prop, "Edge Threshold", "Threshold for drawing outlines on geometry edges");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "edge_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "edgeR");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Edge Color", "Edge color");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS);
RNA_def_property_ui_text(prop, "Edge", "Draw stylized strokes using Freestyle");
@@ -5220,6 +5185,14 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Current Frame Final",
"Current frame with subframe and time remapping applied");
+ prop = RNA_def_property(srna, "lock_frame_selection_to_range", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_boolean_sdna(prop, NULL, "r.flag", SCER_LOCK_FRAME_SELECTION);
+ RNA_def_property_ui_text(prop, "Lock Frame Selection",
+ "Don't allow frame to be selected with mouse outside of frame range");
+ RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
+ RNA_def_property_ui_icon(prop, ICON_LOCKED, 0);
+
/* Preview Range (frame-range for UI playback) */
prop = RNA_def_property(srna, "use_preview_range", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 89714e49ebf..a9f84f1dcc7 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -340,36 +340,44 @@ static void rna_def_sculpt(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_symmetry_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X);
RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_symmetry_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_Y);
RNA_def_property_ui_text(prop, "Symmetry Y", "Mirror brush across the Y axis");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_symmetry_z", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_Z);
RNA_def_property_ui_text(prop, "Symmetry Z", "Mirror brush across the Z axis");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "lock_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_X);
RNA_def_property_ui_text(prop, "Lock X", "Disallow changes to the X axis of vertices");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "lock_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Y);
RNA_def_property_ui_text(prop, "Lock Y", "Disallow changes to the Y axis of vertices");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "lock_z", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Z);
RNA_def_property_ui_text(prop, "Lock Z", "Disallow changes to the Z axis of vertices");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_symmetry_feather", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMMETRY_FEATHER);
RNA_def_property_ui_text(prop, "Symmetry Feathering",
"Reduce the strength of the brush where it overlaps symmetrical daubs");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_threaded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_USE_OPENMP);
RNA_def_property_ui_text(prop, "Use OpenMP",
"Take advantage of multiple CPU cores to improve sculpting performance");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_deform_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_ONLY_DEFORM);
@@ -400,6 +408,7 @@ static void rna_def_sculpt(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Collapse Short Edges",
"In dynamic-topology mode, collapse short edges "
"in addition to subdividing long ones");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, symmetrize_direction_items);
@@ -432,19 +441,23 @@ static void rna_def_vertex_paint(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_all_faces", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_AREA);
RNA_def_property_ui_text(prop, "All Faces", "Paint on all faces inside brush");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_NORMALS);
RNA_def_property_ui_text(prop, "Normals", "Apply the vertex normal before painting");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_spray", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_SPRAY);
RNA_def_property_ui_text(prop, "Spray", "Keep applying paint effect while holding mouse");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* weight paint only */
prop = RNA_def_property(srna, "use_group_restrict", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_ONLYVGROUP);
RNA_def_property_ui_text(prop, "Restrict", "Restrict painting to vertices in the group");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
static void rna_def_image_paint(BlenderRNA *brna)
@@ -461,27 +474,33 @@ static void rna_def_image_paint(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_occlude", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_XRAY);
RNA_def_property_ui_text(prop, "Occlude", "Only paint onto the faces directly under the brush (slower)");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_BACKFACE);
RNA_def_property_ui_text(prop, "Cull", "Ignore faces pointing away from the view (faster)");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_normal_falloff", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_FLAT);
RNA_def_property_ui_text(prop, "Normal", "Paint most on faces pointing towards the view");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_stencil_layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL);
RNA_def_property_ui_text(prop, "Stencil Layer", "Set the mask layer from the UV map buttons");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "invert_stencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL_INV);
RNA_def_property_ui_text(prop, "Invert", "Invert the stencil layer");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE);
RNA_def_property_ui_text(prop, "Clone Map",
"Use another UV map as clone source, otherwise use the 3D cursor as the source");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* integers */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 73f0d33257c..cf6202f07c6 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -370,7 +370,7 @@ static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values)
View3D *v3d = (View3D *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
Scene *scene = (Scene *)sc->scene;
- const float *loc = give_cursor(scene, v3d);
+ const float *loc = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(values, loc);
}
@@ -380,7 +380,7 @@ static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values)
View3D *v3d = (View3D *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
Scene *scene = (Scene *)sc->scene;
- float *cursor = give_cursor(scene, v3d);
+ float *cursor = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(cursor, values);
}
@@ -1212,7 +1212,8 @@ static int rna_SpaceNodeEditor_tree_type_poll(void *Cv, bNodeTreeType *type)
else
return TRUE;
}
-static EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
+static EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(bContext *C, PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop), int *free)
{
return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, free);
}
@@ -1490,7 +1491,6 @@ static void rna_def_space_outliner(BlenderRNA *brna)
{SO_LIBRARIES, "LIBRARIES", 0, "Blender File", "Display data of current file and linked libraries"},
{SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", "Display all raw datablocks"},
{SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display the user preference datablocks"},
- {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", "Display keymap datablocks"},
{0, NULL, 0, NULL, NULL}
};
@@ -1786,8 +1786,8 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_render_border", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_BORDER);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Render Border",
- "Use a region within the frame size for rendered viewport (when not viewing through the camera)");
+ RNA_def_property_ui_text(prop, "Render Border", "Use a region within the frame size for rendered viewport "
+ "(when not viewing through the camera)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "render_border_min_x", PROP_FLOAT, PROP_NONE);
@@ -1833,7 +1833,8 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "viewport_shade", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "drawtype");
RNA_def_property_enum_items(prop, viewport_shade_items);
- RNA_def_property_enum_funcs(prop, "rna_SpaceView3D_viewport_shade_get", NULL, "rna_SpaceView3D_viewport_shade_itemf");
+ RNA_def_property_enum_funcs(prop, "rna_SpaceView3D_viewport_shade_get", NULL,
+ "rna_SpaceView3D_viewport_shade_itemf");
RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
@@ -1950,6 +1951,11 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Backface Culling", "Use back face culling to hide the back side of faces");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "show_textured_shadeless", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHADELESS_TEX);
+ RNA_def_property_ui_text(prop, "Shadeless", "Show shadeless texture without lighting in textured draw mode");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_OCCLUDE_WIRE);
RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display");
@@ -2070,6 +2076,7 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "tracks_draw_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0, 5, 1, 3);
RNA_def_property_float_sdna(prop, NULL, "bundle_size");
RNA_def_property_ui_text(prop, "Tracks Size", "Display size of tracks from reconstructed data");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -2881,6 +2888,19 @@ static void rna_def_space_graph(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_SpaceGraphEditor_has_ghost_curves_get", NULL);
RNA_def_property_ui_text(prop, "Has Ghost Curves", "Graph Editor instance has some ghost curves stored");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
+
+ /* nromalize curves */
+ prop = RNA_def_property(srna, "use_normalization", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_NORMALIZE);
+ RNA_def_property_ui_text(prop, "Use Normalization", "Display curves in normalized to -1..1 range, "
+ "for easier editing of multiple curves with different ranges");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
+
+ prop = RNA_def_property(srna, "use_auto_normalization", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NORMALIZE_FREEZE);
+ RNA_def_property_ui_text(prop, "Auto Normalization",
+ "Automatically recalculate curve normalization on every curve edit");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
}
static void rna_def_space_nla(BlenderRNA *brna)
@@ -3374,7 +3394,8 @@ static void rna_def_space_node(BlenderRNA *brna)
prop = RNA_def_property(srna, "tree_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, dummy_items);
- RNA_def_property_enum_funcs(prop, "rna_SpaceNodeEditor_tree_type_get", "rna_SpaceNodeEditor_tree_type_set", "rna_SpaceNodeEditor_tree_type_itemf");
+ RNA_def_property_enum_funcs(prop, "rna_SpaceNodeEditor_tree_type_get", "rna_SpaceNodeEditor_tree_type_set",
+ "rna_SpaceNodeEditor_tree_type_itemf");
RNA_def_property_ui_text(prop, "Tree Type", "Node tree type to display and edit");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL);
@@ -3406,7 +3427,8 @@ static void rna_def_space_node(BlenderRNA *brna)
rna_def_space_node_path_api(brna, prop);
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceNodeEditor_node_tree_set", NULL, "rna_SpaceNodeEditor_node_tree_poll");
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceNodeEditor_node_tree_set", NULL,
+ "rna_SpaceNodeEditor_node_tree_poll");
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Node Tree", "Base node tree from context");
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 97f5c24dc56..a0aed94f3c6 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -570,7 +570,8 @@ static MovieTrackingTrack *rna_trackingTracks_new(ID *id, MovieTracking *trackin
return track;
}
-static MovieTrackingTrack *rna_trackingObject_tracks_new(ID *id, MovieTrackingObject *object, const char *name, int frame)
+static MovieTrackingTrack *rna_trackingObject_tracks_new(ID *id, MovieTrackingObject *object, const char *name,
+ int frame)
{
MovieClip *clip = (MovieClip *) id;
ListBase *tracksbase = &object->tracks;
@@ -649,7 +650,8 @@ static void rna_trackingMarkers_delete_frame(MovieTrackingTrack *track, int fram
WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL);
}
-static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_find_frame(MovieTrackingPlaneTrack *plane_track, int framenr, int exact)
+static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_find_frame(MovieTrackingPlaneTrack *plane_track,
+ int framenr, int exact)
{
if (exact)
return BKE_tracking_plane_marker_get_exact(plane_track, framenr);
@@ -657,7 +659,8 @@ static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_find_frame(MovieTracki
return BKE_tracking_plane_marker_get(plane_track, framenr);
}
-static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_insert_frame(MovieTrackingPlaneTrack *plane_track, int framenr)
+static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_insert_frame(MovieTrackingPlaneTrack *plane_track,
+ int framenr)
{
MovieTrackingPlaneMarker plane_marker, *new_plane_marker;
@@ -767,22 +770,6 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
"Limit speed of tracking to make visual feedback easier "
"(this does not affect the tracking quality)");
- /* reconstruction success_threshold */
- prop = RNA_def_property(srna, "reconstruction_success_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_float_default(prop, 0.001f);
- RNA_def_property_range(prop, 0, FLT_MAX);
- RNA_def_property_ui_text(prop, "Success Threshold",
- "Threshold value of reconstruction error which is still considered successful");
-
- /* use fallback reconstruction */
- prop = RNA_def_property(srna, "use_fallback_reconstruction", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_boolean_sdna(prop, NULL, "reconstruction_flag", TRACKING_USE_FALLBACK_RECONSTRUCTION);
- RNA_def_property_ui_text(prop, "Use Fallback",
- "Use fallback reconstruction algorithm in cases main reconstruction algorithm failed "
- "(could give better solution with bad tracks)");
-
/* use keyframe selection */
prop = RNA_def_property(srna, "use_keyframe_selection", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -1105,6 +1092,12 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
"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");
+
+ /* is marker keyframed */
+ prop = RNA_def_property(srna, "is_keyed", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MARKER_TRACKED);
+ RNA_def_property_ui_text(prop, "Keyframed", "Whether the position of the marker is keyframed or tracked");
}
static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1355,6 +1348,20 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "GreasePencil");
RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this track");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+
+ /* weight */
+ prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "weight");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Weight", "Influence of this track on a final solution");
+
+ /* offset */
+ prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION);
+ RNA_def_property_array(prop, 2);
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ RNA_def_property_float_sdna(prop, NULL, "offset");
+ RNA_def_property_ui_text(prop, "Offset", "Offset of track from the parenting point");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
}
static void rna_def_trackingPlaneMarker(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 20e5083b1c4..0e45d6d4aea 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -367,7 +367,7 @@ static void rna_userdef_pathcompare_remove(ReportList *reports, PointerRNA *path
{
bPathCompare *path_cmp = path_cmp_ptr->data;
if (BLI_findindex(&U.autoexec_paths, path_cmp) == -1) {
- BKE_report(reports, RPT_ERROR, "Addon is no longer valid");
+ BKE_report(reports, RPT_ERROR, "Excluded path is no longer valid");
return;
}
@@ -2909,7 +2909,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_tooltips_python", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_TOOLTIPS_PYTHON);
- RNA_def_property_ui_text(prop, "Show Python Tooltips", "Show Python references in tooltips");
+ RNA_def_property_ui_text(prop, "Python Tooltips", "Show Python references in tooltips");
prop = RNA_def_property(srna, "show_object_info", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DRAWVIEWINFO);
@@ -3266,7 +3266,13 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "gp_eraser");
RNA_def_property_range(prop, 0, 100);
RNA_def_property_ui_text(prop, "Grease Pencil Eraser Radius", "Radius of eraser 'brush'");
-
+
+
+ prop = RNA_def_property(srna, "grease_pencil_default_color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_sdna(prop, NULL, "gpencil_new_layer_col");
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_ui_text(prop, "Grease Pencil Default Color", "Color of new Grease Pencil layers");
+
/* sculpt and paint */
prop = RNA_def_property(srna, "sculpt_paint_overlay_color", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -4091,7 +4097,7 @@ static void rna_def_userdef_autoexec_path_collection(BlenderRNA *brna, PropertyR
func = RNA_def_function(srna, "new", "rna_userdef_pathcompare_new");
RNA_def_function_flag(func, FUNC_NO_SELF);
- RNA_def_function_ui_description(func, "Add a new addon");
+ RNA_def_function_ui_description(func, "Add a new path");
/* return type */
parm = RNA_def_pointer(func, "pathcmp", "PathCompare", "", "");
RNA_def_function_return(func, parm);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index c6366745c55..09451599ce5 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -442,13 +442,6 @@ EnumPropertyItem wm_report_items[] = {
{0, NULL, 0, NULL, NULL}
};
-#define KMI_TYPE_KEYBOARD 0
-#define KMI_TYPE_MOUSE 1
-#define KMI_TYPE_TWEAK 2
-#define KMI_TYPE_TEXTINPUT 3
-#define KMI_TYPE_TIMER 4
-#define KMI_TYPE_NDOF 5
-
#ifdef RNA_RUNTIME
#include <assert.h>
@@ -625,13 +618,7 @@ static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
- if (ISTIMER(kmi->type)) return KMI_TYPE_TIMER;
- if (ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD;
- if (ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK;
- if (ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE;
- if (ISNDOF(kmi->type)) return KMI_TYPE_NDOF;
- if (kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT;
- return KMI_TYPE_KEYBOARD;
+ return WM_keymap_map_type_get(kmi);
}
static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
@@ -1055,15 +1042,13 @@ static void operator_draw(bContext *C, wmOperator *op)
}
/* same as exec(), but call cancel */
-static int operator_cancel(bContext *C, wmOperator *op)
+static void operator_cancel(bContext *C, wmOperator *op)
{
extern FunctionRNA rna_Operator_cancel_func;
PointerRNA opr;
ParameterList list;
FunctionRNA *func;
- void *ret;
- int result;
RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
@@ -1072,12 +1057,7 @@ static int operator_cancel(bContext *C, wmOperator *op)
RNA_parameter_set_lookup(&list, "context", &C);
op->type->ext.call(C, &opr, func, &list);
- RNA_parameter_get_lookup(&list, "result", &ret);
- result = *(int *)ret;
-
RNA_parameter_list_free(&list);
-
- return result;
}
void operator_wrapper(wmOperatorType *ot, void *userdata);
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index eb84bb61e1f..91cddd28be0 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -539,10 +539,6 @@ void RNA_api_operator(StructRNA *srna)
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
-
- /* better name? */
- parm = RNA_def_enum_flag(func, "result", operator_return_items, OPERATOR_CANCELLED, "result", "");
- RNA_def_function_return(func, parm);
}
void RNA_api_macro(StructRNA *srna)
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index b689a82c231..c7997bebedb 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -56,10 +56,6 @@ static PointerRNA rna_World_lighting_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_WorldLighting, ptr->id.data);
}
-static PointerRNA rna_World_stars_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_WorldStarsSettings, ptr->id.data);
-}
static PointerRNA rna_World_mist_get(PointerRNA *ptr)
{
@@ -114,14 +110,6 @@ static void rna_World_draw_mist_update(Main *UNUSED(bmain), Scene *UNUSED(scene)
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
-static void rna_World_stars_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- World *wo = ptr->id.data;
-
- DAG_id_tag_update(&wo->id, 0);
- WM_main_add_notifier(NC_WORLD | ND_WORLD_STARS, wo);
-}
-
static void rna_World_use_nodes_update(bContext *C, PointerRNA *ptr)
{
World *wrld = (World *)ptr->data;
@@ -450,46 +438,6 @@ static void rna_def_world_mist(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_World_update");
}
-static void rna_def_world_stars(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "WorldStarsSettings", NULL);
- RNA_def_struct_sdna(srna, "World");
- RNA_def_struct_nested(brna, srna, "World");
- RNA_def_struct_ui_text(srna, "World Stars", "Stars settings for a World data-block");
-
- prop = RNA_def_property(srna, "use_stars", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_STARS);
- RNA_def_property_ui_text(prop, "Use Stars", "Enable starfield generation");
- RNA_def_property_update(prop, 0, "rna_World_stars_update");
-
- prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "starsize");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Size", "Average screen dimension of stars");
- RNA_def_property_update(prop, 0, "rna_World_draw_update"); /* use normal update since this isn't visualized */
-
- prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "starmindist");
- RNA_def_property_range(prop, 0, 1000);
- RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance to the camera for stars");
- RNA_def_property_update(prop, 0, "rna_World_stars_update");
-
- prop = RNA_def_property(srna, "average_separation", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "stardist");
- RNA_def_property_range(prop, 2, 1000);
- RNA_def_property_ui_text(prop, "Average Separation", "Average distance between any two stars");
- RNA_def_property_update(prop, 0, "rna_World_stars_update");
-
- prop = RNA_def_property(srna, "color_random", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "starcolnoise");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Color Randomization", "Randomize star colors");
- RNA_def_property_update(prop, 0, "rna_World_stars_update");
-}
-
void RNA_def_world(BlenderRNA *brna)
{
StructRNA *srna;
@@ -568,12 +516,6 @@ void RNA_def_world(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Mist", "World mist settings");
- prop = RNA_def_property(srna, "star_settings", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "WorldStarsSettings");
- RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Stars", "World stars settings");
-
/* nodes */
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
@@ -588,7 +530,6 @@ void RNA_def_world(BlenderRNA *brna)
rna_def_lighting(brna);
rna_def_world_mist(brna);
- rna_def_world_stars(brna);
rna_def_world_mtex(brna);
}
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 7c47fd5862e..bc38b0e030b 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -384,18 +384,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
Curve *cu = amd->curve_ob->data;
if (cu) {
- float tmp_mat[3][3];
- float scale;
-
- BKE_object_to_mat3(amd->curve_ob, tmp_mat);
- scale = mat3_to_scale(tmp_mat);
-
if (!amd->curve_ob->curve_cache || !amd->curve_ob->curve_cache->path) {
cu->flag |= CU_PATH; // needed for path & bevlist
BKE_displist_make_curveTypes(scene, amd->curve_ob, 0);
}
- if (amd->curve_ob->curve_cache->path)
+ if (amd->curve_ob->curve_cache->path) {
+ float scale = mat4_to_scale(amd->curve_ob->obmat);
length = scale * amd->curve_ob->curve_cache->path->totdist;
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 326ffba3e2e..6a1de92f9b2 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -158,7 +158,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
}
}
- BM_mesh_bevel(bm, bmd->value, bmd->res,
+ /* TODO: add offset_kind to modifier properties to, and pass in as 3rd arg here */
+ BM_mesh_bevel(bm, bmd->value, 0, bmd->res,
vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
dvert, vgroup);
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index a3569cbde68..e4399d1e416 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -196,9 +196,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* update for display only */
dmd->face_count = bm->totface;
result = CDDM_from_bmesh(bm, FALSE);
- BLI_assert(bm->vtoolflagpool == NULL); /* make sure we never alloc'd this */
- BLI_assert(bm->etoolflagpool == NULL);
- BLI_assert(bm->ftoolflagpool == NULL);
+ BLI_assert(bm->vtoolflagpool == NULL &&
+ bm->etoolflagpool == NULL &&
+ bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */
+ BLI_assert(bm->vtable == NULL &&
+ bm->etable == NULL &&
+ bm->ftable == NULL);
+
BM_mesh_free(bm);
#ifdef USE_TIMEIT
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 25254c7a30e..61f5495bee8 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -219,7 +219,7 @@ static void displaceModifier_do(
if (dmd->texture) {
texres.nor = NULL;
- get_texture_value(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, false);
+ BKE_texture_get_value(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, false);
delta = texres.tin - dmd->midlevel;
}
else {
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 0d302fed3e6..839e30d9c1a 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -62,6 +62,8 @@ static void copyData(ModifierData *md, ModifierData *target)
BLI_strncpy(tmmd->vgroup, mmd->vgroup, sizeof(tmmd->vgroup));
tmmd->flag = mmd->flag;
+ tmmd->mode = mmd->mode;
+ tmmd->ob_arm = mmd->ob_arm;
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
@@ -170,7 +172,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
/* if no dverts (i.e. no data for vertex groups exists), we've got an
- * inconsistent situation, so free hashes and return oirginal mesh
+ * inconsistent situation, so free hashes and return original mesh
*/
dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
if (dvert == NULL) {
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 8386f0ff9af..e540d5c1b2c 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -199,10 +199,10 @@ static void meshdeformModifier_do(
if (!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc))
return;
-
+
/* get cage derivedmesh */
if (em) {
- tmpdm = editbmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0);
+ tmpdm = editbmesh_get_derived_cage_and_final(md->scene, mmd->object, em, &cagedm, 0);
if (tmpdm)
tmpdm->release(tmpdm);
}
@@ -346,7 +346,7 @@ static void deformVerts(ModifierData *md, Object *ob,
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
-
+
meshdeformModifier_do(md, ob, dm, vertexCos, numVerts);
if (dm && dm != derivedData)
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 0dd2f2770a4..7955e02cdb6 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -34,6 +34,7 @@
/* Screw modifier: revolves the edges about an axis */
+#include <limits.h>
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -41,19 +42,20 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-
#include "BKE_cdderivedmesh.h"
#include "depsgraph_private.h"
#include "MOD_modifiertypes.h"
#include "MEM_guardedalloc.h"
+#include "BLI_strict_flags.h"
+
/* used for gathering edge connectivity */
typedef struct ScrewVertConnect {
float dist; /* distance from the center axis */
float co[3]; /* loaction relative to the transformed axis */
float no[3]; /* calc normal of the vertex */
- int v[2]; /* 2 verts on either side of this one */
+ unsigned int v[2]; /* 2 verts on either side of this one */
MEdge *e[2]; /* edges on either side, a bit of a waste since each edge ref's 2 edges */
char flag;
} ScrewVertConnect;
@@ -61,18 +63,20 @@ typedef struct ScrewVertConnect {
typedef struct ScrewVertIter {
ScrewVertConnect *v_array;
ScrewVertConnect *v_poin;
- int v;
- int v_other;
+ unsigned int v, v_other;
MEdge *e;
} ScrewVertIter;
+#define SV_UNUSED (UINT_MAX)
+#define SV_INVALID ((UINT_MAX) - 1)
+#define SV_IS_VALID(v) (v < SV_INVALID)
-static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, int v_init, int dir)
+static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, unsigned int v_init, unsigned int dir)
{
iter->v_array = array;
iter->v = v_init;
- if (v_init >= 0) {
+ if (SV_IS_VALID(v_init)) {
iter->v_poin = &array[v_init];
iter->v_other = iter->v_poin->v[dir];
iter->e = iter->v_poin->e[!dir];
@@ -94,7 +98,7 @@ static void screwvert_iter_step(ScrewVertIter *iter)
iter->v_other = iter->v;
iter->v = iter->v_poin->v[0];
}
- if (iter->v >= 0) {
+ if (SV_IS_VALID(iter->v)) {
iter->v_poin = &iter->v_array[iter->v];
iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)];
}
@@ -109,7 +113,7 @@ static void initData(ModifierData *md)
{
ScrewModifierData *ltmd = (ScrewModifierData *) md;
ltmd->ob_axis = NULL;
- ltmd->angle = M_PI * 2.0;
+ ltmd->angle = (float)(M_PI * 2.0);
ltmd->axis = 2;
ltmd->flag = MOD_SCREW_SMOOTH_SHADING;
ltmd->steps = 16;
@@ -143,16 +147,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
int *origindex;
int mpoly_index = 0;
- int step;
- int i, j;
+ unsigned int step;
+ unsigned int i, j;
unsigned int i1, i2;
- int step_tot = useRenderParams ? ltmd->render_steps : ltmd->steps;
- const int do_flip = ltmd->flag & MOD_SCREW_NORMAL_FLIP ? 1 : 0;
- int maxVerts = 0, maxEdges = 0, maxPolys = 0;
- const unsigned int totvert = dm->getNumVerts(dm);
- const unsigned int totedge = dm->getNumEdges(dm);
-
- char axis_char = 'X', close;
+ unsigned int step_tot = useRenderParams ? ltmd->render_steps : ltmd->steps;
+ const bool do_flip = ltmd->flag & MOD_SCREW_NORMAL_FLIP ? 1 : 0;
+ unsigned int maxVerts = 0, maxEdges = 0, maxPolys = 0;
+ const unsigned int totvert = (unsigned int)dm->getNumVerts(dm);
+ const unsigned int totedge = (unsigned int)dm->getNumEdges(dm);
+ const unsigned int totpoly = (unsigned int)dm->getNumPolys(dm);
+ unsigned int *edge_poly_map = NULL;
+
+ char axis_char = 'X';
+ bool close;
float angle = ltmd->angle;
float screw_ofs = ltmd->screw_ofs;
float axis_vec[3] = {0.0f, 0.0f, 0.0f};
@@ -162,14 +169,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
float mtx_tx_inv[4][4]; /* inverted */
float mtx_tmp_a[4][4];
- int vc_tot_linked = 0;
+ unsigned int vc_tot_linked = 0;
short other_axis_1, other_axis_2;
float *tmpf1, *tmpf2;
- int edge_offset;
+ unsigned int edge_offset;
- MPoly *mpoly_new, *mp_new;
- MLoop *mloop_new, *ml_new;
+ MPoly *mpoly_orig, *mpoly_new, *mp_new;
+ MLoop *mloop_orig, *mloop_new, *ml_new;
MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new;
MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base;
@@ -259,7 +266,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
else {
/* exis char is used by i_rotate*/
- axis_char += ltmd->axis; /* 'X' + axis */
+ axis_char = (char)(axis_char + ltmd->axis); /* 'X' + axis */
/* useful to be able to use the axis vec in some cases still */
zero_v3(axis_vec);
@@ -267,8 +274,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
/* apply the multiplier */
- angle *= ltmd->iter;
- screw_ofs *= ltmd->iter;
+ angle *= (float)ltmd->iter;
+ screw_ofs *= (float)ltmd->iter;
/* multiplying the steps is a bit tricky, this works best */
step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);
@@ -299,7 +306,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
maxPolys = totedge * (step_tot - 1);
}
- result = CDDM_from_template(dm, maxVerts, maxEdges, 0, maxPolys * 4, maxPolys);
+ result = CDDM_from_template(dm, (int)maxVerts, (int)maxEdges, 0, (int)maxPolys * 4, (int)maxPolys);
/* copy verts from mesh */
mvert_orig = dm->getVertArray(dm);
@@ -311,12 +318,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
medge_new = result->getEdgeArray(result);
if (!CustomData_has_layer(&result->polyData, CD_ORIGINDEX)) {
- CustomData_add_layer(&result->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, maxPolys);
+ CustomData_add_layer(&result->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, (int)maxPolys);
}
origindex = CustomData_get_layer(&result->polyData, CD_ORIGINDEX);
- DM_copy_vert_data(dm, result, 0, 0, totvert); /* copy first otherwise this overwrites our own vertex normals */
+ DM_copy_vert_data(dm, result, 0, 0, (int)totvert); /* copy first otherwise this overwrites our own vertex normals */
/* Set the locations of the first set of verts */
@@ -333,6 +340,29 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
med_new->flag = med_orig->flag & ~ME_LOOSEEDGE;
}
+ /* build polygon -> edge map */
+ if (totpoly) {
+ MPoly *mp_orig;
+
+ mpoly_orig = dm->getPolyArray(dm);
+ mloop_orig = dm->getLoopArray(dm);
+ edge_poly_map = MEM_mallocN(sizeof(*edge_poly_map) * totedge, __func__);
+ memset(edge_poly_map, 0xff, sizeof(*edge_poly_map) * totedge);
+
+ for (i = 0, mp_orig = mpoly_orig; i < totpoly; i++, mp_orig++) {
+ MLoop *ml_orig = &mloop_orig[mp_orig->loopstart];
+ int k;
+ for (k = 0; k < mp_orig->totloop; k++, ml_orig++) {
+ edge_poly_map[ml_orig->e] = i;
+
+ /* also order edges based on faces */
+ if (medge_new[ml_orig->e].v1 != ml_orig->v) {
+ SWAP(unsigned int, medge_new[ml_orig->e].v1, medge_new[ml_orig->e].v2);
+ }
+ }
+ }
+ }
+
if (ltmd->flag & MOD_SCREW_NORMAL_CALC) {
/*
* Normal Calculation (for face flipping)
@@ -385,7 +415,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->flag = 0;
vc->e[0] = vc->e[1] = NULL;
- vc->v[0] = vc->v[1] = -1;
+ vc->v[0] = vc->v[1] = SV_UNUSED;
mul_m4_v3(mtx_tx, vc->co);
/* length in 2d, don't sqrt because this is only for comparison */
@@ -403,7 +433,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->flag = 0;
vc->e[0] = vc->e[1] = NULL;
- vc->v[0] = vc->v[1] = -1;
+ vc->v[0] = vc->v[1] = SV_UNUSED;
/* length in 2d, don't sqrt because this is only for comparison */
vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
@@ -417,31 +447,31 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
for (i = 0; i < totedge; i++, med_new++) {
vc = &vert_connect[med_new->v1];
- if (vc->v[0] == -1) { /* unused */
+ if (vc->v[0] == SV_UNUSED) { /* unused */
vc->v[0] = med_new->v2;
vc->e[0] = med_new;
}
- else if (vc->v[1] == -1) {
+ else if (vc->v[1] == SV_UNUSED) {
vc->v[1] = med_new->v2;
vc->e[1] = med_new;
}
else {
- vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
+ vc->v[0] = vc->v[1] = SV_INVALID; /* error value - don't use, 3 edges on vert */
}
vc = &vert_connect[med_new->v2];
/* same as above but swap v1/2 */
- if (vc->v[0] == -1) { /* unused */
+ if (vc->v[0] == SV_UNUSED) { /* unused */
vc->v[0] = med_new->v1;
vc->e[0] = med_new;
}
- else if (vc->v[1] == -1) {
+ else if (vc->v[1] == SV_UNUSED) {
vc->v[1] = med_new->v1;
vc->e[1] = med_new;
}
else {
- vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
+ vc->v[0] = vc->v[1] = SV_INVALID; /* error value - don't use, 3 edges on vert */
}
}
@@ -452,12 +482,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
* so resulting faces are flipped the right way */
vc_tot_linked = 0; /* count the number of linked verts for this loop */
if (vc->flag == 0) {
- int v_best = -1, ed_loop_closed = 0; /* vert and vert new */
+ unsigned int v_best = SV_UNUSED, ed_loop_closed = 0; /* vert and vert new */
ScrewVertIter lt_iter;
float fl = -1.0f;
/* compiler complains if not initialized, but it should be initialized below */
- int ed_loop_flip = 0;
+ bool ed_loop_flip = false;
/*printf("Loop on connected vert: %i\n", i);*/
@@ -471,7 +501,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/*printf("\t\tVERT: %i\n", lt_iter.v);*/
if (lt_iter.v_poin->flag) {
/*printf("\t\t\tBreaking Found end\n");*/
- //endpoints[0] = endpoints[1] = -1;
+ //endpoints[0] = endpoints[1] = SV_UNUSED;
ed_loop_closed = 1; /* circle */
break;
}
@@ -493,7 +523,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
/* now we have a collection of used edges. flip their edges the right way*/
- /*if (v_best != -1) - */
+ /*if (v_best != SV_UNUSED) - */
/*printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);*/
@@ -507,7 +537,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* edge connects on each side! */
- if ((vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) {
+ if (SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) {
/*printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/
/* find out which is higher */
@@ -536,7 +566,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
}
}
- else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */
+ else if (SV_IS_VALID(vc_tmp->v[0])) { /*vertex only connected on 1 side */
/*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/
if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */
ed_loop_flip = 1;
@@ -577,7 +607,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* If this is the vert off the best vert and
* the best vert has 2 edges connected too it
* then swap the flip direction */
- if (j == 1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1))
+ if (j == 1 && SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1]))
ed_loop_flip = !ed_loop_flip;
while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) {
@@ -622,8 +652,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
*
* calculate vertex normals that can be propagated on lathing
* use edge connectivity work this out */
- if (vc->v[0] >= 0) {
- if (vc->v[1] >= 0) {
+ if (SV_IS_VALID(vc->v[0])) {
+ if (SV_IS_VALID(vc->v[1])) {
/* 2 edges connedted */
/* make 2 connecting vert locations relative to the middle vert */
sub_v3_v3v3(tmp_vec1, mvert_new[vc->v[0]].co, mvert_new[i].co);
@@ -689,12 +719,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* Add Faces */
for (step = 1; step < step_tot; step++) {
- const int varray_stride = totvert * step;
+ const unsigned int varray_stride = totvert * step;
float step_angle;
float nor_tx[3];
float mat[4][4];
/* Rotation Matrix */
- step_angle = (angle / (step_tot - (!close))) * step;
+ step_angle = (angle / (float)(step_tot - (!close))) * (float)step;
if (ltmd->ob_axis) {
axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle);
@@ -710,7 +740,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot - 1)));
/* copy a slice */
- DM_copy_vert_data(dm, result, 0, varray_stride, totvert);
+ DM_copy_vert_data(dm, result, 0, (int)varray_stride, (int)totvert);
mv_new_base = mvert_new;
mv_new = &mvert_new[varray_stride]; /* advance to the next slice */
@@ -757,7 +787,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
if (close) {
/* last loop of edges, previous loop dosnt account for the last set of edges */
- const int varray_stride = (step_tot - 1) * totvert;
+ const unsigned int varray_stride = (step_tot - 1) * totvert;
for (i = 0; i < totvert; i++) {
med_new->v1 = i;
@@ -775,10 +805,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
edge_offset = totedge + (totvert * (step_tot - (close ? 0 : 1)));
for (i = 0; i < totedge; i++, med_new_firstloop++) {
+ short mat_nr;
+
/* for each edge, make a cylinder of quads */
i1 = med_new_firstloop->v1;
i2 = med_new_firstloop->v2;
+ if (totpoly && (edge_poly_map[i] != UINT_MAX)) {
+ mat_nr = mpoly_orig[edge_poly_map[i]].mat_nr;
+ }
+ else {
+ mat_nr = 0;
+ }
+
for (step = 0; step < step_tot - 1; step++) {
/* new face */
@@ -808,6 +847,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
mp_new->loopstart = mpoly_index * 4;
mp_new->totloop = 4;
+ mp_new->mat_nr = mat_nr;
mp_new->flag = mpoly_flag;
origindex[mpoly_index] = ORIGINDEX_NONE;
mp_new++;
@@ -853,6 +893,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
mp_new->loopstart = mpoly_index * 4;
mp_new->totloop = 4;
+ mp_new->mat_nr = mat_nr;
mp_new->flag = mpoly_flag;
origindex[mpoly_index] = ORIGINDEX_NONE;
mp_new++;
@@ -871,10 +912,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* validate loop edges */
#if 0
{
- i = 0;
+ unsigned i = 0;
printf("\n");
for (; i < maxPolys * 4; i += 4) {
- int ii;
+ unsigned int ii;
ml_new = mloop_new + i;
ii = findEd(medge_new, maxEdges, ml_new[0].v, ml_new[1].v);
printf("%d %d -- ", ii, ml_new[0].e);
@@ -896,6 +937,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
#endif
+ if (edge_poly_map) {
+ MEM_freeN(edge_poly_map);
+ }
+
if ((ltmd->flag & MOD_SCREW_NORMAL_CALC) == 0) {
result->dirty |= DM_DIRTY_NORMALS;
}
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index ffc813068b8..d519c981a23 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -36,7 +36,7 @@
#include "bmesh.h"
#include "bmesh_tools.h"
-static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag)
+static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int quad_method, const int ngon_method)
{
DerivedMesh *result;
BMesh *bm;
@@ -45,7 +45,7 @@ static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag)
bm = DM_to_bmesh(dm, true);
- BM_mesh_triangulate(bm, (flag & MOD_TRIANGULATE_BEAUTY), false, NULL, NULL);
+ BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL);
result = CDDM_from_bmesh(bm, FALSE);
BM_mesh_free(bm);
@@ -69,7 +69,8 @@ static void initData(ModifierData *md)
/* Enable in editmode by default */
md->mode |= eModifierMode_Editmode;
- tmd->flag = MOD_TRIANGULATE_BEAUTY;
+ tmd->quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE;
+ tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY;
}
@@ -88,7 +89,7 @@ static DerivedMesh *applyModifier(ModifierData *md,
{
TriangulateModifierData *tmd = (TriangulateModifierData *)md;
DerivedMesh *result;
- if (!(result = triangulate_dm(dm, tmd->flag))) {
+ if (!(result = triangulate_dm(dm, tmd->quad_method, tmd->ngon_method))) {
return dm;
}
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 230931a1a33..e9fabcd1fd0 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -70,30 +70,6 @@ void modifier_init_texture(Scene *scene, Tex *tex)
BKE_image_user_frame_calc(&tex->iuser, scene->r.cfra, 0);
}
-void get_texture_value(Scene *scene, Tex *texture, float *tex_co, TexResult *texres, bool use_color_management)
-{
- int result_type;
- bool do_color_manage = false;
-
- if (use_color_management) {
- do_color_manage = BKE_scene_check_color_management_enabled(scene);
- }
-
- /* no node textures for now */
- result_type = multitex_ext_safe(texture, tex_co, texres, NULL, do_color_manage);
-
- /* if the texture gave an RGB value, we assume it didn't give a valid
- * intensity, since this is in the context of modifiers don't use perceptual color conversion.
- * if the texture didn't give an RGB value, copy the intensity across
- */
- if (result_type & TEX_RGB) {
- texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
- }
- else {
- copy_v3_fl(&texres->tr, texres->tin);
- }
-}
-
void get_texture_coords(MappingInfoModifierData *dmd, Object *ob,
DerivedMesh *dm,
float (*co)[3], float (*texco)[3],
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index 25632eb5b80..b4dcdc1721a 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -41,7 +41,6 @@ struct Tex;
struct TexResult;
void modifier_init_texture(struct Scene *scene, struct Tex *texture);
-void get_texture_value(struct Scene *scene, struct Tex *texture, float *tex_co, struct TexResult *texres, bool do_color_manage);
void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm,
float (*co)[3], float (*texco)[3], int numVerts);
void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]);
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 4fac201377a..83b05ae708a 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -282,7 +282,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
if (tex_co) {
TexResult texres;
texres.nor = NULL;
- get_texture_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false);
+ BKE_texture_get_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false);
fac *= texres.tin;
}
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 43dc1ba4eb9..168907e293c 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -48,6 +48,7 @@
#include "BKE_library.h"
#include "BKE_object.h"
#include "BKE_scene.h"
+#include "BKE_texture.h"
#include "depsgraph_private.h"
@@ -306,7 +307,7 @@ static void waveModifier_do(WaveModifierData *md,
if (wmd->texture) {
TexResult texres;
texres.nor = NULL;
- get_texture_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false);
+ BKE_texture_get_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false);
amplit *= texres.tin;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index e2267addd53..5c3b87bd92c 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -164,7 +164,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne
do_color_manage = tex_use_channel != MOD_WVG_MASK_TEX_USE_INT;
texres.nor = NULL;
- get_texture_value(scene, texture, tex_co[idx], &texres, do_color_manage);
+ BKE_texture_get_value(scene, texture, tex_co[idx], &texres, do_color_manage);
/* Get the good channel value... */
switch (tex_use_channel) {
case MOD_WVG_MASK_TEX_USE_INT:
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
index 9ae744439bc..5e7bbfaa1d3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
@@ -46,6 +46,36 @@ static bNodeSocketTemplate cmp_node_colorbalance_out[] = {
{-1, 0, ""}
};
+/* Sync functions update formula parameters for other modes, such that the result is comparable.
+ * Note that the results are not exactly the same due to differences in color handling (sRGB conversion happens for LGG),
+ * but this keeps settings comparable.
+ */
+
+void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeColorBalance *n = node->storage;
+ int c;
+
+ for (c = 0; c < 3; ++c) {
+ n->slope[c] = (2.0f - n->lift[c]) * n->gain[c];
+ n->offset[c] = (n->lift[c] - 1.0f) * n->gain[c];
+ n->power[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
+ }
+}
+
+void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeColorBalance *n = node->storage;
+ int c;
+
+ for (c = 0; c < 3; ++c) {
+ float d = n->slope[c] + n->offset[c];
+ n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f * n->offset[c] / d : 0.0f);
+ n->gain[c] = d;
+ n->gamma[c] = (n->power[c] != 0.0f) ? 1.0f / n->power[c] : 1000000.0f;
+ }
+}
+
static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *node)
{
NodeColorBalance *n = node->storage = MEM_callocN(sizeof(NodeColorBalance), "node colorbalance");
@@ -53,6 +83,10 @@ static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *nod
n->lift[0] = n->lift[1] = n->lift[2] = 1.0f;
n->gamma[0] = n->gamma[1] = n->gamma[2] = 1.0f;
n->gain[0] = n->gain[1] = n->gain[2] = 1.0f;
+
+ n->slope[0] = n->slope[1] = n->slope[2] = 1.0f;
+ n->offset[0] = n->offset[1] = n->offset[2] = 0.0f;
+ n->power[0] = n->power[1] = n->power[2] = 1.0f;
}
void register_node_type_cmp_colorbalance(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index d073abf112a..04a56a9f505 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -201,7 +201,7 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node)
* fail and sockets detection will go wrong.
*
* So we manually construct image user to be sure first
- * image from sequence (that one which is set as fileanme
+ * image from sequence (that one which is set as filename
* for image datablock) is used for sockets detection
*/
load_iuser.ok = 1;
diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
index b110cffd080..1d411aafe68 100644
--- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
+++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
@@ -48,12 +48,12 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[] = {
{ -1, 0, "" }
};
-static const char *label(bNode *node)
+static void label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
if (node->custom1 == 0)
- return IFACE_("Undistortion");
+ BLI_strncpy(label, IFACE_("Undistortion"), maxlen);
else
- return IFACE_("Distortion");
+ BLI_strncpy(label, IFACE_("Distortion"), maxlen);
}
static void init(const bContext *C, PointerRNA *ptr)
diff --git a/source/blender/nodes/composite/nodes/node_composite_switch.c b/source/blender/nodes/composite/nodes/node_composite_switch.c
index 3384f31bfd1..d7de26730d0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_switch.c
+++ b/source/blender/nodes/composite/nodes/node_composite_switch.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index a8133460628..a3298de5d59 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -82,9 +82,9 @@ bNodeSocket *node_group_find_output_socket(bNode *groupnode, const char *identif
}
/* groups display their internal tree name as label */
-const char *node_group_label(bNode *node)
+void node_group_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
- return (node->id) ? node->id->name + 2 : IFACE_("Missing Datablock");
+ BLI_strncpy(label, (node->id) ? node->id->name + 2 : IFACE_("Missing Datablock"), maxlen);
}
int node_group_poll_instance(bNode *node, bNodeTree *nodetree)
diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h
index 498da607b91..df3937f5a3e 100644
--- a/source/blender/nodes/intern/node_common.h
+++ b/source/blender/nodes/intern/node_common.h
@@ -37,7 +37,7 @@
struct bNodeTree;
-const char *node_group_label(struct bNode *node);
+void node_group_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
int node_group_poll_instance(struct bNode *node, struct bNodeTree *nodetree);
void ntree_update_reroute_nodes(struct bNodeTree *ntree);
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index 812fe5b4ae7..37018b3a98d 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -207,6 +207,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo
/* prepare all nodes for execution */
for (n = 0, nodeexec = exec->nodeexec; n < totnodes; ++n, ++nodeexec) {
node = nodeexec->node = nodelist[n];
+ nodeexec->freeexecfunc = node->typeinfo->freeexecfunc;
/* tag inputs */
for (sock = node->inputs.first; sock; sock = sock->next) {
@@ -245,9 +246,8 @@ void ntree_exec_end(bNodeTreeExec *exec)
MEM_freeN(exec->stack);
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
- if (nodeexec->node->typeinfo)
- if (nodeexec->node->typeinfo->freeexecfunc)
- nodeexec->node->typeinfo->freeexecfunc(nodeexec->node, nodeexec->data.data);
+ if (nodeexec->freeexecfunc)
+ nodeexec->freeexecfunc(nodeexec->data.data);
}
if (exec->nodeexec)
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index 7d76ef34934..4101c6c4c4d 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -51,6 +51,8 @@ struct bNodeStack;
typedef struct bNodeExec {
struct bNode *node; /* backpointer to node */
bNodeExecData data;
+
+ NodeFreeExecFunction freeexecfunc; /* free function, stored in exec itself to avoid dangling node pointer access */
} bNodeExec;
/* Execution Data for each instance of node tree execution */
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index e77f0a08331..3997d9cbcac 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -36,6 +36,7 @@
#include "DNA_node_types.h"
#include "BLI_listbase.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -82,32 +83,32 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNode
/**** Labels ****/
-const char *node_blend_label(bNode *node)
+void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
const char *name;
RNA_enum_name(ramp_blend_items, node->custom1, &name);
- return IFACE_(name);
+ BLI_strncpy(label, IFACE_(name), maxlen);
}
-const char *node_math_label(bNode *node)
+void node_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
const char *name;
RNA_enum_name(node_math_items, node->custom1, &name);
- return IFACE_(name);
+ BLI_strncpy(label, IFACE_(name), maxlen);
}
-const char *node_vect_math_label(bNode *node)
+void node_vect_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
const char *name;
RNA_enum_name(node_vec_math_items, node->custom1, &name);
- return IFACE_(name);
+ BLI_strncpy(label, IFACE_(name), maxlen);
}
-const char *node_filter_label(bNode *node)
+void node_filter_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
const char *name;
RNA_enum_name(node_filter_items, node->custom1, &name);
- return IFACE_(name);
+ BLI_strncpy(label, IFACE_(name), maxlen);
}
void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index 2b3f84420f9..64b2028874b 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -71,10 +71,10 @@ extern void *node_initexec_curves(struct bNodeExecContext *context, struct bNode
/**** Labels ****/
-const char *node_blend_label(struct bNode *node);
-const char *node_math_label(struct bNode *node);
-const char *node_vect_math_label(struct bNode *node);
-const char *node_filter_label(struct bNode *node);
+void node_blend_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
+void node_math_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
+void node_vect_math_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
+void node_filter_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
void node_update_internal_links_default(struct bNodeTree *ntree, struct bNode *node);
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index 72178018de4..e229fc75686 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -85,7 +85,7 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
return exec;
}
-static void group_freeexec(bNode *UNUSED(node), void *nodedata)
+static void group_freeexec(void *nodedata)
{
bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
index 1e5c10968a5..c22b0f41695 100644
--- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c
+++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
@@ -30,6 +30,7 @@
/* **************** Fresnel ******************** */
static bNodeSocketTemplate sh_node_fresnel_in[] = {
{ SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
@@ -40,8 +41,10 @@ static bNodeSocketTemplate sh_node_fresnel_out[] = {
static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- /* todo: is incoming vector normalized? */
- return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+ if (!in[1].link)
+ in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
index 9b9c3cf705b..832ce582b4b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
+++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
@@ -31,6 +31,7 @@
static bNodeSocketTemplate sh_node_layer_weight_in[] = {
{ SOCK_FLOAT, 1, N_("Blend"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
@@ -40,9 +41,12 @@ static bNodeSocketTemplate sh_node_layer_weight_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_layer_weight(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out))
+static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return 0;
+ if (!in[1].link)
+ in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_layer_weight", in, out, GPU_builtin(GPU_VIEW_POSITION));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c
index 4200f515a80..820e0f479be 100644
--- a/source/blender/nodes/shader/nodes/node_shader_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_material.c
@@ -299,6 +299,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
if (node->type == SH_NODE_MATERIAL_EXT) {
out[MAT_OUT_DIFFUSE].link = shr.diff;
out[MAT_OUT_SPEC].link = shr.spec;
+ GPU_link(mat, "set_rgb_one", &out[MAT_OUT_AO].link);
}
return 1;
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
index 707e295241a..2c515d587c0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
@@ -44,13 +44,26 @@ static bNodeSocketTemplate sh_node_sephsv_out[] = {
{ -1, 0, "" }
};
+static void node_shader_exec_sephsv(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+{
+ rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2],
+ &out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]);
+}
+
+static int gpu_shader_sephsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, "separate_hsv", in, out);
+}
+
void register_node_type_sh_sephsv(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out);
+ node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv);
+ node_type_gpu(&ntype, gpu_shader_sephsv);
nodeRegisterType(&ntype);
}
@@ -68,13 +81,26 @@ static bNodeSocketTemplate sh_node_combhsv_out[] = {
{ -1, 0, "" }
};
+static void node_shader_exec_combhsv(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+{
+ hsv_to_rgb(in[0]->vec[0], in[1]->vec[0], in[2]->vec[0],
+ &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]);
+}
+
+static int gpu_shader_combhsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, "combine_hsv", in, out);
+}
+
void register_node_type_sh_combhsv(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out);
+ node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv);
+ node_type_gpu(&ntype, gpu_shader_combhsv);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index fec6abbf062..7e65c472eef 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -72,7 +72,7 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
return exec;
}
-static void group_freeexec(bNode *UNUSED(node), void *nodedata)
+static void group_freeexec(void *nodedata)
{
bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 92fb506497f..97d88c5d189 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -2879,8 +2879,7 @@ static PyObject *bpy_bmiter_next(BPy_BMIter *self)
{
BMHeader *ele = BM_iter_step(&self->iter);
if (ele == NULL) {
- PyErr_SetString(PyExc_StopIteration,
- "bpy_bmiter_next stop");
+ PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
else {
@@ -3722,47 +3721,11 @@ char *BPy_BMElem_StringFromHType(const char htype)
/* -------------------------------------------------------------------- */
/* keep at bottom */
-/* BAD INCLUDES */
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_editmesh.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-#include "MEM_guardedalloc.h"
-
-/* there are cases where this warning isnt needed, otherwise it could be made into an error */
-static void bm_dealloc_warn(const char *mesh_name)
-{
- PySys_WriteStdout("Modified BMesh '%.200s' from a wrapped editmesh is freed without a call "
- "to bmesh.update_edit_mesh(mesh, destructive=True), this is will likely cause a crash\n",
- mesh_name);
-}
/* this function is called on free, it should stay quite fast */
static void bm_dealloc_editmode_warn(BPy_BMesh *self)
{
if (self->flag & BPY_BMFLAG_IS_WRAPPED) {
- /* likely editmesh */
- BMesh *bm = self->bm;
- Scene *scene;
- for (scene = G.main->scene.first; scene; scene = scene->id.next) {
- Base *base = scene->basact;
- if (base && base->object->type == OB_MESH) {
- Mesh *me = base->object->data;
- BMEditMesh *em = me->edit_btmesh;
- if (em && em->bm == bm) {
- /* not foolproof, scripter may have added/removed verts */
- if (((em->vert_index && (MEM_allocN_len(em->vert_index) / sizeof(*em->vert_index)) != bm->totvert)) ||
- ((em->edge_index && (MEM_allocN_len(em->edge_index) / sizeof(*em->edge_index)) != bm->totedge)) ||
- ((em->face_index && (MEM_allocN_len(em->face_index) / sizeof(*em->face_index)) != bm->totface)))
- {
- bm_dealloc_warn(me->id.name + 2);
- break;
- }
- }
- }
- }
+ /* currently nop - this works without warnings now */
}
}
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 30902c615a1..0ba08f3e8d0 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -113,6 +113,9 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__uv_doc,
PyDoc_STRVAR(bpy_bmlayeraccess_collection__color_doc,
"Accessor for vertex color layer.\n\ntype: :class:`BMLayerCollection`"
);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__skin_doc,
+"Accessor for skin layer.\n\ntype: :class:`BMLayerCollection`"
+);
#ifdef WITH_FREESTYLE
PyDoc_STRVAR(bpy_bmlayeraccess_collection__freestyle_edge_doc,
"Accessor for Freestyle edge layer.\n\ntype: :class:`BMLayerCollection`"
@@ -192,6 +195,7 @@ static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
{(char *)"shape", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__shape_doc, (void *)CD_SHAPEKEY},
{(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT},
+ {(char *)"skin", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__skin_doc, (void *)CD_MVERT_SKIN},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
@@ -1030,6 +1034,11 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
ret = PyFloat_FromDouble(*(float *)value);
break;
}
+ case CD_MVERT_SKIN:
+ {
+ ret = BPy_BMVertSkin_CreatePyObject(value);
+ break;
+ }
default:
{
ret = Py_NotImplemented; /* TODO */
@@ -1147,6 +1156,11 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
}
break;
}
+ case CD_MVERT_SKIN:
+ {
+ ret = BPy_BMVertSkin_AssignPyObject(value, py_value);
+ break;
+ }
default:
{
PyErr_SetString(PyExc_AttributeError, "readonly / unsupported type");
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index 06b11f02b2a..80b07a926f4 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -248,6 +248,115 @@ PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *mloopuv)
/* --- End Mesh Loop UV --- */
+/* Mesh Vert Skin
+ * ************ */
+
+#define BPy_BMVertSkin_Check(v) (Py_TYPE(v) == &BPy_BMVertSkin_Type)
+
+typedef struct BPy_BMVertSkin {
+ PyObject_VAR_HEAD
+ MVertSkin *data;
+} BPy_BMVertSkin;
+
+PyDoc_STRVAR(bpy_bmvertskin_radius_doc,
+"Vert skin radii (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`"
+);
+static PyObject *bpy_bmvertskin_radius_get(BPy_BMVertSkin *self, void *UNUSED(closure))
+{
+ return Vector_CreatePyObject(self->data->radius, 2, Py_WRAP, NULL);
+}
+
+static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void *UNUSED(closure))
+{
+ float tvec[2];
+ if (mathutils_array_parse(tvec, 2, 2, value, "BMVertSkin.radius") != -1) {
+ copy_v2_v2(self->data->radius, tvec);
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+PyDoc_STRVAR(bpy_bmvertskin_flag__use_root_doc,
+"Use as root vertex.\n\n:type: boolean"
+);
+PyDoc_STRVAR(bpy_bmvertskin_flag__use_loose_doc,
+"Use loose vertex.\n\n:type: boolean"
+);
+
+static PyObject *bpy_bmvertskin_flag_get(BPy_BMVertSkin *self, void *flag_p)
+{
+ const int flag = GET_INT_FROM_POINTER(flag_p);
+ return PyBool_FromLong(self->data->flag & flag);
+}
+
+static int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *flag_p)
+{
+ const int flag = GET_INT_FROM_POINTER(flag_p);
+
+ switch (PyLong_AsLong(value)) {
+ case true:
+ self->data->flag |= flag;
+ return 0;
+ case false:
+ self->data->flag &= ~flag;
+ return 0;
+ default:
+ PyErr_SetString(PyExc_TypeError,
+ "expected a boolean type 0/1");
+ return -1;
+ }
+}
+
+/* XXX Todo: Make root settable, currently the code to disable all other verts as roots sits within the modifier */
+static PyGetSetDef bpy_bmvertskin_getseters[] = {
+ /* attributes match rna_mesh_gen */
+ {(char *)"radius", (getter)bpy_bmvertskin_radius_get, (setter)bpy_bmvertskin_radius_set, (char *)bpy_bmvertskin_radius_doc, NULL},
+ {(char *)"use_root", (getter)bpy_bmvertskin_flag_get, (setter)NULL, (char *)bpy_bmvertskin_flag__use_root_doc, (void *)MVERT_SKIN_ROOT},
+ {(char *)"use_loose", (getter)bpy_bmvertskin_flag_get, (setter)bpy_bmvertskin_flag_set, (char *)bpy_bmvertskin_flag__use_loose_doc, (void *)MVERT_SKIN_LOOSE},
+
+ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+};
+
+static PyTypeObject BPy_BMVertSkin_Type = {{{0}}}; /* bm.loops.layers.uv.active */
+
+static void bm_init_types_bmvertskin(void)
+{
+ BPy_BMVertSkin_Type.tp_basicsize = sizeof(BPy_BMVertSkin);
+
+ BPy_BMVertSkin_Type.tp_name = "BMVertSkin";
+
+ BPy_BMVertSkin_Type.tp_doc = NULL; // todo
+
+ BPy_BMVertSkin_Type.tp_getset = bpy_bmvertskin_getseters;
+
+ BPy_BMVertSkin_Type.tp_flags = Py_TPFLAGS_DEFAULT;
+
+ PyType_Ready(&BPy_BMVertSkin_Type);
+}
+
+int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *mvertskin, PyObject *value)
+{
+ if (UNLIKELY(!BPy_BMVertSkin_Check(value))) {
+ PyErr_Format(PyExc_TypeError, "expected BMVertSkin, not a %.200s", Py_TYPE(value)->tp_name);
+ return -1;
+ }
+ else {
+ *((MVertSkin *)mvertskin) = *(((BPy_BMVertSkin *)value)->data);
+ return 0;
+ }
+}
+
+PyObject *BPy_BMVertSkin_CreatePyObject(struct MVertSkin *mvertskin)
+{
+ BPy_BMVertSkin *self = PyObject_New(BPy_BMVertSkin, &BPy_BMVertSkin_Type);
+ self->data = mvertskin;
+ return (PyObject *)self;
+}
+
+/* --- End Mesh Vert Skin --- */
+
/* Mesh Loop Color
* *************** */
@@ -692,5 +801,6 @@ void BPy_BM_init_types_meshdata(void)
bm_init_types_bmloopuv();
bm_init_types_bmloopcol();
bm_init_types_bmdvert();
+ bm_init_types_bmvertskin();
}
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.h b/source/blender/python/bmesh/bmesh_py_types_meshdata.h
index 8280e5c3bc5..07d8a46cc65 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.h
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.h
@@ -44,6 +44,7 @@ struct MTexPoly;
struct MLoopUV;
struct MLoopCol;
struct MDeformVert;
+struct MVertSkin;
int BPy_BMTexPoly_AssignPyObject(struct MTexPoly *mloopuv, PyObject *value);
PyObject *BPy_BMTexPoly_CreatePyObject(struct MTexPoly *mloopuv);
@@ -51,6 +52,9 @@ PyObject *BPy_BMTexPoly_CreatePyObject(struct MTexPoly *mloopuv);
int BPy_BMLoopUV_AssignPyObject(struct MLoopUV *data, PyObject *value);
PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *data);
+int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *data, PyObject *value);
+PyObject *BPy_BMVertSkin_CreatePyObject(struct MVertSkin *data);
+
int BPy_BMLoopColor_AssignPyObject(struct MLoopCol *data, PyObject *value);
PyObject *BPy_BMLoopColor_CreatePyObject(struct MLoopCol *data);
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c
index 5069670a665..1906fc8c90e 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.c
+++ b/source/blender/python/bmesh/bmesh_py_types_select.c
@@ -341,8 +341,7 @@ static PyObject *bpy_bmeditseliter_next(BPy_BMEditSelIter *self)
{
BMEditSelection *ese = self->ese;
if (ese == NULL) {
- PyErr_SetString(PyExc_StopIteration,
- "bpy_bmiter_next stop");
+ PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
else {
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index f7ed5fec891..c3cbe7ddbf9 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -25,15 +25,16 @@
* \ingroup pygen
*/
-
#include <Python.h>
-#include "idprop_py_api.h"
#include "MEM_guardedalloc.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "idprop_py_api.h"
+
+
#include "BKE_idprop.h"
@@ -329,29 +330,48 @@ static int idp_sequence_type(PyObject *seq_fast)
return type;
}
-/* note: group can be a pointer array or a group.
- * assume we already checked key is a string. */
-const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, PyObject *ob)
+/**
+ * \note group can be a pointer array or a group.
+ * assume we already checked key is a string.
+ *
+ * \return success.
+ */
+bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, PyObject *ob)
{
IDProperty *prop = NULL;
IDPropertyTemplate val = {0};
- const char *name = "";
+ const char *name;
if (name_obj) {
Py_ssize_t name_size;
name = _PyUnicode_AsStringAndSize(name_obj, &name_size);
+
+ if (name == NULL) {
+ PyErr_Format(PyExc_KeyError,
+ "invalid id-property key, expected a string, not a %.200s",
+ Py_TYPE(name_obj)->tp_name);
+ return false;
+ }
+
if (name_size > MAX_IDPROP_NAME) {
- return "the length of IDProperty names is limited to 63 characters";
+ PyErr_SetString(PyExc_KeyError, "the length of IDProperty names is limited to 63 characters");
+ return false;
}
}
+ else {
+ name = "";
+ }
if (PyFloat_Check(ob)) {
val.d = PyFloat_AsDouble(ob);
prop = IDP_New(IDP_DOUBLE, &val, name);
}
else if (PyLong_Check(ob)) {
- val.i = (int)PyLong_AsLong(ob);
+ val.i = _PyLong_AsInt(ob);
+ if (val.i == -1 && PyErr_Occurred()) {
+ return false;
+ }
prop = IDP_New(IDP_INT, &val, name);
}
else if (PyUnicode_Check(ob)) {
@@ -381,14 +401,13 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
int i;
if (ob_seq_fast == NULL) {
- PyErr_Print();
- PyErr_Clear();
- return "error converting the sequence";
+ return false;
}
if ((val.array.type = idp_sequence_type(ob_seq_fast)) == -1) {
Py_DECREF(ob_seq_fast);
- return "only floats, ints and dicts are allowed in ID property arrays";
+ PyErr_SetString(PyExc_TypeError, "only floats, ints and dicts are allowed in ID property arrays");
+ return false;
}
/* validate sequence and derive type.
@@ -399,35 +418,52 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
switch (val.array.type) {
case IDP_DOUBLE:
+ {
+ double *prop_data;
+
prop = IDP_New(IDP_ARRAY, &val, name);
+ prop_data = IDP_Array(prop);
for (i = 0; i < val.array.len; i++) {
item = PySequence_Fast_GET_ITEM(ob_seq_fast, i);
- ((double *)IDP_Array(prop))[i] = (float)PyFloat_AsDouble(item);
+ if (((prop_data[i] = PyFloat_AsDouble(item)) == -1.0) && PyErr_Occurred()) {
+ Py_DECREF(ob_seq_fast);
+ return false;
+ }
}
break;
+ }
case IDP_INT:
+ {
+ int *prop_data;
prop = IDP_New(IDP_ARRAY, &val, name);
+ prop_data = IDP_Array(prop);
for (i = 0; i < val.array.len; i++) {
item = PySequence_Fast_GET_ITEM(ob_seq_fast, i);
- ((int *)IDP_Array(prop))[i] = (int)PyLong_AsLong(item);
+ if (((prop_data[i] = _PyLong_AsInt(item)) == -1) && PyErr_Occurred()) {
+ Py_DECREF(ob_seq_fast);
+ return false;
+ }
}
break;
+ }
case IDP_IDPARRAY:
+ {
prop = IDP_NewIDPArray(name);
for (i = 0; i < val.array.len; i++) {
- const char *error;
item = PySequence_Fast_GET_ITEM(ob_seq_fast, i);
- error = BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item);
- if (error) {
+ if (BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item) == false) {
Py_DECREF(ob_seq_fast);
- return error;
+ return false;
}
}
break;
+ }
default:
+ /* should never happen */
Py_DECREF(ob_seq_fast);
- return "internal error with idp array.type";
+ PyErr_SetString(PyExc_RuntimeError, "internal error with idp array.type");
+ return false;
}
Py_DECREF(ob_seq_fast);
@@ -446,23 +482,15 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
for (i = 0; i < len; i++) {
key = PySequence_GetItem(keys, i);
pval = PySequence_GetItem(vals, i);
- if (!PyUnicode_Check(key)) {
- IDP_FreeProperty(prop);
- MEM_freeN(prop);
- Py_XDECREF(keys);
- Py_XDECREF(vals);
- Py_XDECREF(key);
- Py_XDECREF(pval);
- return "invalid element in subgroup dict template!";
- }
- if (BPy_IDProperty_Map_ValidateAndCreate(key, prop, pval)) {
+ if (BPy_IDProperty_Map_ValidateAndCreate(key, prop, pval) == false) {
IDP_FreeProperty(prop);
MEM_freeN(prop);
Py_XDECREF(keys);
Py_XDECREF(vals);
Py_XDECREF(key);
Py_XDECREF(pval);
- return "invalid element in subgroup dict template!";
+ /* error is already set */
+ return false;
}
Py_XDECREF(key);
Py_XDECREF(pval);
@@ -471,7 +499,10 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
Py_XDECREF(vals);
}
else {
- return "invalid property value";
+ PyErr_Format(PyExc_TypeError,
+ "invalid id-property type %.200s not supported",
+ Py_TYPE(ob)->tp_name);
+ return false;
}
if (group->type == IDP_IDPARRAY) {
@@ -483,7 +514,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
IDP_ReplaceInGroup(group, prop);
}
- return NULL;
+ return true;
}
int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
@@ -494,11 +525,19 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
}
if (val == NULL) { /* del idprop[key] */
- IDProperty *pkey = IDP_GetPropertyFromGroup(prop, _PyUnicode_AsString(key));
+ IDProperty *pkey;
+ const char *name = _PyUnicode_AsString(key);
+
+ if (name == NULL) {
+ PyErr_Format(PyExc_KeyError,
+ "expected a string, not %.200s",
+ Py_TYPE(key)->tp_name);
+ return -1;
+ }
+
+ pkey = IDP_GetPropertyFromGroup(prop, name);
if (pkey) {
- IDP_RemFromGroup(prop, pkey);
- IDP_FreeProperty(pkey);
- MEM_freeN(pkey);
+ IDP_FreeFromGroup(prop, pkey);
return 0;
}
else {
@@ -507,16 +546,10 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
}
}
else {
- const char *err;
-
- if (!PyUnicode_Check(key)) {
- PyErr_SetString(PyExc_TypeError, "only strings are allowed as subgroup keys");
- return -1;
- }
+ bool ok;
- err = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val);
- if (err) {
- PyErr_SetString(PyExc_KeyError, err);
+ ok = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val);
+ if (ok == false) {
return -1;
}
@@ -670,7 +703,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value)
return NULL;
}
- IDP_RemFromGroup(self->prop, idprop);
+ IDP_RemoveFromGroup(self->prop, idprop);
return pyform;
}
@@ -1054,10 +1087,6 @@ static PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index)
static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value)
{
- int i;
- float f;
- double d;
-
if (index < 0 || index >= self->prop->len) {
PyErr_SetString(PyExc_RuntimeError, "index out of range!");
return -1;
@@ -1065,30 +1094,33 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value)
switch (self->prop->subtype) {
case IDP_FLOAT:
- f = (float)PyFloat_AsDouble(value);
+ {
+ const float f = (float)PyFloat_AsDouble(value);
if (f == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "expected a float");
return -1;
}
((float *)IDP_Array(self->prop))[index] = f;
break;
+ }
case IDP_DOUBLE:
- d = PyFloat_AsDouble(value);
+ {
+ const double d = PyFloat_AsDouble(value);
if (d == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "expected a float");
return -1;
}
((double *)IDP_Array(self->prop))[index] = d;
break;
+ }
case IDP_INT:
- i = PyLong_AsLong(value);
+ {
+ const int i = _PyLong_AsInt(value);
if (i == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "expected an int type");
return -1;
}
((int *)IDP_Array(self->prop))[index] = i;
break;
+ }
}
return 0;
}
@@ -1365,7 +1397,7 @@ static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self)
}
}
else {
- PyErr_SetString(PyExc_StopIteration, "iterator at end");
+ PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
}
diff --git a/source/blender/python/generic/idprop_py_api.h b/source/blender/python/generic/idprop_py_api.h
index cb82676c4d9..279dad40456 100644
--- a/source/blender/python/generic/idprop_py_api.h
+++ b/source/blender/python/generic/idprop_py_api.h
@@ -71,7 +71,7 @@ int BPy_Wrap_SetMapItem(struct IDProperty *prop, PyObject *key, PyObject *val);
PyObject *BPy_IDGroup_WrapData(struct ID *id, struct IDProperty *prop, struct IDProperty *parent);
-const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *key, struct IDProperty *group, PyObject *ob);
+bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *key, struct IDProperty *group, PyObject *ob);
void IDProp_Init_Types(void);
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 63f66afd8a8..8e90d484a9d 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -887,3 +887,19 @@ PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag)
return ret;
}
+
+/* compat only */
+#if PY_VERSION_HEX < 0x03030200
+int
+_PyLong_AsInt(PyObject *obj)
+{
+ int overflow;
+ long result = PyLong_AsLongAndOverflow(obj, &overflow);
+ if (overflow || result > INT_MAX || result < INT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C int");
+ return -1;
+ }
+ return (int)result;
+}
+#endif
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 8928642bc3e..c6792ddfc79 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -72,4 +72,8 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int
int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix);
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
+#if PY_VERSION_HEX < 0x03030200
+int _PyLong_AsInt(PyObject *obj);
+#endif
+
#endif /* __PY_CAPI_UTILS_H__ */
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 2edb0aee783..21767196e11 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -53,7 +53,11 @@
#ifdef BUILD_DATE
extern char build_date[];
extern char build_time[];
-extern char build_rev[];
+extern unsigned long build_commit_timestamp;
+extern char build_commit_date[];
+extern char build_commit_time[];
+extern char build_hash[];
+extern char build_branch[];
extern char build_platform[];
extern char build_type[];
extern char build_cflags[];
@@ -75,7 +79,11 @@ static PyStructSequence_Field app_info_fields[] = {
/* buildinfo */
{(char *)"build_date", (char *)"The date this blender instance was built"},
{(char *)"build_time", (char *)"The time this blender instance was built"},
- {(char *)"build_revision", (char *)"The subversion revision this blender instance was built with"},
+ {(char *)"build_commit_timestamp", (char *)"The unix timestamp of commit this blender instance was built"},
+ {(char *)"build_commit_date", (char *)"The date of commit this blender instance was built"},
+ {(char *)"build_commit_time", (char *)"The time of commit this blender instance was built"},
+ {(char *)"build_hash", (char *)"The commit hash this blender instance was built with"},
+ {(char *)"build_branch", (char *)"The branch this blender instance was built from"},
{(char *)"build_platform", (char *)"The platform this blender instance was built for"},
{(char *)"build_type", (char *)"The type of build (Release, Debug)"},
{(char *)"build_cflags", (char *)"C compiler flags"},
@@ -107,10 +115,8 @@ static PyObject *make_app_info(void)
if (app_info == NULL) {
return NULL;
}
-#if 0
#define SetIntItem(flag) \
PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag))
-#endif
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str))
#define SetBytesItem(str) \
@@ -133,7 +139,11 @@ static PyObject *make_app_info(void)
#ifdef BUILD_DATE
SetBytesItem(build_date);
SetBytesItem(build_time);
- SetBytesItem(build_rev);
+ SetIntItem(build_commit_timestamp);
+ SetBytesItem(build_commit_date);
+ SetBytesItem(build_commit_time);
+ SetBytesItem(build_hash);
+ SetBytesItem(build_branch);
SetBytesItem(build_platform);
SetBytesItem(build_type);
SetBytesItem(build_cflags);
@@ -143,6 +153,10 @@ static PyObject *make_app_info(void)
#else
SetBytesItem("Unknown");
SetBytesItem("Unknown");
+ SetIntItem(0);
+ SetBytesItem("Unknown");
+ SetBytesItem("Unknown");
+ SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c
index 61e12c1cea0..2f7577928c5 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.c
+++ b/source/blender/python/intern/bpy_app_ffmpeg.c
@@ -89,7 +89,7 @@ static PyObject *make_ffmpeg_info(void)
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, obj)
#ifdef WITH_FFMPEG
-# define FFMPEG_LIB_VERSION(lib) { \
+# define FFMPEG_LIB_VERSION(lib) { \
curversion = lib ## _version(); \
SetObjItem(Py_BuildValue("(iii)", \
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
@@ -97,7 +97,7 @@ static PyObject *make_ffmpeg_info(void)
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
} (void)0
#else
-# define FFMPEG_LIB_VERSION(lib) { \
+# define FFMPEG_LIB_VERSION(lib) { \
SetStrItem("Unknown"); \
SetStrItem("Unknown"); \
} (void)0
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 959e4a788dd..f8725d61167 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -50,7 +50,7 @@ static PyStructSequence_Field app_cb_info_fields[] = {
{(char *)"render_post", (char *)"Callback list - on render (after)"},
{(char *)"render_stats", (char *)"Callback list - on printing render statistics"},
{(char *)"render_complete", (char *)"Callback list - on completion of render job"},
- {(char *)"render_cancel", (char *)"Callback list - on cancelling a render job"},
+ {(char *)"render_cancel", (char *)"Callback list - on canceling a render job"},
{(char *)"load_pre", (char *)"Callback list - on loading a new blend file (before)"},
{(char *)"load_post", (char *)"Callback list - on loading a new blend file (after)"},
{(char *)"save_pre", (char *)"Callback list - on saving a blend file (before)"},
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index d13ec3c461a..754952cd65f 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -345,7 +345,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
error_val = pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
if (error_val == 0)
- buf = WM_operator_pystring(C, ot, &ptr, all_args);
+ buf = WM_operator_pystring_ex(C, NULL, all_args, ot, &ptr);
WM_operator_properties_free(&ptr);
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4d4d4873390..5a87870d198 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -6044,7 +6044,7 @@ static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self)
static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *self)
{
if (self->iter.valid == false) {
- PyErr_SetString(PyExc_StopIteration, "pyrna_prop_collection_iter stop");
+ PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
else {
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 1043f68dbdb..9aefe5a733f 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -203,7 +203,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- /* class spesific callbacks */
+ /* class specific callbacks */
if (RNA_struct_is_a(srna, &RNA_Space)) {
if (!PyArg_ParseTuple(args, "OOO!ss:Space.draw_handler_add",
&cls, &cb_func, /* already assigned, no matter */
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 8b5b74c480a..584861d4c49 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1563,7 +1563,7 @@ static PyObject *M_Geometry_convex_hull_2d(PyObject *UNUSED(self), PyObject *poi
int *index_map;
Py_ssize_t len_ret, i;
- index_map = MEM_mallocN(sizeof(*index_map) * len, __func__);
+ index_map = MEM_mallocN(sizeof(*index_map) * len * 2, __func__);
/* Non Python function */
len_ret = BLI_convexhull_2d((const float (*)[2])points, len, index_map);
diff --git a/source/blender/quicktime/CMakeLists.txt b/source/blender/quicktime/CMakeLists.txt
index 0c5c4d8a9f1..b0a8c92e559 100644
--- a/source/blender/quicktime/CMakeLists.txt
+++ b/source/blender/quicktime/CMakeLists.txt
@@ -41,23 +41,13 @@ set(INC_SYS
${QUICKTIME_INCLUDE_DIRS}
)
-if(USE_QTKIT)
- set(SRC
- apple/qtkit_import.m
- apple/qtkit_export.m
+set(SRC
+ apple/qtkit_import.m
+ apple/qtkit_export.m
- quicktime_export.h
- quicktime_import.h
- )
-else()
- set(SRC
- apple/quicktime_import.c
- apple/quicktime_export.c
-
- quicktime_export.h
- quicktime_import.h
- )
-endif()
+ quicktime_export.h
+ quicktime_import.h
+)
add_definitions(-DWITH_QUICKTIME)
diff --git a/source/blender/quicktime/SConscript b/source/blender/quicktime/SConscript
index a6debf06226..1fc2bc96b21 100644
--- a/source/blender/quicktime/SConscript
+++ b/source/blender/quicktime/SConscript
@@ -28,12 +28,8 @@
Import ('env')
-if env['USE_QTKIT']:
- source_files = ['apple/qtkit_import.m',
+source_files = ['apple/qtkit_import.m',
'apple/qtkit_export.m']
-else:
- source_files = ['apple/quicktime_import.c',
- 'apple/quicktime_export.c']
incs = ['.',
@@ -58,8 +54,5 @@ priorities = [200,235]
defs=['WITH_QUICKTIME']
-if env['WITH_GHOST_COCOA']:
- defs.append('GHOST_COCOA')
- env.BlenderLib ('bf_quicktime', sources=source_files, includes=incs, defines=defs, libtype=types, priority=priorities, cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++') # always use default-Apple-gcc for objC language, gnu-compilers do not support it fully yet
-else:
- env.BlenderLib ('bf_quicktime', sources=source_files, includes=incs, defines=defs, libtype=types, priority=priorities)
+env.BlenderLib ('bf_quicktime', sources=source_files, includes=incs, defines=defs, libtype=types, priority=priorities, cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++') # always use default-Apple-gcc for objC language, gnu-compilers do not support it fully yet
+
diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c
deleted file mode 100644
index 52ef21e4f39..00000000000
--- a/source/blender/quicktime/apple/quicktime_export.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/*
- * ***** 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 written by Rob Haarsma (phase)
- *
- * Contributor(s): Stefan Gartner (sgefant)
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/quicktime/apple/quicktime_export.c
- * \ingroup quicktime
- *
- * Code to create QuickTime Movies with Blender
- */
-
-
-#ifdef WITH_QUICKTIME
-#if defined(_WIN32) || defined(__APPLE__)
-#ifndef USE_QTKIT
-
-#include "DNA_scene_types.h"
-#include "DNA_windowmanager_types.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "BKE_context.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_report.h"
-#include "BKE_scene.h"
-
-#include "BLI_blenlib.h"
-
-#include "BLI_sys_types.h"
-
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "quicktime_import.h"
-#include "quicktime_export.h"
-
-#ifdef _WIN32
-#include <QTML.h>
-#include <Movies.h>
-#include <QuickTimeComponents.h>
-#include <TextUtils.h>
-#include <string.h>
-#include <memory.h>
-
-#endif /* _WIN32 */
-
-#ifdef __APPLE__
-/* evil */
-#ifndef __AIFF__
-#define __AIFF__
-#endif
-#include <QuickTime/Movies.h>
-#include <QuickTime/QuickTimeComponents.h>
-#include <fcntl.h> /* open() */
-#include <unistd.h> /* close() */
-#include <sys/stat.h> /* file permissions */
-#endif /* __APPLE__ */
-
-#define kMyCreatorType FOUR_CHAR_CODE('TVOD')
-#define kTrackStart 0
-#define kMediaStart 0
-
-static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, int recty, struct ReportList *reports);
-static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
-static void QT_EndAddVideoSamplesToMedia(void);
-static void QT_CreateMyVideoTrack(int rectx, int recty, struct ReportList *reports);
-static void QT_EndCreateMyVideoTrack(struct ReportList *reports);
-static void check_renderbutton_framerate(struct RenderData *rd, struct ReportList *reports);
-static int get_qtcodec_settings(struct RenderData *rd, struct ReportList *reports);
-
-typedef struct QuicktimeExport {
-
- FSSpec theSpec;
- short resRefNum;
- Str255 qtfilename;
-
- Media theMedia;
- Movie theMovie;
- Track theTrack;
-
- GWorldPtr theGWorld;
- PixMapHandle thePixMap;
- ImageDescription **anImageDescription;
-
- ImBuf *ibuf; /* imagedata for Quicktime's Gworld */
- ImBuf *ibuf2; /* copy of renderdata, to be Y-flipped */
-
-} QuicktimeExport;
-
-typedef struct QuicktimeComponentData {
-
- ComponentInstance theComponent;
- SCTemporalSettings gTemporalSettings;
- SCSpatialSettings gSpatialSettings;
- SCDataRateSettings aDataRateSetting;
- TimeValue duration;
- long kVideoTimeScale;
-
-} QuicktimeComponentData;
-
-static struct QuicktimeExport *qtexport;
-static struct QuicktimeComponentData *qtdata;
-
-static int sframe;
-
-/* RNA functions */
-
-static QuicktimeCodecTypeDesc qtVideoCodecList[] = {
- {kRawCodecType, 1, "Uncompressed"},
- {kJPEGCodecType, 2, "JPEG"},
- {kMotionJPEGACodecType, 3, "M-JPEG A"},
- {kMotionJPEGBCodecType, 4, "M-JPEG B"},
- {kDVCPALCodecType, 5, "DV PAL"},
- {kDVCNTSCCodecType, 6, "DV/DVCPRO NTSC"},
- {kDVCPROHD720pCodecType, 7, "DVCPRO HD 720p"},
- {kDVCPROHD1080i50CodecType, 8, "DVCPRO HD 1080i50"},
- {kDVCPROHD1080i60CodecType, 9, "DVCPRO HD 1080i60"},
- {kMPEG4VisualCodecType, 10, "MPEG4"},
- {kH263CodecType, 11, "H.263"},
- {kH264CodecType, 12, "H.264"},
- {0, 0, NULL}
-};
-
-static int qtVideoCodecCount = 12;
-
-int quicktime_get_num_videocodecs()
-{
- return qtVideoCodecCount;
-}
-
-QuicktimeCodecTypeDesc *quicktime_get_videocodecType_desc(int indexValue)
-{
- if ((indexValue >= 0) && (indexValue < qtVideoCodecCount))
- return &qtVideoCodecList[indexValue];
- else
- return NULL;
-}
-
-int quicktime_rnatmpvalue_from_videocodectype(int codecType)
-{
- int i;
- for (i = 0; i < qtVideoCodecCount; i++) {
- if (qtVideoCodecList[i].codecType == codecType)
- return qtVideoCodecList[i].rnatmpvalue;
- }
-
- return 0;
-}
-
-int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue)
-{
- int i;
- for (i = 0; i < qtVideoCodecCount; i++) {
- if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue)
- return qtVideoCodecList[i].codecType;
- }
-
- return 0;
-}
-
-
-
-static void CheckError(OSErr err, char *msg, ReportList *reports)
-{
- if (err != noErr) {
- BKE_reportf(reports, RPT_ERROR, "%s: %d", msg, err);
- }
-}
-
-
-static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
-{
- QTAtomContainer myContainer = NULL;
- ComponentResult myErr = noErr;
- Ptr myPtr;
- long mySize = 0;
-
- CodecInfo ci;
-
- QuicktimeCodecData *qcd = rd->qtcodecdata;
-
- /* check if current scene already has qtcodec settings, and clear them */
- if (qcd) {
- free_qtcodecdata(qcd);
- }
- else {
- qcd = rd->qtcodecdata = MEM_callocN(sizeof(QuicktimeCodecData), "QuicktimeCodecData");
- }
-
- /* obtain all current codec settings */
- SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
- SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
-
- /* retreive codecdata from quicktime in a atomcontainer */
- myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer);
- if (myErr != noErr) {
- BKE_report(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed");
- goto bail;
- }
-
- /* get the size of the atomcontainer */
- mySize = GetHandleSize((Handle)myContainer);
-
- /* lock and convert the atomcontainer to a *valid* pointer */
- QTLockContainer(myContainer);
- myPtr = *(Handle)myContainer;
-
- /* copy the Quicktime data into the blender qtcodecdata struct */
- if (myPtr) {
- qcd->cdParms = MEM_mallocN(mySize, "qt.cdParms");
- memcpy(qcd->cdParms, myPtr, mySize);
- qcd->cdSize = mySize;
-
- GetCodecInfo(&ci, qtdata->gSpatialSettings.codecType, 0);
- }
- else {
- BKE_report(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed");
- }
-
- QTUnlockContainer(myContainer);
-
-bail:
- if (myContainer != NULL)
- QTDisposeAtomContainer(myContainer);
-
- return((OSErr)myErr);
-}
-
-
-static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
-{
- Handle myHandle = NULL;
- ComponentResult myErr = noErr;
-
- QuicktimeCodecData *qcd = rd->qtcodecdata;
-
- /* if there is codecdata in the blendfile, convert it to a Quicktime handle */
- if (qcd) {
- myHandle = NewHandle(qcd->cdSize);
- PtrToHand(qcd->cdParms, &myHandle, qcd->cdSize);
- }
-
- /* restore codecsettings to the quicktime component */
- if (qcd->cdParms && qcd->cdSize) {
- myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle);
- if (myErr != noErr) {
- BKE_report(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed");
- goto bail;
- }
-
- /* update runtime codecsettings for use with the codec dialog */
- SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
- SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
-
-
- /* Fill the render QuicktimeCodecSettigns struct */
- rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality;
- /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */
- rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate;
-
- rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType;
- rd->qtcodecsettings.codec = (int)qtdata->gSpatialSettings.codec;
- rd->qtcodecsettings.colorDepth = qtdata->gSpatialSettings.depth;
- rd->qtcodecsettings.codecSpatialQuality = (qtdata->gSpatialSettings.spatialQuality * 100) / codecLosslessQuality;
-
- rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate;
- rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality;
- rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality;
- /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */
-
- }
- else {
- BKE_report(reports, RPT_ERROR, "Quicktime: QT_GetCodecSettingsFromScene failed");
- }
-bail:
- if (myHandle != NULL)
- DisposeHandle(myHandle);
-
- return((OSErr)myErr);
-}
-
-
-static OSErr QT_AddUserDataTextToMovie(Movie theMovie, char *theText, OSType theType)
-{
- UserData myUserData = NULL;
- Handle myHandle = NULL;
- long myLength = strlen(theText);
- OSErr myErr = noErr;
-
- /* get the movie's user data list */
- myUserData = GetMovieUserData(theMovie);
- if (myUserData == NULL)
- return(paramErr);
-
- /* copy the specified text into a new handle */
- myHandle = NewHandleClear(myLength);
- if (myHandle == NULL)
- return(MemError());
-
- BlockMoveData(theText, *myHandle, myLength);
-
- /* add the data to the movie's user data */
- myErr = AddUserDataText(myUserData, myHandle, theType, 1, (short)GetScriptManagerVariable(smRegionCode));
-
- /* clean up */
- DisposeHandle(myHandle);
- return(myErr);
-}
-
-
-static void QT_CreateMyVideoTrack(int rectx, int recty, ReportList *reports)
-{
- OSErr err = noErr;
- Rect trackFrame;
-// MatrixRecord myMatrix;
-
- trackFrame.top = 0;
- trackFrame.left = 0;
- trackFrame.bottom = recty;
- trackFrame.right = rectx;
-
- qtexport->theTrack = NewMovieTrack(qtexport->theMovie,
- FixRatio(trackFrame.right, 1),
- FixRatio(trackFrame.bottom, 1),
- 0);
- CheckError(GetMoviesError(), "NewMovieTrack error", reports);
-
- // SetIdentityMatrix(&myMatrix);
- // ScaleMatrix(&myMatrix, fixed1, Long2Fix(-1), 0, 0);
- // TranslateMatrix(&myMatrix, 0, Long2Fix(trackFrame.bottom));
- // SetMovieMatrix(qtexport->theMovie, &myMatrix);
-
- qtexport->theMedia = NewTrackMedia(qtexport->theTrack,
- VideoMediaType,
- qtdata->kVideoTimeScale,
- nil,
- 0);
- CheckError(GetMoviesError(), "NewTrackMedia error", reports);
-
- err = BeginMediaEdits(qtexport->theMedia);
- CheckError(err, "BeginMediaEdits error", reports);
-
- QT_StartAddVideoSamplesToMedia(&trackFrame, rectx, recty, reports);
-}
-
-
-static void QT_EndCreateMyVideoTrack(ReportList *reports)
-{
- OSErr err = noErr;
-
- QT_EndAddVideoSamplesToMedia();
-
- err = EndMediaEdits(qtexport->theMedia);
- CheckError(err, "EndMediaEdits error", reports);
-
- err = InsertMediaIntoTrack(qtexport->theTrack,
- kTrackStart, /* track start time */
- kMediaStart, /* media start time */
- GetMediaDuration(qtexport->theMedia),
- fixed1);
- CheckError(err, "InsertMediaIntoTrack error", reports);
-}
-
-
-static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, int recty, ReportList *reports)
-{
- SCTemporalSettings gTemporalSettings;
- OSErr err = noErr;
-
- qtexport->ibuf = IMB_allocImBuf(rectx, recty, 32, IB_rect);
- qtexport->ibuf2 = IMB_allocImBuf(rectx, recty, 32, IB_rect);
-
- err = NewGWorldFromPtr(&qtexport->theGWorld,
- k32ARGBPixelFormat,
- trackFrame,
- NULL, NULL, 0,
- (Ptr)qtexport->ibuf->rect,
- rectx * 4);
- CheckError(err, "NewGWorldFromPtr error", reports);
-
- qtexport->thePixMap = GetGWorldPixMap(qtexport->theGWorld);
- LockPixels(qtexport->thePixMap);
-
- SCDefaultPixMapSettings(qtdata->theComponent, qtexport->thePixMap, true);
-
- /* workaround for crash with H.264, which requires an upgrade to
- * the new callback based api for proper encoding, but that's not
- * really compatible with rendering out frames sequentially */
- gTemporalSettings = qtdata->gTemporalSettings;
- if (qtdata->gSpatialSettings.codecType == kH264CodecType) {
- if (gTemporalSettings.temporalQuality != codecMinQuality) {
- BKE_report(reports, RPT_WARNING, "Only minimum quality compression supported for Quicktime H.264");
- gTemporalSettings.temporalQuality = codecMinQuality;
- }
- }
-
- SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &gTemporalSettings);
- SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
-
- err = SCCompressSequenceBegin(qtdata->theComponent, qtexport->thePixMap, NULL, &qtexport->anImageDescription);
- CheckError(err, "SCCompressSequenceBegin error", reports);
-}
-
-
-static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int recty, ReportList *reports)
-{
- OSErr err = noErr;
- Rect imageRect;
-
- int index;
- int boxsize;
- unsigned char *from, *to;
-
- short syncFlag;
- long dataSize;
- Handle compressedData;
- Ptr myPtr;
-
-
- /* copy and flip renderdata */
- memcpy(qtexport->ibuf2->rect, pixels, 4 * rectx * recty);
- IMB_flipy(qtexport->ibuf2);
-
- /* get pointers to parse bitmapdata */
- myPtr = GetPixBaseAddr(qtexport->thePixMap);
- imageRect = (**qtexport->thePixMap).bounds;
-
- from = (unsigned char *) qtexport->ibuf2->rect;
- to = (unsigned char *) myPtr;
-
- /* parse RGBA bitmap into Quicktime's ARGB GWorld */
- boxsize = rectx * recty;
- for (index = 0; index < boxsize; index++) {
- to[0] = from[3];
- to[1] = from[0];
- to[2] = from[1];
- to[3] = from[2];
- to += 4, from += 4;
- }
-
- err = SCCompressSequenceFrame(qtdata->theComponent,
- qtexport->thePixMap,
- &imageRect,
- &compressedData,
- &dataSize,
- &syncFlag);
- CheckError(err, "SCCompressSequenceFrame error", reports);
-
- err = AddMediaSample(qtexport->theMedia,
- compressedData,
- 0,
- dataSize,
- qtdata->duration,
- (SampleDescriptionHandle)qtexport->anImageDescription,
- 1,
- syncFlag,
- NULL);
- CheckError(err, "AddMediaSample error", reports);
-}
-
-
-static void QT_EndAddVideoSamplesToMedia(void)
-{
- SCCompressSequenceEnd(qtdata->theComponent);
-
- UnlockPixels(qtexport->thePixMap);
- if (qtexport->theGWorld)
- DisposeGWorld(qtexport->theGWorld);
-
- if (qtexport->ibuf)
- IMB_freeImBuf(qtexport->ibuf);
-
- if (qtexport->ibuf2)
- IMB_freeImBuf(qtexport->ibuf2);
-}
-
-
-void filepath_qt(char *string, RenderData *rd)
-{
- char txt[64];
-
- if (string == 0) return;
-
- strcpy(string, rd->pic);
- BLI_path_abs(string, G.main->name);
-
- BLI_make_existing_file(string);
-
- if (BLI_strcasecmp(string + strlen(string) - 4, ".mov")) {
- sprintf(txt, "%04d-%04d.mov", (rd->sfra), (rd->efra));
- strcat(string, txt);
- }
-}
-
-
-int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, ReportList *reports)
-{
- OSErr err = noErr;
-
- char name[2048];
- char theFullPath[255];
-
-#ifdef __APPLE__
- int myFile;
- FSRef myRef;
-#else
- char *qtname;
-#endif
- int success = 1;
-
- if (qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
-
- if (qtdata) {
- if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
- free_qtcomponentdata();
- }
-
- qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeCodecDataExt");
-
- if (rd->qtcodecdata == NULL || rd->qtcodecdata->cdParms == NULL) {
- get_qtcodec_settings(rd, reports);
- }
- else {
- qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
-
- QT_GetCodecSettingsFromScene(rd, reports);
- check_renderbutton_framerate(rd, reports);
- }
-
- sframe = (rd->sfra);
-
- filepath_qt(name, rd);
-
-#ifdef __APPLE__
- EnterMoviesOnThread(0);
- strcpy(theFullPath, name);
-
- /* hack: create an empty file to make FSPathMakeRef() happy */
- myFile = open(theFullPath, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRUSR | S_IWUSR);
- if (myFile < 0) {
- BKE_report(reports, RPT_ERROR, "Error while creating movie file!");
- /* do something? */
- }
- close(myFile);
- err = FSPathMakeRef((const UInt8 *)theFullPath, &myRef, 0);
- CheckError(err, "FsPathMakeRef error", reports);
- err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &qtexport->theSpec, NULL);
- CheckError(err, "FsGetCatalogInfoRef error", reports);
-#endif
-#ifdef _WIN32
- qtname = get_valid_qtname(name);
- strcpy(theFullPath, qtname);
- strcpy(name, qtname);
- MEM_freeN(qtname);
-
- CopyCStringToPascal(theFullPath, qtexport->qtfilename);
- err = FSMakeFSSpec(0, 0L, qtexport->qtfilename, &qtexport->theSpec);
-#endif
-
- err = CreateMovieFile(&qtexport->theSpec,
- kMyCreatorType,
- smCurrentScript,
- createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
- &qtexport->resRefNum,
- &qtexport->theMovie);
- CheckError(err, "CreateMovieFile error", reports);
-
- if (err != noErr) {
- BKE_reportf(reports, RPT_ERROR, "Unable to create Quicktime movie: %s", name);
- success = 0;
-#ifdef __APPLE__
- ExitMoviesOnThread();
-#endif
- }
- else {
- /* printf("Created QuickTime movie: %s\n", name); */
-
- QT_CreateMyVideoTrack(rectx, recty, reports);
- }
-
- return success;
-}
-
-
-int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports)
-{
- QT_DoAddVideoSamplesToMedia(frame, pixels, rectx, recty, reports);
- return 1;
-}
-
-
-void end_qt(void)
-{
- OSErr err = noErr;
- short resId = movieInDataForkResID;
-
- if (qtexport->theMovie) {
- QT_EndCreateMyVideoTrack(NULL);
-
- err = AddMovieResource(qtexport->theMovie, qtexport->resRefNum, &resId, qtexport->qtfilename);
- CheckError(err, "AddMovieResource error", NULL);
-
- err = QT_AddUserDataTextToMovie(qtexport->theMovie, "Made with Blender", kUserDataTextInformation);
- CheckError(err, "AddUserDataTextToMovie error", NULL);
-
- err = UpdateMovieResource(qtexport->theMovie, qtexport->resRefNum, resId, qtexport->qtfilename);
- CheckError(err, "UpdateMovieResource error", NULL);
-
- if (qtexport->resRefNum) CloseMovieFile(qtexport->resRefNum);
-
- DisposeMovie(qtexport->theMovie);
-
- /* printf("Finished QuickTime movie.\n"); */
- }
-
-#ifdef __APPLE__
- ExitMoviesOnThread();
-#endif
-
- if (qtexport) {
- MEM_freeN(qtexport);
- qtexport = NULL;
- }
-}
-
-
-void free_qtcomponentdata(void)
-{
- if (qtdata) {
- if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
- MEM_freeN(qtdata);
- qtdata = NULL;
- }
-}
-
-
-static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
-{
- /* to keep float framerates consistent between the codec dialog and frs/sec button. */
- OSErr err;
-
- err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
- CheckError(err, "SCGetInfo fr error", reports);
-
- if ( (rd->frs_sec == 24 || rd->frs_sec == 30 || rd->frs_sec == 60) &&
- (qtdata->gTemporalSettings.frameRate == 1571553 ||
- qtdata->gTemporalSettings.frameRate == 1964113 ||
- qtdata->gTemporalSettings.frameRate == 3928227))
- {
- /* do nothing */
- }
- else {
- if (rd->frs_sec_base > 0)
- qtdata->gTemporalSettings.frameRate =
- ((float)(rd->frs_sec << 16) / rd->frs_sec_base);
- }
-
- err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
- CheckError(err, "SCSetInfo error", reports);
-
- if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */
- qtdata->kVideoTimeScale = 24000;
- qtdata->duration = 1001;
- }
- else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */
- qtdata->kVideoTimeScale = 30000;
- qtdata->duration = 1001;
- }
- else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */
- qtdata->kVideoTimeScale = 60000;
- qtdata->duration = 1001;
- }
- else {
- qtdata->kVideoTimeScale = (qtdata->gTemporalSettings.frameRate >> 16) * 100;
- qtdata->duration = 100;
- }
-}
-
-void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf)
-{
- if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) {
- if ((rd->qtcodecsettings.codecType == 0) ||
- (rd->qtcodecsettings.codecSpatialQuality < 0) ||
- (rd->qtcodecsettings.codecSpatialQuality > 100))
- {
- rd->qtcodecsettings.codecType = kJPEGCodecType;
- rd->qtcodecsettings.codec = (int)anyCodec;
- rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality * 100) / codecLosslessQuality;
- rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality * 100) / codecLosslessQuality;
- rd->qtcodecsettings.keyFrameRate = 25;
- rd->qtcodecsettings.bitRate = 5000000; /* 5 Mbps */
- }
- }
-}
-
-int get_qtcodec_settings(RenderData *rd, ReportList *reports)
-{
- OSErr err = noErr;
- /* erase any existing codecsetting */
- if (qtdata) {
- if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
- free_qtcomponentdata();
- }
-
- /* allocate new */
- qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData");
- qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
-
- /* get previous selected codecsetting, from qtatom or detailed settings */
- if (rd->qtcodecdata && rd->qtcodecdata->cdParms) {
- QT_GetCodecSettingsFromScene(rd, reports);
- }
- else {
- SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
- SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
-
- qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType;
- qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec;
- qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100;
- qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100;
- qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate;
- qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate;
- qtdata->gSpatialSettings.depth = rd->qtcodecsettings.colorDepth;
- qtdata->aDataRateSetting.minSpatialQuality = (rd->qtcodecsettings.minSpatialQuality * codecLosslessQuality) / 100;
- qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100;
-
- qtdata->aDataRateSetting.frameDuration = rd->frs_sec;
- SetMovieTimeScale(qtexport->theMovie, rd->frs_sec_base * 1000);
-
-
- err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
- CheckError(err, "SCSetInfo1 error", reports);
- err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- CheckError(err, "SCSetInfo2 error", reports);
- err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
- CheckError(err, "SCSetInfo3 error", reports);
- }
-
- check_renderbutton_framerate(rd, reports);
-
- return err;
-}
-
-static int request_qtcodec_settings_exec(bContext *C, wmOperator *op)
-{
- OSErr err = noErr;
- Scene *scene = CTX_data_scene(C);
- RenderData *rd = &scene->r;
-
- /* erase any existing codecsetting */
- if (qtdata) {
- if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
- free_qtcomponentdata();
- }
-
- /* allocate new */
- qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData");
- qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
-
- /* get previous selected codecsetting, from qtatom or detailed settings */
- if (rd->qtcodecdata && rd->qtcodecdata->cdParms) {
- QT_GetCodecSettingsFromScene(rd, op->reports);
- }
- else {
- SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
- SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
-
- qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType;
- qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec;
- qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100;
- qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100;
- qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate;
- qtdata->gTemporalSettings.frameRate = ((float)(rd->frs_sec << 16) / rd->frs_sec_base);
- qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate;
- qtdata->gSpatialSettings.depth = rd->qtcodecsettings.colorDepth;
- qtdata->aDataRateSetting.minSpatialQuality = (rd->qtcodecsettings.minSpatialQuality * codecLosslessQuality) / 100;
- qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100;
-
- qtdata->aDataRateSetting.frameDuration = rd->frs_sec;
-
- err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
- CheckError(err, "SCSetInfo1 error", op->reports);
- err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- CheckError(err, "SCSetInfo2 error", op->reports);
- err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
- CheckError(err, "SCSetInfo3 error", op->reports);
- }
- /* put up the dialog box - it needs to be called from the main thread */
- err = SCRequestSequenceSettings(qtdata->theComponent);
-
- if (err == scUserCancelled) {
- return OPERATOR_FINISHED;
- }
-
- /* update runtime codecsettings for use with the codec dialog */
- SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
- SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
- SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
-
-
- /* Fill the render QuicktimeCodecSettings struct */
- rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality;
- /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */
- rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate;
-
- rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType;
- rd->qtcodecsettings.codec = (int)qtdata->gSpatialSettings.codec;
- rd->qtcodecsettings.colorDepth = qtdata->gSpatialSettings.depth;
- rd->qtcodecsettings.codecSpatialQuality = (qtdata->gSpatialSettings.spatialQuality * 100) / codecLosslessQuality;
-
- rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate;
- rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality;
- rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality;
- /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */
-
- QT_SaveCodecSettingsToScene(rd, op->reports);
-
- /* framerate jugglin' */
- if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */
- qtdata->kVideoTimeScale = 24000;
- qtdata->duration = 1001;
-
- rd->frs_sec = 24;
- rd->frs_sec_base = 1.001;
- }
- else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */
- qtdata->kVideoTimeScale = 30000;
- qtdata->duration = 1001;
-
- rd->frs_sec = 30;
- rd->frs_sec_base = 1.001;
- }
- else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */
- qtdata->kVideoTimeScale = 60000;
- qtdata->duration = 1001;
-
- rd->frs_sec = 60;
- rd->frs_sec_base = 1.001;
- }
- else {
- double fps = qtdata->gTemporalSettings.frameRate;
-
- qtdata->kVideoTimeScale = 60000;
- qtdata->duration = qtdata->kVideoTimeScale / (qtdata->gTemporalSettings.frameRate / 65536);
-
- if ((qtdata->gTemporalSettings.frameRate & 0xffff) == 0) {
- rd->frs_sec = fps / 65536;
- rd->frs_sec_base = 1.0;
- }
- else {
- /* we do our very best... */
- rd->frs_sec = fps / 65536;
- rd->frs_sec_base = 1.0;
- }
- }
-
- return OPERATOR_FINISHED;
-}
-
-static int ED_operator_setqtcodec(bContext *C)
-{
- return G.have_quicktime != FALSE;
-}
-
-#if defined(__APPLE__) && defined(GHOST_COCOA)
-/* Need to set up a Cocoa NSAutoReleasePool to avoid memory leak
- * And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that */
-extern int cocoa_request_qtcodec_settings_exec(bContext *C, wmOperator *op);
-
-int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
-{
- return request_qtcodec_settings_exec(C, op);
-}
-#endif
-
-
-void SCENE_OT_render_data_set_quicktime_codec(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Change Codec";
- ot->description = "Change Quicktime codec Settings";
- ot->idname = "SCENE_OT_render_data_set_quicktime_codec";
-
- /* api callbacks */
-#if defined(__APPLE__) && defined(GHOST_COCOA)
- ot->exec = cocoa_request_qtcodec_settings_exec;
-#else
- ot->exec = request_qtcodec_settings_exec;
-#endif
- ot->poll = ED_operator_setqtcodec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-#endif /* USE_QTKIT */
-#endif /* _WIN32 || __APPLE__ */
-#endif /* WITH_QUICKTIME */
-
diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c
deleted file mode 100644
index 511b62d856a..00000000000
--- a/source/blender/quicktime/apple/quicktime_import.c
+++ /dev/null
@@ -1,833 +0,0 @@
-/*
- * ***** 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 written by Rob Haarsma (phase)
- *
- * Contributor(s): Stefan Gartner (sgefant)
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/quicktime/apple/quicktime_import.c
- * \ingroup quicktime
- *
- * Code to use Quicktime to load images/movies as texture.
- */
-
-#ifdef WITH_QUICKTIME
-
-#if defined(_WIN32) || defined(__APPLE__)
-#ifndef USE_QTKIT
-
-#include "MEM_guardedalloc.h"
-#include "IMB_anim.h"
-#include "BLI_sys_types.h"
-#include "BKE_global.h"
-#include "BLI_dynstr.h"
-#include "BLI_path_util.h"
-
-#ifdef __APPLE__
-#include <QuickTime/Movies.h>
-#include <QuickTime/QuickTimeComponents.h>
-#endif
-
-#ifdef _WIN32
-#include <Movies.h>
-#include <QTML.h>
-#include <TextUtils.h>
-#include <QuickTimeComponents.h>
-#include <QTLoadLibraryUtils.h>
-#endif /* _WIN32 */
-
-
-#include "quicktime_import.h"
-#include "quicktime_export.h"
-
-#define RECT_WIDTH(r) (r.right - r.left)
-#define RECT_HEIGHT(r) (r.bottom - r.top)
-
-#define QTIME_DEBUG 0
-
-typedef struct _QuicktimeMovie {
-
- GWorldPtr offscreenGWorld;
- PixMapHandle offscreenPixMap;
- Movie movie;
- Rect movieBounds;
- short movieRefNum;
- short movieResId;
- int movWidth, movHeight;
-
-
- int framecount;
-
-
- ImBuf *ibuf;
-
-
- TimeValue *frameIndex;
- Media theMedia;
- Track theTrack;
- long trackIndex;
- short depth;
-
- int have_gw; /* ugly */
-} QuicktimeMovie;
-
-
-
-void quicktime_init(void)
-{
- OSErr nerr;
-#ifdef _WIN32
- QTLoadLibrary("QTCF.dll");
- nerr = InitializeQTML(0);
- if (nerr != noErr) {
- G.have_quicktime = FALSE;
- }
- else
- G.have_quicktime = TRUE;
-#endif /* _WIN32 */
-
- /* Initialize QuickTime */
-#if defined(_WIN32) || defined(__APPLE__)
- nerr = EnterMovies();
- if (nerr != noErr)
- G.have_quicktime = FALSE;
- else
-#endif /* _WIN32 || __APPLE__ */
-#ifdef __linux__
- /* inititalize quicktime codec registry */
- lqt_registry_init();
-#endif
- G.have_quicktime = TRUE;
-}
-
-
-void quicktime_exit(void)
-{
-#if defined(_WIN32) || defined(__APPLE__)
-#ifdef WITH_QUICKTIME
- if (G.have_quicktime) {
- free_qtcomponentdata();
- ExitMovies();
-#ifdef _WIN32
- TerminateQTML();
-#endif /* _WIN32 */
- }
-#endif /* WITH_QUICKTIME */
-#endif /* _WIN32 || __APPLE__ */
-}
-
-
-#ifdef _WIN32
-char *get_valid_qtname(char *name)
-{
- TCHAR Buffer[MAX_PATH];
- DWORD dwRet;
- char *qtname;
- DynStr *ds = BLI_dynstr_new();
-
- dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
-
- if (name[1] != ':') {
- char drive[2];
-
- if (name[0] == '/' || name[0] == '\\') {
- drive[0] = Buffer[0];
- drive[1] = '\0';
-
- BLI_dynstr_append(ds, drive);
- BLI_dynstr_append(ds, ":");
- BLI_dynstr_append(ds, name);
- }
- else {
- BLI_dynstr_append(ds, Buffer);
- BLI_dynstr_append(ds, "/");
- BLI_dynstr_append(ds, name);
- }
- }
- else {
- BLI_dynstr_append(ds, name);
- }
-
- qtname = BLI_dynstr_get_cstring(ds);
- BLI_dynstr_free(ds);
-
- return qtname;
-}
-#endif /* _WIN32 */
-
-
-int anim_is_quicktime(const char *name)
-{
- FSSpec theFSSpec;
- char theFullPath[255];
-
- Boolean isMovieFile = false;
- AliasHandle myAlias = NULL;
- Component myImporter = NULL;
-#ifdef __APPLE__
- FInfo myFinderInfo;
- FSRef myRef;
-#else
- char *qtname;
- Str255 dst;
-#endif
- OSErr err = noErr;
-
- // don't let quicktime movie import handle these
- if (BLI_testextensie(name, ".swf") ||
- BLI_testextensie(name, ".txt") ||
- BLI_testextensie(name, ".mpg") ||
- BLI_testextensie(name, ".avi") || /* wouldn't be appropriate ;) */
- BLI_testextensie(name, ".tga") ||
- BLI_testextensie(name, ".png") ||
- BLI_testextensie(name, ".bmp") ||
- BLI_testextensie(name, ".jpg") ||
- BLI_testextensie(name, ".tif") ||
- BLI_testextensie(name, ".exr") ||
- BLI_testextensie(name, ".wav") ||
- BLI_testextensie(name, ".zip") ||
- BLI_testextensie(name, ".mp3"))
- {
- return 0;
- }
-
- if (QTIME_DEBUG) printf("qt: checking as movie: %s\n", name);
-
-#ifdef __APPLE__
- strcpy(theFullPath, name);
-
- err = FSPathMakeRef(theFullPath, &myRef, 0);
- err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
-#else
- qtname = get_valid_qtname(name);
- strcpy(theFullPath, qtname);
- MEM_freeN(qtname);
-
- CopyCStringToPascal(theFullPath, dst);
- err = FSMakeFSSpec(0, 0L, dst, &theFSSpec);
-#endif
-
-#ifdef __APPLE__
- // see whether the file type is MovieFileType; to do this, get the Finder information
- err = FSpGetFInfo(&theFSSpec, &myFinderInfo);
- if (err == noErr) {
- if (myFinderInfo.fdType == kQTFileTypeMovie) {
- return(true);
- }
- }
-#endif
-
-/* on mac os x this results in using quicktime for other formats as well
- * not sure whether this is intended
- */
- // if it isn't a movie file, see whether the file can be imported as a movie
- err = QTNewAlias(&theFSSpec, &myAlias, true);
- if (err == noErr) {
- if (myAlias != NULL) {
- err = GetMovieImporterForDataRef(rAliasType, (Handle)myAlias, kGetMovieImporterDontConsiderGraphicsImporters, &myImporter);
- DisposeHandle((Handle)myAlias);
- }
- }
-
- if ((err == noErr) && (myImporter != NULL)) { /* this file is a movie file */
- isMovieFile = true;
- }
-
- return(isMovieFile);
-}
-
-
-void free_anim_quicktime(struct anim *anim)
-{
- if (anim == NULL) return;
- if (anim->qtime == NULL) return;
-
- UnlockPixels(anim->qtime->offscreenPixMap);
-
- if (anim->qtime->have_gw)
- DisposeGWorld(anim->qtime->offscreenGWorld);
- if (anim->qtime->ibuf)
- IMB_freeImBuf(anim->qtime->ibuf);
-
- DisposeMovie(anim->qtime->movie);
- CloseMovieFile(anim->qtime->movieRefNum);
-
- if (anim->qtime->frameIndex) MEM_freeN(anim->qtime->frameIndex);
- if (anim->qtime) MEM_freeN(anim->qtime);
-
- anim->qtime = NULL;
-
- anim->duration = 0;
-}
-
-
-static OSErr QT_get_frameIndexes(struct anim *anim)
-{
- int i;
- OSErr anErr = noErr;
- OSType media = VideoMediaType;
- TimeValue nextTime = 0;
- TimeValue startPoint;
- TimeValue tmpstartPoint;
- long sampleCount = 0;
-
- startPoint = -1;
-
- GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample + nextTimeEdgeOK, (TimeValue)1, &media, 0,
- 1, &startPoint, NULL);
-
- tmpstartPoint = startPoint;
-
- anim->qtime->framecount = 0;
-
- sampleCount = GetMediaSampleCount(anim->qtime->theMedia);
- anErr = GetMoviesError();
- if (anErr != noErr) return anErr;
-
- anim->qtime->framecount = sampleCount;
-
- anim->qtime->frameIndex = (TimeValue *) MEM_callocN(sizeof(TimeValue) * anim->qtime->framecount, "qtframeindex");
-
- //rewind
- GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample, 1, &media, (TimeValue)1, 0, &tmpstartPoint, NULL);
-
- anim->qtime->frameIndex[0] = startPoint;
- for (i = 1; i < anim->qtime->framecount; i++) {
- nextTime = 0;
- GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample, 1, &media, startPoint, 0, &nextTime, NULL);
- startPoint = nextTime;
- anim->qtime->frameIndex[i] = nextTime;
- }
-
- anErr = GetMoviesError();
- return anErr;
-}
-
-
-ImBuf *qtime_fetchibuf(struct anim *anim, int position)
-{
- PixMapHandle myPixMap = NULL;
- Ptr myPtr;
-
- register int index;
- register int boxsize;
-
- register uint32_t *readPos;
- register uint32_t *changePos;
-
- ImBuf *ibuf = NULL;
- unsigned int *rect;
-#ifdef __APPLE__
- unsigned char *from, *to;
-#endif
-#ifdef _WIN32
- unsigned char *crect;
-#endif
-
- if (anim == NULL) {
- return (NULL);
- }
-
- ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect);
- rect = ibuf->rect;
-
- SetMovieTimeValue(anim->qtime->movie, anim->qtime->frameIndex[position]);
- UpdateMovie(anim->qtime->movie);
- MoviesTask(anim->qtime->movie, 0);
-
-
- myPixMap = GetGWorldPixMap(anim->qtime->offscreenGWorld);
- myPtr = GetPixBaseAddr(myPixMap);
-
- if (myPtr == NULL) {
- printf("Error reading frame from Quicktime");
- IMB_freeImBuf(ibuf);
- return NULL;
- }
-
- boxsize = anim->x * anim->y;
- readPos = (uint32_t *) myPtr;
- changePos = (uint32_t *) rect; //textureIMBuf *THE* data pointerrr
-
-#ifdef __APPLE__
- // Swap alpha byte to the end, so ARGB become RGBA;
- from = (unsigned char *)readPos;
- to = (unsigned char *)changePos;
-
- for (index = 0; index < boxsize; index++, from += 4, to += 4) {
- to[3] = from[0];
- to[0] = from[1];
- to[1] = from[2];
- to[2] = from[3];
- }
-#endif
-
-#ifdef _WIN32
- for (index = 0; index < boxsize; index++, changePos++, readPos++)
- *(changePos) = *(readPos);
-
- if (anim->qtime->depth < 32) {
- //add alpha to ibuf
- boxsize = anim->x * anim->y * 4;
- crect = (unsigned char *) rect;
- for (index = 0; index < boxsize; index += 4, crect += 4) {
- crect[3] = 0xFF;
- }
- }
-#endif
-
- IMB_flipy(ibuf);
- return ibuf;
-}
-
-
-// following two functions only here to get movie pixeldepth
-
-static int GetFirstVideoMedia(struct anim *anim)
-{
- long numTracks;
- OSType mediaType;
-
- numTracks = GetMovieTrackCount(anim->qtime->movie);
-
- for (anim->qtime->trackIndex = 1; anim->qtime->trackIndex <= numTracks; (anim->qtime->trackIndex)++) {
- anim->qtime->theTrack = GetMovieIndTrack(anim->qtime->movie, anim->qtime->trackIndex);
-
- if (anim->qtime->theTrack)
- anim->qtime->theMedia = GetTrackMedia(anim->qtime->theTrack);
-
- if (anim->qtime->theMedia)
- GetMediaHandlerDescription(anim->qtime->theMedia, &mediaType, nil, nil);
- if (mediaType == VideoMediaType) return 1;
- }
-
- anim->qtime->trackIndex = 0; // trackIndex can't be 0
- return 0; // went through all tracks and no video
-}
-
-static short GetFirstVideoTrackPixelDepth(struct anim *anim)
-{
- SampleDescriptionHandle imageDescH = (SampleDescriptionHandle)NewHandle(sizeof(Handle));
-// long trackIndex = 0; /*unused*/
-
- if (!GetFirstVideoMedia(anim))
- return -1;
-
- if (!anim->qtime->trackIndex || !anim->qtime->theMedia) return -1; // we need both
- GetMediaSampleDescription(anim->qtime->theMedia, anim->qtime->trackIndex, imageDescH);
-
- return (*(ImageDescriptionHandle)imageDescH)->depth;
-}
-
-
-int startquicktime(struct anim *anim)
-{
- FSSpec theFSSpec;
-
- OSErr err = noErr;
- char theFullPath[255];
-#ifdef __APPLE__
- FSRef myRef;
-#else
- char *qtname;
- Str255 dst;
-#endif
- short depth = 0;
-
- anim->qtime = MEM_callocN(sizeof(QuicktimeMovie), "animqt");
- anim->qtime->have_gw = FALSE;
-
- if (anim->qtime == NULL) {
- if (QTIME_DEBUG) printf("Can't alloc qtime: %s\n", anim->name);
- return -1;
- }
-
- if (QTIME_DEBUG) printf("qt: attempting to load as movie %s\n", anim->name);
-
-#ifdef __APPLE__
- strcpy(theFullPath, anim->name);
-
- err = FSPathMakeRef(theFullPath, &myRef, 0);
- err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
-#else
- qtname = get_valid_qtname(anim->name);
- strcpy(theFullPath, qtname);
- MEM_freeN(qtname);
-
- CopyCStringToPascal(theFullPath, dst);
- FSMakeFSSpec(0, 0L, dst, &theFSSpec);
-#endif
-
- err = OpenMovieFile(&theFSSpec, &anim->qtime->movieRefNum, fsRdPerm);
-
- if (err == noErr) {
- if (QTIME_DEBUG) printf("qt: movie opened\n");
- err = NewMovieFromFile(&anim->qtime->movie,
- anim->qtime->movieRefNum,
- &anim->qtime->movieResId, NULL, newMovieActive, NULL);
- }
-
- if (err) {
- if (QTIME_DEBUG) printf("qt: bad movie %s\n", anim->name);
- if (anim->qtime->movie) {
- DisposeMovie(anim->qtime->movie);
- MEM_freeN(anim->qtime);
- if (QTIME_DEBUG) printf("qt: can't load %s\n", anim->name);
- return -1;
- }
- }
-
- GetMovieBox(anim->qtime->movie, &anim->qtime->movieBounds);
- anim->x = anim->qtime->movWidth = RECT_WIDTH(anim->qtime->movieBounds);
- anim->y = anim->qtime->movHeight = RECT_HEIGHT(anim->qtime->movieBounds);
- if (QTIME_DEBUG) printf("qt: got bounds %s\n", anim->name);
-
- if (anim->x == 0 && anim->y == 0) {
- if (QTIME_DEBUG) printf("qt: error, no dimensions\n");
- free_anim_quicktime(anim);
- return -1;
- }
-
- anim->qtime->ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect);
-
-#ifdef _WIN32
- err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld,
- k32RGBAPixelFormat,
- &anim->qtime->movieBounds,
- NULL, NULL, 0,
- (unsigned char *)anim->qtime->ibuf->rect,
- anim->x * 4);
-#else
- err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld,
- k32ARGBPixelFormat,
- &anim->qtime->movieBounds,
- NULL, NULL, 0,
- (unsigned char *)anim->qtime->ibuf->rect,
- anim->x * 4);
-#endif /* _WIN32 */
-
- if (err == noErr) {
- anim->qtime->have_gw = TRUE;
-
- SetMovieGWorld(anim->qtime->movie,
- anim->qtime->offscreenGWorld,
- GetGWorldDevice(anim->qtime->offscreenGWorld));
- SetMoviePlayHints(anim->qtime->movie, hintsHighQuality, hintsHighQuality);
-
- // sets Media and Track!
- depth = GetFirstVideoTrackPixelDepth(anim);
-
- QT_get_frameIndexes(anim);
- }
-
- anim->qtime->offscreenPixMap = GetGWorldPixMap(anim->qtime->offscreenGWorld);
- LockPixels(anim->qtime->offscreenPixMap);
-
- //fill blender's anim struct
- anim->qtime->depth = depth;
-
- anim->duration = anim->qtime->framecount;
- anim->params = 0;
-
- anim->interlacing = 0;
- anim->orientation = 0;
- anim->framesize = anim->x * anim->y * 4;
-
- anim->curposition = 0;
-
- if (QTIME_DEBUG) printf("qt: load %s %dx%dx%d frames %d\n", anim->name, anim->qtime->movWidth,
- anim->qtime->movHeight, anim->qtime->depth, anim->qtime->framecount);
-
- return 0;
-}
-
-int imb_is_a_quicktime(char *name)
-{
- GraphicsImportComponent theImporter = NULL;
-
- FSSpec theFSSpec;
-#ifdef _WIN32
- Str255 dst; /*unused*/
-#endif
- char theFullPath[255];
-
-// Boolean isMovieFile = false; /*unused*/
-// AliasHandle myAlias = NULL; /*unused*/
-// Component myImporter = NULL; /*unused*/
-#ifdef __APPLE__
-// FInfo myFinderInfo; /*unused*/
- FSRef myRef;
-#endif
- OSErr err = noErr;
-
- if (!G.have_quicktime) return 0;
-
- if (QTIME_DEBUG) printf("qt: checking as image %s\n", name);
-
- // don't let quicktime image import handle these
- if (BLI_testextensie(name, ".swf") ||
- BLI_testextensie(name, ".txt") ||
- BLI_testextensie(name, ".mpg") ||
- BLI_testextensie(name, ".wav") ||
- BLI_testextensie(name, ".mov") || // not as image, doesn't work
- BLI_testextensie(name, ".avi") ||
- BLI_testextensie(name, ".mp3"))
- {
- return 0;
- }
-
- strcpy(theFullPath, name);
-#ifdef __APPLE__
- err = FSPathMakeRef(theFullPath, &myRef, 0);
- err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
-#else
- CopyCStringToPascal(theFullPath, dst);
- err = FSMakeFSSpec(0, 0L, dst, &theFSSpec);
-#endif
-
- GetGraphicsImporterForFile(&theFSSpec, &theImporter);
-
- if (theImporter != NULL) {
- if (QTIME_DEBUG) printf("qt: %s valid\n", name);
- CloseComponent(theImporter);
- return 1;
- }
-
- return 0;
-}
-
-ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
-{
- Rect myRect;
- OSErr err = noErr;
- GraphicsImportComponent gImporter = NULL;
-
- ImageDescriptionHandle desc;
-
- ComponentInstance dataHandler;
- PointerDataRef dataref;
-
- int x, y, depth;
- int have_gw = FALSE;
- ImBuf *ibuf = NULL;
-// ImBuf *imbuf = NULL; /*unused*/
- GWorldPtr offGWorld;
- PixMapHandle myPixMap = NULL;
-
-#ifdef __APPLE__
- Ptr myPtr;
-
- register int index;
- register int boxsize;
-
- register uint32_t *readPos;
- register uint32_t *changePos;
-
- ImBuf *wbuf = NULL;
- unsigned int *rect;
- unsigned char *from, *to;
-#endif
-
- if (mem == NULL || !G.have_quicktime)
- goto bail;
-
- if (QTIME_DEBUG) printf("qt: attempt to load mem as image\n");
-
- dataref = (PointerDataRef)NewHandle(sizeof(PointerDataRefRecord));
- (**dataref).data = mem;
- (**dataref).dataLength = size;
-
- err = OpenADataHandler((Handle)dataref,
- PointerDataHandlerSubType,
- nil,
- (OSType)0,
- nil,
- kDataHCanRead,
- &dataHandler);
- if (err != noErr) {
- if (QTIME_DEBUG) printf("no datahandler\n");
- goto bail;
- }
-
- err = GetGraphicsImporterForDataRef((Handle)dataref, PointerDataHandlerSubType, &gImporter);
- if (err != noErr) {
- if (QTIME_DEBUG) printf("no graphimport\n");
- goto bail;
- }
-
- err = GraphicsImportGetNaturalBounds(gImporter, &myRect);
- if (err != noErr) {
- if (QTIME_DEBUG) printf("no bounds\n");
- goto bail;
- }
-
- err = GraphicsImportGetImageDescription(gImporter, &desc);
- if (err != noErr) {
- if (QTIME_DEBUG) printf("no imagedescription\n");
- goto bail;
- }
-
- x = RECT_WIDTH(myRect);
- y = RECT_HEIGHT(myRect);
- depth = (**desc).depth;
-
- if (flags & IB_test) {
- ibuf = IMB_allocImBuf(x, y, depth, 0);
- ibuf->ftype = QUICKTIME;
- DisposeHandle((Handle)dataref);
- if (gImporter != NULL) CloseComponent(gImporter);
- return ibuf;
- }
-
-#ifdef __APPLE__
- ibuf = IMB_allocImBuf(x, y, 32, IB_rect);
- wbuf = IMB_allocImBuf(x, y, 32, IB_rect);
-
- err = NewGWorldFromPtr(&offGWorld,
- k32ARGBPixelFormat,
- &myRect, NULL, NULL, 0,
- (unsigned char *)wbuf->rect, x * 4);
-#else
-
- ibuf = IMB_allocImBuf(x, y, 32, IB_rect);
-
- err = NewGWorldFromPtr(&offGWorld,
- k32RGBAPixelFormat,
- &myRect, NULL, NULL, 0,
- (unsigned char *)ibuf->rect, x * 4);
-#endif
-
- if (err != noErr) {
- if (QTIME_DEBUG) printf("no newgworld\n");
- goto bail;
- }
- else {
- have_gw = TRUE;
- }
-
- GraphicsImportSetGWorld(gImporter, offGWorld, NULL);
- GraphicsImportDraw(gImporter);
-
-#ifdef __APPLE__
- rect = ibuf->rect;
-
- myPixMap = GetGWorldPixMap(offGWorld);
- LockPixels(myPixMap);
- myPtr = GetPixBaseAddr(myPixMap);
-
- if (myPtr == NULL) {
- printf("Error reading frame from Quicktime");
- IMB_freeImBuf(ibuf);
- return NULL;
- }
-
- boxsize = x * y;
- readPos = (uint32_t *) myPtr;
- changePos = (uint32_t *) rect;
-
- // Swap alpha byte to the end, so ARGB become RGBA;
- from = (unsigned char *)readPos;
- to = (unsigned char *)changePos;
-
- for (index = 0; index < boxsize; index++, from += 4, to += 4) {
- to[3] = from[0];
- to[0] = from[1];
- to[1] = from[2];
- to[2] = from[3];
- }
-#endif
-
-bail:
-
- DisposeHandle((Handle)dataref);
- UnlockPixels(myPixMap);
- if (have_gw) DisposeGWorld(offGWorld);
-
-#ifdef __APPLE__
- if (wbuf) {
- IMB_freeImBuf(wbuf);
- wbuf = NULL;
- }
-#endif
-
- if (gImporter != NULL) CloseComponent(gImporter);
-
- if (err != noErr) {
- if (QTIME_DEBUG) printf("quicktime import unsuccesfull\n");
- if (ibuf) {
- IMB_freeImBuf(ibuf);
- ibuf = NULL;
- }
- }
-
- if (ibuf) {
-
-#ifdef _WIN32
-// add non transparent alpha layer, so images without alpha show up in the sequence editor
-// exception for GIF images since these can be transparent without being 32 bit
-// (might also be nescessary for OSX)
- int i;
- int box = x * y;
- unsigned char *arect = (unsigned char *) ibuf->rect;
-
- if (depth < 32 && (**desc).cType != kGIFCodecType) {
- for (i = 0; i < box; i++, arect += 4)
- arect[3] = 0xFF;
- }
-#endif
-
- IMB_flipy(ibuf);
- ibuf->ftype = QUICKTIME;
- }
- return ibuf;
-}
-
-#endif /* USE_QTKIT */
-#endif /* _WIN32 || __APPLE__ */
-
-#endif /* WITH_QUICKTIME */
-
-
-#if 0
-
-struct ImageDescription {
- long idSize;
- CodecType cType;
- long resvd1;
- short resvd2;
- short dataRefIndex;
- short version;
- short revisionLevel;
- long vendor;
- CodecQ temporalQuality;
- CodecQ spatialQuality;
- short width;
- short height;
- Fixed hRes;
- Fixed vRes;
- long dataSize;
- short frameCount;
- Str31 name;
- short depth;
- short clutID;
-};
-
-#endif // 0
diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h
index 55323c05278..35e424b9081 100644
--- a/source/blender/quicktime/quicktime_export.h
+++ b/source/blender/quicktime/quicktime_export.h
@@ -69,25 +69,18 @@ QuicktimeCodecTypeDesc *quicktime_get_videocodecType_desc(int indexValue);
int quicktime_rnatmpvalue_from_videocodectype(int codecType);
int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue);
-#ifdef USE_QTKIT
/*Audio codec type*/
int quicktime_get_num_audiocodecs(void);
QuicktimeCodecTypeDesc *quicktime_get_audiocodecType_desc(int indexValue);
int quicktime_rnatmpvalue_from_audiocodectype(int codecType);
int quicktime_audiocodecType_from_rnatmpvalue(int rnatmpvalue);
-#endif
-
-#ifndef USE_QTKIT
-void SCENE_OT_render_data_set_quicktime_codec(struct wmOperatorType *ot); //Operator to raise quicktime standard dialog to request codec settings
-#endif
-
void free_qtcomponentdata(void);
void makeqtstring(struct RenderData *rd, char *string); //for playanim.c
-#if (defined(USE_QTKIT) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 && __LP64__)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 && __LP64__)
//Include the quicktime codec types constants that are missing in QTKitDefines.h
enum {
kRawCodecType = 'raw ',
diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h
index 4ec435db982..e45720496cc 100644
--- a/source/blender/quicktime/quicktime_import.h
+++ b/source/blender/quicktime/quicktime_import.h
@@ -42,18 +42,6 @@
#include "../imbuf/IMB_imbuf.h"
#include "../imbuf/IMB_imbuf_types.h"
-#ifndef USE_QTKIT
-# ifndef __MOVIES__
-# ifdef _WIN32
-# include <Movies.h>
-# elif defined(__APPLE__)
-# define __CARBONSOUND__
-# import <Carbon/Carbon.h>
-# include <QuickTime/Movies.h>
-# endif
-# endif /* __MOVIES__ */
-#endif /* USE_QTKIT */
-
#ifdef _WIN32
# ifndef __FIXMATH__
# include <FixMath.h>
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index 94a95974009..db23cd97b74 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -98,7 +98,6 @@ set(SRC
intern/include/raycounter.h
intern/include/rayobject.h
intern/include/rayintersection.h
- intern/include/raycounter.h
intern/include/render_types.h
intern/include/render_result.h
intern/include/rendercore.h
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 79826a63690..109524c9814 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -247,10 +247,6 @@ int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct
/* do a full sample buffer compo */
void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce, struct bNodeTree *ntree);
-/* ancient stars function... go away! */
-void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void),
- void (*vertexfunc)(const float *), void (*termfunc)(void));
-
/* display and event callbacks */
void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr));
void RE_display_clear_cb(struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr));
diff --git a/source/blender/render/intern/source/bake.c b/source/blender/render/intern/source/bake.c
index 72e47f89bb2..c150133b276 100644
--- a/source/blender/render/intern/source/bake.c
+++ b/source/blender/render/intern/source/bake.c
@@ -322,6 +322,10 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
if (bs->rect_mask) {
bs->rect_mask[bs->rectx * y + x] = FILTER_MASK_USED;
}
+
+ if (bs->do_update) {
+ *bs->do_update = true;
+ }
}
static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist, int x, int y)
@@ -1141,7 +1145,7 @@ struct Image *RE_bake_shade_get_image(void)
static void add_single_heights_margin(const ImBuf *ibuf, const char *mask, float *heights_buffer)
{
- int x ,y;
+ int x, y;
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
@@ -1200,11 +1204,11 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma
if (auto_range_fit) {
/* If automatic range fitting is enabled. */
for (y = 0; y < ibuf->y; y++) {
- const int Yu = y == (ibuf->y - 1) ? (ibuf->y - 1) : (y+1);
+ const int Yu = y == (ibuf->y - 1) ? (ibuf->y - 1) : (y + 1);
const int Yc = y;
const int Yd = y == 0 ? 0 : (y - 1);
- for (x= 0; x < ibuf->x; x++) {
+ for (x = 0; x < ibuf->x; x++) {
const int Xl = x == 0 ? 0 : (x - 1);
const int Xc = x;
const int Xr = x == (ibuf->x - 1) ? (ibuf->x - 1) : (x + 1);
@@ -1244,11 +1248,11 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma
/* Output derivatives. */
auto_range_fit &= (max_num_deriv > 0);
for (y = 0; y < ibuf->y; y++) {
- const int Yu= y==(ibuf->y-1) ? (ibuf->y-1) : (y+1);
- const int Yc= y;
- const int Yd= y==0 ? 0 : (y-1);
+ const int Yu = y == (ibuf->y - 1) ? (ibuf->y - 1) : (y + 1);
+ const int Yc = y;
+ const int Yd = y == 0 ? 0 : (y - 1);
- for(x= 0; x<ibuf->x; x++) {
+ for (x = 0; x < ibuf->x; x++) {
const int Xl = x == 0 ? 0 : (x - 1);
const int Xc = x;
const int Xr = x == (ibuf->x - 1) ? (ibuf->x - 1) : (x + 1);
@@ -1269,14 +1273,15 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma
/* Early out. */
index = ibuf->x * y + x;
- if (mask[index] != FILTER_MASK_USED){
+ if (mask[index] != FILTER_MASK_USED) {
continue;
}
if (auto_range_fit) {
deriv_x /= max_num_deriv;
deriv_y /= max_num_deriv;
- } else {
+ }
+ else {
deriv_x *= (fmult / denom);
deriv_y *= (fmult / denom);
}
@@ -1296,8 +1301,9 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma
rrgbf[1] = deriv_y;
rrgbf[2] = 0.0f;
rrgbf[3] = 1.0f;
- } else {
- char *rrgb = (char*)ibuf->rect + index * 4;
+ }
+ else {
+ char *rrgb = (char *)ibuf->rect + index * 4;
rrgb[0] = FTOCHAR(deriv_x);
rrgb[1] = FTOCHAR(deriv_y);
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 18f658fb169..fb9f96b0ef7 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -135,206 +135,11 @@
#endif
/* ------------------------------------------------------------------------- */
-
-/* Stuff for stars. This sits here because it uses gl-things. Part of
- * this code may move down to the converter. */
-/* ------------------------------------------------------------------------- */
-/* this is a bad beast, since it is misused by the 3d view drawing as well. */
-
-static HaloRen *initstar(Render *re, ObjectRen *obr, const float vec[3], float hasize)
-{
- HaloRen *har;
- float hoco[4];
-
- projectverto(vec, re->winmat, hoco);
-
- har= RE_findOrAddHalo(obr, obr->tothalo++);
-
- /* projectvert is done in function zbufvlaggen again, because of parts */
- copy_v3_v3(har->co, vec);
- har->hasize= hasize;
-
- har->zd= 0.0;
- har->pool = re->pool;
-
- return har;
-}
-
-/* there must be a 'fixed' amount of stars generated between
- * near and far
- * all stars must by preference lie on the far and solely
- * differ in clarity/color
- */
-
-void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void),
- void (*vertexfunc)(const float *), void (*termfunc)(void))
-{
- extern unsigned char hash[512];
- ObjectRen *obr= NULL;
- World *wrld= NULL;
- HaloRen *har;
- Scene *scene;
- Object *camera;
- Camera *cam;
- RNG *rng;
- double dblrand, hlfrand;
- float vec[4], fx, fy, fz;
- float fac, starmindist, clipend;
- float mat[4][4], stargrid, maxrand, maxjit, force, alpha;
- int x, y, z, sx, sy, sz, ex, ey, ez, done = FALSE;
- unsigned int totstar= 0;
-
- if (initfunc) {
- scene= scenev3d;
- wrld= scene->world;
- }
- else {
- scene= re->scene;
- wrld= &(re->wrld);
- }
-
- stargrid = wrld->stardist; /* distance between stars */
- maxrand = 2.0; /* amount a star can be shifted (in grid units) */
- maxjit = (wrld->starcolnoise); /* amount a color is being shifted */
-
- /* size of stars */
- force = ( wrld->starsize );
-
- /* minimal free space (starting at camera) */
- starmindist= wrld->starmindist;
-
- if (stargrid <= 0.10f) return;
-
- if (re) re->flag |= R_HALO;
- else stargrid *= 1.0f; /* then it draws fewer */
-
- if (re) invert_m4_m4(mat, re->viewmat);
- else unit_m4(mat);
-
- /* BOUNDING BOX CALCULATION
- * bbox goes from z = loc_near_var | loc_far_var,
- * x = -z | +z,
- * y = -z | +z
- */
-
- camera= re ? RE_GetCamera(re) : scene->camera;
-
- if (camera==NULL || camera->type != OB_CAMERA)
- return;
-
- cam = camera->data;
- clipend = cam->clipend;
-
- /* convert to grid coordinates */
-
- sx = ((mat[3][0] - clipend) / stargrid) - maxrand;
- sy = ((mat[3][1] - clipend) / stargrid) - maxrand;
- sz = ((mat[3][2] - clipend) / stargrid) - maxrand;
-
- ex = ((mat[3][0] + clipend) / stargrid) + maxrand;
- ey = ((mat[3][1] + clipend) / stargrid) + maxrand;
- ez = ((mat[3][2] + clipend) / stargrid) + maxrand;
-
- dblrand = maxrand * stargrid;
- hlfrand = 2.0 * dblrand;
-
- if (initfunc) {
- initfunc();
- }
-
- if (re) /* add render object for stars */
- obr= RE_addRenderObject(re, NULL, NULL, 0, 0, 0);
-
- rng = BLI_rng_new(0);
-
- for (x = sx, fx = sx * stargrid; x <= ex; x++, fx += stargrid) {
- for (y = sy, fy = sy * stargrid; y <= ey; y++, fy += stargrid) {
- for (z = sz, fz = sz * stargrid; z <= ez; z++, fz += stargrid) {
-
- BLI_rng_seed(rng, (hash[z & 0xff] << 24) + (hash[y & 0xff] << 16) + (hash[x & 0xff] << 8));
- vec[0] = fx + (hlfrand * BLI_rng_get_double(rng)) - dblrand;
- vec[1] = fy + (hlfrand * BLI_rng_get_double(rng)) - dblrand;
- vec[2] = fz + (hlfrand * BLI_rng_get_double(rng)) - dblrand;
- vec[3] = 1.0;
-
- if (vertexfunc) {
- if (done & 1) vertexfunc(vec);
- done++;
- }
- else {
- if (re)
- mul_m4_v3(re->viewmat, vec);
-
- /* in vec are global coordinates
- * calculate distance to camera
- * and using that, define the alpha
- */
- alpha = len_v3(vec);
-
- if (alpha >= clipend) alpha = 0.0;
- else if (alpha <= starmindist) alpha = 0.0;
- else if (alpha <= 2.0f * starmindist) {
- alpha = (alpha - starmindist) / starmindist;
- }
- else {
- alpha -= 2.0f * starmindist;
- alpha /= (clipend - 2.0f * starmindist);
- alpha = 1.0f - alpha;
- }
-
-
- if (alpha != 0.0f) {
- fac = force * BLI_rng_get_double(rng);
-
- har = initstar(re, obr, vec, fac);
-
- if (har) {
- har->alfa = sqrt(sqrt(alpha));
- har->add= 255;
- har->r = har->g = har->b = 1.0;
- if (maxjit) {
- har->r += ((maxjit * BLI_rng_get_double(rng)) ) - maxjit;
- har->g += ((maxjit * BLI_rng_get_double(rng)) ) - maxjit;
- har->b += ((maxjit * BLI_rng_get_double(rng)) ) - maxjit;
- }
- har->hard = 32;
- har->lay= -1;
- har->type |= HA_ONLYSKY;
- done++;
- }
- }
- }
-
- /* break out of the loop if generating stars takes too long */
- if (re && !(totstar % 1000000)) {
- if (re->test_break(re->tbh)) {
- x= ex + 1;
- y= ey + 1;
- z= ez + 1;
- }
- }
-
- totstar++;
- }
- /* do not call blender_test_break() here, since it is used in UI as well, confusing the callback system */
- /* main cause is G.is_break of course, a global again... (ton) */
- }
- }
- if (termfunc) termfunc();
-
- if (obr)
- re->tothalo += obr->tothalo;
-
- BLI_rng_free(rng);
-}
-
-
-/* ------------------------------------------------------------------------- */
/* tool functions/defines for ad hoc simplification and possible future
* cleanup */
/* ------------------------------------------------------------------------- */
-#define UVTOINDEX(u,v) (startvlak + (u) * sizev + (v))
+#define UVTOINDEX(u, v) (startvlak + (u) * sizev + (v))
/*
*
* NOTE THAT U/V COORDINATES ARE SOMETIMES SWAPPED !!
@@ -860,28 +665,13 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[4][4], int
/* Orco hash and Materials */
/* ------------------------------------------------------------------------- */
-static float *get_object_orco(Render *re, Object *ob)
+static float *get_object_orco(Render *re, void *ob)
{
- float *orco;
-
- if (!re->orco_hash)
- re->orco_hash = BLI_ghash_ptr_new("get_object_orco gh");
-
- orco = BLI_ghash_lookup(re->orco_hash, ob);
-
- if (!orco) {
- if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
- orco = BKE_curve_make_orco(re->scene, ob, NULL);
- }
- else if (ob->type==OB_SURF) {
- orco = BKE_curve_surf_make_orco(ob);
- }
-
- if (orco)
- BLI_ghash_insert(re->orco_hash, ob, orco);
+ if (!re->orco_hash) {
+ return NULL;
}
- return orco;
+ return BLI_ghash_lookup(re->orco_hash, ob);
}
static void set_object_orco(Render *re, void *ob, float *orco)
@@ -1676,8 +1466,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if (path_nbr) {
if (!ELEM(ma->material_type, MA_TYPE_HALO, MA_TYPE_WIRE)) {
- sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos");
- set_object_orco(re, psys, sd.orco);
+ sd.orco = get_object_orco(re, psys);
+ if (!sd.orco) {
+ sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos");
+ set_object_orco(re, psys, sd.orco);
+ }
}
}
@@ -1848,9 +1641,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if (strandbuf) {
int orignum = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, cpa->num) : cpa->num;
- if (orignum > sbound - strandbuf->bound) {
- sbound= strandbuf->bound + orignum;
- sbound->start= sbound->end= obr->totstrand;
+ if ((orignum > sbound - strandbuf->bound) &&
+ (orignum < strandbuf->totbound))
+ {
+ sbound = &strandbuf->bound[orignum];
+ sbound->start = sbound->end = obr->totstrand;
}
}
}
@@ -2829,9 +2624,12 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset)
if (dm) {
if (need_orco) {
- orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1);
- if (orco) {
- set_object_orco(re, ob, orco);
+ orco = get_object_orco(re, ob);
+ if (!orco) {
+ orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1);
+ if (orco) {
+ set_object_orco(re, ob, orco);
+ }
}
}
@@ -2840,7 +2638,11 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset)
}
else {
if (need_orco) {
- orco= get_object_orco(re, ob);
+ orco = get_object_orco(re, ob);
+ if (!orco) {
+ orco = BKE_curve_surf_make_orco(ob);
+ set_object_orco(re, ob, orco);
+ }
}
/* walk along displaylist and create rendervertices/-faces */
@@ -2900,9 +2702,12 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
if (dm) {
if (need_orco) {
- orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1);
- if (orco) {
- set_object_orco(re, ob, orco);
+ orco = get_object_orco(re, ob);
+ if (!orco) {
+ orco = BKE_displist_make_orco(re->scene, ob, dm, 1, 1);
+ if (orco) {
+ set_object_orco(re, ob, orco);
+ }
}
}
@@ -2912,6 +2717,10 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
else {
if (need_orco) {
orco = get_object_orco(re, ob);
+ if (!orco) {
+ orco = BKE_curve_make_orco(re->scene, ob, NULL);
+ set_object_orco(re, ob, orco);
+ }
}
while (dl) {
@@ -3401,10 +3210,13 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
if (dm==NULL) return; /* in case duplicated object fails? */
if (mask & CD_MASK_ORCO) {
- orco= dm->getVertDataArray(dm, CD_ORCO);
- if (orco) {
- orco= MEM_dupallocN(orco);
- set_object_orco(re, ob, orco);
+ orco = get_object_orco(re, ob);
+ if (!orco) {
+ orco= dm->getVertDataArray(dm, CD_ORCO);
+ if (orco) {
+ orco= MEM_dupallocN(orco);
+ set_object_orco(re, ob, orco);
+ }
}
}
@@ -5361,15 +5173,7 @@ void RE_Database_Preprocess(Render *re)
if (!re->test_break(re->tbh)) {
int tothalo;
- /* don't sort stars */
tothalo= re->tothalo;
- if (!re->test_break(re->tbh)) {
- if (re->wrld.mode & WO_STARS) {
- re->i.infostr = IFACE_("Creating Starfield");
- re->stats_draw(re->sdh, &re->i);
- RE_make_stars(re, NULL, NULL, NULL, NULL);
- }
- }
sort_halos(re, tothalo);
init_camera_inside_volumes(re);
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 6cac2fa3fa6..28932d0e93b 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -555,7 +555,7 @@ void RE_parts_init(Render *re, int do_crop)
/* this is render info for caller, is not reset when parts are freed! */
re->i.totpart = 0;
re->i.curpart = 0;
- re->i.partsdone = FALSE;
+ re->i.partsdone = 0;
/* just for readable code.. */
xminb = re->disprect.xmin;
@@ -608,7 +608,7 @@ void RE_parts_init(Render *re, int do_crop)
RenderPart *pa = MEM_callocN(sizeof(RenderPart), "new part");
/* Non-box filters need 2 pixels extra to work */
- if (do_crop && (re->r.filtertype || (re->r.mode & R_EDGE))) {
+ if (do_crop && re->r.filtertype) {
pa->crop = 2;
disprect.xmin -= pa->crop;
disprect.ymin -= pa->crop;
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index 3259608c18f..3ae075b4936 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -95,6 +95,7 @@ typedef struct {
char *texels;
const MResolvePixelData *data;
MFlushPixel flush_pixel;
+ short *do_update;
} MBakeRast;
typedef struct {
@@ -162,7 +163,8 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],
}
}
-static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data, MFlushPixel flush_pixel)
+static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data,
+ MFlushPixel flush_pixel, short *do_update)
{
BakeImBufuserData *userdata = (BakeImBufuserData *) ibuf->userdata;
@@ -173,6 +175,7 @@ static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResol
bake_rast->h = ibuf->y;
bake_rast->data = data;
bake_rast->flush_pixel = flush_pixel;
+ bake_rast->do_update = do_update;
}
static void flush_pixel(const MResolvePixelData *data, const int x, const int y)
@@ -240,6 +243,9 @@ static void set_rast_triangle(const MBakeRast *bake_rast, const int x, const int
if ((bake_rast->texels[y * w + x]) == 0) {
bake_rast->texels[y * w + x] = FILTER_MASK_USED;
flush_pixel(bake_rast->data, x, y);
+ if (bake_rast->do_update) {
+ *bake_rast->do_update = true;
+ }
}
}
}
@@ -529,7 +535,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, int require_ta
handle->height_min = FLT_MAX;
handle->height_max = -FLT_MAX;
- init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel);
+ init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel, bkr->do_update);
if (tot_thread > 1)
BLI_insert_thread(&threads, handle);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index fa05f8dd18d..d11f4615698 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1600,6 +1600,7 @@ static void tag_scenes_for_render(Render *re)
/* check for render-layers nodes using other scenes, we tag them LIB_DOIT */
for (node = re->scene->nodetree->nodes.first; node; node = node->next) {
+ node->flag &= ~NODE_TEST;
if (node->type == CMP_NODE_R_LAYERS) {
if (node->id) {
if (!MAIN_VERSION_ATLEAST(re->main, 265, 5)) {
@@ -1617,8 +1618,12 @@ static void tag_scenes_for_render(Render *re)
}
}
- if (node->id != (ID *)re->scene)
- node->id->flag |= LIB_DOIT;
+ if (node->id != (ID *)re->scene) {
+ if ((node->id->flag & LIB_DOIT) == 0) {
+ node->flag |= NODE_TEST;
+ node->id->flag |= LIB_DOIT;
+ }
+ }
}
}
}
@@ -1640,12 +1645,12 @@ static void ntree_render_scenes(Render *re)
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) {
+ if (node->flag & NODE_TEST) {
Scene *scene = (Scene *)node->id;
render_scene(re, scene, cfra);
restore_scene = (scene != re->scene);
- node->id->flag &= ~LIB_DOIT;
+ node->flag &= ~NODE_TEST;
nodeUpdate(re->scene->nodetree, node);
}
@@ -1679,7 +1684,7 @@ static void add_freestyle(Render *re, int render)
* real bmain uses. This is needed because freestyle's
* bmain could be used to tag scenes for update, which
* implies call of ED_render_scene_update in some cases
- * and that function requires proper windoew manager
+ * and that function requires proper window manager
* to present (sergey)
*/
re->freestyle_bmain.wm = re->main->wm;
@@ -2288,13 +2293,6 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
BKE_report(reports, RPT_ERROR, "Cannot save render buffers, check the temp default path");
return 0;
}
-
- /* no fullsample and edge */
- if ((scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) {
- BKE_report(reports, RPT_ERROR, "Full sample does not support edge enhance");
- return 0;
- }
-
}
if (scemode & R_DOCOMP) {
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
index 43e052a6efc..feaf68a8c4a 100644
--- a/source/blender/render/intern/source/pixelshading.c
+++ b/source/blender/render/intern/source/pixelshading.c
@@ -289,7 +289,6 @@ int shadeHaloFloat(HaloRen *har, float col[4], int zz,
if (R.wrld.mode & WO_MIST) {
if (har->type & HA_ONLYSKY) {
- /* stars but no mist */
alpha= har->alfa;
}
else {
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 37587d89ce0..487de42515d 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -1124,7 +1124,13 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd)
*/
if (ibuf->rect) {
if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) {
- IMB_float_from_rect(ibuf);
+ if (rd->im_format.depth == R_IMF_CHAN_DEPTH_8) {
+ /* Higher depth bits are supported but not needed for current file output. */
+ ibuf->rect_float = NULL;
+ }
+ else {
+ IMB_float_from_rect(ibuf);
+ }
}
else {
/* ensure no float buffer remained from previous frame */
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 49052150fe3..049d7e5a732 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -1724,7 +1724,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
const float bf = -0.04f*Tnor*mtex->norfac;
int rgbnor;
/* disable internal bump eval */
- float* nvec = texres->nor;
+ float *nvec = texres->nor;
texres->nor = NULL;
/* du & dv estimates, constant value defaults */
du = dv = 0.01f;
@@ -3558,12 +3558,15 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene)
/* strip material copy from unsupported flags */
for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
- if (mat->septex & (1<<tex_nr)) continue;
if (mat->mtex[tex_nr]) {
MTex *mtex = mat->mtex[tex_nr];
- if (!mtex->tex) continue;
+ /* just in case make all non-used mtexes empty*/
+ Tex *cur_tex = mtex->tex;
+ mtex->tex = NULL;
+
+ if (mat->septex & (1<<tex_nr) || !cur_tex) continue;
/* only keep compatible texflags */
mtex->texflag = mtex->texflag & (MTEX_RGBTOINT | MTEX_STENCIL | MTEX_NEGATIVE | MTEX_ALPHAMIX);
@@ -3598,7 +3601,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene)
}
/* copy texture */
- tex= mtex->tex = localize_texture(mtex->tex);
+ tex= mtex->tex = localize_texture(cur_tex);
/* update texture anims */
BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM);
@@ -3646,7 +3649,8 @@ void RE_free_sample_material(Material *mat)
}
}
- BKE_material_free(mat);
+ /* don't update user counts as we are freeing a duplicate */
+ BKE_material_free_ex(mat, false);
MEM_freeN(mat);
}
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 89d8345a0d7..8791af55792 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -967,25 +967,6 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma
ps->shadfac= 0;
}
-static void edge_enhance_add(RenderPart *pa, float *rectf, float *arect)
-{
- float addcol[4];
- int pix;
-
- if (arect==NULL)
- return;
-
- for (pix= pa->rectx*pa->recty; pix>0; pix--, arect++, rectf+=4) {
- if (*arect != 0.0f) {
- addcol[0]= *arect * R.r.edgeR;
- addcol[1]= *arect * R.r.edgeG;
- addcol[2]= *arect * R.r.edgeB;
- addcol[3]= *arect;
- addAlphaOverFloat(rectf, addcol);
- }
- }
-}
-
/* clamp alpha and RGB to 0..1 and 0..inf, can go outside due to filter */
static void clamp_alpha_rgb_range(RenderPart *pa, RenderLayer *rl)
{
@@ -1010,67 +991,6 @@ static void clamp_alpha_rgb_range(RenderPart *pa, RenderLayer *rl)
}
}
-/* adds only alpha values */
-static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz)
-{
- /* use zbuffer to define edges, add it to the image */
- int y, x, col, *rz, *rz1, *rz2, *rz3;
- int zval1, zval2, zval3;
- float *rf;
-
- /* shift values in zbuffer 4 to the right (anti overflows), for filter we need multiplying with 12 max */
- rz= rectz;
- if (rz==NULL) return;
-
- for (y=0; y<pa->recty; y++)
- for (x=0; x<pa->rectx; x++, rz++) (*rz)>>= 4;
-
- rz1= rectz;
- rz2= rz1+pa->rectx;
- rz3= rz2+pa->rectx;
-
- rf= rectf+pa->rectx+1;
-
- for (y=0; y<pa->recty-2; y++) {
- for (x=0; x<pa->rectx-2; x++, rz1++, rz2++, rz3++, rf++) {
-
- /* prevent overflow with sky z values */
- zval1= rz1[0] + 2*rz1[1] + rz1[2];
- zval2= 2*rz2[0] + 2*rz2[2];
- zval3= rz3[0] + 2*rz3[1] + rz3[2];
-
- col= ( 4*rz2[1] - (zval1 + zval2 + zval3)/3 );
- if (col<0) col= -col;
-
- col >>= 5;
- if (col > (1<<16)) col= (1<<16);
- else col= (R.r.edgeint*col)>>8;
-
- if (col>0) {
- float fcol;
-
- if (col>255) fcol= 1.0f;
- else fcol= (float)col/255.0f;
-
- if (R.osa)
- *rf+= fcol/(float)R.osa;
- else
- *rf= fcol;
- }
- }
- rz1+= 2;
- rz2+= 2;
- rz3+= 2;
- rf+= 2;
- }
-
- /* shift back zbuf values, we might need it still */
- rz= rectz;
- for (y=0; y<pa->recty; y++)
- for (x=0; x<pa->rectx; x++, rz++) (*rz)<<= 4;
-
-}
-
static void reset_sky_speed(RenderPart *pa, RenderLayer *rl)
{
/* for all pixels with max speed, set to zero */
@@ -1149,7 +1069,6 @@ static void addAlphaOverFloatMask(float *dest, float *source, unsigned short dma
typedef struct ZbufSolidData {
RenderLayer *rl;
ListBase *psmlist;
- float *edgerect;
} ZbufSolidData;
static void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *data)
@@ -1171,10 +1090,6 @@ static void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *da
}
}
}
-
- if (sdata->rl->layflag & SCE_LAY_EDGE)
- if (R.r.mode & R_EDGE)
- edge_enhance_tile(pa, sdata->edgerect, zspan->rectz);
}
/* main call for shading Delta Accum, for OSA */
@@ -1184,7 +1099,6 @@ void zbufshadeDA_tile(RenderPart *pa)
RenderResult *rr= pa->result;
RenderLayer *rl;
ListBase psmlist= {NULL, NULL};
- float *edgerect= NULL;
/* allocate the necessary buffers */
/* zbuffer inits these rects */
@@ -1195,21 +1109,16 @@ void zbufshadeDA_tile(RenderPart *pa)
if ((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK))
pa->rectmask= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectmask");
- /* initialize pixelstructs and edge buffer */
+ /* initialize pixelstructs */
addpsmain(&psmlist);
pa->rectdaps= MEM_callocN(sizeof(intptr_t)*pa->rectx*pa->recty+4, "zbufDArectd");
- if (rl->layflag & SCE_LAY_EDGE)
- if (R.r.mode & R_EDGE)
- edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge");
-
/* always fill visibility */
for (pa->sample=0; pa->sample<R.osa; pa->sample+=4) {
ZbufSolidData sdata;
sdata.rl= rl;
sdata.psmlist= &psmlist;
- sdata.edgerect= edgerect;
zbuffer_solid(pa, rl, make_pixelstructs, &sdata);
if (R.test_break(R.tbh)) break;
}
@@ -1276,18 +1185,12 @@ void zbufshadeDA_tile(RenderPart *pa)
}
/* sun/sky */
- if (rl->layflag & SCE_LAY_SKY)
+ if (rl->layflag & SCE_LAY_SKY) {
atm_tile(pa, rl);
-
- /* sky before edge */
- if (rl->layflag & SCE_LAY_SKY)
sky_tile(pa, rl);
+ }
- /* extra layers */
- if (rl->layflag & SCE_LAY_EDGE)
- if (R.r.mode & R_EDGE)
- edge_enhance_add(pa, rl->rectf, edgerect);
-
+ /* extra layers */
if (rl->passflag & SCE_PASS_VECTOR)
reset_sky_speed(pa, rl);
@@ -1297,9 +1200,6 @@ void zbufshadeDA_tile(RenderPart *pa)
/* free stuff within loop! */
MEM_freeN(pa->rectdaps); pa->rectdaps= NULL;
freeps(&psmlist);
-
- if (edgerect) MEM_freeN(edgerect);
- edgerect= NULL;
if (pa->rectmask) {
MEM_freeN(pa->rectmask);
@@ -1328,7 +1228,6 @@ void zbufshade_tile(RenderPart *pa)
RenderResult *rr= pa->result;
RenderLayer *rl;
PixStr ps;
- float *edgerect= NULL;
/* fake pixel struct, to comply to osa render */
ps.next= NULL;
@@ -1350,14 +1249,6 @@ void zbufshade_tile(RenderPart *pa)
if (!R.test_break(R.tbh)) { /* NOTE: this if () is not consistent */
- /* edges only for solid part, ztransp doesn't support it yet anti-aliased */
- if (rl->layflag & SCE_LAY_EDGE) {
- if (R.r.mode & R_EDGE) {
- edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge");
- edge_enhance_tile(pa, edgerect, pa->rectz);
- }
- }
-
/* initialize scanline updates for main thread */
rr->renrect.ymin = 0;
rr->renlay= rl;
@@ -1438,24 +1329,13 @@ void zbufshade_tile(RenderPart *pa)
}
/* sun/sky */
- if (rl->layflag & SCE_LAY_SKY)
+ if (rl->layflag & SCE_LAY_SKY) {
atm_tile(pa, rl);
-
- /* sky before edge */
- if (rl->layflag & SCE_LAY_SKY)
sky_tile(pa, rl);
-
- if (!R.test_break(R.tbh)) {
- if (rl->layflag & SCE_LAY_EDGE)
- if (R.r.mode & R_EDGE)
- edge_enhance_add(pa, rl->rectf, edgerect);
}
if (rl->passflag & SCE_PASS_VECTOR)
reset_sky_speed(pa, rl);
-
- if (edgerect) MEM_freeN(edgerect);
- edgerect= NULL;
if (pa->rectmask) {
MEM_freeN(pa->rectmask);
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index 114961394c4..dbc9c47446f 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -1789,18 +1789,20 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
}
/* AO pass */
- if (R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) {
- if (((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) ||
- (passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT)))
- {
- if (R.r.mode & R_SHADOW) {
- /* AO was calculated for scanline already */
- if (shi->depth || shi->volume_depth)
- ambient_occlusion(shi);
- copy_v3_v3(shr->ao, shi->ao);
- copy_v3_v3(shr->env, shi->env); /* XXX multiply */
- copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */
- }
+ if (((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) ||
+ (passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) {
+ if ((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && (R.r.mode & R_SHADOW)) {
+ /* AO was calculated for scanline already */
+ if (shi->depth || shi->volume_depth)
+ ambient_occlusion(shi);
+ copy_v3_v3(shr->ao, shi->ao);
+ copy_v3_v3(shr->env, shi->env); /* XXX multiply */
+ copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */
+ }
+ else {
+ shr->ao[0]= shr->ao[1]= shr->ao[2]= 1.0f;
+ zero_v3(shr->env);
+ zero_v3(shr->indirect);
}
}
diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c
index 732892ed357..3ec487f63dc 100644
--- a/source/blender/render/intern/source/sss.c
+++ b/source/blender/render/intern/source/sss.c
@@ -878,7 +878,7 @@ static void sss_create_tree_mat(Render *re, Material *mat)
re->r.mode &= ~R_OSA;
re->sss_points= &points;
re->sss_mat= mat;
- re->i.partsdone = FALSE;
+ re->i.partsdone = 0;
if (!(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)))
re->result= NULL;
diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c
index 6912f998e7a..e5e3aff573d 100644
--- a/source/blender/render/intern/source/volume_precache.c
+++ b/source/blender/render/intern/source/volume_precache.c
@@ -495,7 +495,7 @@ typedef struct VolPrecacheState {
int totparts;
} VolPrecacheState;
-static void vol_precache_part(TaskPool *pool, void *taskdata, int threadid)
+static void vol_precache_part(TaskPool *pool, void *taskdata, int UNUSED(threadid))
{
VolPrecacheState *state = (VolPrecacheState *)BLI_task_pool_userdata(pool);
VolPrecachePart *pa = (VolPrecachePart *)taskdata;
@@ -513,7 +513,7 @@ static void vol_precache_part(TaskPool *pool, void *taskdata, int threadid)
if (re->test_break && re->test_break(re->tbh))
return;
- printf("thread id %d\n", threadid);
+ //printf("thread id %d\n", threadid);
res[0]= pa->res[0];
res[1]= pa->res[1];
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index b9a5b5ffaae..5f993297840 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -124,14 +124,6 @@ if(WITH_GAMEENGINE)
add_definitions(-DWITH_GAMEENGINE)
endif()
-if(APPLE)
- if(NOT WITH_COCOA)
- list(APPEND SRC
- intern/wm_apple.c
- )
- endif()
-endif()
-
if(WITH_BUILDINFO)
add_definitions(-DWITH_BUILDINFO)
endif()
diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript
index 0a2f48f0488..00d363e1539 100644
--- a/source/blender/windowmanager/SConscript
+++ b/source/blender/windowmanager/SConscript
@@ -66,9 +66,6 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', '
incs += ' ' + env['BF_PTHREADS_INC']
incs += ' ../../intern/utfconv'
-if env['OURPLATFORM'] != 'darwin' or env['WITH_GHOST_COCOA']:
- sources.remove('intern' + os.sep + 'wm_apple.c')
-
if env['BF_BUILDINFO']:
defs.append('WITH_BUILDINFO')
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c338d49fe17..1f38368399a 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -272,7 +272,9 @@ bool WM_operator_last_properties_store(struct wmOperator *op);
/* operator as a python command (resultuing string must be freed) */
-char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args);
+char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args,
+ struct wmOperatorType *ot, struct PointerRNA *opptr);
+char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args);
char *WM_prop_pystring_assign(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
void WM_operator_bl_idname(char *to, const char *from);
void WM_operator_py_idname(char *to, const char *from);
@@ -294,20 +296,20 @@ void WM_menutype_free(void);
/* default operator callbacks for border/circle/lasso */
int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_border_select_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
-int WM_border_select_cancel(struct bContext *C, struct wmOperator *op);
+void WM_border_select_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
-int WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op);
+void WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
-int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op);
+void WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
-int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op);
+void WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op);
const int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2];
int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
-int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op);
+void WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op);
/* Gesture manager API */
struct wmGesture *WM_gesture_new(struct bContext *C, const struct wmEvent *event, int type);
@@ -378,6 +380,7 @@ int WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
float WM_jobs_progress(struct wmWindowManager *wm, void *owner);
char *WM_jobs_name(struct wmWindowManager *wm, void *owner);
void *WM_jobs_customdata(struct wmWindowManager *wm, void *owner);
+void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type);
int WM_jobs_is_running(struct wmJob *);
void *WM_jobs_customdata_get(struct wmJob *);
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index eab27286709..ce6481c8929 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -91,6 +91,7 @@ void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C);
void WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
+int WM_keymap_map_type_get(struct wmKeyMapItem *kmi);
/* Key Event */
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index ac9af832671..dabb90b2ba0 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -311,7 +311,6 @@ typedef struct wmNotifier {
/* NC_WORLD World */
#define ND_WORLD_DRAW (45<<16)
-#define ND_WORLD_STARS (46<<16)
/* NC_TEXT Text */
#define ND_CURSOR (50<<16)
@@ -535,7 +534,7 @@ typedef struct wmOperatorType {
* canceled due to some external reason, cancel is called
* - see defines below for return values */
int (*invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT;
- int (*cancel)(struct bContext *, struct wmOperator *);
+ void (*cancel)(struct bContext *, struct wmOperator *);
int (*modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT;
/* verify if the operator can be executed in the current context, note
diff --git a/source/blender/windowmanager/intern/wm_apple.c b/source/blender/windowmanager/intern/wm_apple.c
deleted file mode 100644
index 842fc353699..00000000000
--- a/source/blender/windowmanager/intern/wm_apple.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * ***** 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) 2007 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/intern/wm_apple.c
- * \ingroup wm
- */
-
-/* note, this file builds on apple-carbon only! */
-
-#include "BKE_context.h"
-#include "BKE_global.h"
-#include "WM_api.h"
-
-#include <OpenGL/OpenGL.h>
-#define __CARBONSOUND__
-/* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */
-#define ID ID_
-#include <Carbon/Carbon.h>
-
-/* To avoid killing small end comps, we want to allow
- * blender to start maximized if all the followings are true :
- * - Renderer is OpenGL capable
- * - Hardware acceleration
- * - VRAM > 16 Mo
- *
- * We will bail out if VRAM is less than 8Mo
- */
-
-/* bad global, used in wm_window.c to open windows */
-int macPrefState = 0;
-
-static int checkAppleVideoCard(void)
-{
- CGLRendererInfoObj rend;
- long theErr;
- unsigned long display_mask;
- long nrend;
- int j;
- long value;
- long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */
-
- display_mask = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID() );
-
- theErr = CGLQueryRendererInfo(display_mask, &rend, &nrend);
- if (theErr == 0) {
- theErr = CGLDescribeRenderer(rend, 0, kCGLRPRendererCount, &nrend);
- if (theErr == 0) {
- for (j = 0; j < nrend; j++) {
- theErr = CGLDescribeRenderer(rend, j, kCGLRPVideoMemory, &value);
- if (value > maxvram)
- maxvram = value;
- if ((theErr == 0) && (value >= 20000000)) {
- theErr = CGLDescribeRenderer(rend, j, kCGLRPAccelerated, &value);
- if ((theErr == 0) && (value != 0)) {
- theErr = CGLDescribeRenderer(rend, j, kCGLRPCompliant, &value);
- if ((theErr == 0) && (value != 0)) {
- /*fprintf(stderr, "make it big\n");*/
- CGLDestroyRendererInfo(rend);
- macPrefState = 8;
- return 1;
- }
- }
- }
- }
- }
- }
- if (maxvram < 7500000) { /* put a standard alert and quit*/
- SInt16 junkHit;
- char inError[] = "* Not enough VRAM ";
- char inText[] = "* blender needs at least 8Mb ";
- inError[0] = 16;
- inText[0] = 28;
-
- fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram);
- StandardAlert(kAlertStopAlert, (ConstStr255Param) & inError, (ConstStr255Param) & inText, NULL, &junkHit);
- abort();
- }
- CGLDestroyRendererInfo(rend);
- return 0;
-}
-
-static void getMacAvailableBounds(short *top, short *left, short *bottom, short *right)
-{
- Rect outAvailableRect;
-
- GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect);
-
- *top = outAvailableRect.top;
- *left = outAvailableRect.left;
- *bottom = outAvailableRect.bottom;
- *right = outAvailableRect.right;
-}
-
-
-void wm_set_apple_prefsize(int scr_x, int scr_y)
-{
-
- /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */
-
- if (checkAppleVideoCard()) {
- short top, left, bottom, right;
-
- getMacAvailableBounds(&top, &left, &bottom, &right);
- WM_init_state_size_set(left + 10, scr_y - bottom + 10, right - left - 20, bottom - 64);
- G.windowstate = 0;
-
- }
- else {
-
- /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
- WM_init_state_size_set(120, 40, 850, 684);
- G.windowstate = 0;
- }
-}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 825c1ca9252..d60901f1325 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -491,7 +491,7 @@ int WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context)
static void wm_operator_print(bContext *C, wmOperator *op)
{
/* context is needed for enum function */
- char *buf = WM_operator_pystring(C, op->type, op->ptr, false);
+ char *buf = WM_operator_pystring(C, op, false);
printf("%s\n", buf);
MEM_freeN(buf);
}
@@ -626,7 +626,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal
if (op->type->flag & OPTYPE_REGISTER) {
if (G.background == 0) { /* ends up printing these in the terminal, gets annoying */
/* Report the python string representation of the operator */
- char *buf = WM_operator_pystring(C, op->type, op->ptr, false);
+ char *buf = WM_operator_pystring(C, op, false);
BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
MEM_freeN(buf);
}
@@ -660,7 +660,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
if (repeat == 0) {
if (G.debug & G_DEBUG_WM) {
- char *buf = WM_operator_pystring(C, op->type, op->ptr, false);
+ char *buf = WM_operator_pystring(C, op, false);
BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
MEM_freeN(buf);
}
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 05ee23e2361..4d4d46d063a 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -293,13 +293,15 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
}
-static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt)
+static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled)
{
short *lasso = (short *)gt->customdata;
int i;
- draw_filled_lasso(win, gt);
-
+ if (filled) {
+ draw_filled_lasso(win, gt);
+ }
+
glEnable(GL_LINE_STIPPLE);
glColor3ub(96, 96, 96);
glLineStipple(1, 0xAAAA);
@@ -365,9 +367,9 @@ void wm_gesture_draw(wmWindow *win)
wm_gesture_draw_cross(win, gt);
}
else if (gt->type == WM_GESTURE_LINES)
- wm_gesture_draw_lasso(win, gt);
+ wm_gesture_draw_lasso(win, gt, false);
else if (gt->type == WM_GESTURE_LASSO)
- wm_gesture_draw_lasso(win, gt);
+ wm_gesture_draw_lasso(win, gt, true);
else if (gt->type == WM_GESTURE_STRAIGHTLINE)
wm_gesture_draw_line(gt);
}
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index c9c3d2df788..b3856a2aa9c 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -166,22 +166,27 @@ static void wm_job_main_thread_yield(wmJob *wm_job, bool ending)
}
/* finds:
- * if type, compare for it, otherwise any matching job
+ * if type or owner, compare for it, otherwise any matching job
*/
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
wmJob *wm_job;
- for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
- if (wm_job->owner == owner) {
-
- if (job_type) {
- if ( wm_job->job_type == job_type)
- return wm_job;
- }
- else
+ if (owner && job_type) {
+ for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
+ if (wm_job->owner == owner && wm_job->job_type == job_type)
return wm_job;
- }
+ }
+ else if (owner) {
+ for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
+ if (wm_job->owner == owner)
+ return wm_job;
+ }
+ else if (job_type) {
+ for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
+ if (wm_job->job_type == job_type)
+ return wm_job;
+ }
return NULL;
}
@@ -263,7 +268,16 @@ void *WM_jobs_customdata(wmWindowManager *wm, void *owner)
return WM_jobs_customdata_get(wm_job);
return NULL;
+}
+void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type)
+{
+ wmJob *wm_job = wm_job_find(wm, NULL, job_type);
+
+ if (wm_job)
+ return WM_jobs_customdata_get(wm_job);
+
+ return NULL;
}
int WM_jobs_is_running(wmJob *wm_job)
@@ -509,9 +523,9 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho
wm_job = wm->jobs.first;
while (wm_job) {
if (wm_job->owner == owner || wm_job->startjob == startjob) {
- wmJob *bill = wm_job;
+ wmJob *wm_job_kill = wm_job;
wm_job = wm_job->next;
- wm_jobs_kill_job(wm, bill);
+ wm_jobs_kill_job(wm, wm_job_kill);
}
else {
wm_job = wm_job->next;
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index f6ba3a29344..8e202eb93f0 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -139,6 +139,30 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties
wm_keymap_item_properties_set(kmi);
}
+int WM_keymap_map_type_get(wmKeyMapItem *kmi)
+{
+ if (ISTIMER(kmi->type)) {
+ return KMI_TYPE_TIMER;
+ }
+ if (ISKEYBOARD(kmi->type)) {
+ return KMI_TYPE_KEYBOARD;
+ }
+ if (ISTWEAK(kmi->type)) {
+ return KMI_TYPE_TWEAK;
+ }
+ if (ISMOUSE(kmi->type)) {
+ return KMI_TYPE_MOUSE;
+ }
+ if (ISNDOF(kmi->type)) {
+ return KMI_TYPE_NDOF;
+ }
+ if (kmi->type == KM_TEXTINPUT) {
+ return KMI_TYPE_TEXTINPUT;
+ }
+ return KMI_TYPE_KEYBOARD;
+}
+
+
/**************************** Keymap Diff Item *********************************
* Item in a diff keymap, used for saving diff of keymaps in user preferences */
@@ -686,11 +710,13 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPrope
if (!items) {
/* init modal items from default config */
wmWindowManager *wm = G.main->wm.first;
- wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
+ if (wm->defaultconf) {
+ wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
- if (defaultkm) {
- km->modal_items = defaultkm->modal_items;
- km->poll = defaultkm->poll;
+ if (defaultkm) {
+ km->modal_items = defaultkm->modal_items;
+ km->poll = defaultkm->poll;
+ }
}
}
@@ -779,6 +805,10 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
int propvalue;
if (km && (km->flag & KEYMAP_MODAL) && !km->modal_items) {
+ if (wm->defaultconf == NULL) {
+ return;
+ }
+
defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
if (!defaultkm)
@@ -1091,7 +1121,7 @@ static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km)
wmKeyMap *keymap;
keymap = WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid);
- if (!keymap)
+ if (!keymap && wm->defaultconf)
keymap = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid);
return keymap;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 6091ec4a371..50575095825 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -341,14 +341,14 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
return wm_macro_end(op, retval);
}
-static int wm_macro_cancel(bContext *C, wmOperator *op)
+static void wm_macro_cancel(bContext *C, wmOperator *op)
{
/* call cancel on the current modal operator, if any */
if (op->opm && op->opm->type->cancel) {
op->opm->type->cancel(C, op->opm);
}
- return wm_macro_end(op, OPERATOR_CANCELLED);
+ wm_macro_end(op, OPERATOR_CANCELLED);
}
/* Names have to be static for now */
@@ -521,13 +521,14 @@ void WM_operator_bl_idname(char *to, const char *from)
to[0] = 0;
}
-/* print a string representation of the operator, with the args that it runs
- * so python can run it again,
+/* Print a string representation of the operator, with the args that it runs so python can run it again.
*
- * When calling from an existing wmOperator do.
- * WM_operator_pystring(op->type, op->ptr);
+ * When calling from an existing wmOperator, better to use simple version:
+ * WM_operator_pystring(C, op);
+ *
+ * Note: both op and opptr may be NULL (op is only used for macro operators).
*/
-char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, int all_args)
+char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, wmOperatorType *ot, PointerRNA *opptr)
{
char idname_py[OP_MAX_TYPENAME];
@@ -539,24 +540,53 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i
/* arbitrary, but can get huge string with stroke painting otherwise */
int max_prop_length = 10;
- /* only to get the orginal props for comparisons */
- PointerRNA opptr_default;
+ WM_operator_py_idname(idname_py, ot->idname);
+ BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py);
+
+ if (op && op->macro.first) {
+ /* Special handling for macros, else we only get default values in this case... */
+ wmOperator *opm;
+ bool first_op = true;
+ for (opm = op->macro.first; opm; opm = opm->next) {
+ PointerRNA *opmptr = opm->ptr;
+ PointerRNA opmptr_default;
+ if (opmptr == NULL) {
+ WM_operator_properties_create_ptr(&opmptr_default, opm->type);
+ opmptr = &opmptr_default;
+ }
- if (opptr == NULL) {
- WM_operator_properties_create_ptr(&opptr_default, ot);
- opptr = &opptr_default;
+ cstring_args = RNA_pointer_as_string_id(C, opmptr);
+ if (first_op) {
+ BLI_dynstr_appendf(dynstr, "%s=%s", opm->type->idname, cstring_args);
+ first_op = false;
+ }
+ else {
+ BLI_dynstr_appendf(dynstr, ", %s=%s", opm->type->idname, cstring_args);
+ }
+ MEM_freeN(cstring_args);
+
+ if (opmptr == &opmptr_default) {
+ WM_operator_properties_free(&opmptr_default);
+ }
+ }
}
+ else {
+ /* only to get the orginal props for comparisons */
+ PointerRNA opptr_default;
- WM_operator_py_idname(idname_py, ot->idname);
- BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py);
+ if (opptr == NULL) {
+ WM_operator_properties_create_ptr(&opptr_default, ot);
+ opptr = &opptr_default;
+ }
- cstring_args = RNA_pointer_as_string_keywords(C, opptr, false,
- all_args, max_prop_length);
- BLI_dynstr_append(dynstr, cstring_args);
- MEM_freeN(cstring_args);
+ cstring_args = RNA_pointer_as_string_keywords(C, opptr, false, all_args, max_prop_length);
+ BLI_dynstr_append(dynstr, cstring_args);
+ MEM_freeN(cstring_args);
- if (opptr == &opptr_default)
- WM_operator_properties_free(&opptr_default);
+ if (opptr == &opptr_default) {
+ WM_operator_properties_free(&opptr_default);
+ }
+ }
BLI_dynstr_append(dynstr, ")");
@@ -565,6 +595,11 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i
return cstring;
}
+char *WM_operator_pystring(bContext *C, wmOperator *op, const bool all_args)
+{
+ return WM_operator_pystring_ex(C, op, all_args, op->type, op->ptr);
+}
+
/* return NULL if no match is found */
#if 0
static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
@@ -1396,12 +1431,19 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
return block;
}
-static void wm_operator_ui_popup_cancel(struct bContext *UNUSED(C), void *userData)
+static void wm_operator_ui_popup_cancel(struct bContext *C, void *userData)
{
wmOpPopUp *data = userData;
- if (data->free_op && data->op) {
- wmOperator *op = data->op;
- WM_operator_free(op);
+ wmOperator *op = data->op;
+
+ if (op) {
+ if (op->type->cancel) {
+ op->type->cancel(C, op);
+ }
+
+ if (data->free_op) {
+ WM_operator_free(op);
+ }
}
MEM_freeN(data);
@@ -1634,18 +1676,20 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
#ifdef WITH_BUILDINFO
- int ver_width, rev_width;
- char version_buf[128];
- char revision_buf[128];
- extern char build_rev[];
-
- BLI_snprintf(version_buf, sizeof(version_buf),
- "%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
- BLI_snprintf(revision_buf, sizeof(revision_buf), "r%s", build_rev);
+ int label_delta = 0;
+ int hash_width, date_width;
+ char date_buf[128] = "\0";
+ char hash_buf[128] = "\0";
+ extern unsigned long build_commit_timestamp;
+ extern char build_hash[], build_commit_date[], build_commit_time[], build_branch[];
+
+ /* Builds made from tag only shows tag sha */
+ BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash);
+ BLI_snprintf(date_buf, sizeof(date_buf), "Date: %s %s", build_commit_date, build_commit_time);
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi);
- ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 0.5f * U.widget_unit;
- rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 0.5f * U.widget_unit;
+ hash_width = (int)BLF_width(style->widgetlabel.uifont_id, hash_buf) + 0.5f * U.widget_unit;
+ date_width = (int)BLF_width(style->widgetlabel.uifont_id, date_buf) + 0.5f * U.widget_unit;
#endif /* WITH_BUILDINFO */
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
@@ -1660,9 +1704,20 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
uiButSetFunc(but, wm_block_splash_close, block, NULL);
uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL);
-#ifdef WITH_BUILDINFO
- uiDefBut(block, LABEL, 0, version_buf, U.pixelsize * 494 - ver_width, U.pixelsize * 258, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
- uiDefBut(block, LABEL, 0, revision_buf, U.pixelsize * 494 - rev_width, U.pixelsize * 246, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+#ifdef WITH_BUILDINFO
+ if (build_commit_timestamp != 0) {
+ uiDefBut(block, LABEL, 0, date_buf, U.pixelsize * 494 - date_width, U.pixelsize * 270, date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ label_delta = 12;
+ }
+ uiDefBut(block, LABEL, 0, hash_buf, U.pixelsize * 494 - hash_width, U.pixelsize * (270 - label_delta), hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+
+ if (!STREQ(build_branch, "master")) {
+ char branch_buf[128] = "\0";
+ int branch_width;
+ BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch);
+ branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf) + 0.5f * U.widget_unit;
+ uiDefBut(block, LABEL, 0, branch_buf, U.pixelsize * 494 - branch_width, U.pixelsize * (258 - label_delta), branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ }
#endif /* WITH_BUILDINFO */
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, style);
@@ -1686,11 +1741,11 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
col = uiLayoutColumn(split, FALSE);
uiItemL(col, IFACE_("Links"), ICON_NONE);
uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url",
- "http://www.blender.org/blenderorg/blender-foundation/donation-payment");
+ "http://www.blender.org/foundation/donation-payment/");
uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url",
- "http://www.blender.org/development/credits");
+ "http://www.blender.org/about/credits/");
uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url",
- "http://www.blender.org/development/release-logs/blender-269");
+ "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70");
uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url",
"http://wiki.blender.org/index.php/Doc:2.6/Manual");
uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org");
@@ -1745,7 +1800,7 @@ static void WM_OT_splash(wmOperatorType *ot)
{
ot->name = "Splash Screen";
ot->idname = "WM_OT_splash";
- ot->description = "Opens a blocking popup region with release info";
+ ot->description = "Opens the splash screen with release info";
ot->invoke = wm_splash_invoke;
ot->poll = WM_operator_winactive;
@@ -2844,11 +2899,9 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-int WM_border_select_cancel(bContext *C, wmOperator *op)
+void WM_border_select_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
-
- return OPERATOR_CANCELLED;
}
/* **************** circle gesture *************** */
@@ -2961,11 +3014,9 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-int WM_gesture_circle_cancel(bContext *C, wmOperator *op)
+void WM_gesture_circle_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
-
- return OPERATOR_CANCELLED;
}
#if 0
@@ -3188,18 +3239,14 @@ int WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event)
return WM_gesture_lasso_modal(C, op, event);
}
-int WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
+void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
-
- return OPERATOR_CANCELLED;
}
-int WM_gesture_lines_cancel(bContext *C, wmOperator *op)
+void WM_gesture_lines_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
-
- return OPERATOR_CANCELLED;
}
/**
@@ -3365,11 +3412,9 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
return OPERATOR_RUNNING_MODAL;
}
-int WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
+void WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
-
- return OPERATOR_CANCELLED;
}
#if 0
@@ -3803,7 +3848,7 @@ static void radial_control_set_value(RadialControl *rc, float val)
}
}
-static int radial_control_cancel(bContext *C, wmOperator *op)
+static void radial_control_cancel(bContext *C, wmOperator *op)
{
RadialControl *rc = op->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
@@ -3821,8 +3866,6 @@ static int radial_control_cancel(bContext *C, wmOperator *op)
glDeleteTextures(1, &rc->gltex);
MEM_freeN(rc);
-
- return OPERATOR_CANCELLED;
}
static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -4255,6 +4298,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "UV_OT_circle_select");
WM_modalkeymap_assign(keymap, "CLIP_OT_select_circle");
WM_modalkeymap_assign(keymap, "MASK_OT_select_circle");
+ WM_modalkeymap_assign(keymap, "NODE_OT_select_circle");
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 9e89c17e024..5f344340643 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -133,10 +133,6 @@ static void wm_window_check_position(rcti *rect)
wm_get_screensize(&width, &height);
-#if defined(__APPLE__) && !defined(GHOST_COCOA)
- height -= 70;
-#endif
-
if (rect->xmin < 0) {
rect->xmax -= rect->xmin;
rect->xmin = 0;
@@ -338,12 +334,6 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
* in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */
GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved);
-#if defined(__APPLE__) && !defined(GHOST_COCOA)
- if (wm->file_saved)
- GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateUnModified);
- else
- GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateModified);
-#endif
}
}
@@ -428,20 +418,12 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
if (wm_init_state.size_x == 0) {
wm_get_screensize(&wm_init_state.size_x, &wm_init_state.size_y);
-#if defined(__APPLE__) && !defined(GHOST_COCOA)
- /* Cocoa provides functions to get correct max window size */
- {
- extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */
-
- wm_set_apple_prefsize(wm_init_state.size_x, wm_init_state.size_y);
- }
-#else
- /* note!, this isnt quite correct, active screen maybe offset 1000s if PX,
- * we'd need a wm_get_screensize like function that gives offset,
- * in practice the window manager will likely move to the correct monitor */
- wm_init_state.start_x = 0;
- wm_init_state.start_y = 0;
-#endif
+ /* note!, this isnt quite correct, active screen maybe offset 1000s if PX,
+ * we'd need a wm_get_screensize like function that gives offset,
+ * in practice the window manager will likely move to the correct monitor */
+ wm_init_state.start_x = 0;
+ wm_init_state.start_y = 0;
+
#if !defined(__APPLE__) && !defined(WIN32) /* X11 */
/* X11, start maximized but use default sane size */
diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt
index 529e2017989..b158a61749e 100644
--- a/source/blenderplayer/CMakeLists.txt
+++ b/source/blenderplayer/CMakeLists.txt
@@ -92,6 +92,7 @@ endif()
ge_player_common
bf_intern_string
bf_intern_ghost
+ bf_intern_ghostndof3dconnexion
bf_rna
bf_blenkernel
bf_intern_rigidbody
diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt
index e8e7ee6ea0a..1d681d28589 100644
--- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt
+++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt
@@ -1,3 +1,4 @@
+
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
@@ -51,8 +52,12 @@ if(WITH_BUILDINFO)
)
add_definitions(-DBUILD_DATE="\"\""
-DBUILD_TIME="\"\""
- -DBUILD_REV="\"\""
+ -DBUILD_COMMIT_TIMESTAMP=0
+ -DBUILD_COMMIT_DATE="\"\""
+ -DBUILD_COMMIT_TIME="\"\""
+ -DBUILD_HASH="\"\""
-DBUILD_PLATFORM="\"\""
+ -DBUILD_BRANCH="\"\""
-DBUILD_TYPE="\"\""
)
endif()
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index f55f307e095..f61b54ac360 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -85,6 +85,7 @@ struct MetaBall;
struct ModifierData;
struct MovieClip;
struct MultiresModifierData;
+struct HookModifierData;
struct NodeBlurData;
struct Nurb;
struct Object;
@@ -166,6 +167,9 @@ void RE_free_sample_material(struct Material *mat) {STUB_ASSERT(0);}
void RE_sample_material_color(struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3],
int face_index, short hit_quad, struct DerivedMesh *orcoDm, struct Object *ob) {STUB_ASSERT(0);}
+/* skin modifier*/
+void modifier_skin_customdata_ensure(struct Object *ob) {STUB_ASSERT(0);}
+
/* nodes */
struct RenderResult *RE_GetResult(struct Render *re) {STUB_ASSERT(0); return (struct RenderResult *) NULL;}
struct Render *RE_GetRender(const char *name) {STUB_ASSERT(0); return (struct Render *) NULL;}
@@ -191,7 +195,7 @@ void RE_BlenderFrame(struct Render *re, struct Scene *scene, int frame) {STUB_AS
int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]) {STUB_ASSERT(0); return 0; }
/* rna */
-float *give_cursor(struct Scene *scene, struct View3D *v3d) {STUB_ASSERT(0); return (float *) NULL;}
+float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d) {STUB_ASSERT(0); return (float *) NULL;}
void WM_menutype_free(void) {STUB_ASSERT(0);}
void WM_menutype_freelink(struct MenuType *mt) {STUB_ASSERT(0);}
int WM_menutype_add(struct MenuType *mt) {STUB_ASSERT(0); return 0;}
@@ -284,6 +288,7 @@ void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keym
void WM_keymap_properties_reset(struct wmKeyMapItem *kmi) {STUB_ASSERT(0);}
void WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) {STUB_ASSERT(0);}
int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2) {STUB_ASSERT(0); return 0;}
+int WM_keymap_map_type_get(struct wmKeyMapItem *kmi) {STUB_ASSERT(0); return 0;}
/* rna editors */
@@ -348,6 +353,7 @@ void ED_object_modifier_clear(struct Main *bmain, struct Object *ob) {STUB_ASSER
void ED_object_editmode_enter(struct bContext *C, int flag) {STUB_ASSERT(0);}
void ED_object_editmode_exit(struct bContext *C, int flag) {STUB_ASSERT(0);}
bool ED_object_editmode_load(struct Object *obedit) {STUB_ASSERT(0); return false; }
+void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object) {STUB_ASSERT(0);}
int uiLayoutGetActive(struct uiLayout *layout) {STUB_ASSERT(0); return 0;}
int uiLayoutGetOperatorContext(struct uiLayout *layout) {STUB_ASSERT(0); return 0;}
int uiLayoutGetAlignment(struct uiLayout *layout) {STUB_ASSERT(0); return 0;}
@@ -536,7 +542,8 @@ void WM_operator_py_idname(char *to, const char *from) {STUB_ASSERT(0);}
void WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width, int height) {STUB_ASSERT(0);}
short insert_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag) {STUB_ASSERT(0); return 0;}
short delete_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag) {STUB_ASSERT(0); return 0;}
-char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args) {STUB_ASSERT(0); return (char *)NULL;}
+char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args, struct wmOperatorType *ot, struct PointerRNA *opptr) {STUB_ASSERT(0); return (char *)NULL;}
+char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args) {STUB_ASSERT(0); return (char *)NULL;}
struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value) {STUB_ASSERT(0); return (struct wmKeyMapItem *)NULL;}
struct wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value) {STUB_ASSERT(0); return (struct wmKeyMapItem *)NULL;}
struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items) {STUB_ASSERT(0); return (struct wmKeyMap *) NULL;}
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 921443d9ab9..7162e5e9b6e 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -131,7 +131,11 @@ if(WITH_BUILDINFO)
# # define in header now, else these get out of date on rebuilds.
# -DBUILD_DATE="${BUILD_DATE}"
# -DBUILD_TIME="${BUILD_TIME}"
- # -DBUILD_REV="${BUILD_REV}"
+ # -DBUILD_COMMIT_TIMESTAMP="${BUILD_COMMIT_TIMESTAMP}"
+ # -DBUILD_COMMIT_TIME="${BUILD_COMMIT_TIME}"
+ # -DBUILD_COMMIT_DATE="${BUILD_COMMIT_DATE}"
+ # -DBUILD_HASH="${BUILD_HASH}"
+ # -DBUILD_BRANCH="${BUILD_BRANCH}"
-DWITH_BUILDINFO_HEADER # alternative to lines above
-DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
-DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
@@ -302,7 +306,7 @@ if(WITH_PYTHON)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
DESTINATION ${TARGETDIR_VER}
- PATTERN ".svn" EXCLUDE
+ PATTERN ".git" EXCLUDE
PATTERN "__pycache__" EXCLUDE
PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE
PATTERN "${FREESTYLE_EXCLUDE_CONDITIONAL}" EXCLUDE
@@ -316,11 +320,48 @@ endif()
if(WITH_INTERNATIONAL)
install(
DIRECTORY
- ${CMAKE_SOURCE_DIR}/release/datafiles/locale
${CMAKE_SOURCE_DIR}/release/datafiles/fonts
DESTINATION ${TARGETDIR_VER}/datafiles
- PATTERN ".svn" EXCLUDE
)
+
+ set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
+ set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale)
+
+ file(GLOB _po_files "${_locale_dir}/po/*.po")
+ foreach(_po_file ${_po_files})
+ msgfmt_simple(${_po_file} _all_mo_files)
+ endforeach()
+
+ # Create a custom target which will compile all po to mo
+ add_custom_target(
+ locales
+ DEPENDS ${_all_mo_files})
+
+ add_dependencies(blender locales)
+
+ # Generate INSTALL rules
+ install(
+ FILES ${_locale_dir}/languages
+ DESTINATION ${_locale_target_dir}
+ )
+
+ foreach(_mo_file ${_all_mo_files})
+ get_filename_component(_locale_name ${_mo_file} NAME_WE)
+ install(
+ FILES ${_mo_file}
+ DESTINATION ${_locale_target_dir}/${_locale_name}/LC_MESSAGES
+ RENAME blender.mo
+ )
+ unset(_locale_name)
+ endforeach()
+
+ unset(_all_mo_files)
+ unset(_po_files)
+ unset(_po_file)
+ unset(_mo_file)
+ unset(_locale_target_dir)
+
+ unset(_locale_dir)
endif()
# color management
@@ -328,7 +369,6 @@ if(WITH_OPENCOLORIO)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/colormanagement
DESTINATION ${TARGETDIR_VER}/datafiles
- PATTERN ".svn" EXCLUDE
)
endif()
@@ -405,7 +445,6 @@ if(UNIX AND NOT APPLE)
${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
- PATTERN ".svn" EXCLUDE
PATTERN "*.svg" EXCLUDE
)
install(
@@ -695,6 +734,7 @@ elseif(APPLE)
install(
DIRECTORY ${from}
DESTINATION ${to}
+ PATTERN ".git" EXCLUDE
PATTERN ".svn" EXCLUDE
PATTERN "*.pyc" EXCLUDE
PATTERN "*.pyo" EXCLUDE
diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c
index d747fe8e1ff..795eec0df40 100644
--- a/source/creator/buildinfo.c
+++ b/source/creator/buildinfo.c
@@ -39,7 +39,11 @@
/* currently only these are defined in the header */
char build_date[] = BUILD_DATE;
char build_time[] = BUILD_TIME;
-char build_rev[] = BUILD_REV;
+char build_hash[] = BUILD_HASH;
+unsigned long build_commit_timestamp = BUILD_COMMIT_TIMESTAMP;
+char build_commit_date[16] = "\0";
+char build_commit_time[16] = "\0";
+char build_branch[] = BUILD_BRANCH;
char build_platform[] = BUILD_PLATFORM;
char build_type[] = BUILD_TYPE;
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 1596fe5359c..420dceb812b 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -63,6 +63,7 @@
#include <stddef.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
/* This little block needed for linking to Blender... */
@@ -153,7 +154,14 @@
#ifdef BUILD_DATE
extern char build_date[];
extern char build_time[];
-extern char build_rev[];
+extern char build_hash[];
+extern unsigned long build_commit_timestamp;
+
+/* TODO(sergey): ideally size need to be in sync with buildinfo.c */
+extern char build_commit_date[16];
+extern char build_commit_time[16];
+
+extern char build_branch[];
extern char build_platform[];
extern char build_type[];
extern char build_cflags[];
@@ -219,7 +227,9 @@ static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUS
#ifdef BUILD_DATE
printf("\tbuild date: %s\n", build_date);
printf("\tbuild time: %s\n", build_time);
- printf("\tbuild revision: %s\n", build_rev);
+ printf("\tbuild commit date: %s\n", build_commit_date);
+ printf("\tbuild commit time: %s\n", build_commit_time);
+ printf("\tbuild hash: %s\n", build_hash);
printf("\tbuild platform: %s\n", build_platform);
printf("\tbuild type: %s\n", build_type);
printf("\tbuild c flags: %s\n", build_cflags);
@@ -590,13 +600,12 @@ static void blender_crash_handler(int signum)
printf("Writing: %s\n", fname);
fflush(stdout);
- BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Revision: %s\n", BLEND_VERSION_ARG,
-#ifdef BUILD_DATE
- build_rev
+#ifndef BUILD_DATE
+ BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG);
#else
- "Unknown"
+ BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Commit date: %s %s, Hash %s\n",
+ BLEND_VERSION_ARG, build_commit_date, build_commit_time, build_hash);
#endif
- );
/* open the crash log */
errno = 0;
@@ -1470,7 +1479,7 @@ int main(int argc, const char **argv)
#endif
#ifdef WIN32 /* Win32 Unicode Args */
- /* NOTE: cannot use guardedalloc malloc here, as it's not yet initialised
+ /* NOTE: cannot use guardedalloc malloc here, as it's not yet initialized
* (it depends on the args passed in, which is what we're getting here!)
*/
wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
@@ -1504,6 +1513,22 @@ int main(int argc, const char **argv)
}
}
+#ifdef BUILD_DATE
+ {
+ time_t temp_time = build_commit_timestamp;
+ struct tm *tm = gmtime(&temp_time);
+ if (LIKELY(tm)) {
+ strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm);
+ strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm);
+ }
+ else {
+ const char *unknown = "date-unknown";
+ BLI_strncpy(build_commit_date, unknown, sizeof(build_commit_date));
+ BLI_strncpy(build_commit_time, unknown, sizeof(build_commit_time));
+ }
+ }
+#endif
+
C = CTX_create();
#ifdef WITH_PYTHON_MODULE
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 484e51c4ed1..2b1c8a10cce 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -42,11 +42,9 @@
#include "GL/glew.h"
-#include "KX_BlenderGL.h"
#include "KX_BlenderCanvas.h"
#include "KX_BlenderKeyboardDevice.h"
#include "KX_BlenderMouseDevice.h"
-#include "KX_BlenderRenderTools.h"
#include "KX_BlenderSystem.h"
#include "BL_Material.h"
@@ -276,7 +274,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
if (animation_record) usefixed= false; /* override since you don't want to run full-speed for sim recording */
- // create the canvas, rasterizer and rendertools
+ // create the canvas and rasterizer
RAS_ICanvas* canvas = new KX_BlenderCanvas(wm, win, area_rect, ar);
// default mouse state set on render panel
@@ -292,7 +290,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
else
canvas->SetSwapInterval((startscene->gm.vsync == VSYNC_ON) ? 1 : 0);
- RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
RAS_IRasterizer* rasterizer = NULL;
//Don't use displaylists with VBOs
//If auto starts using VBOs, make sure to check for that here
@@ -324,7 +321,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
ketsjiengine->SetMouseDevice(mousedevice);
ketsjiengine->SetNetworkDevice(networkdevice);
ketsjiengine->SetCanvas(canvas);
- ketsjiengine->SetRenderTools(rendertools);
ketsjiengine->SetRasterizer(rasterizer);
ketsjiengine->SetUseFixedTime(usefixed);
ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
@@ -474,7 +470,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
else if (gs.matmode == GAME_MAT_GLSL)
usemat = false;
- if (usemat && (gs.matmode != GAME_MAT_TEXFACE))
+ if (usemat)
sceneconverter->SetMaterials(true);
if (useglslmat && (gs.matmode == GAME_MAT_GLSL))
sceneconverter->SetGLSLMaterials(true);
@@ -518,7 +514,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
// convert and add scene
sceneconverter->ConvertScene(
startscene,
- rendertools,
+ rasterizer,
canvas);
ketsjiengine->AddScene(startscene);
@@ -664,11 +660,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
delete rasterizer;
rasterizer = NULL;
}
- if (rendertools)
- {
- delete rendertools;
- rendertools = NULL;
- }
if (canvas)
{
canvas->SetSwapInterval(previous_vsync); // Set the swap interval back
diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt
index 67739706e3c..73dbe005518 100644
--- a/source/gameengine/BlenderRoutines/CMakeLists.txt
+++ b/source/gameengine/BlenderRoutines/CMakeLists.txt
@@ -39,20 +39,16 @@ set(SRC
BL_KetsjiEmbedStart.cpp
BL_System.cpp
KX_BlenderCanvas.cpp
- KX_BlenderGL.cpp
KX_BlenderInputDevice.cpp
KX_BlenderKeyboardDevice.cpp
KX_BlenderMouseDevice.cpp
- KX_BlenderRenderTools.cpp
KX_BlenderSystem.cpp
BL_System.h
KX_BlenderCanvas.h
- KX_BlenderGL.h
KX_BlenderInputDevice.h
KX_BlenderKeyboardDevice.h
KX_BlenderMouseDevice.h
- KX_BlenderRenderTools.h
KX_BlenderSystem.h
)
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index 3089b3fd44d..b3e0b4c3ea6 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -29,13 +29,33 @@
* \ingroup blroutines
*/
+#include <GL/glew.h>
+
+#include "MEM_guardedalloc.h"
#include "KX_BlenderCanvas.h"
+
+#include "DNA_image_types.h"
+#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
-#include <stdio.h>
+
+#include "BKE_image.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
#include <assert.h>
+extern "C" {
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "WM_api.h"
+#include "wm_cursors.h"
+#include "wm_window.h"
+}
KX_BlenderCanvas::KX_BlenderCanvas(wmWindowManager *wm, wmWindow *win, RAS_Rect &rect, struct ARegion *ar) :
m_wm(wm),
@@ -63,17 +83,17 @@ void KX_BlenderCanvas::Init()
void KX_BlenderCanvas::SwapBuffers()
{
- BL_SwapBuffers(m_win);
+ wm_window_swap_buffers(m_win);
}
void KX_BlenderCanvas::SetSwapInterval(int interval)
{
- BL_SetSwapInterval(m_win, interval);
+ wm_window_set_swap_interval(m_win, interval);
}
int KX_BlenderCanvas::GetSwapInterval()
{
- return BL_GetSwapInterval(m_win);
+ return wm_window_get_swap_interval(m_win);
}
void KX_BlenderCanvas::ResizeWindow(int width, int height)
@@ -96,7 +116,7 @@ bool KX_BlenderCanvas::BeginDraw()
{
// in case of multi-window we need to ensure we are drawing to the correct
// window always, because it may change in window event handling
- BL_MakeDrawable(m_wm, m_win);
+ wm_window_make_drawable(m_wm, m_win);
return true;
}
@@ -247,17 +267,17 @@ void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate)
{
case MOUSE_INVISIBLE:
{
- BL_HideMouse(m_win);
+ WM_cursor_set(m_win, CURSOR_NONE);
break;
}
case MOUSE_WAIT:
{
- BL_WaitMouse(m_win);
+ WM_cursor_set(m_win, CURSOR_WAIT);
break;
}
case MOUSE_NORMAL:
{
- BL_NormalMouse(m_win);
+ WM_cursor_set(m_win, CURSOR_STD);
break;
}
default:
@@ -275,18 +295,71 @@ void KX_BlenderCanvas::SetMousePosition(int x,int y)
int winY = m_frame_rect.GetBottom();
int winH = m_frame_rect.GetHeight();
- BL_warp_pointer(m_win, winX + x, winY + (winH-y));
+ WM_cursor_warp(m_win, winX + x, winY + (winH-y));
}
+/* get shot from frontbuffer sort of a copy from screendump.c */
+static unsigned int *screenshot(ScrArea *curarea, int *dumpsx, int *dumpsy)
+{
+ int x=0, y=0;
+ unsigned int *dumprect= NULL;
+
+ x= curarea->totrct.xmin;
+ y= curarea->totrct.ymin;
+ *dumpsx= curarea->totrct.xmax-x;
+ *dumpsy= curarea->totrct.ymax-y;
+
+ if (*dumpsx && *dumpsy) {
+
+ dumprect= (unsigned int *)MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
+ glReadBuffer(GL_FRONT);
+ glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
+ glFinish();
+ glReadBuffer(GL_BACK);
+ }
+
+ return dumprect;
+}
void KX_BlenderCanvas::MakeScreenShot(const char *filename)
{
ScrArea area_dummy= {0};
+ bScreen *screen = m_win->screen;
+ unsigned int *dumprect;
+ int dumpsx, dumpsy;
+
area_dummy.totrct.xmin = m_frame_rect.GetLeft();
area_dummy.totrct.xmax = m_frame_rect.GetRight();
area_dummy.totrct.ymin = m_frame_rect.GetBottom();
area_dummy.totrct.ymax = m_frame_rect.GetTop();
- BL_MakeScreenShot(m_win->screen, &area_dummy, filename);
+ dumprect = screenshot(&area_dummy, &dumpsx, &dumpsy);
+
+ if (dumprect) {
+ /* initialize image file format data */
+ Scene *scene = (screen)? screen->scene: NULL;
+ ImageFormatData im_format;
+
+ if (scene)
+ im_format = scene->r.im_format;
+ else
+ BKE_imformat_defaults(&im_format);
+
+ /* create file path */
+ char path[FILE_MAX];
+ BLI_strncpy(path, filename, sizeof(path));
+ BLI_path_abs(path, G.main->name);
+ BKE_add_image_extension_from_type(path, im_format.imtype);
+
+ /* create and save imbuf */
+ ImBuf *ibuf = IMB_allocImBuf(dumpsx, dumpsy, 24, 0);
+ ibuf->rect = dumprect;
+
+ BKE_imbuf_write_as(ibuf, path, &im_format, false);
+
+ ibuf->rect = NULL;
+ IMB_freeImBuf(ibuf);
+ MEM_freeN(dumprect);
+ }
}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
index c5318b882fa..9ad80cb1737 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -34,15 +34,11 @@
#ifdef WIN32
#include <windows.h>
-#endif
-
-#include "GL/glew.h"
+#endif
#include "RAS_ICanvas.h"
#include "RAS_Rect.h"
-#include "KX_BlenderGL.h"
-
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
@@ -70,7 +66,7 @@ public:
*
* \param area The Blender ARegion to run the game within.
*/
- KX_BlenderCanvas(struct wmWindowManager *wm, struct wmWindow* win, class RAS_Rect &rect, struct ARegion* ar);
+ KX_BlenderCanvas(struct wmWindowManager *wm, struct wmWindow* win, RAS_Rect &rect, struct ARegion* ar);
~KX_BlenderCanvas();
void
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
deleted file mode 100644
index 6ed4866579c..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/BlenderRoutines/KX_BlenderGL.cpp
- * \ingroup blroutines
- */
-
-
-#include "KX_BlenderGL.h"
-
-/*
- * This little block needed for linking to Blender...
- */
-#ifdef WIN32
-#include <vector>
-#include "BLI_winstuff.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "GL/glew.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BL_Material.h" // MAXTEX
-
-/* Data types encoding the game world: */
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_world_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_image_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_material_types.h"
-#include "DNA_space_types.h"
-#include "DNA_windowmanager_types.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_bmfont.h"
-#include "BKE_image.h"
-
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-
-extern "C" {
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-#include "WM_api.h"
-#include "WM_types.h"
-#include "wm_event_system.h"
-#include "wm_cursors.h"
-#include "wm_window.h"
-#include "BLF_api.h"
-}
-
-/* end of blender block */
-void BL_warp_pointer(wmWindow *win, int x,int y)
-{
- WM_cursor_warp(win, x, y);
-}
-
-void BL_SwapBuffers(wmWindow *win)
-{
- wm_window_swap_buffers(win);
-}
-
-void BL_MakeDrawable(wmWindowManager *wm, wmWindow *win)
-{
- wm_window_make_drawable(wm, win);
-}
-
-void BL_SetSwapInterval(struct wmWindow *win, int interval)
-{
- wm_window_set_swap_interval(win, interval);
-}
-
-int BL_GetSwapInterval(struct wmWindow *win)
-{
- return wm_window_get_swap_interval(win);
-}
-
-static void DisableForText()
-{
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */
-
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
-
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
-
- if (GLEW_ARB_multitexture) {
- for (int i=0; i<MAXTEX; i++) {
- glActiveTextureARB(GL_TEXTURE0_ARB+i);
-
- if (GLEW_ARB_texture_cube_map)
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
-
- glDisable(GL_TEXTURE_2D);
- }
-
- glActiveTextureARB(GL_TEXTURE0_ARB);
- }
- else {
- if (GLEW_ARB_texture_cube_map)
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
-
- glDisable(GL_TEXTURE_2D);
- }
-}
-
-void BL_draw_gamedebug_box(int xco, int yco, int width, int height, float percentage)
-{
- /* This is a rather important line :( The gl-mode hasn't been left
- * behind quite as neatly as we'd have wanted to. I don't know
- * what cause it, though :/ .*/
- glDisable(GL_DEPTH_TEST);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glOrtho(0, width, 0, height, -100, 100);
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- yco = height - yco;
- int barsize = 50;
-
- /* draw in black first*/
- glColor3ub(0, 0, 0);
- glBegin(GL_QUADS);
- glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10);
- glVertex2f(xco + 1, yco - 1 + 10);
- glVertex2f(xco + 1, yco - 1);
- glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1);
- glEnd();
-
- glColor3ub(255, 255, 255);
- glBegin(GL_QUADS);
- glVertex2f(xco + 1 + barsize * percentage, yco + 10);
- glVertex2f(xco, yco + 10);
- glVertex2f(xco, yco);
- glVertex2f(xco + 1 + barsize * percentage, yco);
- glEnd();
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glEnable(GL_DEPTH_TEST);
-}
-
-/* Print 3D text */
-void BL_print_game_line(int fontid, const char *text, int size, int dpi, float *color, double *mat, float aspect)
-{
- /* gl prepping */
- DisableForText();
-
- /* the actual drawing */
- glColor4fv(color);
-
- /* multiply the text matrix by the object matrix */
- BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
- BLF_matrix(fontid, mat);
-
- /* aspect is the inverse scale that allows you to increase */
- /* your resolution without sizing the final text size */
- /* the bigger the size, the smaller the aspect */
- BLF_aspect(fontid, aspect, aspect, aspect);
-
- BLF_size(fontid, size, dpi);
- BLF_position(fontid, 0, 0, 0);
- BLF_draw(fontid, (char *)text, 65535);
-
- BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
-}
-
-void BL_print_gamedebug_line(const char *text, int xco, int yco, int width, int height)
-{
- /* gl prepping */
- DisableForText();
- glDisable(GL_DEPTH_TEST);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glOrtho(0, width, 0, height, -100, 100);
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- /* the actual drawing */
- glColor3ub(255, 255, 255);
- BLF_size(blf_mono_font, 11, 72);
- BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
- BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glEnable(GL_DEPTH_TEST);
-}
-
-void BL_print_gamedebug_line_padded(const char *text, int xco, int yco, int width, int height)
-{
- /* This is a rather important line :( The gl-mode hasn't been left
- * behind quite as neatly as we'd have wanted to. I don't know
- * what cause it, though :/ .*/
- DisableForText();
- glDisable(GL_DEPTH_TEST);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glOrtho(0, width, 0, height, -100, 100);
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- /* draw in black first*/
- glColor3ub(0, 0, 0);
- BLF_size(blf_mono_font, 11, 72);
- BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
- BLF_draw(blf_mono_font, (char *)text, 65535);/* XXX, use real len */
-
- glColor3ub(255, 255, 255);
- BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
- BLF_draw(blf_mono_font, (char *)text, 65535);
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glEnable(GL_DEPTH_TEST);
-}
-
-void BL_HideMouse(wmWindow *win)
-{
- WM_cursor_set(win, CURSOR_NONE);
-}
-
-
-void BL_WaitMouse(wmWindow *win)
-{
- WM_cursor_set(win, CURSOR_WAIT);
-}
-
-
-void BL_NormalMouse(wmWindow *win)
-{
- WM_cursor_set(win, CURSOR_STD);
-}
-/* get shot from frontbuffer sort of a copy from screendump.c */
-static unsigned int *screenshot(ScrArea *curarea, int *dumpsx, int *dumpsy)
-{
- int x=0, y=0;
- unsigned int *dumprect= NULL;
-
- x= curarea->totrct.xmin;
- y= curarea->totrct.ymin;
- *dumpsx= curarea->totrct.xmax-x;
- *dumpsy= curarea->totrct.ymax-y;
-
- if (*dumpsx && *dumpsy) {
-
- dumprect= (unsigned int *)MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
- glReadBuffer(GL_FRONT);
- glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
- glFinish();
- glReadBuffer(GL_BACK);
- }
-
- return dumprect;
-}
-
-/* based on screendump.c::screenshot_exec */
-void BL_MakeScreenShot(bScreen *screen, ScrArea *curarea, const char *filename)
-{
- unsigned int *dumprect;
- int dumpsx, dumpsy;
-
- dumprect = screenshot(curarea, &dumpsx, &dumpsy);
-
- if (dumprect) {
- /* initialize image file format data */
- Scene *scene = (screen)? screen->scene: NULL;
- ImageFormatData im_format;
-
- if (scene)
- im_format = scene->r.im_format;
- else
- BKE_imformat_defaults(&im_format);
-
- /* create file path */
- char path[FILE_MAX];
- BLI_strncpy(path, filename, sizeof(path));
- BLI_path_abs(path, G.main->name);
- BKE_add_image_extension_from_type(path, im_format.imtype);
-
- /* create and save imbuf */
- ImBuf *ibuf = IMB_allocImBuf(dumpsx, dumpsy, 24, 0);
- ibuf->rect = dumprect;
-
- BKE_imbuf_write_as(ibuf, path, &im_format, false);
-
- ibuf->rect = NULL;
- IMB_freeImBuf(ibuf);
- MEM_freeN(dumprect);
- }
-}
-
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
deleted file mode 100644
index 8032d9a594a..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_BlenderGL.h
- * \ingroup blroutines
- */
-
-#ifndef __KX_BLENDERGL_H__
-#define __KX_BLENDERGL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-struct ARegion;
-struct bScreen;
-struct wmWindow;
-struct wmWindowManager;
-
-// special swapbuffers, that takes care of which area (viewport) needs to be swapped
-void BL_SwapBuffers(struct wmWindow *win);
-void BL_SetSwapInterval(struct wmWindow *win, int interval);
-int BL_GetSwapInterval(struct wmWindow *win);
-
-void BL_MakeDrawable(struct wmWindowManager *wm, struct wmWindow *win);
-
-void BL_warp_pointer(struct wmWindow *win,int x,int y);
-
-void BL_MakeScreenShot(struct bScreen *screen, struct ScrArea *curarea, const char *filename);
-
-void BL_HideMouse(struct wmWindow *win);
-void BL_NormalMouse(struct wmWindow *win);
-void BL_WaitMouse(struct wmWindow *win);
-
-void BL_draw_gamedebug_box(int xco, int yco, int width, int height, float percentage);
-void BL_print_game_line(int fontid, const char* text, int size, int dpi, float* color, double* mat, float aspect);
-void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height);
-void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height);
-
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __KX_BLENDERGL_H__ */
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
deleted file mode 100644
index bcc62a341f8..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
- * \ingroup blroutines
- */
-
-
-#include "GL/glew.h"
-
-#include "RAS_IRenderTools.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_LightObject.h"
-#include "RAS_ICanvas.h"
-#include "RAS_GLExtensionManager.h"
-#include "RAS_MeshObject.h"
-
-#include "KX_GameObject.h"
-#include "KX_PolygonMaterial.h"
-#include "KX_BlenderMaterial.h"
-#include "KX_RayCast.h"
-#include "KX_IPhysicsController.h"
-#include "KX_Light.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-
-#include "STR_String.h"
-
-#include "GPU_draw.h"
-
-#include "KX_BlenderGL.h" // for text printing
-#include "KX_BlenderRenderTools.h"
-
-unsigned int KX_BlenderRenderTools::m_numgllights;
-
-KX_BlenderRenderTools::KX_BlenderRenderTools()
-{
- glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights);
- if (m_numgllights < 8)
- m_numgllights = 8;
-}
-
-KX_BlenderRenderTools::~KX_BlenderRenderTools()
-{
-}
-
-void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty)
-{
- m_clientobject = NULL;
- m_lastlightlayer = -1;
- m_lastauxinfo = NULL;
- m_lastlighting = true; /* force disable in DisableOpenGLLights() */
- DisableOpenGLLights();
-}
-
-void KX_BlenderRenderTools::EndFrame(RAS_IRasterizer* rasty)
-{
-}
-
-/* ProcessLighting performs lighting on objects. the layer is a bitfield that
- * contains layer information. There are 20 'official' layers in blender. A
- * light is applied on an object only when they are in the same layer. OpenGL
- * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in
- * a scene. */
-
-void KX_BlenderRenderTools::ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat)
-{
- bool enable = false;
- int layer= -1;
-
- /* find the layer */
- if (uselights) {
- if (m_clientobject)
- layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
- }
-
- /* avoid state switching */
- if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo)
- return;
-
- m_lastlightlayer = layer;
- m_lastauxinfo = m_auxilaryClientInfo;
-
- /* enable/disable lights as needed */
- if (layer >= 0)
- enable = applyLights(layer, viewmat);
-
- if (enable)
- EnableOpenGLLights(rasty);
- else
- DisableOpenGLLights();
-}
-
-void KX_BlenderRenderTools::EnableOpenGLLights(RAS_IRasterizer *rasty)
-{
- if (m_lastlighting == true)
- return;
-
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
-
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (rasty->GetCameraOrtho())? GL_FALSE: GL_TRUE);
- if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
-
- m_lastlighting = true;
-}
-
-void KX_BlenderRenderTools::DisableOpenGLLights()
-{
- if (m_lastlighting == false)
- return;
-
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
-
- m_lastlighting = false;
-}
-
-
-void KX_BlenderRenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj)
-{
- if (m_clientobject != obj)
- {
- bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling());
- rasty->SetFrontFace(ccw);
-
- m_clientobject = obj;
- }
-}
-
-bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void * const data)
-{
- double* const oglmatrix = (double* const) data;
-
- RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
- if (!poly->IsVisible())
- return false;
-
- MT_Point3 resultpoint(result->m_hitPoint);
- MT_Vector3 resultnormal(result->m_hitNormal);
- MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
- MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
- left = (dir.cross(resultnormal)).safe_normalized();
- // for the up vector, we take the 'resultnormal' returned by the physics
-
- double maat[16] = {left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- resultnormal[0], resultnormal[1], resultnormal[2], 0,
- 0, 0, 0, 1};
-
- glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
- //glMultMatrixd(oglmatrix);
- glMultMatrixd(maat);
- return true;
-}
-
-void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode )
-{
- /* FIXME:
- blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
- MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed.
-
- Program received signal SIGABRT, Aborted.
- [Switching to Thread 16384 (LWP 1519)]
- 0x40477571 in kill () from /lib/libc.so.6
- (gdb) bt
- #7 0x08334368 in MT_Vector3::normalized() const ()
- #8 0x0833e6ec in KX_BlenderRenderTools::applyTransform(RAS_IRasterizer*, double*, int) ()
- */
-
- if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
- objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
- {
- // rotate the billboard/halo
- //page 360/361 3D Game Engine Design, David Eberly for a discussion
- // on screen aligned and axis aligned billboards
- // assumed is that the preprocessor transformed all billboard polygons
- // so that their normal points into the positive x direction (1.0, 0.0, 0.0)
- // when new parenting for objects is done, this rotation
- // will be moved into the object
-
- MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- MT_Point3 campos = rasty->GetCameraPosition();
- MT_Vector3 dir = (campos - objpos).safe_normalized();
- MT_Vector3 up(0,0,1.0);
-
- KX_GameObject* gameobj = (KX_GameObject *)this->m_clientobject;
- // get scaling of halo object
- MT_Vector3 size = gameobj->GetSGNode()->GetWorldScaling();
-
- bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
- if (screenaligned)
- {
- up = (up - up.dot(dir) * dir).safe_normalized();
- } else
- {
- dir = (dir - up.dot(dir)*up).safe_normalized();
- }
-
- MT_Vector3 left = dir.normalized();
- dir = (left.cross(up)).normalized();
-
- // we have calculated the row vectors, now we keep
- // local scaling into account:
-
- left *= size[0];
- dir *= size[1];
- up *= size[2];
-
- double maat[16] = {left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- up[0], up[1], up[2], 0,
- 0, 0, 0, 1};
-
- glTranslated(objpos[0],objpos[1],objpos[2]);
- glMultMatrixd(maat);
- }
- else {
- if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
- {
- // shadow must be cast to the ground, physics system needed here!
- MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- KX_GameObject *gameobj = (KX_GameObject *)this->m_clientobject;
- MT_Vector3 direction = MT_Vector3(0,0,-1);
-
- direction.normalize();
- direction *= 100000;
-
- MT_Point3 topoint = frompoint + direction;
-
- KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
- PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
- KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
-
- KX_GameObject *parent = gameobj->GetParent();
- if (!physics_controller && parent)
- physics_controller = parent->GetPhysicsController();
- if (parent)
- parent->Release();
-
- KX_RayCast::Callback<KX_BlenderRenderTools> callback(this, physics_controller, oglmatrix);
- if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
- {
- // couldn't find something to cast the shadow on...
- glMultMatrixd(oglmatrix);
- }
- else
- { // we found the "ground", but the cast matrix doesn't take
- // scaling in consideration, so we must apply the object scale
- MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
- glScalef(size[0], size[1], size[2]);
- }
- } else
- {
-
- // 'normal' object
- glMultMatrixd(oglmatrix);
- }
- }
-}
-
-void KX_BlenderRenderTools::RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage)
-{
- BL_draw_gamedebug_box(xco, yco, width, height, percentage);
-}
-
-void KX_BlenderRenderTools::RenderText3D(int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect)
-{
- BL_print_game_line(fontid, text, size, dpi, color, mat, aspect);
-}
-
-void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height)
-{
- if (mode == RAS_IRenderTools::RAS_TEXT_PADDED)
- BL_print_gamedebug_line_padded(text, xco, yco, width, height);
- else
- BL_print_gamedebug_line(text, xco, yco, width, height);
-}
-
-/* Render Text renders text into a (series of) polygon, using a texture font,
- * Each character consists of one polygon (one quad or two triangles) */
-
-void KX_BlenderRenderTools::RenderText(
- int mode,
- RAS_IPolyMaterial* polymat,
- float v1[3], float v2[3], float v3[3], float v4[3], int glattrib)
-{
- const STR_String &mytext = ((CValue *)m_clientobject)->GetPropertyText("Text");
-
- const unsigned int flag = polymat->GetFlag();
- struct MTFace* tface = 0;
- unsigned int *col = 0;
-
- if (flag & RAS_BLENDERMAT) {
- KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(polymat);
- tface = bl_mat->GetMTFace();
- col = bl_mat->GetMCol();
- } else {
- KX_PolygonMaterial* blenderpoly = static_cast<KX_PolygonMaterial*>(polymat);
- tface = blenderpoly->GetMTFace();
- col = blenderpoly->GetMCol();
- }
-
- GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib);
-}
-
-
-void KX_BlenderRenderTools::PushMatrix()
-{
- glPushMatrix();
-}
-
-void KX_BlenderRenderTools::PopMatrix()
-{
- glPopMatrix();
-}
-
-
-int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& viewmat)
-{
- // taken from blender source, incompatibility between Blender Object / GameObject
- KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo;
- float glviewmat[16];
- unsigned int count;
- std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin();
-
- for (count=0; count<m_numgllights; count++)
- glDisable((GLenum)(GL_LIGHT0+count));
-
- viewmat.getValue(glviewmat);
-
- glPushMatrix();
- glLoadMatrixf(glviewmat);
- for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
- {
- RAS_LightObject* lightdata = (*lit);
- KX_LightObject *kxlight = (KX_LightObject*)lightdata->m_light;
-
- if (kxlight->ApplyLight(kxscene, objectlayer, count))
- count++;
- }
- glPopMatrix();
-
- return count;
-}
-
-void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
-{
- int state = rasterizer->GetMotionBlurState();
- float motionblurvalue;
- if (state)
- {
- motionblurvalue = rasterizer->GetMotionBlurValue();
- if (state==1)
- {
- //bugfix:load color buffer into accum buffer for the first time(state=1)
- glAccum(GL_LOAD, 1.0);
- rasterizer->SetMotionBlurState(2);
- }
- else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) {
- glAccum(GL_MULT, motionblurvalue);
- glAccum(GL_ACCUM, 1-motionblurvalue);
- glAccum(GL_RETURN, 1.0);
- glFlush();
- }
- }
-}
-
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
deleted file mode 100644
index 228763e7d2d..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_BlenderRenderTools.h
- * \ingroup blroutines
- */
-
-#ifndef __KX_BLENDERRENDERTOOLS_H__
-#define __KX_BLENDERRENDERTOOLS_H__
-
-#ifdef _MSC_VER
- /* don't show stl-warnings */
-# pragma warning (disable:4786)
-#endif
-
-#include "RAS_IRenderTools.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-struct KX_ClientObjectInfo;
-class KX_RayCast;
-
-/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which
- * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon)
- * text, lighting.
- *
- * Most of this code is duplicated in GPC_RenderTools, so this should be
- * moved to some common location to avoid duplication. */
-
-class KX_BlenderRenderTools : public RAS_IRenderTools
-{
- int m_lastlightlayer;
- bool m_lastlighting;
- void *m_lastauxinfo;
- static unsigned int m_numgllights;
-
-public:
- KX_BlenderRenderTools();
- virtual ~KX_BlenderRenderTools();
-
- void EndFrame(RAS_IRasterizer* rasty);
- void BeginFrame(RAS_IRasterizer* rasty);
-
- void EnableOpenGLLights(RAS_IRasterizer *rasty);
- void DisableOpenGLLights();
- void ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat);
-
- void RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage);
-
-
- void RenderText3D(int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect);
-
- void RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height);
- void RenderText(int mode,
- class RAS_IPolyMaterial* polymat,
- float v1[3],
- float v2[3],
- float v3[3],
- float v4[3],
- int glattrib);
-
- void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
- int applyLights(int objectlayer, const MT_Transform& viewmat);
-
- void PushMatrix();
- void PopMatrix();
-
- bool RayHit(KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data);
- bool NeedRayCast(KX_ClientObjectInfo*) { return true; }
-
- virtual void MotionBlur(RAS_IRasterizer* rasterizer);
-
- virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderRenderTools")
-#endif
-};
-
-#endif /* __KX_BLENDERRENDERTOOLS_H__ */
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index d8ddb33ddc4..7ce1c7c815a 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -42,6 +42,7 @@
#include "BIK_api.h"
#include "BKE_action.h"
#include "BKE_armature.h"
+#include "BKE_library.h"
#include "BKE_constraint.h"
#include "CTR_Map.h"
@@ -120,6 +121,10 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
pchan->constraints.last = NULL;
}
+ if (pchan->custom) {
+ id_us_plus(&pchan->custom->id);
+ }
+
// fails to link, props are not used in the BGE yet.
#if 0
if (pchan->prop)
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index b0555abbea4..1b27fde4fa4 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -39,11 +39,9 @@
#include <algorithm>
#include "BL_BlenderDataConversion.h"
-#include "KX_BlenderGL.h"
#include "KX_BlenderScalarInterpolator.h"
#include "RAS_IPolygonMaterial.h"
-#include "KX_PolygonMaterial.h"
// Expressions
#include "ListValue.h"
@@ -80,7 +78,6 @@
#include "RAS_Polygon.h"
#include "RAS_TexVert.h"
#include "RAS_BucketManager.h"
-#include "RAS_IRenderTools.h"
#include "BL_Material.h"
#include "KX_BlenderMaterial.h"
#include "BL_Texture.h"
@@ -893,167 +890,33 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
RAS_IPolyMaterial* polymat = converter->FindCachedPolyMaterial(scene, ma);
BL_Material* bl_mat = converter->FindCachedBlenderMaterial(scene, ma);
KX_BlenderMaterial* kx_blmat = NULL;
- KX_PolygonMaterial* kx_polymat = NULL;
-
- if (converter->GetMaterials()) {
- /* do Blender Multitexture and Blender GLSL materials */
-
- /* first is the BL_Material */
- if (!bl_mat)
- {
- bl_mat = new BL_Material();
-
- ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol,
- converter->GetGLSLMaterials());
- if (ma && (ma->mode & MA_FACETEXTURE) == 0)
- converter->CacheBlenderMaterial(scene, ma, bl_mat);
- }
-
- const bool use_vcol = GetMaterialUseVColor(ma, bl_mat->glslmat);
- GetRGB(use_vcol, mface, mcol, ma, rgb);
+ /* first is the BL_Material */
+ if (!bl_mat)
+ {
+ bl_mat = new BL_Material();
- GetUVs(bl_mat, layers, mface, tface, uvs);
-
- /* then the KX_BlenderMaterial */
- if (polymat == NULL)
- {
- kx_blmat = new KX_BlenderMaterial();
+ ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol,
+ converter->GetGLSLMaterials());
- kx_blmat->Initialize(scene, bl_mat, (ma?&ma->game:NULL), lightlayer);
- polymat = static_cast<RAS_IPolyMaterial*>(kx_blmat);
- if (ma && (ma->mode & MA_FACETEXTURE) == 0)
- converter->CachePolyMaterial(scene, ma, polymat);
- }
+ if (ma && (ma->mode & MA_FACETEXTURE) == 0)
+ converter->CacheBlenderMaterial(scene, ma, bl_mat);
}
- else {
- /* do Texture Face materials */
- Image* bima = (tface)? (Image*)tface->tpage: NULL;
- STR_String imastr = (tface)? (bima? (bima)->id.name : "" ) : "";
-
- char alpha_blend=0;
- short tile=0;
- int tilexrep=4,tileyrep = 4;
-
- /* set material properties - old TexFace */
- if (ma) {
- alpha_blend = ma->game.alpha_blend;
- /* Commented out for now. If we ever get rid of
- * "Texture Face/Singletexture" we can then think about it */
-
- /* Texture Face mode ignores texture but requires "Face Textures to be True "*/
- #if 0
- if ((ma->mode &MA_FACETEXTURE)==0 && (ma->game.flag &GEMAT_TEXT)==0) {
- bima = NULL;
- imastr = "";
- alpha_blend = GEMAT_SOLID;
- }
- else {
- alpha_blend = ma->game.alpha_blend;
- }
- #endif
- }
- /* check for tface tex to fallback on */
- else {
- if (bima) {
- /* see if depth of the image is 32 */
- if (BKE_image_has_alpha(bima))
- alpha_blend = GEMAT_ALPHA;
- else
- alpha_blend = GEMAT_SOLID;
- }
- else {
- alpha_blend = GEMAT_SOLID;
- }
- }
-
- if (bima) {
- tilexrep = bima->xrep;
- tileyrep = bima->yrep;
- }
- /* set UV properties */
- if (tface) {
- uvs[0][0].setValue(tface->uv[0]);
- uvs[1][0].setValue(tface->uv[1]);
- uvs[2][0].setValue(tface->uv[2]);
-
- if (mface->v4)
- uvs[3][0].setValue(tface->uv[3]);
+ const bool use_vcol = GetMaterialUseVColor(ma, bl_mat->glslmat);
+ GetRGB(use_vcol, mface, mcol, ma, rgb);
- tile = tface->tile;
- }
- else {
- /* no texfaces */
- tile = 0;
- }
+ GetUVs(bl_mat, layers, mface, tface, uvs);
- /* get vertex colors */
- if (mcol) {
- /* we have vertex colors */
- rgb[0] = KX_Mcol2uint_new(mcol[0]);
- rgb[1] = KX_Mcol2uint_new(mcol[1]);
- rgb[2] = KX_Mcol2uint_new(mcol[2]);
-
- if (mface->v4)
- rgb[3] = KX_Mcol2uint_new(mcol[3]);
- }
- else {
- /* no vertex colors, take from material, otherwise white */
- unsigned int color = 0xFFFFFFFFL;
-
- if (ma)
- {
- union
- {
- unsigned char cp[4];
- unsigned int integer;
- } col_converter;
-
- col_converter.cp[3] = (unsigned char) (ma->r*255.0);
- col_converter.cp[2] = (unsigned char) (ma->g*255.0);
- col_converter.cp[1] = (unsigned char) (ma->b*255.0);
- col_converter.cp[0] = (unsigned char) (ma->alpha*255.0);
-
- color = col_converter.integer;
- }
-
- rgb[0] = KX_rgbaint2uint_new(color);
- rgb[1] = KX_rgbaint2uint_new(color);
- rgb[2] = KX_rgbaint2uint_new(color);
-
- if (mface->v4)
- rgb[3] = KX_rgbaint2uint_new(color);
- }
-
- // only zsort alpha + add
- const bool alpha = ELEM3(alpha_blend, GEMAT_ALPHA, GEMAT_ADD, GEMAT_ALPHA_SORT);
- const bool zsort = (alpha_blend == GEMAT_ALPHA_SORT);
- const bool light = (ma)?(ma->mode & MA_SHLESS)==0:default_light_mode;
-
- // don't need zort anymore, deal as if it it's alpha blend
- if (alpha_blend == GEMAT_ALPHA_SORT) alpha_blend = GEMAT_ALPHA;
-
- if (polymat == NULL)
- {
- kx_polymat = new KX_PolygonMaterial();
- kx_polymat->Initialize(imastr, ma, (int)mface->mat_nr,
- tile, tilexrep, tileyrep,
- alpha_blend, alpha, zsort, light, lightlayer, tface, (unsigned int*)mcol);
- polymat = static_cast<RAS_IPolyMaterial*>(kx_polymat);
-
- if (ma) {
- polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec;
- polymat->m_shininess = (float)ma->har/4.0f; // 0 < ma->har <= 512
- polymat->m_diffuse = MT_Vector3(ma->r, ma->g, ma->b)*(ma->emit + ma->ref);
- }
- else {
- polymat->m_specular.setValue(0.0f,0.0f,0.0f);
- polymat->m_shininess = 35.0;
- }
+ /* then the KX_BlenderMaterial */
+ if (polymat == NULL)
+ {
+ kx_blmat = new KX_BlenderMaterial();
+ kx_blmat->Initialize(scene, bl_mat, (ma?&ma->game:NULL), lightlayer);
+ polymat = static_cast<RAS_IPolyMaterial*>(kx_blmat);
+ if (ma && (ma->mode & MA_FACETEXTURE) == 0)
converter->CachePolyMaterial(scene, ma, polymat);
- }
}
// see if a bucket was reused or a new one was created
@@ -1063,8 +926,7 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
if (bucketCreated) {
// this is needed to free up memory afterwards
converter->RegisterPolyMaterial(polymat);
- if (converter->GetMaterials())
- converter->RegisterBlenderMaterial(bl_mat);
+ converter->RegisterBlenderMaterial(bl_mat);
}
return bucket;
@@ -1557,12 +1419,12 @@ static void BL_CreateGraphicObjectNew(KX_GameObject* gameobj,
PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
CcdGraphicController* ctrl = new CcdGraphicController(env, motionstate);
gameobj->SetGraphicController(ctrl);
- ctrl->setNewClientInfo(gameobj->getClientInfo());
- ctrl->setLocalAabb(localAabbMin, localAabbMax);
+ ctrl->SetNewClientInfo(gameobj->getClientInfo());
+ ctrl->SetLocalAabb(localAabbMin, localAabbMax);
if (isActive) {
// add first, this will create the proxy handle, only if the object is visible
if (gameobj->GetVisible())
- env->addCcdGraphicController(ctrl);
+ env->AddCcdGraphicController(ctrl);
// update the mesh if there is a deformer, this will also update the bounding box for modifiers
RAS_Deformer* deformer = gameobj->GetDeformer();
if (deformer)
@@ -1874,7 +1736,7 @@ static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
-static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter)
+static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRasterizer *rasterizer, KX_BlenderSceneConverter *converter)
{
RAS_LightObject lightobj;
KX_LightObject *gamelight;
@@ -1913,7 +1775,7 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l
lightobj.m_type = RAS_LightObject::LIGHT_NORMAL;
}
- gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools,
+ gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rasterizer,
lightobj, glslmat);
return gamelight;
@@ -1934,7 +1796,7 @@ static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_Blen
static KX_GameObject *gameobject_from_blenderobject(
Object *ob,
KX_Scene *kxscene,
- RAS_IRenderTools *rendertools,
+ RAS_IRasterizer *rendertools,
KX_BlenderSceneConverter *converter,
bool libloading)
{
@@ -2165,22 +2027,8 @@ static void UNUSED_FUNCTION(RBJconstraints)(Object *ob)//not used
}
#include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
#include "PHY_DynamicTypes.h"
-#if 0 /* UNUSED */
-static KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc) {//not used
-
- for (int j=0;j<sumolist->GetCount();j++)
- {
- KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j);
- if (gameobje->GetName()==busc)
- return gameobje->GetPhysicsController();
- }
-
- return 0;
-}
-#endif
static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist)
{
@@ -2359,7 +2207,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
KX_Scene* kxscene,
KX_KetsjiEngine* ketsjiEngine,
e_PhysicsEngine physics_engine,
- RAS_IRenderTools* rendertools,
+ RAS_IRasterizer* rendertools,
RAS_ICanvas* canvas,
KX_BlenderSceneConverter* converter,
bool alwaysUseExpandFraming,
@@ -2723,7 +2571,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
kxscene->SetDbvtOcclusionRes(blenderscene->gm.occlusionRes);
}
if (blenderscene->world)
- kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->gm.physubstep);
+ kxscene->GetPhysicsEnvironment()->SetNumTimeSubSteps(blenderscene->gm.physubstep);
// now that the scenegraph is complete, let's instantiate the deformers.
// We need that to create reusable derived mesh and physic shapes
@@ -2814,12 +2662,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
KX_GameObject *gotar=getGameOb(dat->tar->id.name+2,sumolist);
if (gotar && ((gotar->GetLayer()&activeLayerBitInfo)!=0) && gotar->GetPhysicsController())
- physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData();
+ physctr2 = gotar->GetPhysicsController();
}
if (gameobj->GetPhysicsController())
{
- PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData();
+ PHY_IPhysicsController* physctrl = gameobj->GetPhysicsController();
//we need to pass a full constraint frame, not just axis
//localConstraintFrameBasis
@@ -2828,7 +2676,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
MT_Vector3 axis1 = localCFrame.getColumn(1);
MT_Vector3 axis2 = localCFrame.getColumn(2);
- int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,
+ int constraintId = kxscene->GetPhysicsEnvironment()->CreateConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,
(float)dat->pivY,(float)dat->pivZ,
(float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
(float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
@@ -2844,11 +2692,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
if (dat->flag & dofbit)
{
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
+ kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
} else
{
//minLimit > maxLimit means free(disabled limit) for this degree of freedom
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+ kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
}
dofbit<<=1;
}
@@ -2862,12 +2710,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
if (dat->flag & dofbit)
{
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
+ kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
}
else
{
//maxLimit < 0 means free(disabled limit) for this degree of freedom
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+ kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
}
dofbit<<=1;
}
@@ -2879,12 +2727,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
if (dat->flag & dofbit)
{
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,
+ kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,
dat->minLimit[dof],dat->maxLimit[dof]);
} else
{
//minLimit > maxLimit means free(disabled limit) for this degree of freedom
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+ kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
}
}
}
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h
index f3a680929fb..6bd77954b88 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.h
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.h
@@ -44,7 +44,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
class KX_Scene* kxscene,
class KX_KetsjiEngine* ketsjiEngine,
e_PhysicsEngine physics_engine,
- class RAS_IRenderTools* rendertools,
+ class RAS_IRasterizer* rendertools,
class RAS_ICanvas* canvas,
class KX_BlenderSceneConverter* sceneconverter,
bool alwaysUseExpandFraming,
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp
index ec52eaac637..82f49ad5227 100644
--- a/source/gameengine/Converter/BL_ModifierDeformer.cpp
+++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp
@@ -192,7 +192,7 @@ bool BL_ModifierDeformer::Update(void)
float min_r[3], max_r[3];
INIT_MINMAX(min_r, max_r);
m_dm->getMinMax(m_dm, min_r, max_r);
- ctrl->setLocalAabb(min_r, max_r);
+ ctrl->SetLocalAabb(min_r, max_r);
}
}
m_lastModifierUpdate=m_gameobj->GetLastFrame();
diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp
index 25da8155867..f1f264b3367 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.cpp
+++ b/source/gameengine/Converter/BlenderWorldInfo.cpp
@@ -33,7 +33,6 @@
#include <stdio.h> // printf()
#include "BlenderWorldInfo.h"
-#include "KX_BlenderGL.h"
/* This little block needed for linking to Blender... */
#ifdef WIN32
diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h
index 30de5e89269..af535d65d62 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.h
+++ b/source/gameengine/Converter/BlenderWorldInfo.h
@@ -33,7 +33,6 @@
#define __BLENDERWORLDINFO_H__
#include "MT_CmMatrix4x4.h"
#include "KX_WorldInfo.h"
-#include "KX_BlenderGL.h"
class BlenderWorldInfo : public KX_WorldInfo
{
diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt
index 084a85c8a1f..9c0d25e56ff 100644
--- a/source/gameengine/Converter/CMakeLists.txt
+++ b/source/gameengine/Converter/CMakeLists.txt
@@ -37,7 +37,6 @@ set(INC
../Physics/common
../Rasterizer
../Rasterizer/RAS_OpenGLRasterizer
- ../Rasterizer/RAS_OpenGLRasterizer
../SceneGraph
../../blender
../../blender/blenkernel
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 98af99825e1..e682f335608 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -42,11 +42,9 @@
#include "PHY_IPhysicsEnvironment.h"
#include "KX_KetsjiEngine.h"
#include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import
-#include "KX_IPhysicsController.h"
#include "BL_Material.h"
#include "BL_ActionActuator.h"
#include "KX_BlenderMaterial.h"
-#include "KX_PolygonMaterial.h"
#include "BL_System.h"
@@ -313,7 +311,7 @@ struct BlenderDebugDraw : public btIDebugDraw
#endif
void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
- class RAS_IRenderTools* rendertools,
+ class RAS_IRasterizer* rendertools,
class RAS_ICanvas* canvas,
bool libloading)
{
@@ -356,15 +354,15 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
case UseBullet:
{
CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment(useDbvtCulling);
- ccdPhysEnv->setDebugDrawer(new BlenderDebugDraw());
- ccdPhysEnv->setDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
- ccdPhysEnv->setDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
- ccdPhysEnv->setDeactivationTime(blenderscene->gm.deactivationtime);
+ ccdPhysEnv->SetDebugDrawer(new BlenderDebugDraw());
+ ccdPhysEnv->SetDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
+ ccdPhysEnv->SetDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
+ ccdPhysEnv->SetDeactivationTime(blenderscene->gm.deactivationtime);
SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/
int visualizePhysics = SYS_GetCommandLineInt(syshandle,"show_physics",0);
if (visualizePhysics)
- ccdPhysEnv->setDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
+ ccdPhysEnv->SetDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
//todo: get a button in blender ?
//disable / enable debug drawing (contact points, aabb's etc)
@@ -710,7 +708,6 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
if (gameObj->IsDynamic())
{
- //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
Object* blenderObject = gameObj->GetBlenderObject();
if (blenderObject)
@@ -826,7 +823,6 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
Object* blenderObject = gameObj->GetBlenderObject();
if (blenderObject && blenderObject->parent==NULL && gameObj->IsDynamic())
{
- //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
if (blenderObject->adt==NULL)
BKE_id_add_animdata(&blenderObject->id);
@@ -945,7 +941,6 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
if (gameObj->IsDynamic())
{
- //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
#if 0
Object* blenderObject = gameObj->GetBlenderObject();
@@ -1419,15 +1414,8 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie)
RAS_IPolyMaterial *mat= (*polymit).second;
Material *bmat= NULL;
- /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */
- if (mat->GetFlag() & RAS_BLENDERMAT) {
- KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat);
- bmat= bl_mat->GetBlenderMaterial();
-
- } else {
- KX_PolygonMaterial *kx_mat = static_cast<KX_PolygonMaterial*>(mat);
- bmat= kx_mat->GetBlenderMaterial();
- }
+ KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat);
+ bmat= bl_mat->GetBlenderMaterial();
if (IS_TAGGED(bmat)) {
/* only remove from bucket */
@@ -1444,15 +1432,8 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie)
RAS_IPolyMaterial *mat= (*polymit).second;
Material *bmat= NULL;
- /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */
- if (mat->GetFlag() & RAS_BLENDERMAT) {
- KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat);
- bmat= bl_mat->GetBlenderMaterial();
-
- } else {
- KX_PolygonMaterial *kx_mat = static_cast<KX_PolygonMaterial*>(mat);
- bmat= kx_mat->GetBlenderMaterial();
- }
+ KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat);
+ bmat= bl_mat->GetBlenderMaterial();
if (bmat) {
//printf("FOUND MAT '%s' !!! ", ((ID*)bmat)->name+2);
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
index 7ed75ad7614..3ae90301553 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -111,7 +111,7 @@ public:
*/
virtual void ConvertScene(
class KX_Scene* destinationscene,
- class RAS_IRenderTools* rendertools,
+ class RAS_IRasterizer* rendertools,
class RAS_ICanvas* canvas,
bool libloading=false
);
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 3bb12c12cd1..b9bd9aabc54 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -80,7 +80,6 @@
#include "KX_Scene.h"
#include "IntValue.h"
#include "KX_BlenderKeyboardDevice.h"
-#include "KX_BlenderGL.h"
#include "RAS_ICanvas.h"
#include "PHY_IPhysicsEnvironment.h"
diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
index d860b2ee694..fcdaaaa761a 100644
--- a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
+++ b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
@@ -48,7 +48,6 @@
#include "CcdPhysicsController.h"
#include "BulletSoftBody/btSoftBody.h"
-#include "KX_BulletPhysicsController.h"
#include "btBulletDynamicsCommon.h"
void KX_SoftBodyDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
@@ -66,7 +65,7 @@ void KX_SoftBodyDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
bool KX_SoftBodyDeformer::Apply(class RAS_IPolyMaterial *polymat)
{
- KX_BulletPhysicsController* ctrl = (KX_BulletPhysicsController*) m_gameobj->GetPhysicsController();
+ CcdPhysicsController* ctrl = (CcdPhysicsController*) m_gameobj->GetPhysicsController();
if (!ctrl)
return false;
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
index 41a0fa7d095..d1c7b58a52c 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
@@ -141,6 +141,7 @@ CValue* SCA_ExpressionController::FindIdentifier(const STR_String& identifiernam
{
identifierval = new CBoolValue(sensor->GetState());
//identifierval = sensor->AddRef();
+ break;
}
//if (!sensor->IsPositiveTrigger())
diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt
index 4f2531cec2a..2fc4df86332 100644
--- a/source/gameengine/GamePlayer/common/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/common/CMakeLists.txt
@@ -63,12 +63,10 @@ set(SRC
GPC_Canvas.cpp
GPC_KeyboardDevice.cpp
GPC_MouseDevice.cpp
- GPC_RenderTools.cpp
GPC_Canvas.h
GPC_KeyboardDevice.h
GPC_MouseDevice.h
- GPC_RenderTools.h
)
add_definitions(-DGLEW_STATIC)
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
deleted file mode 100644
index 0d851c4f10d..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/GamePlayer/common/GPC_RenderTools.cpp
- * \ingroup player
- */
-
-
-#include "GL/glew.h"
-
-#include "RAS_IRenderTools.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_LightObject.h"
-#include "RAS_ICanvas.h"
-#include "RAS_GLExtensionManager.h"
-#include "RAS_MeshObject.h"
-
-#include "KX_GameObject.h"
-#include "KX_PolygonMaterial.h"
-#include "KX_BlenderMaterial.h"
-#include "KX_RayCast.h"
-#include "KX_IPhysicsController.h"
-#include "KX_Light.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-
-#include "STR_String.h"
-
-#include "GPU_draw.h"
-
-#include "BKE_bmfont.h" // for text printing
-#include "BKE_bmfont_types.h"
-
-#include "GPC_RenderTools.h"
-
-extern "C" {
-#include "BLF_api.h"
-}
-
-
-unsigned int GPC_RenderTools::m_numgllights;
-
-GPC_RenderTools::GPC_RenderTools()
-{
- glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights);
- if (m_numgllights < 8)
- m_numgllights = 8;
-}
-
-GPC_RenderTools::~GPC_RenderTools()
-{
-}
-
-void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty)
-{
- m_clientobject = NULL;
- m_lastlightlayer = -1;
- m_lastauxinfo = NULL;
- m_lastlighting = true; /* force disable in DisableOpenGLLights() */
- DisableOpenGLLights();
-}
-
-void GPC_RenderTools::EndFrame(RAS_IRasterizer* rasty)
-{
-}
-
-/* ProcessLighting performs lighting on objects. the layer is a bitfield that
- * contains layer information. There are 20 'official' layers in blender. A
- * light is applied on an object only when they are in the same layer. OpenGL
- * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in
- * a scene. */
-
-void GPC_RenderTools::ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat)
-{
- bool enable = false;
- int layer= -1;
-
- /* find the layer */
- if (uselights) {
- if (m_clientobject)
- layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
- }
-
- /* avoid state switching */
- if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo)
- return;
-
- m_lastlightlayer = layer;
- m_lastauxinfo = m_auxilaryClientInfo;
-
- /* enable/disable lights as needed */
- if (layer >= 0)
- enable = applyLights(layer, viewmat);
-
- if (enable)
- EnableOpenGLLights(rasty);
- else
- DisableOpenGLLights();
-}
-
-void GPC_RenderTools::EnableOpenGLLights(RAS_IRasterizer *rasty)
-{
- if (m_lastlighting == true)
- return;
-
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
-
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (rasty->GetCameraOrtho())? GL_FALSE: GL_TRUE);
- if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
-
- m_lastlighting = true;
-}
-
-void GPC_RenderTools::DisableOpenGLLights()
-{
- if (m_lastlighting == false)
- return;
-
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
-
- m_lastlighting = false;
-}
-
-
-void GPC_RenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj)
-{
- if (m_clientobject != obj)
- {
- bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling());
- rasty->SetFrontFace(ccw);
-
- m_clientobject = obj;
- }
-}
-
-bool GPC_RenderTools::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void * const data)
-{
- double* const oglmatrix = (double* const) data;
-
- RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
- if (!poly->IsVisible())
- return false;
-
- MT_Point3 resultpoint(result->m_hitPoint);
- MT_Vector3 resultnormal(result->m_hitNormal);
- MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
- MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
- left = (dir.cross(resultnormal)).safe_normalized();
- // for the up vector, we take the 'resultnormal' returned by the physics
-
- double maat[16] = {left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- resultnormal[0], resultnormal[1], resultnormal[2], 0,
- 0, 0, 0, 1};
-
- glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
- //glMultMatrixd(oglmatrix);
- glMultMatrixd(maat);
- return true;
-}
-
-void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode )
-{
- /* FIXME:
- blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
- MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed.
-
- Program received signal SIGABRT, Aborted.
- [Switching to Thread 16384 (LWP 1519)]
- 0x40477571 in kill () from /lib/libc.so.6
- (gdb) bt
- #7 0x08334368 in MT_Vector3::normalized() const ()
- #8 0x0833e6ec in GPC_RenderTools::applyTransform(RAS_IRasterizer*, double*, int) ()
- */
-
- if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
- objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
- {
- // rotate the billboard/halo
- //page 360/361 3D Game Engine Design, David Eberly for a discussion
- // on screen aligned and axis aligned billboards
- // assumed is that the preprocessor transformed all billboard polygons
- // so that their normal points into the positive x direction (1.0, 0.0, 0.0)
- // when new parenting for objects is done, this rotation
- // will be moved into the object
-
- MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- MT_Point3 campos = rasty->GetCameraPosition();
- MT_Vector3 dir = (campos - objpos).safe_normalized();
- MT_Vector3 up(0,0,1.0);
-
- KX_GameObject* gameobj = (KX_GameObject *)this->m_clientobject;
- // get scaling of halo object
- MT_Vector3 size = gameobj->GetSGNode()->GetWorldScaling();
-
- bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
- if (screenaligned)
- {
- up = (up - up.dot(dir) * dir).safe_normalized();
- } else
- {
- dir = (dir - up.dot(dir)*up).safe_normalized();
- }
-
- MT_Vector3 left = dir.normalized();
- dir = (left.cross(up)).normalized();
-
- // we have calculated the row vectors, now we keep
- // local scaling into account:
-
- left *= size[0];
- dir *= size[1];
- up *= size[2];
-
- double maat[16] = {left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- up[0], up[1], up[2], 0,
- 0, 0, 0, 1};
-
- glTranslated(objpos[0],objpos[1],objpos[2]);
- glMultMatrixd(maat);
- }
- else {
- if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
- {
- // shadow must be cast to the ground, physics system needed here!
- MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- KX_GameObject *gameobj = (KX_GameObject *)this->m_clientobject;
- MT_Vector3 direction = MT_Vector3(0,0,-1);
-
- direction.normalize();
- direction *= 100000;
-
- MT_Point3 topoint = frompoint + direction;
-
- KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
- PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
- KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
-
- KX_GameObject *parent = gameobj->GetParent();
- if (!physics_controller && parent)
- physics_controller = parent->GetPhysicsController();
- if (parent)
- parent->Release();
-
- KX_RayCast::Callback<GPC_RenderTools> callback(this, physics_controller, oglmatrix);
- if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
- {
- // couldn't find something to cast the shadow on...
- glMultMatrixd(oglmatrix);
- }
- else
- { // we found the "ground", but the cast matrix doesn't take
- // scaling in consideration, so we must apply the object scale
- MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
- glScalef(size[0], size[1], size[2]);
- }
- } else
- {
-
- // 'normal' object
- glMultMatrixd(oglmatrix);
- }
- }
-}
-
-void GPC_RenderTools::RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage)
-{
- // Save and change OpenGL settings
- int texture2D;
- glGetIntegerv(GL_TEXTURE_2D, (GLint*)&texture2D);
- glDisable(GL_TEXTURE_2D);
- int fog;
- glGetIntegerv(GL_FOG, (GLint*)&fog);
- glDisable(GL_FOG);
-
- int light;
- glGetIntegerv(GL_LIGHTING, (GLint*)&light);
- glDisable(GL_LIGHTING);
-
- glDisable(GL_DEPTH_TEST);
-
- // Set up viewing settings
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, width, 0, height, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- yco = height - yco;
- int barsize = 50;
-
- // draw in black first
- glColor3ub(0, 0, 0);
- glBegin(GL_QUADS);
- glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10);
- glVertex2f(xco + 1, yco - 1 + 10);
- glVertex2f(xco + 1, yco - 1);
- glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1);
- glEnd();
-
- glColor3ub(255, 255, 255);
- glBegin(GL_QUADS);
- glVertex2f(xco + 1 + barsize * percentage, yco + 10);
- glVertex2f(xco, yco + 10);
- glVertex2f(xco, yco);
- glVertex2f(xco + 1 + barsize * percentage, yco);
- glEnd();
-
- // Restore view settings
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-
- // Restore OpenGL Settings
- if (fog)
- glEnable(GL_FOG);
- else
- glDisable(GL_FOG);
-
- if (texture2D)
- glEnable(GL_TEXTURE_2D);
- else
- glDisable(GL_TEXTURE_2D);
- if (light)
- glEnable(GL_LIGHTING);
- else
- glDisable(GL_LIGHTING);
-}
-
-
-void GPC_RenderTools::RenderText3D( int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect)
-{
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */
-
- if (GLEW_ARB_multitexture) {
- for (int i=0; i<MAXTEX; i++) {
- glActiveTextureARB(GL_TEXTURE0_ARB+i);
-
- if (GLEW_ARB_texture_cube_map)
- if (glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
-
- if (glIsEnabled(GL_TEXTURE_2D))
- glDisable(GL_TEXTURE_2D);
- }
-
- glActiveTextureARB(GL_TEXTURE0_ARB);
- }
- else {
- if (GLEW_ARB_texture_cube_map)
- if (glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
-
- if (glIsEnabled(GL_TEXTURE_2D))
- glDisable(GL_TEXTURE_2D);
- }
-
- /* the actual drawing */
- glColor4fv(color);
-
- /* multiply the text matrix by the object matrix */
- BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
- BLF_matrix(fontid, mat);
-
- /* aspect is the inverse scale that allows you to increase */
- /* your resolution without sizing the final text size */
- /* the bigger the size, the smaller the aspect */
- BLF_aspect(fontid, aspect, aspect, aspect);
-
- BLF_size(fontid, size, dpi);
- BLF_position(fontid, 0, 0, 0);
- BLF_draw(fontid, text, 65535);
-
- BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
- glEnable(GL_DEPTH_TEST);
-}
-
-
-
-void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height)
-{
- /*
- STR_String tmpstr(text);
- char* s = tmpstr.Ptr(); */
-
- // Save and change OpenGL settings
- int texture2D;
- glGetIntegerv(GL_TEXTURE_2D, (GLint*)&texture2D);
- glDisable(GL_TEXTURE_2D);
- int fog;
- glGetIntegerv(GL_FOG, (GLint*)&fog);
- glDisable(GL_FOG);
-
- int light;
- glGetIntegerv(GL_LIGHTING, (GLint*)&light);
- glDisable(GL_LIGHTING);
-
- glDisable(GL_DEPTH_TEST);
-
- // Set up viewing settings
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, width, 0, height, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Actual drawing (draw black first if padded)
- if (mode == RAS_IRenderTools::RAS_TEXT_PADDED)
- {
- glColor3ub(0, 0, 0);
- BLF_draw_default(xco+1, height-yco-1, 0.f, text, 65536);
- }
-
- glColor3ub(255, 255, 255);
- BLF_draw_default(xco, height-yco, 0.f, text, 65536);
-
- // Restore view settings
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-
- // Restore OpenGL Settings
- if (fog)
- glEnable(GL_FOG);
- else
- glDisable(GL_FOG);
-
- if (texture2D)
- glEnable(GL_TEXTURE_2D);
- else
- glDisable(GL_TEXTURE_2D);
- if (light)
- glEnable(GL_LIGHTING);
- else
- glDisable(GL_LIGHTING);
-}
-
-/* Render Text renders text into a (series of) polygon, using a texture font,
- * Each character consists of one polygon (one quad or two triangles) */
-
-void GPC_RenderTools::RenderText(
- int mode,
- RAS_IPolyMaterial* polymat,
- float v1[3], float v2[3], float v3[3], float v4[3], int glattrib)
-{
- const STR_String &mytext = ((CValue *)m_clientobject)->GetPropertyText("Text");
-
- const unsigned int flag = polymat->GetFlag();
- struct MTFace* tface = 0;
- unsigned int *col = 0;
-
- if (flag & RAS_BLENDERMAT) {
- KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(polymat);
- tface = bl_mat->GetMTFace();
- col = bl_mat->GetMCol();
- } else {
- KX_PolygonMaterial* blenderpoly = static_cast<KX_PolygonMaterial*>(polymat);
- tface = blenderpoly->GetMTFace();
- col = blenderpoly->GetMCol();
- }
-
- GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib);
-}
-
-
-void GPC_RenderTools::PushMatrix()
-{
- glPushMatrix();
-}
-
-void GPC_RenderTools::PopMatrix()
-{
- glPopMatrix();
-}
-
-
-int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat)
-{
- // taken from blender source, incompatibility between Blender Object / GameObject
- KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo;
- float glviewmat[16];
- unsigned int count;
- std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin();
-
- for (count=0; count<m_numgllights; count++)
- glDisable((GLenum)(GL_LIGHT0+count));
-
- viewmat.getValue(glviewmat);
-
- glPushMatrix();
- glLoadMatrixf(glviewmat);
- for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
- {
- RAS_LightObject* lightdata = (*lit);
- KX_LightObject *kxlight = (KX_LightObject*)lightdata->m_light;
-
- if (kxlight->ApplyLight(kxscene, objectlayer, count))
- count++;
- }
- glPopMatrix();
-
- return count;
-}
-
-void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
-{
- int state = rasterizer->GetMotionBlurState();
- float motionblurvalue;
- if (state)
- {
- motionblurvalue = rasterizer->GetMotionBlurValue();
- if (state==1)
- {
- //bugfix:load color buffer into accum buffer for the first time(state=1)
- glAccum(GL_LOAD, 1.0);
- rasterizer->SetMotionBlurState(2);
- }
- else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) {
- glAccum(GL_MULT, motionblurvalue);
- glAccum(GL_ACCUM, 1-motionblurvalue);
- glAccum(GL_RETURN, 1.0);
- glFlush();
- }
- }
-}
-
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
deleted file mode 100644
index f4dcddd3250..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file GPC_RenderTools.h
- * \ingroup player
- */
-
-#ifndef __GPC_RENDERTOOLS_H__
-#define __GPC_RENDERTOOLS_H__
-
-#ifdef WIN32
-// don't show stl-warnings
-#pragma warning (disable:4786)
-#include <windows.h>
-#endif /* WIN32 */
-
-#include "RAS_IRenderTools.h"
-
-struct KX_ClientObjectInfo;
-class KX_RayCast;
-
-/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which
- * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon)
- * text, lighting.
- *
- * Most of this code is duplicated in KX_BlenderRenderTools, so this should be
- * moved to some common location to avoid duplication. */
-
-class GPC_RenderTools : public RAS_IRenderTools
-{
- int m_lastlightlayer;
- bool m_lastlighting;
- void *m_lastauxinfo;
- static unsigned int m_numgllights;
-
-// XXX BMF_Font* m_font;
-
-public:
- GPC_RenderTools();
- virtual ~GPC_RenderTools();
-
- void EndFrame(RAS_IRasterizer* rasty);
- void BeginFrame(RAS_IRasterizer* rasty);
-
- void EnableOpenGLLights(RAS_IRasterizer *rasty);
- void DisableOpenGLLights();
- void ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat);
-
- void RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage);
-
- void RenderText3D(int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect);
- /* \attention mode is ignored here */
- void RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height);
- void RenderText(int mode,
- class RAS_IPolyMaterial* polymat,
- float v1[3],
- float v2[3],
- float v3[3],
- float v4[3],
- int glattrib);
-
- void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
- int applyLights(int objectlayer, const MT_Transform& viewmat);
-
- void PushMatrix();
- void PopMatrix();
-
- bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
- bool NeedRayCast(KX_ClientObjectInfo* client) { return true; }
-
- virtual void MotionBlur(RAS_IRasterizer* rasterizer);
-
- virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj);
-};
-
-#endif /* __GPC_RENDERTOOLS_H__ */
diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript
index 85c4b091718..e30c2eb5859 100644
--- a/source/gameengine/GamePlayer/common/SConscript
+++ b/source/gameengine/GamePlayer/common/SConscript
@@ -33,7 +33,6 @@ source_files = [
'GPC_Canvas.cpp',
'GPC_KeyboardDevice.cpp',
'GPC_MouseDevice.cpp',
- 'GPC_RenderTools.cpp',
]
incs = [
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index c74e3daf7b2..d51d0bf5c10 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -86,7 +86,6 @@ extern "C"
#include "NG_LoopBackNetworkDeviceInterface.h"
#include "GPC_MouseDevice.h"
-#include "GPC_RenderTools.h"
#include "GPG_Canvas.h"
#include "GPG_KeyboardDevice.h"
#include "GPG_System.h"
@@ -126,8 +125,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system)
m_kxsystem(0),
m_keyboard(0),
m_mouse(0),
- m_canvas(0),
- m_rendertools(0),
+ m_canvas(0),
m_rasterizer(0),
m_sceneconverter(0),
m_networkdevice(0),
@@ -591,10 +589,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
m_canvas->Init();
if (gm->flag & GAME_SHOW_MOUSE)
m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
-
- m_rendertools = new GPC_RenderTools();
- if (!m_rendertools)
- goto initFailed;
//Don't use displaylists with VBOs
//If auto starts using VBOs, make sure to check for that here
@@ -639,7 +633,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
m_ketsjiengine->SetMouseDevice(m_mouse);
m_ketsjiengine->SetNetworkDevice(m_networkdevice);
m_ketsjiengine->SetCanvas(m_canvas);
- m_ketsjiengine->SetRenderTools(m_rendertools);
m_ketsjiengine->SetRasterizer(m_rasterizer);
KX_KetsjiEngine::SetExitKey(ConvertKeyCode(gm->exitkey));
@@ -667,10 +660,8 @@ initFailed:
delete m_mouse;
delete m_keyboard;
delete m_rasterizer;
- delete m_rendertools;
delete m_canvas;
m_canvas = NULL;
- m_rendertools = NULL;
m_rasterizer = NULL;
m_keyboard = NULL;
m_mouse = NULL;
@@ -712,7 +703,7 @@ bool GPG_Application::startEngine(void)
// if (always_use_expand_framing)
// sceneconverter->SetAlwaysUseExpandFraming(true);
- if (m_blendermat && (m_globalSettings->matmode != GAME_MAT_TEXFACE))
+ if (m_blendermat)
m_sceneconverter->SetMaterials(true);
if (m_blenderglslmat && (m_globalSettings->matmode == GAME_MAT_GLSL))
m_sceneconverter->SetGLSLMaterials(true);
@@ -752,7 +743,7 @@ bool GPG_Application::startEngine(void)
#endif
m_sceneconverter->ConvertScene(
startscene,
- m_rendertools,
+ m_rasterizer,
m_canvas);
m_ketsjiengine->AddScene(startscene);
@@ -870,11 +861,6 @@ void GPG_Application::exitEngine()
delete m_rasterizer;
m_rasterizer = 0;
}
- if (m_rendertools)
- {
- delete m_rendertools;
- m_rendertools = 0;
- }
if (m_canvas)
{
delete m_canvas;
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h
index f141443e738..2d21b50e664 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h
@@ -48,7 +48,6 @@ class GHOST_ISystem;
class GHOST_ITimerTask;
class GHOST_IWindow;
class GPC_MouseDevice;
-class GPC_RenderTools;
class GPG_Canvas;
class GPG_KeyboardDevice;
class GPG_System;
@@ -151,8 +150,6 @@ protected:
GPC_MouseDevice* m_mouse;
/** The game engine's canvas abstraction. */
GPG_Canvas* m_canvas;
- /** The game engine's platform dependent render tools. */
- GPC_RenderTools* m_rendertools;
/** the rasterizer */
RAS_IRasterizer* m_rasterizer;
/** Converts Blender data files. */
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 5bed4fa40b6..14b5bca1101 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -40,11 +40,6 @@
#endif /* __alpha__ */
#endif /* __linux__ */
-#ifdef __APPLE__
-// Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh)
-//#include <Carbon/Carbon.h>
-//#include <CFBundle.h>
-#endif // __APPLE__
#include "KX_KetsjiEngine.h"
#include "KX_PythonInit.h"
#include "KX_PythonMain.h"
@@ -88,6 +83,8 @@ extern "C"
#include "BLF_translation.h"
extern int datatoc_bfont_ttf_size;
extern char datatoc_bfont_ttf[];
+extern int datatoc_bmonofont_ttf_size;
+extern char datatoc_bmonofont_ttf[];
#ifdef __cplusplus
}
@@ -424,27 +421,6 @@ int main(int argc, char** argv)
#endif /* __linux__ */
BLI_init_program_path(argv[0]);
BLI_init_temporary_dir(NULL);
-#ifdef __APPLE__
- // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh)
- /*
- IBNibRef nibRef;
- WindowRef window;
- OSStatus err;
-
- // Create a Nib reference passing the name of the nib file (without the .nib extension)
- // CreateNibReference only searches into the application bundle.
- err = ::CreateNibReference(CFSTR("main"), &nibRef);
- if (err) return -1;
-
- // Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar
- // object. This name is set in InterfaceBuilder when the nib is created.
- err = ::SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
- if (err) return -1;
-
- // We don't need the nib reference anymore.
- ::DisposeNibReference(nibRef);
- */
-#endif // __APPLE__
// We don't use threads directly in the BGE, but we need to call this so things like
// freeing up GPU_Textures works correctly.
@@ -475,6 +451,8 @@ int main(int argc, char** argv)
BLF_lang_set("");
BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+ if (blf_mono_font == -1)
+ blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
// Parse command line options
#if defined(DEBUG)
@@ -771,11 +749,6 @@ int main(int argc, char** argv)
if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION)
#endif
{
-#ifdef __APPLE__
- //SYS_WriteCommandLineInt(syshandle, "show_framerate", 1);
- //SYS_WriteCommandLineInt(syshandle, "nomipmap", 1);
- //fullScreen = false; // Can't use full screen
-#endif
if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) {
GPU_set_mipmap(0);
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index 6d9b22eed91..a974ffbf672 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -34,6 +34,8 @@
#include "KX_IpoConvert.h"
#include "KX_GameObject.h"
+#include "SG_Controller.h"
+
// These three are for getting the action from the logic manager
#include "KX_Scene.h"
#include "SCA_LogicManager.h"
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index 7da63dcc6f4..141dd5e25f3 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -71,7 +71,6 @@ set(SRC
BL_Texture.cpp
KX_ArmatureSensor.cpp
KX_BlenderMaterial.cpp
- KX_BulletPhysicsController.cpp
KX_Camera.cpp
KX_CameraActuator.cpp
KX_CameraIpoSGController.cpp
@@ -86,7 +85,6 @@ set(SRC
KX_GameObject.cpp
KX_IpoConvert.cpp
KX_IPO_SGController.cpp
- KX_IPhysicsController.cpp
KX_IpoActuator.cpp
KX_KetsjiEngine.cpp
KX_Light.cpp
@@ -103,7 +101,6 @@ set(SRC
KX_OrientationInterpolator.cpp
KX_ParentActuator.cpp
KX_PolyProxy.cpp
- KX_PolygonMaterial.cpp
KX_PositionInterpolator.cpp
KX_PyConstraintBinding.cpp
KX_PyMath.cpp
@@ -147,7 +144,6 @@ set(SRC
BL_Texture.h
KX_ArmatureSensor.h
KX_BlenderMaterial.h
- KX_BulletPhysicsController.h
KX_Camera.h
KX_CameraActuator.h
KX_CameraIpoSGController.h
@@ -165,7 +161,6 @@ set(SRC
KX_IpoConvert.h
KX_IPOTransform.h
KX_IPO_SGController.h
- KX_IPhysicsController.h
KX_IScalarInterpolator.h
KX_ISceneConverter.h
KX_ISystem.h
@@ -186,7 +181,6 @@ set(SRC
KX_ParentActuator.h
KX_PhysicsEngineEnums.h
KX_PolyProxy.h
- KX_PolygonMaterial.h
KX_PositionInterpolator.h
KX_PyConstraintBinding.h
KX_PyMath.h
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
index e5b8159753b..efaaed7b567 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
@@ -129,13 +129,13 @@ KX_BlenderMaterial::~KX_BlenderMaterial()
OnExit();
}
-MTFace* KX_BlenderMaterial::GetMTFace(void) const
+MTFace* KX_BlenderMaterial::GetMTFace() const
{
// fonts on polys
return &mMaterial->tface;
}
-unsigned int* KX_BlenderMaterial::GetMCol(void) const
+unsigned int* KX_BlenderMaterial::GetMCol() const
{
// fonts on polys
return mMaterial->rgb;
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h
index 0a2675f04a8..b7c64215eaf 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.h
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h
@@ -79,8 +79,8 @@ public:
Material* GetBlenderMaterial() const;
Image* GetBlenderImage() const;
- MTFace* GetMTFace(void) const;
- unsigned int* GetMCol(void) const;
+ MTFace* GetMTFace() const;
+ unsigned int* GetMCol() const;
BL_Texture * getTex (unsigned int idx) {
return (idx < MAXTEX) ? mTextures + idx : NULL;
}
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
deleted file mode 100644
index e990974a646..00000000000
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * ***** 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_BulletPhysicsController.cpp
- * \ingroup ketsji
- */
-
-//under visual studio the #define in KX_ConvertPhysicsObject.h is quicker for recompilation
-#include "KX_ConvertPhysicsObject.h"
-
-#ifdef WITH_BULLET
-
-#include "KX_BulletPhysicsController.h"
-
-#include "btBulletDynamicsCommon.h"
-#include "SG_Spatial.h"
-
-#include "KX_GameObject.h"
-#include "KX_MotionState.h"
-#include "KX_ClientObjectInfo.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-#include "CcdPhysicsEnvironment.h"
-#include "BulletSoftBody/btSoftBody.h"
-
-
-KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool character, bool compound)
-: KX_IPhysicsController(dyna,sensor,character,compound,(PHY_IPhysicsController*)this),
-CcdPhysicsController(ci),
-m_savedCollisionFlags(0),
-m_savedCollisionFilterGroup(0),
-m_savedCollisionFilterMask(0),
-m_savedMass(0.0),
-m_savedDyna(false),
-m_suspended(false),
-m_bulletChildShape(NULL)
-{
-}
-
-KX_BulletPhysicsController::~KX_BulletPhysicsController ()
-{
- // The game object has a direct link to
- if (m_pObject)
- {
- // If we cheat in SetObject, we must also cheat here otherwise the
- // object will still things it has a physical controller
- // Note that it requires that m_pObject is reset in case the object is deleted
- // before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec)
- // The non usual case is when the object is not deleted because its reference is hanging
- // in a AddObject actuator but the node is deleted. This case is covered here.
- KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject();
- gameobj->SetPhysicsController(NULL,false);
- }
-}
-
-void KX_BulletPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
- CcdPhysicsController::resolveCombinedVelocities(linvelX,linvelY,linvelZ,angVelX,angVelY,angVelZ);
-
-}
-
-
- ///////////////////////////////////
- // KX_IPhysicsController interface
- ////////////////////////////////////
-
-void KX_BulletPhysicsController::applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)
-{
- CcdPhysicsController::applyImpulse(attach[0],attach[1],attach[2],impulse[0],impulse[1],impulse[2]);
-
-}
-
-float KX_BulletPhysicsController::GetLinVelocityMin()
-{
- return (float)CcdPhysicsController::GetLinVelocityMin();
-}
-void KX_BulletPhysicsController::SetLinVelocityMin(float val)
-{
- CcdPhysicsController::SetLinVelocityMin(val);
-}
-
-void KX_BulletPhysicsController::Jump()
-{
- CcdPhysicsController::Jump();
-}
-
-float KX_BulletPhysicsController::GetLinVelocityMax()
-{
- return (float)CcdPhysicsController::GetLinVelocityMax();
-}
-void KX_BulletPhysicsController::SetLinVelocityMax(float val)
-{
- CcdPhysicsController::SetLinVelocityMax(val);
-}
-
-void KX_BulletPhysicsController::SetObject (SG_IObject* object)
-{
- SG_Controller::SetObject(object);
-
- // cheating here...
- //should not be necessary, is it for duplicates ?
-
- KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
- gameobj->SetPhysicsController(this,gameobj->IsDynamic());
- CcdPhysicsController::setNewClientInfo(gameobj->getClientInfo());
-
- if (m_bSensor)
- {
- // use a different callback function for sensor object,
- // bullet will not synchronize, we must do it explicitly
- SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions();
- callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
- }
-}
-
-MT_Scalar KX_BulletPhysicsController::GetRadius()
-{
- return MT_Scalar(CcdPhysicsController::GetRadius());
-}
-
-void KX_BulletPhysicsController::setMargin (float collisionMargin)
-{
- CcdPhysicsController::SetMargin(collisionMargin);
-}
-void KX_BulletPhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local)
-{
- CcdPhysicsController::RelativeTranslate(dloc[0],dloc[1],dloc[2],local);
-
-}
-
-void KX_BulletPhysicsController::SetWalkDirection(const MT_Vector3& dloc,bool local)
-{
- CcdPhysicsController::SetWalkDirection(dloc[0],dloc[1],dloc[2],local);
-}
-
-void KX_BulletPhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool local)
-{
- float rotval[9];
- drot.getValue3x3(rotval);
- CcdPhysicsController::RelativeRotate(rotval,local);
-}
-
-void KX_BulletPhysicsController::ApplyTorque(const MT_Vector3& torque,bool local)
-{
- CcdPhysicsController::ApplyTorque(torque.x(),torque.y(),torque.z(),local);
-}
-void KX_BulletPhysicsController::ApplyForce(const MT_Vector3& force,bool local)
-{
- CcdPhysicsController::ApplyForce(force.x(),force.y(),force.z(),local);
-}
-MT_Vector3 KX_BulletPhysicsController::GetLinearVelocity()
-{
- float angVel[3];
- //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
- CcdPhysicsController::GetLinearVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
- return MT_Vector3(angVel[0],angVel[1],angVel[2]);
-}
-MT_Vector3 KX_BulletPhysicsController::GetAngularVelocity()
-{
- float angVel[3];
- //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
- CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
- return MT_Vector3(angVel[0],angVel[1],angVel[2]);
-}
-MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos)
-{
- float linVel[3];
- CcdPhysicsController::GetVelocity(pos[0], pos[1], pos[2], linVel[0],linVel[1],linVel[2]);
- return MT_Vector3(linVel[0],linVel[1],linVel[2]);
-}
-
-MT_Vector3 KX_BulletPhysicsController::GetWalkDirection()
-{
- float dir[3];
- CcdPhysicsController::GetWalkDirection(dir[0], dir[1], dir[2]);
- return MT_Vector3(dir[0], dir[1], dir[2]);
-}
-
-void KX_BulletPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
- CcdPhysicsController::SetAngularVelocity(ang_vel.x(),ang_vel.y(),ang_vel.z(),local);
-
-}
-void KX_BulletPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- CcdPhysicsController::SetLinearVelocity(lin_vel.x(),lin_vel.y(),lin_vel.z(),local);
-}
-void KX_BulletPhysicsController::getOrientation(MT_Quaternion& orn)
-{
- float myorn[4];
- CcdPhysicsController::getOrientation(myorn[0],myorn[1],myorn[2],myorn[3]);
- orn = MT_Quaternion(myorn[0],myorn[1],myorn[2],myorn[3]);
-}
-void KX_BulletPhysicsController::setOrientation(const MT_Matrix3x3& orn)
-{
- btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]);
- CcdPhysicsController::setWorldOrientation(btmat);
-}
-void KX_BulletPhysicsController::setPosition(const MT_Point3& pos)
-{
- CcdPhysicsController::setPosition(pos.x(),pos.y(),pos.z());
-}
-void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling)
-{
- CcdPhysicsController::setScaling(scaling.x(),scaling.y(),scaling.z());
-}
-void KX_BulletPhysicsController::SetTransform()
-{
- btVector3 pos;
- btVector3 scale;
- float ori[12];
- m_MotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
- m_MotionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
- m_MotionState->getWorldOrientation(ori);
- btMatrix3x3 rot(ori[0], ori[4], ori[8],
- ori[1], ori[5], ori[9],
- ori[2], ori[6], ori[10]);
- CcdPhysicsController::forceWorldTransform(rot, pos);
-}
-
-MT_Scalar KX_BulletPhysicsController::GetMass()
-{
- if (GetSoftBody())
- return GetSoftBody()->getTotalMass();
-
- MT_Scalar invmass = 0.f;
- if (GetRigidBody())
- invmass = GetRigidBody()->getInvMass();
- if (invmass)
- return 1.f/invmass;
- return 0.f;
-
-}
-
-MT_Vector3 KX_BulletPhysicsController::GetLocalInertia()
-{
- MT_Vector3 inertia(0.f, 0.f, 0.f);
- btVector3 inv_inertia;
- if (GetRigidBody()) {
- inv_inertia = GetRigidBody()->getInvInertiaDiagLocal();
- if (!btFuzzyZero(inv_inertia.getX()) &&
- !btFuzzyZero(inv_inertia.getY()) &&
- !btFuzzyZero(inv_inertia.getZ()))
- inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ());
- }
- return inertia;
-}
-
-MT_Vector3 KX_BulletPhysicsController::getReactionForce()
-{
- assert(0);
- return MT_Vector3(0.f,0.f,0.f);
-}
-void KX_BulletPhysicsController::setRigidBody(bool rigid)
-{
- CcdPhysicsController::setRigidBody(rigid);
-}
-
-/* This function dynamically adds the collision shape of another controller to
- * the current controller shape provided it is a compound shape.
- * The idea is that dynamic parenting on a compound object will dynamically extend the shape
- */
-void KX_BulletPhysicsController::AddCompoundChild(KX_IPhysicsController* child)
-{
- if (child == NULL || !IsCompound())
- return;
- // other controller must be a bullet controller too
- // verify that body and shape exist and match
- KX_BulletPhysicsController* childCtrl = dynamic_cast<KX_BulletPhysicsController*>(child);
- btRigidBody* rootBody = GetRigidBody();
- btRigidBody* childBody = childCtrl->GetRigidBody();
- if (!rootBody || !childBody)
- return;
- const btCollisionShape* rootShape = rootBody->getCollisionShape();
- const btCollisionShape* childShape = childBody->getCollisionShape();
- if (!rootShape ||
- !childShape ||
- rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE ||
- childShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
- return;
- btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
- // compute relative transformation between parent and child
- btTransform rootTrans;
- btTransform childTrans;
- rootBody->getMotionState()->getWorldTransform(rootTrans);
- childBody->getMotionState()->getWorldTransform(childTrans);
- btVector3 rootScale = rootShape->getLocalScaling();
- rootScale[0] = 1.0/rootScale[0];
- rootScale[1] = 1.0/rootScale[1];
- rootScale[2] = 1.0/rootScale[2];
- // relative scale = child_scale/parent_scale
- btVector3 relativeScale = childShape->getLocalScaling()*rootScale;
- btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose();
- // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale)
- btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale);
- // relative rot = parent_rot^-1 * child_rot
- btMatrix3x3 relativeRot = rootRotInverse*childTrans.getBasis();
- // create a proxy shape info to store the transformation
- CcdShapeConstructionInfo* proxyShapeInfo = new CcdShapeConstructionInfo();
- // store the transformation to this object shapeinfo
- proxyShapeInfo->m_childTrans.setOrigin(relativePos);
- proxyShapeInfo->m_childTrans.setBasis(relativeRot);
- proxyShapeInfo->m_childScale.setValue(relativeScale[0], relativeScale[1], relativeScale[2]);
- // we will need this to make sure that we remove the right proxy later when unparenting
- proxyShapeInfo->m_userData = childCtrl;
- proxyShapeInfo->SetProxy(childCtrl->GetShapeInfo()->AddRef());
- // add to parent compound shapeinfo (increments ref count)
- GetShapeInfo()->AddShape(proxyShapeInfo);
- // create new bullet collision shape from the object shapeinfo and set scaling
- btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin(), childCtrl->getConstructionInfo().m_bGimpact, true);
- newChildShape->setLocalScaling(relativeScale);
- // add bullet collision shape to parent compound collision shape
- compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape);
- // proxyShapeInfo is not needed anymore, release it
- proxyShapeInfo->Release();
- // remember we created this shape
- childCtrl->m_bulletChildShape = newChildShape;
- // recompute inertia of parent
- if (!rootBody->isStaticOrKinematicObject())
- {
- btVector3 localInertia;
- float mass = 1.f/rootBody->getInvMass();
- compoundShape->calculateLocalInertia(mass,localInertia);
- rootBody->setMassProps(mass,localInertia);
- }
- // must update the broadphase cache,
- GetPhysicsEnvironment()->refreshCcdPhysicsController(this);
- // remove the children
- GetPhysicsEnvironment()->disableCcdPhysicsController(childCtrl);
-}
-
-/* Reverse function of the above, it will remove a shape from a compound shape
- * provided that the former was added to the later using AddCompoundChild()
- */
-void KX_BulletPhysicsController::RemoveCompoundChild(KX_IPhysicsController* child)
-{
- if (child == NULL || !IsCompound())
- return;
- // other controller must be a bullet controller too
- // verify that body and shape exist and match
- KX_BulletPhysicsController* childCtrl = dynamic_cast<KX_BulletPhysicsController*>(child);
- btRigidBody* rootBody = GetRigidBody();
- btRigidBody* childBody = childCtrl->GetRigidBody();
- if (!rootBody || !childBody)
- return;
- const btCollisionShape* rootShape = rootBody->getCollisionShape();
- if (!rootShape ||
- rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE)
- return;
- btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
- // retrieve the shapeInfo
- CcdShapeConstructionInfo* childShapeInfo = childCtrl->GetShapeInfo();
- CcdShapeConstructionInfo* rootShapeInfo = GetShapeInfo();
- // and verify that the child is part of the parent
- int i = rootShapeInfo->FindChildShape(childShapeInfo, childCtrl);
- if (i < 0)
- return;
- rootShapeInfo->RemoveChildShape(i);
- if (childCtrl->m_bulletChildShape)
- {
- int numChildren = compoundShape->getNumChildShapes();
- for (i=0; i<numChildren; i++)
- {
- if (compoundShape->getChildShape(i) == childCtrl->m_bulletChildShape)
- {
- compoundShape->removeChildShapeByIndex(i);
- compoundShape->recalculateLocalAabb();
- break;
- }
- }
- delete childCtrl->m_bulletChildShape;
- childCtrl->m_bulletChildShape = NULL;
- }
- // recompute inertia of parent
- if (!rootBody->isStaticOrKinematicObject())
- {
- btVector3 localInertia;
- float mass = 1.f/rootBody->getInvMass();
- compoundShape->calculateLocalInertia(mass,localInertia);
- rootBody->setMassProps(mass,localInertia);
- }
- // must update the broadphase cache,
- GetPhysicsEnvironment()->refreshCcdPhysicsController(this);
- // reactivate the children
- GetPhysicsEnvironment()->enableCcdPhysicsController(childCtrl);
-}
-
-void KX_BulletPhysicsController::SetMass(MT_Scalar newmass)
-{
- btRigidBody *body = GetRigidBody();
- if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON)
- {
- btVector3 grav = body->getGravity();
- btVector3 accel = grav / GetMass();
-
- btBroadphaseProxy* handle = body->getBroadphaseHandle();
- GetPhysicsEnvironment()->updateCcdPhysicsController(this,
- newmass,
- body->getCollisionFlags(),
- handle->m_collisionFilterGroup,
- handle->m_collisionFilterMask);
- body->setGravity(accel);
- }
-}
-
-void KX_BulletPhysicsController::SuspendDynamics(bool ghost)
-{
- btRigidBody *body = GetRigidBody();
- if (body && !m_suspended && !IsSensor())
- {
- btBroadphaseProxy* handle = body->getBroadphaseHandle();
- m_savedCollisionFlags = body->getCollisionFlags();
- m_savedMass = GetMass();
- m_savedDyna = m_bDyna;
- m_savedCollisionFilterGroup = handle->m_collisionFilterGroup;
- m_savedCollisionFilterMask = handle->m_collisionFilterMask;
- m_suspended = true;
- GetPhysicsEnvironment()->updateCcdPhysicsController(this,
- 0.0,
- btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
- btBroadphaseProxy::StaticFilter,
- btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
- m_bDyna = false;
- }
-}
-
-void KX_BulletPhysicsController::RestoreDynamics()
-{
- btRigidBody *body = GetRigidBody();
- if (body && m_suspended)
- {
- // before make sure any position change that was done in this logic frame are accounted for
- SetTransform();
- GetPhysicsEnvironment()->updateCcdPhysicsController(this,
- m_savedMass,
- m_savedCollisionFlags,
- m_savedCollisionFilterGroup,
- m_savedCollisionFilterMask);
- body->activate();
- m_bDyna = m_savedDyna;
- m_suspended = false;
- }
-}
-
-SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
-{
- PHY_IMotionState* motionstate = new KX_MotionState(destnode);
-
- KX_BulletPhysicsController* physicsreplica = new KX_BulletPhysicsController(*this);
-
- //parentcontroller is here be able to avoid collisions between parent/child
-
- PHY_IPhysicsController* parentctrl = NULL;
- KX_BulletPhysicsController* parentKxCtrl = NULL;
- CcdPhysicsController* ccdParent = NULL;
-
-
- if (destnode != destnode->GetRootSGParent())
- {
- KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject();
- if (clientgameobj)
- {
- parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController();
- } else
- {
- // it could be a false node, try the children
- NodeList::const_iterator childit;
- for (
- childit = destnode->GetSGChildren().begin();
- childit!= destnode->GetSGChildren().end();
- ++childit
- ) {
- KX_GameObject *clientgameobj_child = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj_child)
- {
- parentKxCtrl = (KX_BulletPhysicsController*)clientgameobj_child->GetPhysicsController();
- parentctrl = parentKxCtrl;
- ccdParent = parentKxCtrl;
- }
- }
- }
- }
-
- physicsreplica->setParentCtrl(ccdParent);
- physicsreplica->PostProcessReplica(motionstate,parentctrl);
- physicsreplica->m_userdata = (PHY_IPhysicsController*)physicsreplica;
- physicsreplica->m_bulletChildShape = NULL;
- return physicsreplica;
-
-}
-
-
-
-void KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly)
-{
-
- if (!m_bDyna && !m_bSensor && !m_bCharacter)
- {
- btCollisionObject* object = GetRigidBody();
- object->setActivationState(ACTIVE_TAG);
- object->setCollisionFlags(object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- } else
- {
- if (!nondynaonly)
- {
- /*
- btTransform worldTrans;
- if (GetRigidBody())
- {
- GetRigidBody()->getMotionState()->getWorldTransform(worldTrans);
- GetRigidBody()->setCenterOfMassTransform(worldTrans);
- }
- */
- /*
- scaling?
- if (m_bDyna)
- {
- m_sumoObj->setScaling(MT_Vector3(1,1,1));
- } else
- {
- MT_Vector3 scale;
- GetWorldScaling(scale);
- m_sumoObj->setScaling(scale);
- }
- */
-
- }
- }
-}
-
-// todo: remove next line !
-void KX_BulletPhysicsController::SetSimulatedTime(double time)
-{
-}
-
-// call from scene graph to update
-bool KX_BulletPhysicsController::Update(double time)
-{
- return false;
-
- // todo: check this code
- //if (GetMass())
- //{
- // return false;//true;
-// }
-// return false;
-}
-
-
-const char* KX_BulletPhysicsController::getName()
-{
- if (m_pObject)
- {
- KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject();
- return gameobj->GetName();
- }
- return 0;
-}
-
-#endif // WITH_BULLET
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
deleted file mode 100644
index 3d13744567b..00000000000
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h
+++ /dev/null
@@ -1,102 +0,0 @@
-
-/** \file KX_BulletPhysicsController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_BULLETPHYSICSCONTROLLER_H__
-#define __KX_BULLETPHYSICSCONTROLLER_H__
-
-
-#include "KX_IPhysicsController.h"
-#ifdef WITH_BULLET
-#include "CcdPhysicsController.h"
-#endif
-
-class KX_BulletPhysicsController : public KX_IPhysicsController, public CcdPhysicsController
-{
-private:
- int m_savedCollisionFlags;
- int m_savedActivationState;
- short int m_savedCollisionFilterGroup;
- short int m_savedCollisionFilterMask;
- MT_Scalar m_savedMass;
- bool m_savedDyna;
- bool m_suspended;
- btCollisionShape* m_bulletChildShape;
-
-public:
-#ifdef WITH_BULLET
- KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool character, bool compound);
- virtual ~KX_BulletPhysicsController ();
-#endif
- ///////////////////////////////////
- // KX_IPhysicsController interface
- ////////////////////////////////////
-
- virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
- virtual void SetObject (SG_IObject* object);
- virtual void setMargin (float collisionMargin);
- virtual void RelativeTranslate(const MT_Vector3& dloc,bool local);
- virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local);
- virtual void ApplyTorque(const MT_Vector3& torque,bool local);
- virtual void ApplyForce(const MT_Vector3& force,bool local);
- virtual void SetWalkDirection(const MT_Vector3& dir,bool local);
- virtual MT_Vector3 GetLinearVelocity();
- virtual MT_Vector3 GetAngularVelocity();
- virtual MT_Vector3 GetVelocity(const MT_Point3& pos);
- virtual MT_Vector3 GetWalkDirection();
- virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
- virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
- virtual void Jump();
- virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Matrix3x3& orn);
- virtual void setPosition(const MT_Point3& pos);
- virtual void setScaling(const MT_Vector3& scaling);
- virtual void SetTransform();
- virtual MT_Scalar GetMass();
- virtual void SetMass(MT_Scalar newmass);
- virtual MT_Vector3 GetLocalInertia();
- virtual MT_Vector3 getReactionForce();
- virtual void setRigidBody(bool rigid);
- virtual void AddCompoundChild(KX_IPhysicsController* child);
- virtual void RemoveCompoundChild(KX_IPhysicsController* child);
-
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
-
- virtual void SuspendDynamics(bool ghost);
- virtual void RestoreDynamics();
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
-
- virtual MT_Scalar GetRadius();
-
- virtual float GetLinVelocityMin();
- virtual void SetLinVelocityMin(float val);
- virtual float GetLinVelocityMax();
- virtual void SetLinVelocityMax(float val);
-
- virtual void SetSumoTransform(bool nondynaonly);
- // todo: remove next line !
- virtual void SetSimulatedTime(double time);
-
- // call from scene graph to update
- virtual bool Update(double time);
- void* GetUserData() { return m_userdata;}
-
- virtual const char* getName();
-
- void
- SetOption(
- int option,
- int value
- ) {
- // intentionally empty
- };
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BulletPhysicsController")
-#endif
-};
-
-#endif /* __KX_BULLETPHYSICSCONTROLLER_H__ */
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index 73ebf89bea3..4ab768e4240 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -37,6 +37,9 @@
#include "KX_PythonInit.h"
#include "KX_Python.h"
#include "KX_PyMath.h"
+
+#include "RAS_ICanvas.h"
+
KX_Camera::KX_Camera(void* sgReplicationInfo,
SG_Callbacks callbacks,
const RAS_CameraData& camdata,
diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
index 899a153d80f..fdf4fa01b03 100644
--- a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
@@ -34,8 +34,6 @@ KX_CharacterWrapper::KX_CharacterWrapper(PHY_ICharacter* character) :
KX_CharacterWrapper::~KX_CharacterWrapper()
{
- if (m_character)
- delete m_character; // We're responsible for the character object!
}
#ifdef WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
index a3059317d36..0c5e21322df 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
@@ -331,7 +331,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
{
MT_Point3 topoint = position + (m_maximumBound) * direction;
PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
- KX_IPhysicsController *spc = obj->GetPhysicsController();
+ PHY_IPhysicsController *spc = obj->GetPhysicsController();
if (!pe) {
std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl;
@@ -345,7 +345,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
parent->Release();
}
}
- KX_RayCast::Callback<KX_ConstraintActuator> callback(this,spc);
+ KX_RayCast::Callback<KX_ConstraintActuator> callback(this,dynamic_cast<PHY_IPhysicsController*>(spc));
result = KX_RayCast::RayTest(pe, position, topoint, callback);
if (result) {
MT_Vector3 newnormal = callback.m_hitNormal;
@@ -379,7 +379,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
// logically we should cancel the speed along the ray direction as we set the
// position along that axis
spc = obj->GetPhysicsController();
- if (spc && spc->IsDyna()) {
+ if (spc && spc->IsDynamic()) {
MT_Vector3 linV = spc->GetLinearVelocity();
// cancel the projection along the ray direction
MT_Scalar fallspeed = linV.dot(direction);
@@ -444,20 +444,20 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
normal.normalize();
{
PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
- KX_IPhysicsController *spc = obj->GetPhysicsController();
+ PHY_IPhysicsController *spc = obj->GetPhysicsController();
if (!pe) {
std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl;
goto CHECK_TIME;
}
- if (!spc || !spc->IsDyna()) {
+ if (!spc || !spc->IsDynamic()) {
// the object is not dynamic, it won't support setting speed
goto CHECK_TIME;
}
m_hitObject = NULL;
// distance of Fh area is stored in m_minimum
MT_Point3 topoint = position + (m_minimumBound+spc->GetRadius()) * direction;
- KX_RayCast::Callback<KX_ConstraintActuator> callback(this,spc);
+ KX_RayCast::Callback<KX_ConstraintActuator> callback(this, spc);
result = KX_RayCast::RayTest(pe, position, topoint, callback);
// we expect a hit object
if (!m_hitObject)
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
index e09449c4f1d..793324fab75 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
@@ -64,7 +64,7 @@ PyObject *KX_ConstraintWrapper::PyGetParam(PyObject *args, PyObject *kwds)
if (!PyArg_ParseTuple(args,"i:getParam",&dof))
return NULL;
- value = m_physenv->getConstraintParam(m_constraintId,dof);
+ value = m_physenv->GetConstraintParam(m_constraintId,dof);
return PyFloat_FromDouble(value);
}
@@ -77,7 +77,7 @@ PyObject *KX_ConstraintWrapper::PySetParam(PyObject *args, PyObject *kwds)
if (!PyArg_ParseTuple(args,"iff:setParam",&dof,&minLimit,&maxLimit))
return NULL;
- m_physenv->setConstraintParam(m_constraintId,dof,minLimit,maxLimit);
+ m_physenv->SetConstraintParam(m_constraintId,dof,minLimit,maxLimit);
Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index ece6abc9447..bde50588fd3 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -65,7 +65,6 @@ extern "C"{
#include "CcdPhysicsController.h"
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
-#include "KX_BulletPhysicsController.h"
#include "btBulletDynamicsCommon.h"
#ifdef WIN32
@@ -255,7 +254,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
{
//find parent, compound shape and add to it
//take relative transform into account!
- KX_BulletPhysicsController* parentCtrl = (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
+ CcdPhysicsController* parentCtrl = (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
assert(parentCtrl);
CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo();
btRigidBody* rigidbody = parentCtrl->GetRigidBody();
@@ -424,12 +423,13 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_contactProcessingThreshold = objprop->m_contactProcessingThreshold;//todo: expose this in advanced settings, just like margin, default to 10000 or so
ci.m_bSoft = objprop->m_softbody;
+ ci.m_bDyna = isbulletdyna;
ci.m_bSensor = isbulletsensor;
ci.m_bCharacter = isbulletchar;
ci.m_bGimpact = useGimpact;
MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
- KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,isbulletsensor,isbulletchar,objprop->m_hasCompoundChildren);
+ CcdPhysicsController* physicscontroller = new CcdPhysicsController(ci);
// shapeInfo is reference counted, decrement now as we don't use it anymore
if (shapeInfo)
shapeInfo->Release();
@@ -438,9 +438,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
// don't add automatically sensor object, they are added when a collision sensor is registered
if (!isbulletsensor && objprop->m_in_active_layer)
{
- env->addCcdPhysicsController( physicscontroller);
+ env->AddCcdPhysicsController( physicscontroller);
}
- physicscontroller->setNewClientInfo(gameobj->getClientInfo());
+ physicscontroller->SetNewClientInfo(gameobj->getClientInfo());
{
btRigidBody* rbody = physicscontroller->GetRigidBody();
@@ -459,8 +459,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
}
}
- CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0;
- physicscontroller->setParentCtrl(parentCtrl);
+ CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0;
+ physicscontroller->SetParentCtrl(parentCtrl);
//Now done directly in ci.m_collisionFlags so that it propagates to replica
@@ -504,13 +504,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
}
- gameobj->GetSGNode()->AddSGController(physicscontroller);
STR_String materialname;
if (meshobj)
materialname = meshobj->GetMaterialName(0);
- physicscontroller->SetObject(gameobj->GetSGNode());
#if 0
///test for soft bodies
@@ -546,7 +544,7 @@ void KX_ClearBulletSharedShapes()
*/
bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj)
{
- KX_BulletPhysicsController *spc= static_cast<KX_BulletPhysicsController*>((gameobj->GetPhysicsController()));
+ CcdPhysicsController *spc= static_cast<CcdPhysicsController*>(gameobj->GetPhysicsController());
CcdShapeConstructionInfo *shapeInfo;
/* if this is the child of a compound shape this can happen
@@ -568,7 +566,7 @@ bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *fro
shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
/* create the new bullet mesh */
- CcdConstructionInfo& cci = spc->getConstructionInfo();
+ CcdConstructionInfo& cci = spc->GetConstructionInfo();
btCollisionShape* bm= shapeInfo->CreateBulletShape(cci.m_margin, cci.m_bGimpact, !cci.m_bSoft);
spc->ReplaceControllerShape(bm);
diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp
index 85fa0b2b3ce..f87d4799abc 100644
--- a/source/gameengine/Ketsji/KX_Dome.cpp
+++ b/source/gameengine/Ketsji/KX_Dome.cpp
@@ -48,8 +48,6 @@ KX_Dome::KX_Dome (
RAS_ICanvas* canvas,
/// rasterizer
RAS_IRasterizer* rasterizer,
- /// render tools
- RAS_IRenderTools* rendertools,
/// engine
KX_KetsjiEngine* engine,
@@ -71,7 +69,6 @@ KX_Dome::KX_Dome (
m_tilt(tilt),
m_canvas(canvas),
m_rasterizer(rasterizer),
- m_rendertools(rendertools),
m_engine(engine)
{
warp.usemesh = false;
@@ -2047,6 +2044,6 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i)
cam->NodeUpdateGS(0.f);
scene->CalculateVisibleMeshes(m_rasterizer,cam);
- scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
+ scene->RenderBuckets(camtrans, m_rasterizer);
}
diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h
index 3bc90bf6c35..a7e798a3944 100644
--- a/source/gameengine/Ketsji/KX_Dome.h
+++ b/source/gameengine/Ketsji/KX_Dome.h
@@ -36,7 +36,6 @@
#include "DNA_screen_types.h"
#include "RAS_ICanvas.h"
#include "RAS_IRasterizer.h"
-#include "RAS_IRenderTools.h"
#include "KX_KetsjiEngine.h"
#include "GL/glew.h"
@@ -62,8 +61,6 @@ public:
KX_Dome (RAS_ICanvas* m_canvas,
/// rasterizer
RAS_IRasterizer* m_rasterizer,
- /// render tools
- RAS_IRenderTools* m_rendertools,
/// engine
KX_KetsjiEngine* m_engine,
diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp
index c6d1041a12a..a0266a54411 100644
--- a/source/gameengine/Ketsji/KX_FontObject.cpp
+++ b/source/gameengine/Ketsji/KX_FontObject.cpp
@@ -31,10 +31,12 @@
#include "KX_FontObject.h"
#include "DNA_curve_types.h"
+#include "DNA_vfont_types.h"
#include "KX_Scene.h"
#include "KX_PythonInit.h"
#include "BLI_math.h"
#include "StringValue.h"
+#include "RAS_IRasterizer.h"
/* paths needed for font load */
#include "BLI_blenlib.h"
@@ -75,14 +77,14 @@ static std::vector<STR_String> split_string(STR_String str)
KX_FontObject::KX_FontObject(void* sgReplicationInfo,
SG_Callbacks callbacks,
- RAS_IRenderTools* rendertools,
+ RAS_IRasterizer* rasterizer,
Object *ob,
bool do_color_management):
KX_GameObject(sgReplicationInfo, callbacks),
m_object(ob),
m_dpi(72),
m_resolution(1.f),
- m_rendertools(rendertools),
+ m_rasterizer(rasterizer),
m_do_color_management(do_color_management)
{
Curve *text = static_cast<Curve *> (ob->data);
@@ -212,7 +214,7 @@ void KX_FontObject::DrawText()
mat[13] -= spacing[1];
mat[14] -= spacing[2];
}
- m_rendertools->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, color, mat, aspect);
+ m_rasterizer->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, color, mat, aspect);
}
}
diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h
index 3d8c1d99dcc..8b66accb797 100644
--- a/source/gameengine/Ketsji/KX_FontObject.h
+++ b/source/gameengine/Ketsji/KX_FontObject.h
@@ -32,8 +32,6 @@
#ifndef __KX_FONTOBJECT_H__
#define __KX_FONTOBJECT_H__
#include "KX_GameObject.h"
-#include "DNA_vfont_types.h"
-#include "RAS_IRenderTools.h"
class KX_FontObject : public KX_GameObject
{
@@ -41,7 +39,7 @@ public:
Py_Header
KX_FontObject(void* sgReplicationInfo,
SG_Callbacks callbacks,
- RAS_IRenderTools* rendertools,
+ RAS_IRasterizer* rasterizer,
Object *ob,
bool do_color_management);
@@ -68,7 +66,7 @@ protected:
float m_line_spacing;
MT_Vector3 m_offset;
- class RAS_IRenderTools* m_rendertools; //needed for drawing routine
+ class RAS_IRasterizer* m_rasterizer; //needed for drawing routine
bool m_do_color_management;
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index e06f7ab6633..96f76ff21b1 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -55,7 +55,6 @@ typedef unsigned long uint_ptr;
#include "KX_PolyProxy.h"
#include <stdio.h> // printf
#include "SG_Controller.h"
-#include "KX_IPhysicsController.h"
#include "PHY_IGraphicController.h"
#include "SG_Node.h"
#include "SG_Controller.h"
@@ -105,7 +104,7 @@ KX_GameObject::KX_GameObject(
m_bVisible(true),
m_bCulled(true),
m_bOccluder(false),
- m_pPhysicsController1(NULL),
+ m_pPhysicsController(NULL),
m_pGraphicController(NULL),
m_xray(false),
m_pHitObject(NULL),
@@ -177,6 +176,11 @@ KX_GameObject::~KX_GameObject()
delete m_pGraphicController;
}
+ if (m_pPhysicsController)
+ {
+ delete m_pPhysicsController;
+ }
+
if (m_pObstacleSimulation)
{
m_pObstacleSimulation->DestroyObstacleForObj(this);
@@ -245,9 +249,9 @@ void KX_GameObject::SetName(const char *name)
m_name = name;
}
-KX_IPhysicsController* KX_GameObject::GetPhysicsController()
+PHY_IPhysicsController* KX_GameObject::GetPhysicsController()
{
- return m_pPhysicsController1;
+ return m_pPhysicsController;
}
KX_GameObject* KX_GameObject::GetDupliGroupObject()
@@ -333,9 +337,9 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom
RemoveParent(scene);
obj->GetSGNode()->AddChild(GetSGNode());
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
- m_pPhysicsController1->SuspendDynamics(ghost);
+ m_pPhysicsController->SuspendDynamics(ghost);
}
// Set us to our new scale, position, and orientation
scale2[0] = 1.0/scale2[0];
@@ -356,16 +360,16 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom
Release();
// if the new parent is a compound object, add this object shape to the compound shape.
// step 0: verify this object has physical controller
- if (m_pPhysicsController1 && addToCompound)
+ if (m_pPhysicsController && addToCompound)
{
// step 1: find the top parent (not necessarily obj)
KX_GameObject* rootobj = (KX_GameObject*)obj->GetSGNode()->GetRootSGParent()->GetSGClientObject();
// step 2: verify it has a physical controller and compound shape
if (rootobj != NULL &&
- rootobj->m_pPhysicsController1 != NULL &&
- rootobj->m_pPhysicsController1->IsCompound())
+ rootobj->m_pPhysicsController != NULL &&
+ rootobj->m_pPhysicsController->IsCompound())
{
- rootobj->m_pPhysicsController1->AddCompoundChild(m_pPhysicsController1);
+ rootobj->m_pPhysicsController->AddCompoundChild(m_pPhysicsController);
}
}
// graphically, the object hasn't change place, no need to update m_pGraphicController
@@ -392,27 +396,27 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
if (!rootlist->SearchValue(this))
// object was not in root list, add it now and increment ref count
rootlist->Add(AddRef());
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
// in case this controller was added as a child shape to the parent
if (rootobj != NULL &&
- rootobj->m_pPhysicsController1 != NULL &&
- rootobj->m_pPhysicsController1->IsCompound())
+ rootobj->m_pPhysicsController != NULL &&
+ rootobj->m_pPhysicsController->IsCompound())
{
- rootobj->m_pPhysicsController1->RemoveCompoundChild(m_pPhysicsController1);
+ rootobj->m_pPhysicsController->RemoveCompoundChild(m_pPhysicsController);
}
- m_pPhysicsController1->RestoreDynamics();
- if (m_pPhysicsController1->IsDyna() && (rootobj != NULL && rootobj->m_pPhysicsController1))
+ m_pPhysicsController->RestoreDynamics();
+ if (m_pPhysicsController->IsDynamic() && (rootobj != NULL && rootobj->m_pPhysicsController))
{
// dynamic object should remember the velocity they had while being parented
MT_Point3 childPoint = GetSGNode()->GetWorldPosition();
MT_Point3 rootPoint = rootobj->GetSGNode()->GetWorldPosition();
MT_Point3 relPoint;
relPoint = (childPoint-rootPoint);
- MT_Vector3 linVel = rootobj->m_pPhysicsController1->GetVelocity(relPoint);
- MT_Vector3 angVel = rootobj->m_pPhysicsController1->GetAngularVelocity();
- m_pPhysicsController1->SetLinearVelocity(linVel, false);
- m_pPhysicsController1->SetAngularVelocity(angVel, false);
+ MT_Vector3 linVel = rootobj->m_pPhysicsController->GetVelocity(relPoint);
+ MT_Vector3 angVel = rootobj->m_pPhysicsController->GetAngularVelocity();
+ m_pPhysicsController->SetLinearVelocity(linVel, false);
+ m_pPhysicsController->SetAngularVelocity(angVel, false);
}
}
// graphically, the object hasn't change place, no need to update m_pGraphicController
@@ -488,9 +492,9 @@ void KX_GameObject::SetTimes(short layer, float start, float end)
void KX_GameObject::ProcessReplica()
{
SCA_IObject::ProcessReplica();
-
- m_pPhysicsController1 = NULL;
+
m_pGraphicController = NULL;
+ m_pPhysicsController = NULL;
m_pSGNode = NULL;
m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
m_pClient_info->m_gameobject = this;
@@ -570,16 +574,16 @@ CValue* KX_GameObject::GetReplica()
void KX_GameObject::ApplyForce(const MT_Vector3& force,bool local)
{
- if (m_pPhysicsController1)
- m_pPhysicsController1->ApplyForce(force,local);
+ if (m_pPhysicsController)
+ m_pPhysicsController->ApplyForce(force,local);
}
void KX_GameObject::ApplyTorque(const MT_Vector3& torque,bool local)
{
- if (m_pPhysicsController1)
- m_pPhysicsController1->ApplyTorque(torque,local);
+ if (m_pPhysicsController)
+ m_pPhysicsController->ApplyTorque(torque,local);
}
@@ -588,9 +592,9 @@ void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local)
{
if (GetSGNode())
{
- if (m_pPhysicsController1) // (IsDynamic())
+ if (m_pPhysicsController) // (IsDynamic())
{
- m_pPhysicsController1->RelativeTranslate(dloc,local);
+ m_pPhysicsController->RelativeTranslate(dloc,local);
}
GetSGNode()->RelativeTranslate(dloc,GetSGNode()->GetSGParent(),local);
}
@@ -605,8 +609,8 @@ void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local)
if (GetSGNode()) {
GetSGNode()->RelativeRotate(rotmat,local);
- if (m_pPhysicsController1) { // (IsDynamic())
- m_pPhysicsController1->RelativeRotate(rotmat,local);
+ if (m_pPhysicsController) { // (IsDynamic())
+ m_pPhysicsController->RelativeRotate(rotmat,local);
}
}
}
@@ -730,11 +734,8 @@ void KX_GameObject::RemoveMeshes()
void KX_GameObject::UpdateTransform()
{
// HACK: saves function call for dynamic object, they are handled differently
- if (m_pPhysicsController1 && !m_pPhysicsController1->IsDyna())
- // Note that for Bullet, this does not even update the transform of static object
- // but merely sets there collision flag to "kinematic" because the synchronization is
- // done during physics simulation
- m_pPhysicsController1->SetSumoTransform(true);
+ if (m_pPhysicsController && !m_pPhysicsController->IsDynamic())
+ m_pPhysicsController->SetTransform();
if (m_pGraphicController)
// update the culling tree
m_pGraphicController->SetGraphicTransform();
@@ -749,8 +750,8 @@ void KX_GameObject::UpdateTransformFunc(SG_IObject* node, void* gameobj, void* s
void KX_GameObject::SynchronizeTransform()
{
// only used for sensor object, do full synchronization as bullet doesn't do it
- if (m_pPhysicsController1)
- m_pPhysicsController1->SetTransform();
+ if (m_pPhysicsController)
+ m_pPhysicsController->SetTransform();
if (m_pGraphicController)
m_pGraphicController->SetGraphicTransform();
}
@@ -935,10 +936,10 @@ KX_GameObject::GetLayer(
void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local)
{
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
MT_Vector3 lv = local ? NodeGetWorldOrientation() * lin_vel : lin_vel;
- m_pPhysicsController1->SetLinearVelocity(lv + m_pPhysicsController1->GetLinearVelocity(), 0);
+ m_pPhysicsController->SetLinearVelocity(lv + m_pPhysicsController->GetLinearVelocity(), 0);
}
}
@@ -946,16 +947,16 @@ void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local)
void KX_GameObject::setLinearVelocity(const MT_Vector3& lin_vel,bool local)
{
- if (m_pPhysicsController1)
- m_pPhysicsController1->SetLinearVelocity(lin_vel,local);
+ if (m_pPhysicsController)
+ m_pPhysicsController->SetLinearVelocity(lin_vel,local);
}
void KX_GameObject::setAngularVelocity(const MT_Vector3& ang_vel,bool local)
{
- if (m_pPhysicsController1)
- m_pPhysicsController1->SetAngularVelocity(ang_vel,local);
+ if (m_pPhysicsController)
+ m_pPhysicsController->SetAngularVelocity(ang_vel,local);
}
@@ -965,12 +966,12 @@ void KX_GameObject::ResolveCombinedVelocities(
bool lin_vel_local,
bool ang_vel_local
) {
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
MT_Vector3 lv = lin_vel_local ? NodeGetWorldOrientation() * lin_vel : lin_vel;
MT_Vector3 av = ang_vel_local ? NodeGetWorldOrientation() * ang_vel : ang_vel;
- m_pPhysicsController1->resolveCombinedVelocities(
+ m_pPhysicsController->ResolveCombinedVelocities(
lv.x(),lv.y(),lv.z(),av.x(),av.y(),av.z());
}
}
@@ -1082,9 +1083,9 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
MT_Scalar KX_GameObject::GetMass()
{
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
- return m_pPhysicsController1->GetMass();
+ return m_pPhysicsController->GetMass();
}
return 0.0;
}
@@ -1092,9 +1093,9 @@ MT_Scalar KX_GameObject::GetMass()
MT_Vector3 KX_GameObject::GetLocalInertia()
{
MT_Vector3 local_inertia(0.0,0.0,0.0);
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
- local_inertia = m_pPhysicsController1->GetLocalInertia();
+ local_inertia = m_pPhysicsController->GetLocalInertia();
}
return local_inertia;
}
@@ -1103,9 +1104,9 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local)
{
MT_Vector3 velocity(0.0,0.0,0.0), locvel;
MT_Matrix3x3 ori;
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
- velocity = m_pPhysicsController1->GetLinearVelocity();
+ velocity = m_pPhysicsController->GetLinearVelocity();
if (local)
{
@@ -1122,9 +1123,9 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local)
{
MT_Vector3 velocity(0.0,0.0,0.0), locvel;
MT_Matrix3x3 ori;
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
- velocity = m_pPhysicsController1->GetAngularVelocity();
+ velocity = m_pPhysicsController->GetAngularVelocity();
if (local)
{
@@ -1139,9 +1140,9 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local)
MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point)
{
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
- return m_pPhysicsController1->GetVelocity(point);
+ return m_pPhysicsController->GetVelocity(point);
}
return MT_Vector3(0.0,0.0,0.0);
}
@@ -1154,13 +1155,13 @@ void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans)
if (!GetSGNode())
return;
- if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
+ if (m_pPhysicsController && !GetSGNode()->GetSGParent())
{
// don't update physic controller if the object is a child:
// 1) the transformation will not be right
// 2) in this case, the physic controller is necessarily a static object
// that is updated from the normal kinematic synchronization
- m_pPhysicsController1->setPosition(trans);
+ m_pPhysicsController->SetPosition(trans);
}
GetSGNode()->SetLocalPosition(trans);
@@ -1175,10 +1176,10 @@ void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot)
if (!GetSGNode())
return;
- if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
+ if (m_pPhysicsController && !GetSGNode()->GetSGParent())
{
// see note above
- m_pPhysicsController1->setOrientation(rot);
+ m_pPhysicsController->SetOrientation(rot);
}
GetSGNode()->SetLocalOrientation(rot);
}
@@ -1201,10 +1202,10 @@ void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
if (!GetSGNode())
return;
- if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
+ if (m_pPhysicsController && !GetSGNode()->GetSGParent())
{
// see note above
- m_pPhysicsController1->setScaling(scale);
+ m_pPhysicsController->SetScaling(scale);
}
GetSGNode()->SetLocalScale(scale);
}
@@ -1216,13 +1217,13 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale)
if (GetSGNode())
{
GetSGNode()->RelativeScale(scale);
- if (m_pPhysicsController1 && (!GetSGNode()->GetSGParent()))
+ if (m_pPhysicsController && (!GetSGNode()->GetSGParent()))
{
// see note above
// we can use the local scale: it's the same thing for a root object
// and the world scale is not yet updated
MT_Vector3 newscale = GetSGNode()->GetLocalScale();
- m_pPhysicsController1->setScaling(newscale);
+ m_pPhysicsController->SetScaling(newscale);
}
}
}
@@ -1355,13 +1356,13 @@ void KX_GameObject::UnregisterCollisionCallbacks()
// Unregister from callbacks
KX_Scene* scene = GetScene();
PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
- PHY_IPhysicsController* spc = static_cast<PHY_IPhysicsController*> (GetPhysicsController()->GetUserData());
+ PHY_IPhysicsController* spc = GetPhysicsController();
// If we are the last to unregister on this physics controller
- if (pe->removeCollisionCallback(spc)){
+ if (pe->RemoveCollisionCallback(spc)){
// If we are a sensor object
if (m_pClient_info->isSensor())
// Remove sensor body from physics world
- pe->removeSensor(spc);
+ pe->RemoveSensor(spc);
}
}
@@ -1375,13 +1376,13 @@ void KX_GameObject::RegisterCollisionCallbacks()
// Register from callbacks
KX_Scene* scene = GetScene();
PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
- PHY_IPhysicsController* spc = static_cast<PHY_IPhysicsController*> (GetPhysicsController()->GetUserData());
+ PHY_IPhysicsController* spc = GetPhysicsController();
// If we are the first to register on this physics controller
- if (pe->requestCollisionCallback(spc)){
+ if (pe->RequestCollisionCallback(spc)){
// If we are a sensor object
if (m_pClient_info->isSensor())
// Add sensor body to physics world
- pe->addSensor(spc);
+ pe->AddSensor(spc);
}
}
void KX_GameObject::RunCollisionCallbacks(KX_GameObject *collider)
@@ -2170,14 +2171,14 @@ PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF
PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_IPhysicsController *spc = self->GetPhysicsController();
+ PHY_IPhysicsController *spc = self->GetPhysicsController();
return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0);
}
int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_IPhysicsController *spc = self->GetPhysicsController();
+ PHY_IPhysicsController *spc = self->GetPhysicsController();
MT_Scalar val = PyFloat_AsDouble(value);
if (val < 0.0) { /* also accounts for non float */
PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above");
@@ -2193,14 +2194,14 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd
PyObject *KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_IPhysicsController *spc = self->GetPhysicsController();
+ PHY_IPhysicsController *spc = self->GetPhysicsController();
return PyFloat_FromDouble(spc ? spc->GetLinVelocityMin() : 0.0f);
}
int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_IPhysicsController *spc = self->GetPhysicsController();
+ PHY_IPhysicsController *spc = self->GetPhysicsController();
MT_Scalar val = PyFloat_AsDouble(value);
if (val < 0.0) { /* also accounts for non float */
PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above");
@@ -2216,14 +2217,14 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF
PyObject *KX_GameObject::pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_IPhysicsController *spc = self->GetPhysicsController();
+ PHY_IPhysicsController *spc = self->GetPhysicsController();
return PyFloat_FromDouble(spc ? spc->GetLinVelocityMax() : 0.0f);
}
int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_IPhysicsController *spc = self->GetPhysicsController();
+ PHY_IPhysicsController *spc = self->GetPhysicsController();
MT_Scalar val = PyFloat_AsDouble(value);
if (val < 0.0) { /* also accounts for non float */
PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above");
@@ -2307,8 +2308,8 @@ PyObject *KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB
return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL);
#else
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- if (self->GetPhysicsController())
- return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia());
+ if (self->GetPhysicsController1())
+ return PyObjectFrom(self->GetPhysicsController1()->GetLocalInertia());
return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
#endif
}
@@ -2854,14 +2855,8 @@ PyObject *KX_GameObject::PyGetVelocity(PyObject *args)
if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point)))
return NULL;
-
- if (m_pPhysicsController1)
- {
- return PyObjectFrom(m_pPhysicsController1->GetVelocity(point));
- }
- else {
- return PyObjectFrom(MT_Vector3(0.0,0.0,0.0));
- }
+
+ return PyObjectFrom(GetVelocity(point));
}
PyObject *KX_GameObject::PyGetReactionForce()
@@ -2870,8 +2865,8 @@ PyObject *KX_GameObject::PyGetReactionForce()
// XXX - Currently not working with bullet intergration, see KX_BulletPhysicsController.cpp's getReactionForce
#if 0
- if (GetPhysicsController())
- return PyObjectFrom(GetPhysicsController()->getReactionForce());
+ if (GetPhysicsController1())
+ return PyObjectFrom(GetPhysicsController1()->getReactionForce());
return PyObjectFrom(dummy_point);
#endif
@@ -2884,7 +2879,7 @@ PyObject *KX_GameObject::PyGetReactionForce()
PyObject *KX_GameObject::PyEnableRigidBody()
{
if (GetPhysicsController())
- GetPhysicsController()->setRigidBody(true);
+ GetPhysicsController()->SetRigidBody(true);
Py_RETURN_NONE;
}
@@ -2894,7 +2889,7 @@ PyObject *KX_GameObject::PyEnableRigidBody()
PyObject *KX_GameObject::PyDisableRigidBody()
{
if (GetPhysicsController())
- GetPhysicsController()->setRigidBody(false);
+ GetPhysicsController()->SetRigidBody(false);
Py_RETURN_NONE;
}
@@ -2935,9 +2930,9 @@ PyObject *KX_GameObject::PySetCollisionMargin(PyObject *value)
return NULL;
}
- if (m_pPhysicsController1)
+ if (m_pPhysicsController)
{
- m_pPhysicsController1->setMargin(collisionMargin);
+ m_pPhysicsController->SetMargin(collisionMargin);
Py_RETURN_NONE;
}
PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
@@ -2951,7 +2946,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
PyObject *pyattach;
PyObject *pyimpulse;
- if (!m_pPhysicsController1) {
+ if (!m_pPhysicsController) {
PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
return NULL;
}
@@ -2962,7 +2957,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
MT_Vector3 impulse;
if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse))
{
- m_pPhysicsController1->applyImpulse(attach, impulse);
+ m_pPhysicsController->ApplyImpulse(attach, impulse);
Py_RETURN_NONE;
}
@@ -2975,7 +2970,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
PyObject *KX_GameObject::PySuspendDynamics()
{
- SuspendDynamics();
+ GetPhysicsController()->SuspendDynamics();
Py_RETURN_NONE;
}
@@ -2983,7 +2978,7 @@ PyObject *KX_GameObject::PySuspendDynamics()
PyObject *KX_GameObject::PyRestoreDynamics()
{
- RestoreDynamics();
+ GetPhysicsController()->RestoreDynamics();
Py_RETURN_NONE;
}
@@ -3023,11 +3018,11 @@ PyObject *KX_GameObject::PyGetAxisVect(PyObject *value)
PyObject *KX_GameObject::PyGetPhysicsId()
{
- KX_IPhysicsController* ctrl = GetPhysicsController();
+ PHY_IPhysicsController* ctrl = GetPhysicsController();
uint_ptr physid=0;
if (ctrl)
{
- physid= (uint_ptr)ctrl->GetUserData();
+ physid= (uint_ptr)ctrl;
}
return PyLong_FromLong((long)physid);
}
@@ -3190,7 +3185,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized();
PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment();
- KX_IPhysicsController *spc = GetPhysicsController();
+ PHY_IPhysicsController *spc = GetPhysicsController();
KX_GameObject *parent = GetParent();
if (!spc && parent)
spc = parent->GetPhysicsController();
@@ -3336,7 +3331,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
}
PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment();
- KX_IPhysicsController *spc = GetPhysicsController();
+ PHY_IPhysicsController *spc = GetPhysicsController();
KX_GameObject *parent = GetParent();
if (!spc && parent)
spc = parent->GetPhysicsController();
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index dde3ff53299..55e2b31c5bf 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -49,7 +49,6 @@
#include "CTR_HashedPtr.h"
#include "KX_Scene.h"
#include "KX_KetsjiEngine.h" /* for m_anim_framerate */
-#include "KX_IPhysicsController.h" /* for suspend/resume */
#include "DNA_object_types.h"
#include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
@@ -57,9 +56,9 @@
struct KX_ClientObjectInfo;
class KX_RayCast;
class RAS_MeshObject;
-class KX_IPhysicsController;
class PHY_IGraphicController;
class PHY_IPhysicsEnvironment;
+class PHY_IPhysicsController;
class BL_ActionManager;
struct Object;
class KX_ObstacleSimulation;
@@ -107,7 +106,7 @@ protected:
bool m_bCulled;
bool m_bOccluder;
- KX_IPhysicsController* m_pPhysicsController1;
+ PHY_IPhysicsController* m_pPhysicsController;
PHY_IGraphicController* m_pGraphicController;
STR_String m_testPropName;
bool m_xray;
@@ -465,12 +464,12 @@ public:
* \return a pointer to the physics controller owned by this class.
*/
- KX_IPhysicsController* GetPhysicsController();
+ PHY_IPhysicsController* GetPhysicsController();
- void SetPhysicsController(KX_IPhysicsController* physicscontroller,bool isDynamic)
+ void SetPhysicsController(PHY_IPhysicsController* physicscontroller,bool isDynamic)
{
m_bDyna = isDynamic;
- m_pPhysicsController1 = physicscontroller;
+ m_pPhysicsController = physicscontroller;
}
virtual class RAS_Deformer* GetDeformer()
@@ -885,32 +884,6 @@ public:
* Resume making progress
*/
void Resume(void);
-
- void SuspendDynamics(void) {
- if (m_bSuspendDynamics)
- {
- return;
- }
-
- if (m_pPhysicsController1)
- {
- m_pPhysicsController1->SuspendDynamics();
- }
- m_bSuspendDynamics = true;
- }
-
- void RestoreDynamics(void) {
- if (!m_bSuspendDynamics)
- {
- return;
- }
-
- if (m_pPhysicsController1)
- {
- m_pPhysicsController1->RestoreDynamics();
- }
- m_bSuspendDynamics = false;
- }
void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
{
diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
index f221b7c6cd4..f75633659ff 100644
--- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp
+++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
@@ -48,7 +48,7 @@ typedef unsigned long uint_ptr;
#include "KX_IPO_SGController.h"
#include "KX_ScalarInterpolator.h"
#include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
+#include "PHY_IPhysicsController.h"
#include "DNA_ipo_types.h"
#include "BLI_math.h"
@@ -154,9 +154,10 @@ bool KX_IpoSGController::Update(double currentTime)
{
if (m_game_object && ob && m_game_object->GetPhysicsController())
{
- m_game_object->GetPhysicsController()->ApplyForce(m_ipo_local ?
- ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
- m_ipo_xform.GetPosition(), false);
+ MT_Vector3 vec = m_ipo_local ?
+ ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
+ m_ipo_xform.GetPosition();
+ m_game_object->GetPhysicsController()->ApplyForce(vec, false);
}
}
else
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h
deleted file mode 100644
index 2019be57679..00000000000
--- a/source/gameengine/Ketsji/KX_IPhysicsController.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_IPhysicsController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_IPHYSICSCONTROLLER_H__
-#define __KX_IPHYSICSCONTROLLER_H__
-
-#include "SG_Controller.h"
-#include "MT_Vector3.h"
-#include "MT_Point3.h"
-#include "MT_Transform.h"
-#include "MT_Matrix3x3.h"
-
-struct KX_ClientObjectInfo;
-
-/**
- * Physics Controller, a special kind of Scene Graph Transformation Controller.
- * It get's callbacks from Physics in case a transformation change took place.
- * Each time the scene graph get's updated, the controller get's a chance
- * in the 'Update' method to reflect changed.
- */
-
-class KX_IPhysicsController : public SG_Controller
-
-{
-protected:
- bool m_bDyna;
- bool m_bSensor;
- bool m_bCharacter;
- bool m_bCompound;
- bool m_suspendDynamics;
- void* m_userdata;
-public:
- KX_IPhysicsController(bool dyna,bool sensor,bool character,bool compound, void* userdata);
- virtual ~KX_IPhysicsController();
-
-
- virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0;
- virtual void SetObject (SG_IObject* object)=0;
- virtual void setMargin (float collisionMargin)=0;
-
- virtual void RelativeTranslate(const MT_Vector3& dloc,bool local)=0;
- virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local)=0;
- virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0;
- virtual void ApplyForce(const MT_Vector3& force,bool local)=0;
- virtual void SetWalkDirection(const MT_Vector3& dir,bool local)=0;
- virtual MT_Vector3 GetLinearVelocity()=0;
- virtual MT_Vector3 GetAngularVelocity()=0;
- virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0;
- virtual MT_Vector3 GetWalkDirection()=0;
- virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
- virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0;
- virtual void Jump()=0;
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
-
- virtual void getOrientation(MT_Quaternion& orn)=0;
- virtual void setOrientation(const MT_Matrix3x3& orn)=0;
- virtual void SetTransform()=0;
- //virtual void setOrientation(const MT_Quaternion& orn)=0;
- virtual void setPosition(const MT_Point3& pos)=0;
- virtual void setScaling(const MT_Vector3& scaling)=0;
- virtual MT_Scalar GetMass()=0;
- virtual void SetMass(MT_Scalar newmass)=0;
-
- virtual float GetLinVelocityMin()=0;
- virtual void SetLinVelocityMin(float newmass)=0;
- virtual float GetLinVelocityMax()=0;
- virtual void SetLinVelocityMax(float newmass)=0;
-
- virtual MT_Vector3 GetLocalInertia()=0;
- virtual MT_Vector3 getReactionForce()=0;
- virtual void setRigidBody(bool rigid)=0;
- virtual void AddCompoundChild(KX_IPhysicsController* child) = 0;
- virtual void RemoveCompoundChild(KX_IPhysicsController* child) = 0;
-
- virtual void SuspendDynamics(bool ghost=false)=0;
- virtual void RestoreDynamics()=0;
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode)=0;
-
- void SetDyna(bool isDynamic) {
- m_bDyna = isDynamic;
- }
-
- void SetSensor(bool isSensor) {
- m_bSensor = isSensor;
- }
-
- void SetCharacter(bool isCharacter) {
- m_bCharacter = isCharacter;
- }
-
- bool IsDyna(void) {
- return m_bDyna;
- }
-
- bool IsSensor(void) {
- return m_bSensor;
- }
-
- bool IsCharacter(void) {
- return m_bCharacter;
- }
-
- bool IsCompound(void) {
- return m_bCompound;
- }
-
- virtual MT_Scalar GetRadius()=0;
- virtual void SetSumoTransform(bool nondynaonly)=0;
- // todo: remove next line !
- virtual void SetSimulatedTime(double time)=0;
-
- // call from scene graph to update
- virtual bool Update(double time)=0;
- void* GetUserData() { return m_userdata;}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IPhysicsController")
-#endif
-};
-
-#endif /* __KX_IPHYSICSCONTROLLER_H__ */
diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h
index 616895a8269..a07d4b2195c 100644
--- a/source/gameengine/Ketsji/KX_ISceneConverter.h
+++ b/source/gameengine/Ketsji/KX_ISceneConverter.h
@@ -56,7 +56,7 @@ public:
*/
virtual void ConvertScene(
class KX_Scene* destinationscene,
- class RAS_IRenderTools* rendertools,
+ class RAS_IRasterizer* rendertools,
class RAS_ICanvas* canvas,
bool libloading=false)=0;
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index c685dcfe068..0e9e2cd8328 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -48,7 +48,6 @@
#include "RAS_BucketManager.h"
#include "RAS_Rect.h"
#include "RAS_IRasterizer.h"
-#include "RAS_IRenderTools.h"
#include "RAS_ICanvas.h"
#include "MT_Vector3.h"
#include "MT_Transform.h"
@@ -121,7 +120,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
: m_canvas(NULL),
m_rasterizer(NULL),
m_kxsystem(system),
- m_rendertools(NULL),
m_sceneconverter(NULL),
m_networkdevice(NULL),
#ifdef WITH_PYTHON
@@ -237,14 +235,6 @@ void KX_KetsjiEngine::SetCanvas(RAS_ICanvas* canvas)
-void KX_KetsjiEngine::SetRenderTools(RAS_IRenderTools* rendertools)
-{
- MT_assert(rendertools);
- m_rendertools = rendertools;
-}
-
-
-
void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer)
{
MT_assert(rasterizer);
@@ -278,7 +268,7 @@ void KX_KetsjiEngine::SetSceneConverter(KX_ISceneConverter* sceneconverter)
void KX_KetsjiEngine::InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text)
{
- m_dome = new KX_Dome(m_canvas, m_rasterizer, m_rendertools,this, res, mode, angle, resbuf, tilt, text);
+ m_dome = new KX_Dome(m_canvas, m_rasterizer,this, res, mode, angle, resbuf, tilt, text);
m_usedome = true;
}
@@ -319,7 +309,6 @@ void KX_KetsjiEngine::RenderDome()
scene = *sceneit;
KX_Camera* cam = scene->GetActiveCamera();
- m_rendertools->BeginFrame(m_rasterizer);
// pass the scene's worldsettings to the rasterizer
SetWorldSettings(scene->GetWorldInfo());
@@ -333,7 +322,7 @@ void KX_KetsjiEngine::RenderDome()
if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer();
- m_rendertools->SetAuxilaryClientInfo(scene);
+ m_rasterizer->SetAuxilaryClientInfo(scene);
// do the rendering
m_dome->RenderDomeFrame(scene,cam, i);
@@ -351,7 +340,7 @@ void KX_KetsjiEngine::RenderDome()
if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer();
- m_rendertools->SetAuxilaryClientInfo(scene);
+ m_rasterizer->SetAuxilaryClientInfo(scene);
// do the rendering
m_dome->RenderDomeFrame(scene, (*it),i);
@@ -362,7 +351,7 @@ void KX_KetsjiEngine::RenderDome()
it++;
}
// Part of PostRenderScene()
- m_rendertools->MotionBlur(m_rasterizer);
+ m_rasterizer->MotionBlur();
scene->Render2DFilters(m_canvas);
// no RunDrawingCallBacks
// no FlushDebugLines
@@ -499,7 +488,6 @@ bool KX_KetsjiEngine::BeginFrame()
ClearFrame();
m_rasterizer->BeginFrame(m_drawingmode , m_kxsystem->GetTimeInSeconds());
- m_rendertools->BeginFrame(m_rasterizer);
return true;
}
@@ -510,7 +498,7 @@ bool KX_KetsjiEngine::BeginFrame()
void KX_KetsjiEngine::EndFrame()
{
- m_rendertools->MotionBlur(m_rasterizer);
+ m_rasterizer->MotionBlur();
// Show profiling info
m_logger->StartLog(tc_overhead, m_kxsystem->GetTimeInSeconds(), true);
@@ -546,9 +534,6 @@ void KX_KetsjiEngine::EndFrame()
m_logger->StartLog(tc_latency, m_kxsystem->GetTimeInSeconds(), true);
m_rasterizer->SwapBuffers();
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
-
- m_rendertools->EndFrame(m_rasterizer);
-
m_canvas->EndDraw();
}
@@ -661,7 +646,7 @@ bool KX_KetsjiEngine::NextFrame()
#endif
KX_SetActiveScene(scene);
- scene->GetPhysicsEnvironment()->endFrame();
+ scene->GetPhysicsEnvironment()->EndFrame();
// Update scenegraph after physics step. This maps physics calculations
// into node positions.
@@ -703,11 +688,11 @@ bool KX_KetsjiEngine::NextFrame()
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
SG_SetActiveStage(SG_STAGE_PHYSICS2);
- scene->GetPhysicsEnvironment()->beginFrame();
+ scene->GetPhysicsEnvironment()->BeginFrame();
// Perform physics calculations on the scene. This can involve
// many iterations of the physics solver.
- scene->GetPhysicsEnvironment()->proceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime);
+ scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime);
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
SG_SetActiveStage(SG_STAGE_PHYSICS2_UPDATE);
@@ -777,7 +762,7 @@ bool KX_KetsjiEngine::NextFrame()
// Perform physics calculations on the scene. This can involve
// many iterations of the physics solver.
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
- scene->GetPhysicsEnvironment()->proceedDeltaTime(m_clockTime,timestep,timestep);
+ scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_clockTime,timestep,timestep);
// Update scenegraph after physics step. This maps physics calculations
// into node positions.
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
@@ -905,7 +890,7 @@ void KX_KetsjiEngine::Render()
if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer();
- m_rendertools->SetAuxilaryClientInfo(scene);
+ m_rasterizer->SetAuxilaryClientInfo(scene);
// do the rendering
RenderFrame(scene, cam);
@@ -921,7 +906,7 @@ void KX_KetsjiEngine::Render()
if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer();
- m_rendertools->SetAuxilaryClientInfo(scene);
+ m_rasterizer->SetAuxilaryClientInfo(scene);
// do the rendering
RenderFrame(scene, (*it));
@@ -954,7 +939,7 @@ void KX_KetsjiEngine::Render()
m_rasterizer->ClearDepthBuffer();
//pass the scene, for picking and raycasting (shadows)
- m_rendertools->SetAuxilaryClientInfo(scene);
+ m_rasterizer->SetAuxilaryClientInfo(scene);
// do the rendering
//RenderFrame(scene);
@@ -970,7 +955,7 @@ void KX_KetsjiEngine::Render()
if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer();
- m_rendertools->SetAuxilaryClientInfo(scene);
+ m_rasterizer->SetAuxilaryClientInfo(scene);
// do the rendering
RenderFrame(scene, (*it));
@@ -1172,7 +1157,7 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
CListValue *lightlist = scene->GetLightList();
int i, drawmode;
- m_rendertools->SetAuxilaryClientInfo(scene);
+ m_rasterizer->SetAuxilaryClientInfo(scene);
for (i=0; i<lightlist->GetCount(); i++) {
KX_GameObject *gameobj = (KX_GameObject*)lightlist->GetValue(i);
@@ -1202,7 +1187,7 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
/* render */
m_rasterizer->ClearDepthBuffer();
m_rasterizer->ClearColorBuffer();
- scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
+ scene->RenderBuckets(camtrans, m_rasterizer);
/* unbind framebuffer object, restore drawmode, free camera */
light->UnbindShadowBuffer(m_rasterizer);
@@ -1338,13 +1323,13 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
scene->RunDrawingCallbacks(scene->GetPreDrawCB());
#endif
- scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
+ scene->RenderBuckets(camtrans, m_rasterizer);
//render all the font objects for this scene
scene->RenderFonts();
if (scene->GetPhysicsEnvironment())
- scene->GetPhysicsEnvironment()->debugDrawWorld();
+ scene->GetPhysicsEnvironment()->DebugDrawWorld();
}
/*
@@ -1475,7 +1460,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
if (m_show_framerate || m_show_profile) {
/* Title for profiling("Profile") */
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
"Profile",
xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin
ycoord,
@@ -1490,7 +1475,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
/* Framerate display */
if (m_show_framerate) {
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
"Frametime :",
xcoord + const_xindent,
ycoord,
@@ -1498,7 +1483,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
m_canvas->GetHeight() /* RdV, TODO ?? */);
debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.f, 1.0/tottime);
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
debugtxt.ReadPtr(),
xcoord + const_xindent + profile_indent,
ycoord,
@@ -1511,7 +1496,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
/* Profile display */
if (m_show_profile) {
for (int j = tc_first; j < tc_numCategories; j++) {
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
m_profileLabels[j],
xcoord + const_xindent,
ycoord,
@@ -1521,13 +1506,13 @@ void KX_KetsjiEngine::RenderDebugProperties()
double time = m_logger->GetAverage((KX_TimeCategory)j);
debugtxt.Format("%5.2fms | %d%%", time*1000.f, (int)(time/tottime * 100.f));
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
debugtxt.ReadPtr(),
xcoord + const_xindent + profile_indent, ycoord,
m_canvas->GetWidth(),
m_canvas->GetHeight());
- m_rendertools->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime);
+ m_rasterizer->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime);
ycoord += const_ysize;
}
}
@@ -1538,7 +1523,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
if (m_show_debug_properties) {
/* Title for debugging("Debug properties") */
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
"Debug Properties",
xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin
ycoord,
@@ -1584,7 +1569,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
first = false;
}
}
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
debugtxt.ReadPtr(),
xcoord + const_xindent,
ycoord,
@@ -1597,7 +1582,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
if (propval) {
STR_String text = propval->GetText();
debugtxt = objname + ": '" + propname + "' = " + text;
- m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
debugtxt.ReadPtr(),
xcoord + const_xindent,
ycoord,
@@ -1704,7 +1689,7 @@ KX_Scene* KX_KetsjiEngine::CreateScene(Scene *scene, bool libloading)
m_canvas);
m_sceneconverter->ConvertScene(tmpscene,
- m_rendertools,
+ m_rasterizer,
m_canvas,
libloading);
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
index d5d7262a418..e7fb250c2d9 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h
@@ -74,7 +74,6 @@ private:
class RAS_ICanvas* m_canvas; // 2D Canvas (2D Rendering Device Context)
class RAS_IRasterizer* m_rasterizer; // 3D Rasterizer (3D Rendering)
class KX_ISystem* m_kxsystem;
- class RAS_IRenderTools* m_rendertools;
class KX_ISceneConverter* m_sceneconverter;
class NG_NetworkDeviceInterface* m_networkdevice;
#ifdef WITH_PYTHON
@@ -217,7 +216,6 @@ public:
void SetMouseDevice(SCA_IInputDevice* mousedevice);
void SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice);
void SetCanvas(RAS_ICanvas* canvas);
- void SetRenderTools(RAS_IRenderTools* rendertools);
void SetRasterizer(RAS_IRasterizer* rasterizer);
#ifdef WITH_PYTHON
void SetPyNamespace(PyObject *pythondictionary);
@@ -229,7 +227,6 @@ public:
RAS_IRasterizer* GetRasterizer() { return m_rasterizer; }
RAS_ICanvas* GetCanvas() { return m_canvas; }
- RAS_IRenderTools* GetRenderTools() { return m_rendertools; }
SCA_IInputDevice* GetKeyboardDevice() { return m_keyboarddevice; }
SCA_IInputDevice* GetMouseDevice() { return m_mousedevice; }
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 0e4db0d351e..4567c17cc3e 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -40,7 +40,7 @@
#include "KX_Light.h"
#include "KX_Camera.h"
#include "RAS_IRasterizer.h"
-#include "RAS_IRenderTools.h"
+#include "RAS_ICanvas.h"
#include "KX_PyMath.h"
@@ -53,16 +53,16 @@
#include "MEM_guardedalloc.h"
KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
- class RAS_IRenderTools* rendertools,
+ RAS_IRasterizer* rasterizer,
const RAS_LightObject& lightobj,
bool glsl)
: KX_GameObject(sgReplicationInfo,callbacks),
- m_rendertools(rendertools)
+ m_rasterizer(rasterizer)
{
m_lightobj = lightobj;
m_lightobj.m_scene = sgReplicationInfo;
m_lightobj.m_light = this;
- m_rendertools->AddLight(&m_lightobj);
+ m_rasterizer->AddLight(&m_lightobj);
m_glsl = glsl;
m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene();
m_base = NULL;
@@ -81,7 +81,7 @@ KX_LightObject::~KX_LightObject()
GPU_lamp_update_spot(lamp, la->spotsize, la->spotblend);
}
- m_rendertools->RemoveLight(&m_lightobj);
+ m_rasterizer->RemoveLight(&m_lightobj);
if (m_base) {
BKE_scene_base_unlink(m_blenderscene, m_base);
@@ -98,7 +98,7 @@ CValue* KX_LightObject::GetReplica()
replica->ProcessReplica();
replica->m_lightobj.m_light = replica;
- m_rendertools->AddLight(&replica->m_lightobj);
+ m_rasterizer->AddLight(&replica->m_lightobj);
return replica;
}
diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h
index 43421a3faf3..4f11c535cf0 100644
--- a/source/gameengine/Ketsji/KX_Light.h
+++ b/source/gameengine/Ketsji/KX_Light.h
@@ -40,7 +40,6 @@ struct Scene;
struct Base;
class KX_Camera;
class RAS_IRasterizer;
-class RAS_IRenderTools;
class MT_Transform;
class KX_LightObject : public KX_GameObject
@@ -48,13 +47,13 @@ class KX_LightObject : public KX_GameObject
Py_Header
protected:
RAS_LightObject m_lightobj;
- class RAS_IRenderTools* m_rendertools; //needed for registering and replication of lightobj
+ class RAS_IRasterizer* m_rasterizer; //needed for registering and replication of lightobj
bool m_glsl;
Scene* m_blenderscene;
Base* m_base;
public:
- KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, bool glsl);
+ KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,RAS_IRasterizer* rasterizer,const RAS_LightObject& lightobj, bool glsl);
virtual ~KX_LightObject();
virtual CValue* GetReplica();
RAS_LightObject* GetLightData() { return &m_lightobj;}
@@ -66,8 +65,8 @@ public:
struct GPULamp *GetGPULamp();
bool HasShadowBuffer();
int GetShadowLayer();
- void BindShadowBuffer(class RAS_IRasterizer *ras, class RAS_ICanvas *canvas, class KX_Camera *cam, class MT_Transform& camtrans);
- void UnbindShadowBuffer(class RAS_IRasterizer *ras);
+ void BindShadowBuffer(RAS_IRasterizer *ras, class RAS_ICanvas *canvas, class KX_Camera *cam, class MT_Transform& camtrans);
+ void UnbindShadowBuffer(RAS_IRasterizer *ras);
struct Image *GetTextureImage(short texslot);
void Update();
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index 2a9d59e8b7b..c288c647fa2 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -39,7 +39,6 @@
#include "KX_VertexProxy.h"
#include "KX_PolyProxy.h"
-#include "KX_PolygonMaterial.h"
#include "KX_BlenderMaterial.h"
#include "KX_PyMath.h"
@@ -388,14 +387,8 @@ PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_
for (i=0; i<tot; mit++, i++) {
RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial();
- if (polymat->GetFlag() & RAS_BLENDERMAT) {
- KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial *>(polymat);
- PyList_SET_ITEM(materials, i, mat->GetProxy());
- }
- else {
- KX_PolygonMaterial *mat = static_cast<KX_PolygonMaterial *>(polymat);
- PyList_SET_ITEM(materials, i, mat->GetProxy());
- }
+ KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial *>(polymat);
+ PyList_SET_ITEM(materials, i, mat->GetProxy());
}
return materials;
}
diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp
index 3ca01e7af74..4728f71a6ea 100644
--- a/source/gameengine/Ketsji/KX_MotionState.cpp
+++ b/source/gameengine/Ketsji/KX_MotionState.cpp
@@ -41,7 +41,7 @@ KX_MotionState::~KX_MotionState()
{
}
-void KX_MotionState::getWorldPosition(float& posX,float& posY,float& posZ)
+void KX_MotionState::GetWorldPosition(float& posX,float& posY,float& posZ)
{
const MT_Point3& pos = m_node->GetWorldPosition();
posX = pos[0];
@@ -49,7 +49,7 @@ void KX_MotionState::getWorldPosition(float& posX,float& posY,float& posZ)
posZ = pos[2];
}
-void KX_MotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
+void KX_MotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
{
const MT_Vector3& scale = m_node->GetWorldScaling();
scaleX = scale[0];
@@ -57,7 +57,7 @@ void KX_MotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
scaleZ = scale[2];
}
-void KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
+void KX_MotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
{
MT_Quaternion orn = m_node->GetWorldOrientation().getRotation();
quatIma0 = orn[0];
@@ -66,24 +66,24 @@ void KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float&
quatReal = orn[3];
}
-void KX_MotionState::getWorldOrientation(float* ori)
+void KX_MotionState::GetWorldOrientation(float* ori)
{
const MT_Matrix3x3& mat = m_node->GetWorldOrientation();
mat.getValue(ori);
}
-void KX_MotionState::setWorldOrientation(const float* ori)
+void KX_MotionState::SetWorldOrientation(const float* ori)
{
m_node->SetLocalOrientation(ori);
}
-void KX_MotionState::setWorldPosition(float posX,float posY,float posZ)
+void KX_MotionState::SetWorldPosition(float posX,float posY,float posZ)
{
m_node->SetLocalPosition(MT_Point3(posX,posY,posZ));
//m_node->SetWorldPosition(MT_Point3(posX,posY,posZ));
}
-void KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
+void KX_MotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
{
MT_Quaternion orn;
orn[0] = quatIma0;
@@ -96,7 +96,7 @@ void KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float qua
}
-void KX_MotionState::calculateWorldTransformations()
+void KX_MotionState::CalculateWorldTransformations()
{
//Not needed, will be done in KX_Scene::UpdateParents() after the physics simulation
//bool parentUpdated = false;
diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h
index 116e62f408f..38046fe4ff9 100644
--- a/source/gameengine/Ketsji/KX_MotionState.h
+++ b/source/gameengine/Ketsji/KX_MotionState.h
@@ -46,15 +46,15 @@ public:
KX_MotionState(class SG_Spatial* spatial);
virtual ~KX_MotionState();
- virtual void getWorldPosition(float& posX,float& posY,float& posZ);
- virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
- virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
- virtual void setWorldPosition(float posX,float posY,float posZ);
- virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
- virtual void getWorldOrientation(float* ori);
- virtual void setWorldOrientation(const float* ori);
+ virtual void GetWorldPosition(float& posX,float& posY,float& posZ);
+ virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
+ virtual void GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
+ virtual void SetWorldPosition(float posX,float posY,float posZ);
+ virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
+ virtual void GetWorldOrientation(float* ori);
+ virtual void SetWorldOrientation(const float* ori);
- virtual void calculateWorldTransformations();
+ virtual void CalculateWorldTransformations();
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index 82ae8c13633..2dbafdad3d9 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -47,7 +47,6 @@
#include "KX_PyMath.h"
#include "KX_RayCast.h"
-#include "KX_IPhysicsController.h"
#include "PHY_IPhysicsController.h"
#include "PHY_IPhysicsEnvironment.h"
@@ -280,7 +279,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
/* 2. Get the object from PhysicsEnvironment */
/* Shoot! Beware that the first argument here is an
* ignore-object. We don't ignore anything... */
- KX_IPhysicsController* physics_controller = cam->GetPhysicsController();
+ PHY_IPhysicsController* physics_controller = cam->GetPhysicsController();
PHY_IPhysicsEnvironment* physics_environment = m_kxscene->GetPhysicsEnvironment();
// get UV mapping
diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp
index e45346db9c7..42f62886ff7 100644
--- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp
+++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp
@@ -30,6 +30,7 @@
#include "BLI_math_vector.h"
#include "KX_NavMeshObject.h"
#include "RAS_MeshObject.h"
+#include "RAS_Polygon.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -126,7 +127,7 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts,
MEM_SAFE_FREE(dtrisToTrisMap);
MEM_SAFE_FREE(trisToFacesMap);
- unsigned short *verticesMap = new unsigned short[nAllVerts];
+ unsigned short *verticesMap = (unsigned short *)MEM_mallocN(sizeof(*verticesMap) * nAllVerts, __func__);
memset(verticesMap, 0xff, sizeof(*verticesMap) * nAllVerts);
int curIdx = 0;
//vertices - mesh verts
@@ -215,6 +216,8 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts,
}
MEM_SAFE_FREE(allVerts);
+
+ MEM_freeN(verticesMap);
}
else
{
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
index cbb4e77d165..6459f35192d 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -68,7 +68,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
if (m_physCtrl)
{
m_physCtrl->SetMargin(m_Margin);
- m_physCtrl->setNewClientInfo(m_client_info);
+ m_physCtrl->SetNewClientInfo(m_client_info);
}
SynchronizeTransform();
}
@@ -84,8 +84,8 @@ void KX_NearSensor::SynchronizeTransform()
const MT_Point3& pos = parent->NodeGetWorldPosition();
float ori[12];
parent->NodeGetWorldOrientation().getValue(ori);
- motionState->setWorldPosition(pos[0], pos[1], pos[2]);
- motionState->setWorldOrientation(ori);
+ motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
+ motionState->SetWorldOrientation(ori);
m_physCtrl->WriteMotionStateToDynamics(true);
}
}
@@ -105,12 +105,12 @@ void KX_NearSensor::ProcessReplica()
if (m_physCtrl)
{
- m_physCtrl = m_physCtrl->GetReplica();
+ m_physCtrl = m_physCtrl->GetReplicaForSensors();
if (m_physCtrl)
{
//static_cast<KX_TouchEventManager*>(m_eventmgr)->GetPhysicsEnvironment()->addSensor(replica->m_physCtrl);
m_physCtrl->SetMargin(m_Margin);
- m_physCtrl->setNewClientInfo(m_client_info);
+ m_physCtrl->SetNewClientInfo(m_client_info);
}
}
@@ -186,7 +186,7 @@ bool KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2)
// need the mapping from PHY_IPhysicsController to gameobjects now
assert(obj1==m_physCtrl && obj2);
- KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>((static_cast<PHY_IPhysicsController*>(obj2))->getNewClientInfo());
+ KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>((static_cast<PHY_IPhysicsController*>(obj2))->GetNewClientInfo());
KX_GameObject* gameobj = ( client_info ?
client_info->m_gameobject :
@@ -216,8 +216,8 @@ bool KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollDat
// need the mapping from PHY_IPhysicsController to gameobjects now
KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (obj1 == m_physCtrl?
- ((PHY_IPhysicsController*)obj2)->getNewClientInfo() :
- ((PHY_IPhysicsController*)obj1)->getNewClientInfo());
+ ((PHY_IPhysicsController*)obj2)->GetNewClientInfo() :
+ ((PHY_IPhysicsController*)obj1)->GetNewClientInfo());
KX_GameObject* gameobj = ( client_info ?
client_info->m_gameobject :
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
index 2965faba8f4..2f85453dd23 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
@@ -36,7 +36,9 @@
#include "KX_ObjectActuator.h"
#include "KX_GameObject.h"
#include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus?
-#include "KX_IPhysicsController.h"
+#include "PHY_IPhysicsController.h"
+#include "PHY_ICharacter.h"
+#include "PHY_IPhysicsEnvironment.h"
/* ------------------------------------------------------------------------- */
/* Native functions */
@@ -84,8 +86,9 @@ KX_ObjectActuator(
if (m_bitLocalFlag.CharacterMotion)
{
KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
+ PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent);
- if (!parent->GetPhysicsController() || !parent->GetPhysicsController()->IsCharacter())
+ if (!character)
{
printf("Character motion enabled on non-character object (%s), falling back to simple motion.\n", parent->GetName().Ptr());
m_bitLocalFlag.CharacterMotion = false;
@@ -109,6 +112,7 @@ bool KX_ObjectActuator::Update()
RemoveAllEvents();
KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
+ PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent);
if (bNegativeEvent) {
// If we previously set the linear velocity we now have to inform
@@ -128,8 +132,7 @@ bool KX_ObjectActuator::Update()
// Explicitly stop the movement if we're using character motion
if (m_bitLocalFlag.CharacterMotion) {
- MT_Vector3 vec(0.0, 0.0, 0.0);
- parent->GetPhysicsController()->SetWalkDirection(vec, true);
+ character->SetWalkDirection(MT_Vector3 (0.0, 0.0, 0.0));
}
m_linear_damping_active = false;
@@ -220,7 +223,7 @@ bool KX_ObjectActuator::Update()
MT_Vector3 dir = m_dloc;
if (m_bitLocalFlag.AddOrSetCharLoc) {
- MT_Vector3 old_dir = parent->GetPhysicsController()->GetWalkDirection();
+ MT_Vector3 old_dir = character->GetWalkDirection();
if (!old_dir.fuzzyZero()) {
MT_Scalar mag = old_dir.length();
@@ -232,7 +235,12 @@ bool KX_ObjectActuator::Update()
}
// We always want to set the walk direction since a walk direction of (0, 0, 0) should stop the character
- parent->GetPhysicsController()->SetWalkDirection(dir, (m_bitLocalFlag.DLoc) != 0);
+ if (m_bitLocalFlag.DLoc)
+ {
+ MT_Matrix3x3 basis = parent->GetPhysicsController()->GetOrientation();
+ dir = basis*dir;
+ }
+ character->SetWalkDirection(dir/parent->GetScene()->GetPhysicsEnvironment()->GetNumTimeSubSteps());
if (!m_bitLocalFlag.ZeroDRot)
{
@@ -240,7 +248,8 @@ bool KX_ObjectActuator::Update()
}
if (m_bitLocalFlag.CharacterJump)
{
- parent->GetPhysicsController()->Jump();
+
+ character->Jump();
}
}
else {
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
index 83092c7d89c..ccc10eb06e3 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -35,8 +35,8 @@
#include "KX_PolyProxy.h"
#include "KX_MeshProxy.h"
#include "RAS_MeshObject.h"
+#include "RAS_Polygon.h"
#include "KX_BlenderMaterial.h"
-#include "KX_PolygonMaterial.h"
#include "KX_PyMath.h"
@@ -259,16 +259,8 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterial,
"getMaterial() : returns a material\n")
{
RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
- if (polymat->GetFlag() & RAS_BLENDERMAT)
- {
- KX_BlenderMaterial* mat = static_cast<KX_BlenderMaterial*>(polymat);
- return mat->GetProxy();
- }
- else
- {
- KX_PolygonMaterial* mat = static_cast<KX_PolygonMaterial*>(polymat);
- return mat->GetProxy();
- }
+ KX_BlenderMaterial* mat = static_cast<KX_BlenderMaterial*>(polymat);
+ return mat->GetProxy();
}
#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
deleted file mode 100644
index 0f53c510cf7..00000000000
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_PolygonMaterial.cpp
- * \ingroup ketsji
- */
-
-
-#include <stddef.h>
-
-#include "KX_PolygonMaterial.h"
-
-#include "BKE_mesh.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-
-#include "DNA_material_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_image_types.h"
-#include "DNA_meshdata_types.h"
-
-#include "IMB_imbuf_types.h"
-
-#include "GPU_draw.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RAS_LightObject.h"
-#include "RAS_MaterialBucket.h"
-
-#include "KX_PyMath.h"
-
-#define KX_POLYGONMATERIAL_CAPSULE_ID "KX_POLYGONMATERIAL_PTR"
-
-KX_PolygonMaterial::KX_PolygonMaterial()
- : PyObjectPlus(),
- RAS_IPolyMaterial(),
-
- m_material(NULL),
-#ifdef WITH_PYTHON
- m_pymaterial(NULL),
-#endif
- m_pass(0)
-{
- memset(&m_tface, 0, sizeof(m_tface));
- memset(&m_mcol, 0, sizeof(m_mcol));
-}
-
-void KX_PolygonMaterial::Initialize(
- const STR_String &texname,
- Material* ma,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int alphablend,
- bool alpha,
- bool zsort,
- bool light,
- int lightlayer,
- struct MTFace* tface,
- unsigned int* mcol)
-{
- RAS_IPolyMaterial::Initialize(
- texname,
- ma?ma->id.name:"",
- materialindex,
- tile,
- tilexrep,
- tileyrep,
- alphablend,
- alpha,
- zsort,
- light,
- (texname && texname != ""?true:false), /* if we have a texture we have image */
- ma?&ma->game:NULL);
-
- if (tface) {
- m_tface = *tface;
- }
- else {
- memset(&m_tface, 0, sizeof(m_tface));
- }
- if (mcol) {
- m_mcol = *mcol;
- }
- else {
- memset(&m_mcol, 0, sizeof(m_mcol));
- }
-
- m_material = ma;
-#ifdef WITH_PYTHON
- m_pymaterial = 0;
-#endif
- m_pass = 0;
-}
-
-KX_PolygonMaterial::~KX_PolygonMaterial()
-{
-#ifdef WITH_PYTHON
- if (m_pymaterial)
- {
- Py_DECREF(m_pymaterial);
- }
-#endif // WITH_PYTHON
-}
-
-Image *KX_PolygonMaterial::GetBlenderImage() const
-{
- return m_tface.tpage;
-}
-
-bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
-{
- bool dopass = false;
-
-#ifdef WITH_PYTHON
- if (m_pymaterial)
- {
- PyObject *pyRasty = PyCapsule_New((void*)rasty, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); /* new reference */
- PyObject *pyCachingInfo = PyCapsule_New((void*) &cachingInfo, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); /* new reference */
- PyObject *ret = PyObject_CallMethod(m_pymaterial, (char *)"activate", (char *)"(NNO)", pyRasty, pyCachingInfo, (PyObject *) this->m_proxy);
- if (ret)
- {
- bool value = PyLong_AsLong(ret);
- Py_DECREF(ret);
- dopass = value;
- }
- else
- {
- PyErr_Print();
- PyErr_Clear();
- PySys_SetObject("last_traceback", NULL);
- }
- }
- else
-#endif // WITH_PYTHON
- {
- switch (m_pass++)
- {
- case 0:
- DefaultActivate(rasty, cachingInfo);
- dopass = true;
- break;
- default:
- m_pass = 0;
- dopass = false;
- break;
- }
- }
-
- return dopass;
-}
-
-void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
-{
- if (GetCachingInfo() != cachingInfo)
- {
- if (!cachingInfo)
- GPU_set_tpage(NULL, 0, 0);
-
- cachingInfo = GetCachingInfo();
-
- if ((m_drawingmode & RAS_IRasterizer::KX_TEX)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED))
- {
- Image *ima = m_tface.tpage;
- GPU_update_image_time(ima, rasty->GetTime());
- GPU_set_tpage(&m_tface, 1, m_alphablend);
- }
- else
- GPU_set_tpage(NULL, 0, 0);
-
- if (m_drawingmode & RAS_IRasterizer::KX_BACKCULL)
- rasty->SetCullFace(true);
- else
- rasty->SetCullFace(false);
-
- if ((m_drawingmode & RAS_IRasterizer::KX_LINES) ||
- (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
- rasty->SetLines(true);
- else
- rasty->SetLines(false);
- rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity);
- rasty->SetShinyness(m_shininess);
- rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0);
- if (m_material)
- rasty->SetPolygonOffset(-m_material->zoffs, 0.0);
- }
-
- //rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity);
- //rasty->SetShinyness(m_shininess);
- //rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0);
- //if (m_material)
- // rasty->SetPolygonOffset(-m_material->zoffs, 0.0);
-}
-
-void KX_PolygonMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
-{
- if (m_material) {
- *rgba++ = (unsigned char) (m_material->r*255.0);
- *rgba++ = (unsigned char) (m_material->g*255.0);
- *rgba++ = (unsigned char) (m_material->b*255.0);
- *rgba++ = (unsigned char) (m_material->alpha*255.0);
- } else
- RAS_IPolyMaterial::GetMaterialRGBAColor(rgba);
-}
-
-#ifdef WITH_PYTHON
-
-//----------------------------------------------------------------------------
-//Python
-
-
-PyMethodDef KX_PolygonMaterial::Methods[] = {
- KX_PYMETHODTABLE(KX_PolygonMaterial, setCustomMaterial),
- KX_PYMETHODTABLE(KX_PolygonMaterial, updateTexture),
- KX_PYMETHODTABLE(KX_PolygonMaterial, setTexture),
- KX_PYMETHODTABLE(KX_PolygonMaterial, activate),
-// KX_PYMETHODTABLE(KX_PolygonMaterial, setPerPixelLights),
-
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_PolygonMaterial::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("texture", KX_PolygonMaterial, pyattr_get_texture),
- KX_PYATTRIBUTE_RO_FUNCTION("material", KX_PolygonMaterial, pyattr_get_material), /* should probably be .name ? */
-
- KX_PYATTRIBUTE_INT_RW("tile", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tile),
- KX_PYATTRIBUTE_INT_RW("tilexrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tilexrep),
- KX_PYATTRIBUTE_INT_RW("tileyrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tileyrep),
- KX_PYATTRIBUTE_INT_RW("drawingmode", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_drawingmode),
- //KX_PYATTRIBUTE_INT_RW("lightlayer", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_lightlayer),
-
- KX_PYATTRIBUTE_BOOL_RW("transparent", KX_PolygonMaterial, m_alpha),
- KX_PYATTRIBUTE_BOOL_RW("zsort", KX_PolygonMaterial, m_zsort),
-
- KX_PYATTRIBUTE_FLOAT_RW("shininess", 0.0f, 1000.0f, KX_PolygonMaterial, m_shininess),
- KX_PYATTRIBUTE_FLOAT_RW("specularity", 0.0f, 1000.0f, KX_PolygonMaterial, m_specularity),
-
- KX_PYATTRIBUTE_RW_FUNCTION("diffuse", KX_PolygonMaterial, pyattr_get_diffuse, pyattr_set_diffuse),
- KX_PYATTRIBUTE_RW_FUNCTION("specular",KX_PolygonMaterial, pyattr_get_specular, pyattr_set_specular),
-
- KX_PYATTRIBUTE_RO_FUNCTION("tface", KX_PolygonMaterial, pyattr_get_tface), /* How the heck is this even useful??? - Campbell */
- KX_PYATTRIBUTE_RO_FUNCTION("gl_texture", KX_PolygonMaterial, pyattr_get_gl_texture), /* could be called 'bindcode' */
- { NULL } //Sentinel
-};
-
-PyTypeObject KX_PolygonMaterial::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_PolygonMaterial",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,0,0,0,0,0,0,0,0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &PyObjectPlus::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setCustomMaterial, "setCustomMaterial(material)")
-{
- PyObject *material;
- if (PyArg_ParseTuple(args, "O:setCustomMaterial", &material))
- {
- if (m_pymaterial) {
- Py_DECREF(m_pymaterial);
- }
- m_pymaterial = material;
- Py_INCREF(m_pymaterial);
- Py_RETURN_NONE;
- }
-
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(KX_PolygonMaterial, updateTexture, "updateTexture(tface, rasty)")
-{
- PyObject *pyrasty, *pytface;
- if (PyArg_ParseTuple(args, "O!O!:updateTexture", &PyCapsule_Type, &pytface, &PyCapsule_Type, &pyrasty))
- {
- MTFace *tface = (MTFace*) PyCapsule_GetPointer(pytface, KX_POLYGONMATERIAL_CAPSULE_ID);
- RAS_IRasterizer *rasty = (RAS_IRasterizer*) PyCapsule_GetPointer(pyrasty, KX_POLYGONMATERIAL_CAPSULE_ID);
- Image *ima = (Image*)tface->tpage;
- GPU_update_image_time(ima, rasty->GetTime());
-
- Py_RETURN_NONE;
- }
-
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setTexture, "setTexture(tface)")
-{
- PyObject *pytface;
- if (PyArg_ParseTuple(args, "O!:setTexture", &PyCapsule_Type, &pytface))
- {
- MTFace *tface = (MTFace*) PyCapsule_GetPointer(pytface, KX_POLYGONMATERIAL_CAPSULE_ID);
- GPU_set_tpage(tface, 1, m_alphablend);
- Py_RETURN_NONE;
- }
-
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(KX_PolygonMaterial, activate, "activate(rasty, cachingInfo)")
-{
- PyObject *pyrasty, *pyCachingInfo;
- if (PyArg_ParseTuple(args, "O!O!:activate", &PyCapsule_Type, &pyrasty, &PyCapsule_Type, &pyCachingInfo))
- {
- RAS_IRasterizer *rasty = static_cast<RAS_IRasterizer*>(PyCapsule_GetPointer(pyrasty, KX_POLYGONMATERIAL_CAPSULE_ID));
- TCachingInfo *cachingInfo = static_cast<TCachingInfo*>(PyCapsule_GetPointer(pyCachingInfo, KX_POLYGONMATERIAL_CAPSULE_ID));
- if (rasty && cachingInfo)
- {
- DefaultActivate(rasty, *cachingInfo);
- Py_RETURN_NONE;
- }
- }
-
- return NULL;
-}
-
-PyObject *KX_PolygonMaterial::pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- return PyUnicode_From_STR_String(self->m_texturename);
-}
-
-PyObject *KX_PolygonMaterial::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- return PyUnicode_From_STR_String(self->m_materialname);
-}
-
-/* this does not seem useful */
-PyObject *KX_PolygonMaterial::pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- return PyCapsule_New(&self->m_tface, KX_POLYGONMATERIAL_CAPSULE_ID, NULL);
-}
-
-PyObject *KX_PolygonMaterial::pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- int bindcode= 0;
- if (self->m_tface.tpage)
- bindcode= self->m_tface.tpage->bindcode;
-
- return PyLong_FromLong(bindcode);
-}
-
-
-PyObject *KX_PolygonMaterial::pyattr_get_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- return PyObjectFrom(self->m_diffuse);
-}
-
-int KX_PolygonMaterial::pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- MT_Vector3 vec;
-
- if (!PyVecTo(value, vec))
- return PY_SET_ATTR_FAIL;
-
- self->m_diffuse= vec;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_PolygonMaterial::pyattr_get_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- return PyObjectFrom(self->m_specular);
-}
-
-int KX_PolygonMaterial::pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v);
- MT_Vector3 vec;
-
- if (!PyVecTo(value, vec))
- return PY_SET_ATTR_FAIL;
-
- self->m_specular= vec;
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h
deleted file mode 100644
index 89bfb4ff9fb..00000000000
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_PolygonMaterial.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_POLYGONMATERIAL_H__
-#define __KX_POLYGONMATERIAL_H__
-
-#include "PyObjectPlus.h"
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_IRasterizer.h"
-#include "DNA_ID.h"
-#include "DNA_meshdata_types.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-struct MTFace;
-struct Material;
-struct MTex;
-struct Image;
-
-/**
- * Material class.
- *
- * This holds the shader, textures and python methods for setting the render state before
- * rendering.
- */
-class KX_PolygonMaterial : public PyObjectPlus, public RAS_IPolyMaterial
-{
- Py_Header
-private:
- /** Blender texture face structure. */
- mutable MTFace m_tface;
- mutable unsigned int m_mcol;
- Material* m_material;
-
-#ifdef WITH_PYTHON
- PyObject* m_pymaterial;
-#endif
-
- mutable int m_pass;
-public:
-
- KX_PolygonMaterial();
- void Initialize(const STR_String &texname,
- Material* ma,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int alphablend,
- bool alpha,
- bool zsort,
- bool light,
- int lightlayer,
- struct MTFace* tface,
- unsigned int* mcol);
-
- virtual ~KX_PolygonMaterial();
-
- /**
- * Returns the caching information for this material,
- * This can be used to speed up the rasterizing process.
- * \return The caching information.
- */
- virtual TCachingInfo GetCachingInfo(void) const
- {
- return (void*) this;
- }
-
- /**
- * Activates the material in the (OpenGL) rasterizer.
- * On entry, the cachingInfo contains info about the last activated material.
- * On exit, the cachingInfo should contain updated info about this material.
- * \param rasty The rasterizer in which the material should be active.
- * \param cachingInfo The information about the material used to speed up rasterizing.
- */
- void DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const;
- virtual bool Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const;
-
- Material *GetBlenderMaterial() const
- {
- return m_material;
- }
-
- Image *GetBlenderImage() const;
-
- /**
- * Returns the Blender texture face structure that is used for this material.
- * \return The material's texture face.
- */
- MTFace* GetMTFace(void) const
- {
- return &m_tface;
- }
-
- unsigned int* GetMCol(void) const
- {
- return &m_mcol;
- }
- virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
-
-#ifdef WITH_PYTHON
- KX_PYMETHOD_DOC(KX_PolygonMaterial, updateTexture);
- KX_PYMETHOD_DOC(KX_PolygonMaterial, setTexture);
- KX_PYMETHOD_DOC(KX_PolygonMaterial, activate);
-
- KX_PYMETHOD_DOC(KX_PolygonMaterial, setCustomMaterial);
- KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram);
-
- virtual PyObject *py_repr(void) { return PyUnicode_FromString(m_material ? ((ID *)m_material)->name+2 : ""); }
-
- static PyObject* pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- static PyObject* pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- static PyObject* pyattr_get_diffuse(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_specular(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif
-
-};
-
-#endif /* __KX_POLYGONMATERIAL_H__ */
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index 2e9b988dff1..e9843b0af5b 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -100,7 +100,7 @@ static PyObject *gPySetGravity(PyObject *self,
if (PyArg_ParseTuple(args,"fff",&x,&y,&z))
{
if (PHY_GetActiveEnvironment())
- PHY_GetActiveEnvironment()->setGravity(x,y,z);
+ PHY_GetActiveEnvironment()->SetGravity(x,y,z);
}
else {
return NULL;
@@ -118,7 +118,7 @@ static PyObject *gPySetDebugMode(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setDebugMode(mode);
+ PHY_GetActiveEnvironment()->SetDebugMode(mode);
}
@@ -141,7 +141,7 @@ static PyObject *gPySetNumTimeSubSteps(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setNumTimeSubSteps(substep);
+ PHY_GetActiveEnvironment()->SetNumTimeSubSteps(substep);
}
}
else {
@@ -160,7 +160,7 @@ static PyObject *gPySetNumIterations(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setNumIterations(iter);
+ PHY_GetActiveEnvironment()->SetNumIterations(iter);
}
}
else {
@@ -179,7 +179,7 @@ static PyObject *gPySetDeactivationTime(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setDeactivationTime(deactive_time);
+ PHY_GetActiveEnvironment()->SetDeactivationTime(deactive_time);
}
}
else {
@@ -198,7 +198,7 @@ static PyObject *gPySetDeactivationLinearTreshold(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setDeactivationLinearTreshold( linearDeactivationTreshold);
+ PHY_GetActiveEnvironment()->SetDeactivationLinearTreshold( linearDeactivationTreshold);
}
}
else {
@@ -217,7 +217,7 @@ static PyObject *gPySetDeactivationAngularTreshold(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setDeactivationAngularTreshold( angularDeactivationTreshold);
+ PHY_GetActiveEnvironment()->SetDeactivationAngularTreshold( angularDeactivationTreshold);
}
}
else {
@@ -235,7 +235,7 @@ static PyObject *gPySetContactBreakingTreshold(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setContactBreakingTreshold( contactBreakingTreshold);
+ PHY_GetActiveEnvironment()->SetContactBreakingTreshold( contactBreakingTreshold);
}
}
else {
@@ -254,7 +254,7 @@ static PyObject *gPySetCcdMode(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setCcdMode( ccdMode);
+ PHY_GetActiveEnvironment()->SetCcdMode( ccdMode);
}
}
else {
@@ -272,7 +272,7 @@ static PyObject *gPySetSorConstant(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setSolverSorConstant( sor);
+ PHY_GetActiveEnvironment()->SetSolverSorConstant( sor);
}
}
else {
@@ -290,7 +290,7 @@ static PyObject *gPySetSolverTau(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setSolverTau( tau);
+ PHY_GetActiveEnvironment()->SetSolverTau( tau);
}
}
else {
@@ -309,7 +309,7 @@ static PyObject *gPySetSolverDamping(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setSolverDamping( damping);
+ PHY_GetActiveEnvironment()->SetSolverDamping( damping);
}
}
else {
@@ -327,7 +327,7 @@ static PyObject *gPySetLinearAirDamping(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setLinearAirDamping( damping);
+ PHY_GetActiveEnvironment()->SetLinearAirDamping( damping);
}
}
else {
@@ -346,7 +346,7 @@ static PyObject *gPySetUseEpa(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setUseEpa(epa);
+ PHY_GetActiveEnvironment()->SetUseEpa(epa);
}
}
else {
@@ -363,7 +363,7 @@ static PyObject *gPySetSolverType(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->setSolverType(solverType);
+ PHY_GetActiveEnvironment()->SetSolverType(solverType);
}
}
else {
@@ -389,7 +389,7 @@ static PyObject *gPyGetVehicleConstraint(PyObject *self,
if (PHY_GetActiveEnvironment())
{
- PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->getVehicleConstraint(constraintid);
+ PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->GetVehicleConstraint(constraintid);
if (vehicle)
{
KX_VehicleWrapper* pyWrapper = new KX_VehicleWrapper(vehicle,PHY_GetActiveEnvironment());
@@ -421,7 +421,7 @@ static PyObject* gPyGetCharacter(PyObject* self,
if (PHY_GetActiveEnvironment())
{
- PHY_ICharacter* character= PHY_GetActiveEnvironment()->getCharacterController(ob);
+ PHY_ICharacter* character= PHY_GetActiveEnvironment()->GetCharacterController(ob);
if (character)
{
KX_CharacterWrapper* pyWrapper = new KX_CharacterWrapper(character);
@@ -523,14 +523,14 @@ static PyObject *gPyCreateConstraint(PyObject *self,
MT_Vector3 axis1 = localCFrame.getColumn(1);
MT_Vector3 axis2 = localCFrame.getColumn(2);
- constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,
+ constraintid = PHY_GetActiveEnvironment()->CreateConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,
pivotX,pivotY,pivotZ,
(float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
(float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
(float)axis2.x(),(float)axis2.y(),(float)axis2.z(),flag);
}
else {
- constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
+ constraintid = PHY_GetActiveEnvironment()->CreateConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
}
KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment());
@@ -567,7 +567,7 @@ static PyObject *gPyGetAppliedImpulse(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- appliedImpulse = PHY_GetActiveEnvironment()->getAppliedImpulse(constraintid);
+ appliedImpulse = PHY_GetActiveEnvironment()->GetAppliedImpulse(constraintid);
}
}
else {
@@ -592,7 +592,7 @@ static PyObject *gPyRemoveConstraint(PyObject *self,
{
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->removeConstraint(constraintid);
+ PHY_GetActiveEnvironment()->RemoveConstraint(constraintid);
}
}
else {
@@ -610,7 +610,7 @@ static PyObject *gPyExportBulletFile(PyObject *, PyObject *args)
if (PHY_GetActiveEnvironment())
{
- PHY_GetActiveEnvironment()->exportFile(filename);
+ PHY_GetActiveEnvironment()->ExportFile(filename);
}
Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 29f28b7cc24..08e240903d1 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -480,7 +480,7 @@ static PyObject *gPySetPhysicsTicRate(PyObject *, PyObject *args)
if (!PyArg_ParseTuple(args, "f:setPhysicsTicRate", &ticrate))
return NULL;
- PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate);
+ PHY_GetActiveEnvironment()->SetFixedTimeStep(true,ticrate);
Py_RETURN_NONE;
}
#if 0 // unused
@@ -498,7 +498,7 @@ static PyObject *gPySetPhysicsDebug(PyObject *, PyObject *args)
static PyObject *gPyGetPhysicsTicRate(PyObject *)
{
- return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep());
+ return PyFloat_FromDouble(PHY_GetActiveEnvironment()->GetFixedTimeStep());
}
static PyObject *gPyGetAverageFrameRate(PyObject *)
@@ -1226,7 +1226,6 @@ static PyObject *gPyGetGLSLMaterialSetting(PyObject *,
return PyLong_FromLong(enabled);
}
-#define KX_TEXFACE_MATERIAL 0
#define KX_BLENDER_MULTITEX_MATERIAL 1
#define KX_BLENDER_GLSL_MATERIAL 2
@@ -1244,8 +1243,6 @@ static PyObject *gPySetMaterialType(PyObject *,
gs->matmode= GAME_MAT_GLSL;
else if (type == KX_BLENDER_MULTITEX_MATERIAL)
gs->matmode= GAME_MAT_MULTITEX;
- else if (type == KX_TEXFACE_MATERIAL)
- gs->matmode= GAME_MAT_TEXFACE;
else {
PyErr_SetString(PyExc_ValueError, "Rasterizer.setMaterialType(int): material type is not known");
return NULL;
@@ -1261,10 +1258,8 @@ static PyObject *gPyGetMaterialType(PyObject *)
if (gs->matmode == GAME_MAT_GLSL)
flag = KX_BLENDER_GLSL_MATERIAL;
- else if (gs->matmode == GAME_MAT_MULTITEX)
- flag = KX_BLENDER_MULTITEX_MATERIAL;
else
- flag = KX_TEXFACE_MATERIAL;
+ flag = KX_BLENDER_MULTITEX_MATERIAL;
return PyLong_FromLong(flag);
}
@@ -2209,7 +2204,6 @@ PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
Py_DECREF(ErrorObject);
/* needed for get/setMaterialType */
- KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL);
KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL);
KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL);
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
index 05bdb3463a6..bacace9199a 100644
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
@@ -57,7 +57,6 @@
#include "KX_ObjectActuator.h"
#include "KX_ParentActuator.h"
#include "KX_PolyProxy.h"
-#include "KX_PolygonMaterial.h"
#include "KX_PythonSeq.h"
#include "KX_SCA_AddObjectActuator.h"
#include "KX_SCA_EndObjectActuator.h"
@@ -211,7 +210,6 @@ void initPyTypes(void)
PyType_Ready_Attr(dict, KX_ObjectActuator, init_getset);
PyType_Ready_Attr(dict, KX_ParentActuator, init_getset);
PyType_Ready_Attr(dict, KX_PolyProxy, init_getset);
- PyType_Ready_Attr(dict, KX_PolygonMaterial, init_getset);
PyType_Ready_Attr(dict, KX_RadarSensor, init_getset);
PyType_Ready_Attr(dict, KX_RaySensor, init_getset);
PyType_Ready_Attr(dict, KX_SCA_AddObjectActuator, init_getset);
diff --git a/source/gameengine/Ketsji/KX_PythonMain.h b/source/gameengine/Ketsji/KX_PythonMain.h
index e638fa9094e..c627a4a147a 100644
--- a/source/gameengine/Ketsji/KX_PythonMain.h
+++ b/source/gameengine/Ketsji/KX_PythonMain.h
@@ -32,6 +32,7 @@
#ifndef __KX_PYTHON_MAIN__
#define __KX_PYTHON_MAIN__
+#include "BLI_sys_types.h"
#include "BKE_main.h"
#include "DNA_scene_types.h"
extern "C" char *KX_GetPythonMain(struct Scene* scene);
diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp
index 247f4173d1d..ab4f2c2d2c9 100644
--- a/source/gameengine/Ketsji/KX_PythonSeq.cpp
+++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp
@@ -383,7 +383,7 @@ static PyObject *KX_PythonSeq_nextIter(KX_PythonSeq *self)
self->iter++;
if ( object==NULL ) {
self->iter= -1; /* for reuse */
- PyErr_SetString(PyExc_StopIteration, "iterator at end");
+ PyErr_SetNone(PyExc_StopIteration);
}
return object; /* can be NULL for end of iterator */
}
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 04d67fc73e1..732bcdc3773 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -166,8 +166,8 @@ void KX_RadarSensor::SynchronizeTransform()
const MT_Point3& pos = trans.getOrigin();
float ori[12];
trans.getBasis().getValue(ori);
- motionState->setWorldPosition(pos[0], pos[1], pos[2]);
- motionState->setWorldOrientation(ori);
+ motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
+ motionState->SetWorldOrientation(ori);
m_physCtrl->WriteMotionStateToDynamics(true);
}
diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp
index f1bfb10220a..333e7b57d67 100644
--- a/source/gameengine/Ketsji/KX_RayCast.cpp
+++ b/source/gameengine/Ketsji/KX_RayCast.cpp
@@ -39,12 +39,11 @@
#include "MT_Point3.h"
#include "MT_Vector3.h"
-#include "KX_IPhysicsController.h"
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IPhysicsController.h"
-KX_RayCast::KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal, bool faceUV)
- :PHY_IRayCastFilterCallback(dynamic_cast<PHY_IPhysicsController*>(ignoreController), faceNormal, faceUV)
+KX_RayCast::KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV)
+ :PHY_IRayCastFilterCallback(ignoreController, faceNormal, faceUV)
{
}
@@ -76,11 +75,11 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_
PHY_IPhysicsController* hit_controller;
- while ((hit_controller = physics_environment->rayTest(callback,
+ while ((hit_controller = physics_environment->RayTest(callback,
frompoint.x(),frompoint.y(),frompoint.z(),
topoint.x(),topoint.y(),topoint.z())) != NULL)
{
- KX_ClientObjectInfo *info = static_cast<KX_ClientObjectInfo*>(hit_controller->getNewClientInfo());
+ KX_ClientObjectInfo *info = static_cast<KX_ClientObjectInfo*>(hit_controller->GetNewClientInfo());
if (!info)
{
diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h
index 544080f31d0..e47ac676eb1 100644
--- a/source/gameengine/Ketsji/KX_RayCast.h
+++ b/source/gameengine/Ketsji/KX_RayCast.h
@@ -40,7 +40,6 @@
class RAS_MeshObject;
struct KX_ClientObjectInfo;
-class KX_IPhysicsController;
/**
* Defines a function for doing a ray cast.
@@ -65,7 +64,7 @@ public:
int m_hitUVOK; // !=0 if UV coordinate in m_hitUV is valid
MT_Vector2 m_hitUV;
- KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal, bool faceUV);
+ KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV);
virtual ~KX_RayCast() {}
/**
@@ -105,7 +104,7 @@ template<class T> class KX_RayCast::Callback : public KX_RayCast
T *self;
void *data;
public:
- Callback(T *_self, KX_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false, bool faceUV=false)
+ Callback(T *_self, PHY_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false, bool faceUV=false)
: KX_RayCast(controller, faceNormal, faceUV),
self(_self),
data(_data)
@@ -121,7 +120,7 @@ public:
virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller)
{
- KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->getNewClientInfo());
+ KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->GetNewClientInfo());
if (!info)
{
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 3fbce690a9f..afd39557130 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -44,7 +44,6 @@
#include "KX_RayCast.h"
#include "KX_PyMath.h"
#include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
#include "PHY_IPhysicsController.h"
#include "DNA_sensor_types.h"
@@ -261,7 +260,7 @@ bool KX_RaySensor::Evaluate()
return false;
}
- KX_IPhysicsController *spc = obj->GetPhysicsController();
+ PHY_IPhysicsController *spc = obj->GetPhysicsController();
KX_GameObject *parent = obj->GetParent();
if (!spc && parent)
spc = parent->GetPhysicsController();
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index 56dccc1d045..f8f79269eaa 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -38,7 +38,6 @@
#include "KX_SCA_AddObjectActuator.h"
#include "SCA_IScene.h"
#include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
#include "PyObjectPlus.h"
/* ------------------------------------------------------------------------- */
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
index 5dc67a4cff3..e02eca3db63 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
@@ -35,6 +35,7 @@
* Please look here for revision history. */
#include "KX_SCA_DynamicActuator.h"
+#include "PHY_IPhysicsController.h"
#ifdef WITH_PYTHON
@@ -105,7 +106,7 @@ bool KX_SCA_DynamicActuator::Update()
// bool result = false; /*unused*/
KX_GameObject *obj = (KX_GameObject*) GetParent();
bool bNegativeEvent = IsNegativeEvent();
- KX_IPhysicsController* controller;
+ PHY_IPhysicsController* controller;
RemoveAllEvents();
if (bNegativeEvent)
@@ -120,16 +121,16 @@ bool KX_SCA_DynamicActuator::Update()
switch (m_dyn_operation)
{
case 0:
- obj->RestoreDynamics();
+ controller->RestoreDynamics();
break;
case 1:
- obj->SuspendDynamics();
+ controller->SuspendDynamics();
break;
case 2:
- controller->setRigidBody(true);
+ controller->SetRigidBody(true);
break;
case 3:
- controller->setRigidBody(false);
+ controller->SetRigidBody(false);
break;
case 4:
controller->SetMass(m_setmass);
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
index 01a91624c41..4eb337c54f5 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
@@ -38,7 +38,6 @@
#include "SCA_LogicManager.h"
#include "KX_GameObject.h"
-#include "KX_IPhysicsController.h"
class KX_SCA_DynamicActuator : public SCA_IActuator
{
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 4fa51b48ab8..2f23bdaccb7 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -62,6 +62,7 @@
#include "SCA_IScene.h"
#include "RAS_IRasterizer.h"
+#include "RAS_ICanvas.h"
#include "RAS_BucketManager.h"
#include "FloatValue.h"
@@ -81,7 +82,6 @@
#include "KX_NetworkEventManager.h"
#include "NG_NetworkScene.h"
#include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
#include "PHY_IGraphicController.h"
#include "KX_BlenderSceneConverter.h"
#include "KX_MotionState.h"
@@ -544,7 +544,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
for (cit = scenegraphcontrollers.begin();!(cit==scenegraphcontrollers.end());++cit)
{
// controller replication is quite complicated
- // only replicate ipo and physics controller for now
+ // only replicate ipo controller for now
SG_Controller* replicacontroller = (*cit)->GetReplica((SG_Node*) replicanode);
if (replicacontroller)
@@ -558,9 +558,29 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
{
PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
PHY_IGraphicController* newctrl = orgobj->GetGraphicController()->GetReplica(motionstate);
- newctrl->setNewClientInfo(newobj->getClientInfo());
+ newctrl->SetNewClientInfo(newobj->getClientInfo());
newobj->SetGraphicController(newctrl);
}
+
+#ifdef WITH_BULLET
+ // replicate physics controller
+ if (orgobj->GetPhysicsController())
+ {
+ PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
+ PHY_IPhysicsController* newctrl = orgobj->GetPhysicsController()->GetReplica();
+
+ KX_GameObject *parent = newobj->GetParent();
+ PHY_IPhysicsController* parentctrl = (parent) ? parent->GetPhysicsController() : NULL;
+
+ newctrl->SetNewClientInfo(newobj->getClientInfo());
+ newobj->SetPhysicsController(newctrl, newobj->IsDynamic());
+ newctrl->PostProcessReplica(motionstate, parentctrl);
+
+ if (parent)
+ parent->Release();
+ }
+#endif
+
return newobj;
}
@@ -610,7 +630,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
newsensorobj = (SCA_IObject*)(*h_obj);
if (!newsensorobj)
{
- // no, then the sensor points outside the hierachy, keep it the same
+ // no, then the sensor points outside the hierarchy, keep it the same
if (m_objectlist->SearchValue(oldsensorobj))
// only replicate links that points to active objects
m_logicmgr->RegisterToSensor(cont,oldsensor);
@@ -650,7 +670,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
if (!newactuatorobj)
{
- // no, then the sensor points outside the hierachy, keep it the same
+ // no, then the sensor points outside the hierarchy, keep it the same
if (m_objectlist->SearchValue(oldactuatorobj))
// only replicate links that points to active objects
m_logicmgr->RegisterToActuator(cont,oldactuator);
@@ -1524,7 +1544,7 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int
double pmat[16] = {0};
cam->GetProjectionMatrix().getValue(pmat);
- dbvt_culling = m_physicsEnvironment->cullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
+ dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
KX_GetActiveEngine()->GetCanvas()->GetViewPort(),
mvmat, pmat);
}
@@ -1593,16 +1613,29 @@ void KX_Scene::UpdateAnimations(double curtime)
CListValue *children = gameobj->GetChildren();
KX_GameObject *child;
+ bool has_mesh = false, has_non_mesh = false;
+
// Check for meshes that haven't been culled
for (int j=0; j<children->GetCount(); ++j) {
child = (KX_GameObject*)children->GetValue(j);
- if (child->GetMeshCount() > 0 && !child->GetCulled()) {
+ if (!child->GetCulled()) {
needs_update = true;
break;
}
+
+ if (child->GetMeshCount() == 0)
+ has_non_mesh = true;
+ else
+ has_mesh = true;
}
+ // If we didn't find a non-culled mesh, check to see
+ // if we even have any meshes, and update if this
+ // armature has only non-mesh children.
+ if (!needs_update && !has_mesh && has_non_mesh)
+ needs_update = true;
+
children->Release();
}
@@ -1678,10 +1711,9 @@ RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool
void KX_Scene::RenderBuckets(const MT_Transform & cameratransform,
- class RAS_IRasterizer* rasty,
- class RAS_IRenderTools* rendertools)
+ class RAS_IRasterizer* rasty)
{
- m_bucketmanager->Renderbuckets(cameratransform,rasty,rendertools);
+ m_bucketmanager->Renderbuckets(cameratransform,rasty);
KX_BlenderMaterial::EndFrame();
}
@@ -1755,14 +1787,14 @@ void KX_Scene::SetNetworkScene(NG_NetworkScene *newScene)
void KX_Scene::SetGravity(const MT_Vector3& gravity)
{
- GetPhysicsEnvironment()->setGravity(gravity[0],gravity[1],gravity[2]);
+ GetPhysicsEnvironment()->SetGravity(gravity[0],gravity[1],gravity[2]);
}
MT_Vector3 KX_Scene::GetGravity()
{
MT_Vector3 gravity;
- GetPhysicsEnvironment()->getGravity(gravity);
+ GetPhysicsEnvironment()->GetGravity(gravity);
return gravity;
}
@@ -1803,10 +1835,6 @@ short KX_Scene::GetAnimationFPS()
return m_blenderScene->r.frs_sec;
}
-#ifdef WITH_BULLET
-#include "KX_BulletPhysicsController.h"
-#endif
-
static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
{
SCA_LogicManager *logicmgr= to->GetLogicManager();
@@ -1839,7 +1867,6 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
#ifdef WITH_BULLET
#include "CcdGraphicController.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
#include "CcdPhysicsEnvironment.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
-#include "KX_BulletPhysicsController.h"
#endif
static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene *from)
@@ -1888,12 +1915,19 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
}
/* graphics controller */
- PHY_IGraphicController *ctrl = gameobj->GetGraphicController();
+ PHY_IController *ctrl = gameobj->GetGraphicController();
if (ctrl) {
/* SHOULD update the m_cullingTree */
ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
}
+#ifdef WITH_BULLET
+ ctrl = gameobj->GetPhysicsController();
+ if (ctrl) {
+ ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
+ }
+#endif
+
/* SG_Node can hold a scene reference */
SG_Node *sg= gameobj->GetSGNode();
if (sg) {
@@ -1905,16 +1939,6 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
for (int i=0; i<children.size(); i++)
children[i]->SetSGClientInfo(to);
}
-#ifdef WITH_BULLET
- SGControllerList::iterator contit;
- SGControllerList& controllers = sg->GetSGControllerList();
- for (contit = controllers.begin();contit!=controllers.end();++contit)
- {
- KX_BulletPhysicsController *phys_ctrl= dynamic_cast<KX_BulletPhysicsController *>(*contit);
- if (phys_ctrl)
- phys_ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
- }
-#endif // WITH_BULLET
}
/* If the object is a light, update it's scene */
if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index edaa0663b22..ee2a994d53c 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -309,8 +309,7 @@ public:
RAS_BucketManager* GetBucketManager();
RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat, bool &bucketCreated);
void RenderBuckets(const MT_Transform& cameratransform,
- RAS_IRasterizer* rasty,
- RAS_IRenderTools* rendertools);
+ RAS_IRasterizer* rasty);
/**
* Update all transforms according to the scenegraph.
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
index 1a9e1442cc8..d010d3d50a0 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
@@ -48,9 +48,9 @@ KX_TouchEventManager::KX_TouchEventManager(class SCA_LogicManager* logicmgr,
//m_scene->addTouchCallback(OBJECT_RESPONSE, KX_TouchEventManager::collisionResponse, this);
//m_scene->addTouchCallback(SENSOR_RESPONSE, KX_TouchEventManager::collisionResponse, this);
- m_physEnv->addTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
- m_physEnv->addTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
- m_physEnv->addTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this);
+ m_physEnv->AddTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
+ m_physEnv->AddTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
+ m_physEnv->AddTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this);
}
@@ -84,8 +84,8 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data,
PHY_IPhysicsController* ctrl1 = static_cast<PHY_IPhysicsController*>(object1);
PHY_IPhysicsController* ctrl2 = static_cast<PHY_IPhysicsController*>(object2);
- KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo()) : NULL;
- KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl2->getNewClientInfo()) : NULL;
+ KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl1->GetNewClientInfo()) : NULL;
+ KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl2->GetNewClientInfo()) : NULL;
// This call back should only be called for controllers of Near and Radar sensor
if (!info1)
@@ -184,7 +184,7 @@ void KX_TouchEventManager::NextFrame()
list<SCA_ISensor*>::iterator sit;
// First client info
- KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo());
+ KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(ctrl1->GetNewClientInfo());
// First gameobject
KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(client_info);
// Invoke sensor response for each object
@@ -195,7 +195,7 @@ void KX_TouchEventManager::NextFrame()
}
// Second client info
- client_info = static_cast<KX_ClientObjectInfo *>(ctrl2->getNewClientInfo());
+ client_info = static_cast<KX_ClientObjectInfo *>(ctrl2->GetNewClientInfo());
// Second gameobject
KX_GameObject *kxObj2 = KX_GameObject::GetClientObject(client_info);
if (client_info) {
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 9d87da48fae..b231a2191ed 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -117,7 +117,7 @@ m_bTouchPulse(bTouchPulse)
//client_info->m_auxilary_info = NULL;
client_info->m_sensors.push_back(this);
- m_physCtrl = dynamic_cast<PHY_IPhysicsController*>(gameobj->GetPhysicsController());
+ m_physCtrl = gameobj->GetPhysicsController();
MT_assert( !gameobj->GetPhysicsController() || m_physCtrl );
Init();
}
@@ -156,7 +156,7 @@ void KX_TouchSensor::ProcessReplica()
void KX_TouchSensor::ReParent(SCA_IObject* parent)
{
KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
- PHY_IPhysicsController *sphy = dynamic_cast<PHY_IPhysicsController*>(((KX_GameObject*)parent)->GetPhysicsController());
+ PHY_IPhysicsController *sphy = ((KX_GameObject*)parent)->GetPhysicsController();
if (sphy)
m_physCtrl = sphy;
@@ -173,11 +173,11 @@ void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman)
{
if (m_physCtrl)
{
- if (touchman->GetPhysicsEnvironment()->requestCollisionCallback(m_physCtrl))
+ if (touchman->GetPhysicsEnvironment()->RequestCollisionCallback(m_physCtrl))
{
- KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
if (client_info->isSensor())
- touchman->GetPhysicsEnvironment()->addSensor(m_physCtrl);
+ touchman->GetPhysicsEnvironment()->AddSensor(m_physCtrl);
}
}
}
@@ -185,12 +185,12 @@ void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman)
{
if (m_physCtrl)
{
- if (touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl))
+ if (touchman->GetPhysicsEnvironment()->RemoveCollisionCallback(m_physCtrl))
{
// no more sensor on the controller, can remove it if it is a sensor object
- KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
if (client_info->isSensor())
- touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
+ touchman->GetPhysicsEnvironment()->RemoveSensor(m_physCtrl);
}
}
}
@@ -203,8 +203,8 @@ bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2)
KX_GameObject* myobj = (KX_GameObject*)GetParent();
KX_GameObject* myparent = myobj->GetParent();
- KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(((PHY_IPhysicsController*)obj2)->getNewClientInfo());
- KX_ClientObjectInfo *my_client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(((PHY_IPhysicsController*)obj2)->GetNewClientInfo());
+ KX_ClientObjectInfo *my_client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
KX_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL);
// first, decrement refcount as GetParent() increases it
@@ -244,8 +244,8 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll
// need the mapping from PHY_IPhysicsController to gameobjects now
KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (object1 == m_physCtrl?
- ((PHY_IPhysicsController*)object2)->getNewClientInfo():
- ((PHY_IPhysicsController*)object1)->getNewClientInfo());
+ ((PHY_IPhysicsController*)object2)->GetNewClientInfo():
+ ((PHY_IPhysicsController*)object1)->GetNewClientInfo());
KX_GameObject* gameobj = ( client_info ?
client_info->m_gameobject :
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
index 3cb80e53e12..fdafc4e507d 100644
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
@@ -35,48 +35,48 @@ CcdGraphicController::CcdGraphicController (CcdPhysicsEnvironment* phyEnv, PHY_I
CcdGraphicController::~CcdGraphicController()
{
if (m_phyEnv)
- m_phyEnv->removeCcdGraphicController(this);
+ m_phyEnv->RemoveCcdGraphicController(this);
if (m_motionState)
delete m_motionState;
}
-void CcdGraphicController::setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax)
+void CcdGraphicController::SetLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax)
{
m_localAabbMin = aabbMin;
m_localAabbMax = aabbMax;
SetGraphicTransform();
}
-void CcdGraphicController::setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax)
+void CcdGraphicController::SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax)
{
m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
SetGraphicTransform();
}
-void CcdGraphicController::setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax)
+void CcdGraphicController::SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax)
{
m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
SetGraphicTransform();
}
-void CcdGraphicController::setLocalAabb(const float* aabbMin,const float* aabbMax)
+void CcdGraphicController::SetLocalAabb(const float* aabbMin,const float* aabbMax)
{
m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
SetGraphicTransform();
}
-void CcdGraphicController::getAabb(btVector3& aabbMin, btVector3& aabbMax)
+void CcdGraphicController::GetAabb(btVector3& aabbMin, btVector3& aabbMax)
{
btVector3 pos;
btVector3 scale;
float ori[12];
- m_motionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
- m_motionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
- m_motionState->getWorldOrientation(ori);
+ m_motionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+ m_motionState->GetWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
+ m_motionState->GetWorldOrientation(ori);
btMatrix3x3 rot(ori[0], ori[4], ori[8],
ori[1], ori[5], ori[9],
ori[2], ori[6], ori[10]);
@@ -109,9 +109,9 @@ bool CcdGraphicController::SetGraphicTransform()
return false;
btVector3 aabbMin;
btVector3 aabbMax;
- getAabb(aabbMin, aabbMax);
+ GetAabb(aabbMin, aabbMax);
// update Aabb in broadphase
- m_phyEnv->getCullingTree()->setAabb(m_handle,aabbMin,aabbMax,NULL);
+ m_phyEnv->GetCullingTree()->setAabb(m_handle,aabbMin,aabbMax,NULL);
return true;
}
@@ -131,7 +131,7 @@ void CcdGraphicController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment*
{
CcdPhysicsEnvironment* phyEnv = static_cast<CcdPhysicsEnvironment*>(env);
/* Updates the m_phyEnv's m_cullingTree & m_cullingCache */
- if (getBroadphaseHandle()) {
+ if (GetBroadphaseHandle()) {
/* insert into the new physics scene */
Activate(false);
m_phyEnv= phyEnv;
@@ -145,8 +145,8 @@ void CcdGraphicController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment*
void CcdGraphicController::Activate(bool active)
{
if (active)
- m_phyEnv->addCcdGraphicController(this);
+ m_phyEnv->AddCcdGraphicController(this);
else
- m_phyEnv->removeCcdGraphicController(this);
+ m_phyEnv->RemoveCcdGraphicController(this);
}
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h
index 064f86040f6..e76ad86301e 100644
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.h
+++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h
@@ -40,16 +40,16 @@ public:
virtual ~CcdGraphicController();
- void setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax);
- void setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax);
- virtual void setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax);
- virtual void setLocalAabb(const float aabbMin[3],const float aabbMax[3]);
+ void SetLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax);
+ void SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax);
+ virtual void SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax);
+ virtual void SetLocalAabb(const float aabbMin[3],const float aabbMax[3]);
PHY_IMotionState* GetMotionState() { return m_motionState; }
- void getAabb(btVector3& aabbMin, btVector3& aabbMax);
+ void GetAabb(btVector3& aabbMin, btVector3& aabbMax);
- virtual void setBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; }
- virtual btBroadphaseProxy* getBroadphaseHandle() { return m_handle; }
+ virtual void SetBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; }
+ virtual btBroadphaseProxy* GetBroadphaseHandle() { return m_handle; }
virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* env);
@@ -67,8 +67,8 @@ public:
virtual void Activate(bool active);
// client info for culling
- virtual void* getNewClientInfo() { return m_newClientInfo; }
- virtual void setNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; }
+ virtual void* GetNewClientInfo() { return m_newClientInfo; }
+ virtual void SetNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; }
virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate);
private:
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 1a8fda0749a..6ce52b60426 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -29,6 +29,8 @@ subject to the following restrictions:
#include "PHY_IMotionState.h"
#include "CcdPhysicsEnvironment.h"
#include "RAS_MeshObject.h"
+#include "RAS_Polygon.h"
+#include "RAS_Deformer.h"
#include "KX_GameObject.h"
#include "BulletSoftBody/btSoftBody.h"
@@ -137,9 +139,14 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
m_shapeInfo = ci.m_shapeInfo;
if (m_shapeInfo)
m_shapeInfo->AddRef();
+
+ m_bulletChildShape = NULL;
m_bulletMotionState = 0;
m_characterController = 0;
+ m_savedCollisionFlags = 0;
+ m_savedMass = 0.0;
+ m_suspended = false;
CreateRigidbody();
}
@@ -148,11 +155,11 @@ btTransform& CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState*
{
static btTransform trans;
btVector3 tmp;
- motionState->getWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]);
+ motionState->GetWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]);
trans.setOrigin(tmp);
float ori[12];
- motionState->getWorldOrientation(ori);
+ motionState->GetWorldOrientation(ori);
trans.getBasis().setFromOpenGLSubMatrix(ori);
//btQuaternion orn;
//motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
@@ -178,18 +185,18 @@ public:
btVector3 pos;
float ori[12];
- m_blenderMotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
- m_blenderMotionState->getWorldOrientation(ori);
+ m_blenderMotionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+ m_blenderMotionState->GetWorldOrientation(ori);
worldTrans.setOrigin(pos);
worldTrans.getBasis().setFromOpenGLSubMatrix(ori);
}
void setWorldTransform(const btTransform& worldTrans)
{
- m_blenderMotionState->setWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ());
+ m_blenderMotionState->SetWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ());
btQuaternion rotQuat = worldTrans.getRotation();
- m_blenderMotionState->setWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]);
- m_blenderMotionState->calculateWorldTransformations();
+ m_blenderMotionState->SetWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]);
+ m_blenderMotionState->CalculateWorldTransformations();
}
};
@@ -236,7 +243,7 @@ bool CcdPhysicsController::CreateSoftbody()
btVector3 p(0,0,0);// = getOrigin();
//btSoftBody* psb=btSoftBodyHelpers::CreateRope(worldInfo, btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2);
btSoftBody* psb = 0;
- btSoftBodyWorldInfo& worldInfo = m_cci.m_physicsEnv->getDynamicsWorld()->getWorldInfo();
+ btSoftBodyWorldInfo& worldInfo = m_cci.m_physicsEnv->GetDynamicsWorld()->getWorldInfo();
if (m_cci.m_collisionShape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE) {
btConvexHullShape* convexHull = (btConvexHullShape* )m_cci.m_collisionShape;
@@ -454,8 +461,8 @@ bool CcdPhysicsController::CreateSoftbody()
btTransform startTrans;
rbci.m_motionState->getWorldTransform(startTrans);
- m_MotionState->setWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ());
- m_MotionState->setWorldOrientation(0,0,0,1);
+ m_MotionState->SetWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ());
+ m_MotionState->SetWorldOrientation(0,0,0,1);
if (!m_prototypeTransformInitialized)
{
@@ -607,7 +614,7 @@ bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape)
if (GetSoftBody()) {
// soft body must be recreated
- m_cci.m_physicsEnv->removeCcdPhysicsController(this);
+ m_cci.m_physicsEnv->RemoveCcdPhysicsController(this);
delete m_object;
m_object = NULL;
// force complete reinitialization
@@ -617,14 +624,14 @@ bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape)
CreateSoftbody();
assert(m_object);
// reinsert the new body
- m_cci.m_physicsEnv->addCcdPhysicsController(this);
+ m_cci.m_physicsEnv->AddCcdPhysicsController(this);
}
/* Copied from CcdPhysicsEnvironment::addCcdPhysicsController() */
/* without this, an object can rest on the old physics mesh
* and not move to account for the physics mesh, even with 'nosleep' */
- btSoftRigidDynamicsWorld* dw= GetPhysicsEnvironment()->getDynamicsWorld();
+ btSoftRigidDynamicsWorld* dw= GetPhysicsEnvironment()->GetDynamicsWorld();
btCollisionObjectArray &obarr= dw->getCollisionObjectArray();
btCollisionObject *ob;
btBroadphaseProxy* proxy;
@@ -646,7 +653,7 @@ CcdPhysicsController::~CcdPhysicsController()
{
//will be reference counted, due to sharing
if (m_cci.m_physicsEnv)
- m_cci.m_physicsEnv->removeCcdPhysicsController(this);
+ m_cci.m_physicsEnv->RemoveCcdPhysicsController(this);
if (m_MotionState)
delete m_MotionState;
@@ -681,17 +688,17 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
btQuaternion worldquat;
btMatrix3x3 trs = sb->m_pose.m_rot*sb->m_pose.m_scl;
trs.getRotation(worldquat);
- m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
- m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
+ m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+ m_MotionState->SetWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
}
else
{
btVector3 aabbMin,aabbMax;
sb->getAabb(aabbMin,aabbMax);
btVector3 worldPos = (aabbMax+aabbMin)*0.5f;
- m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+ m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
}
- m_MotionState->calculateWorldTransformations();
+ m_MotionState->CalculateWorldTransformations();
return true;
}
@@ -717,12 +724,12 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
const btVector3& worldPos = xform.getOrigin();
float ori[12];
worldOri.getOpenGLSubMatrix(ori);
- m_MotionState->setWorldOrientation(ori);
- m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
- m_MotionState->calculateWorldTransformations();
+ m_MotionState->SetWorldOrientation(ori);
+ m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+ m_MotionState->CalculateWorldTransformations();
float scale[3];
- m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
+ m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]);
btVector3 scaling(scale[0],scale[1],scale[2]);
GetCollisionShape()->setLocalScaling(scaling);
} else
@@ -741,7 +748,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
m_MotionState->calculateWorldTransformations();
*/
float scale[3];
- m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
+ m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]);
btVector3 scaling(scale[0],scale[1],scale[2]);
GetCollisionShape()->setLocalScaling(scaling);
}
@@ -765,7 +772,7 @@ void CcdPhysicsController::WriteDynamicsToMotionState()
// controller replication
void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
{
-
+ SetParentCtrl((CcdPhysicsController*)parentctrl);
m_softBodyTransformInitialized=false;
m_MotionState = motionstate;
m_registerCount = 0;
@@ -810,7 +817,7 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
}
// sensor object are added when needed
if (!m_cci.m_bSensor)
- m_cci.m_physicsEnv->addCcdPhysicsController(this);
+ m_cci.m_physicsEnv->AddCcdPhysicsController(this);
/* SM_Object* dynaparent=0;
@@ -855,9 +862,9 @@ void CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *
// since the environment is changing, we must also move the controler to the
// new environment. Note that we don't handle sensor explicitly: this
// function can be called on sensor but only when they are not registered
- if (m_cci.m_physicsEnv->removeCcdPhysicsController(this))
+ if (m_cci.m_physicsEnv->RemoveCcdPhysicsController(this))
{
- physicsEnv->addCcdPhysicsController(this);
+ physicsEnv->AddCcdPhysicsController(this);
// Set the object to be active so it can at least by evaluated once.
// This fixes issues with static objects not having their physics meshes
@@ -902,7 +909,7 @@ void CcdPhysicsController::SetCenterOfMassTransform(btTransform& xform)
}
// kinematic methods
-void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
+void CcdPhysicsController::RelativeTranslate(const MT_Vector3& dlocin,bool local)
{
if (m_object)
{
@@ -915,7 +922,7 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
return;
}
- btVector3 dloc(dlocX,dlocY,dlocZ);
+ btVector3 dloc(dlocin.x(), dlocin.y(), dlocin.z());
btTransform xform = m_object->getWorldTransform();
if (local)
@@ -927,22 +934,7 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
}
-void CcdPhysicsController::SetWalkDirection(float dirX,float dirY,float dirZ,bool local)
-{
-
- if (m_object && m_characterController)
- {
- btVector3 dir(dirX,dirY,dirZ);
- btTransform xform = m_object->getWorldTransform();
-
- if (local)
- dir = xform.getBasis()*dir;
-
- m_characterController->setWalkDirection(dir/GetPhysicsEnvironment()->getNumTimeSubSteps());
- }
-}
-
-void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
+void CcdPhysicsController::RelativeRotate(const MT_Matrix3x3& rotval,bool local)
{
if (m_object)
{
@@ -955,9 +947,9 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
return;
}
- btMatrix3x3 drotmat(rotval[0], rotval[3], rotval[6],
- rotval[1], rotval[4], rotval[7],
- rotval[2], rotval[5], rotval[8]);
+ btMatrix3x3 drotmat(rotval[0].x(), rotval[0].y(), rotval[0].z(),
+ rotval[1].x(), rotval[1].y(), rotval[1].z(),
+ rotval[2].x(), rotval[2].y(), rotval[2].z());
btMatrix3x3 currentOrn;
@@ -976,45 +968,23 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat)
{
float ori[12];
- m_MotionState->getWorldOrientation(ori);
+ m_MotionState->GetWorldOrientation(ori);
mat.setFromOpenGLSubMatrix(ori);
}
-void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
+MT_Matrix3x3 CcdPhysicsController::GetOrientation()
{
- btQuaternion q = m_object->getWorldTransform().getRotation();
- quatImag0 = q[0];
- quatImag1 = q[1];
- quatImag2 = q[2];
- quatReal = q[3];
+ btMatrix3x3 orn = m_object->getWorldTransform().getBasis();
+ return MT_Matrix3x3(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]);
}
-void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
-{
- if (m_object)
- {
- m_object->activate(true);
- if (m_object->isStaticObject())
- {
- if (!m_cci.m_bSensor)
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- // kinematic object should not set the transform, it disturbs the velocity interpolation
- return;
- }
- // not required
- //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
- btTransform xform = m_object->getWorldTransform();
- xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal));
- SetCenterOfMassTransform(xform);
- // not required
- //m_bulletMotionState->setWorldTransform(xform);
-
-
-
- }
+void CcdPhysicsController::SetOrientation(const MT_Matrix3x3& orn)
+{
+ btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]);
+ SetWorldOrientation(btmat);
}
-void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn)
+void CcdPhysicsController::SetWorldOrientation(const btMatrix3x3& orn)
{
if (m_object)
{
@@ -1043,7 +1013,7 @@ void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn)
}
-void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
+void CcdPhysicsController::SetPosition(const MT_Vector3& pos)
{
if (m_object)
{
@@ -1058,7 +1028,7 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
// not required, this function is only used to update the physic controller
//m_MotionState->setWorldPosition(posX,posY,posZ);
btTransform xform = m_object->getWorldTransform();
- xform.setOrigin(btVector3(posX,posY,posZ));
+ xform.setOrigin(btVector3(pos.x(), pos.y(), pos.z()));
SetCenterOfMassTransform(xform);
if (!m_softBodyTransformInitialized)
m_softbodyStartTrans.setOrigin(xform.getOrigin());
@@ -1067,7 +1037,7 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
}
}
-void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos)
+void CcdPhysicsController::ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos)
{
if (m_object)
{
@@ -1078,11 +1048,44 @@ void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btV
}
-void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
+void CcdPhysicsController::ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
{
}
-void CcdPhysicsController::getPosition(MT_Vector3& pos) const
+void CcdPhysicsController::SuspendDynamics(bool ghost)
+{
+ btRigidBody *body = GetRigidBody();
+ if (body && !m_suspended && !GetConstructionInfo().m_bSensor)
+ {
+ m_savedCollisionFlags = body->getCollisionFlags();
+ m_savedMass = GetMass();
+ m_suspended = true;
+ GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
+ 0.0,
+ btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
+ btBroadphaseProxy::StaticFilter,
+ btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
+ }
+}
+
+void CcdPhysicsController::RestoreDynamics()
+{
+ btRigidBody *body = GetRigidBody();
+ if (body && m_suspended)
+ {
+ // before make sure any position change that was done in this logic frame are accounted for
+ SetTransform();
+ GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
+ m_savedMass,
+ m_savedCollisionFlags,
+ GetConstructionInfo().m_collisionFilterGroup,
+ GetConstructionInfo().m_collisionFilterMask);
+ body->activate();
+ m_suspended = false;
+ }
+}
+
+void CcdPhysicsController::GetPosition(MT_Vector3& pos) const
{
const btTransform& xform = m_object->getWorldTransform();
pos[0] = xform.getOrigin().x();
@@ -1090,13 +1093,13 @@ void CcdPhysicsController::getPosition(MT_Vector3& pos) const
pos[2] = xform.getOrigin().z();
}
-void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
+void CcdPhysicsController::SetScaling(const MT_Vector3& scale)
{
- if (!btFuzzyZero(m_cci.m_scaling.x()-scaleX) ||
- !btFuzzyZero(m_cci.m_scaling.y()-scaleY) ||
- !btFuzzyZero(m_cci.m_scaling.z()-scaleZ))
+ if (!btFuzzyZero(m_cci.m_scaling.x()-scale.x()) ||
+ !btFuzzyZero(m_cci.m_scaling.y()-scale.y()) ||
+ !btFuzzyZero(m_cci.m_scaling.z()-scale.z()))
{
- m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ);
+ m_cci.m_scaling = btVector3(scale.x(),scale.y(),scale.z());
if (m_object && m_object->getCollisionShape())
{
@@ -1114,11 +1117,64 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
}
}
}
+
+void CcdPhysicsController::SetTransform()
+{
+ btVector3 pos;
+ btVector3 scale;
+ float ori[12];
+ m_MotionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+ m_MotionState->GetWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
+ m_MotionState->GetWorldOrientation(ori);
+ btMatrix3x3 rot(ori[0], ori[4], ori[8],
+ ori[1], ori[5], ori[9],
+ ori[2], ori[6], ori[10]);
+ ForceWorldTransform(rot, pos);
+
+ if (!IsDynamic() && !GetConstructionInfo().m_bSensor && !GetCharacterController())
+ {
+ btCollisionObject* object = GetRigidBody();
+ object->setActivationState(ACTIVE_TAG);
+ object->setCollisionFlags(object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ }
+}
+
+MT_Scalar CcdPhysicsController::GetMass()
+{
+ if (GetSoftBody())
+ return GetSoftBody()->getTotalMass();
+
+ MT_Scalar invmass = 0.f;
+ if (GetRigidBody())
+ invmass = GetRigidBody()->getInvMass();
+ if (invmass)
+ return 1.f/invmass;
+ return 0.f;
+
+}
+
+void CcdPhysicsController::SetMass(MT_Scalar newmass)
+{
+ btRigidBody *body = GetRigidBody();
+ if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON)
+ {
+ btVector3 grav = body->getGravity();
+ btVector3 accel = grav / GetMass();
+
+ btBroadphaseProxy* handle = body->getBroadphaseHandle();
+ GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
+ newmass,
+ body->getCollisionFlags(),
+ handle->m_collisionFilterGroup,
+ handle->m_collisionFilterMask);
+ body->setGravity(accel);
+ }
+}
// physics methods
-void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
+void CcdPhysicsController::ApplyTorque(const MT_Vector3& torquein,bool local)
{
- btVector3 torque(torqueX,torqueY,torqueZ);
+ btVector3 torque(torquein.x(),torquein.y(),torquein.z());
btTransform xform = m_object->getWorldTransform();
@@ -1156,9 +1212,9 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque
}
}
-void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
+void CcdPhysicsController::ApplyForce(const MT_Vector3& forcein,bool local)
{
- btVector3 force(forceX,forceY,forceZ);
+ btVector3 force(forcein.x(),forcein.y(),forcein.z());
if (m_object && force.length2() > (SIMD_EPSILON*SIMD_EPSILON))
@@ -1189,9 +1245,9 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo
}
}
}
-void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
+void CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
{
- btVector3 angvel(ang_velX,ang_velY,ang_velZ);
+ btVector3 angvel(ang_vel.x(),ang_vel.y(),ang_vel.z());
if (m_object && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
m_object->activate(true);
@@ -1212,10 +1268,10 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo
}
}
-void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)
+void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
{
- btVector3 linVel(lin_velX,lin_velY,lin_velZ);
+ btVector3 linVel(lin_vel.x(),lin_vel.y(),lin_vel.z());
if (m_object/* && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)*/)
{
m_object->activate(true);
@@ -1247,9 +1303,9 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa
}
}
}
-void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
+void CcdPhysicsController::ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein)
{
- btVector3 impulse(impulseX,impulseY,impulseZ);
+ btVector3 impulse(impulsein.x(), impulsein.y(), impulsein.z());
if (m_object && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
@@ -1261,7 +1317,7 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac
return;
}
- btVector3 pos(attachX,attachY,attachZ);
+ btVector3 pos(attach.x(), attach.y(), attach.z());
btRigidBody* body = GetRigidBody();
if (body)
body->applyImpulse(impulse,pos);
@@ -1280,82 +1336,59 @@ void CcdPhysicsController::SetActive(bool active)
{
}
// reading out information from physics
-void CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
+MT_Vector3 CcdPhysicsController::GetLinearVelocity()
{
btRigidBody* body = GetRigidBody();
if (body)
{
const btVector3& linvel = body->getLinearVelocity();
- linvX = linvel.x();
- linvY = linvel.y();
- linvZ = linvel.z();
- } else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
+ return MT_Vector3(linvel.x(), linvel.y(), linvel.z());
}
+ return MT_Vector3(0.f, 0.f, 0.f);
}
-void CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ)
+MT_Vector3 CcdPhysicsController::GetAngularVelocity()
{
btRigidBody* body = GetRigidBody();
if (body)
{
const btVector3& angvel= body->getAngularVelocity();
- angVelX = angvel.x();
- angVelY = angvel.y();
- angVelZ = angvel.z();
- } else
- {
- angVelX = 0.f;
- angVelY = 0.f;
- angVelZ = 0.f;
+ return MT_Vector3(angvel.x(), angvel.y(), angvel.z());
}
+
+ return MT_Vector3(0.f, 0.f, 0.f);
}
-void CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
+MT_Vector3 CcdPhysicsController::GetVelocity(const MT_Point3 &posin)
{
- btVector3 pos(posX,posY,posZ);
+ btVector3 pos(posin.x(), posin.y(), posin.z());
btRigidBody* body = GetRigidBody();
if (body)
{
btVector3 linvel = body->getVelocityInLocalPoint(pos);
- linvX = linvel.x();
- linvY = linvel.y();
- linvZ = linvel.z();
- } else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
+ return MT_Vector3(linvel.x(), linvel.y(), linvel.z());
}
-}
-void CcdPhysicsController::GetWalkDirection(float& dirX,float& dirY,float& dirZ)
-{
- if (m_object && m_characterController)
- {
- const btVector3 dir = m_characterController->getWalkDirection();
- dirX = dir.x();
- dirY = dir.y();
- dirZ = dir.z();
- }
- else
- {
- dirX = 0.f;
- dirY = 0.f;
- dirZ = 0.f;
- }
+ return MT_Vector3(0.f, 0.f, 0.f);
}
-void CcdPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
+MT_Vector3 CcdPhysicsController::GetLocalInertia()
{
+ MT_Vector3 inertia(0.f, 0.f, 0.f);
+ btVector3 inv_inertia;
+ if (GetRigidBody()) {
+ inv_inertia = GetRigidBody()->getInvInertiaDiagLocal();
+ if (!btFuzzyZero(inv_inertia.getX()) &&
+ !btFuzzyZero(inv_inertia.getY()) &&
+ !btFuzzyZero(inv_inertia.getZ()))
+ inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ());
+ }
+ return inertia;
}
// dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted
-void CcdPhysicsController::setRigidBody(bool rigid)
+void CcdPhysicsController::SetRigidBody(bool rigid)
{
btRigidBody* body = GetRigidBody();
if (body)
@@ -1371,13 +1404,21 @@ void CcdPhysicsController::setRigidBody(bool rigid)
}
// clientinfo for raycasts for example
-void* CcdPhysicsController::getNewClientInfo()
+void* CcdPhysicsController::GetNewClientInfo()
{
return m_newClientInfo;
}
-void CcdPhysicsController::setNewClientInfo(void* clientinfo)
+void CcdPhysicsController::SetNewClientInfo(void* clientinfo)
{
m_newClientInfo = clientinfo;
+
+ if (m_cci.m_bSensor)
+ {
+ // use a different callback function for sensor object,
+ // bullet will not synchronize, we must do it explicitly
+ SG_Callbacks& callbacks = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)clientinfo)->GetSGNode()->GetCallBackFunctions();
+ callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
+ }
}
@@ -1390,7 +1431,7 @@ void CcdPhysicsController::UpdateDeactivation(float timeStep)
}
}
-bool CcdPhysicsController::wantsSleeping()
+bool CcdPhysicsController::WantsSleeping()
{
btRigidBody* body = GetRigidBody();
if (body)
@@ -1400,8 +1441,143 @@ bool CcdPhysicsController::wantsSleeping()
//check it out
return true;
}
+/* This function dynamically adds the collision shape of another controller to
+ * the current controller shape provided it is a compound shape.
+ * The idea is that dynamic parenting on a compound object will dynamically extend the shape
+ */
+void CcdPhysicsController::AddCompoundChild(PHY_IPhysicsController* child)
+{
+ if (child == NULL || !IsCompound())
+ return;
+ // other controller must be a bullet controller too
+ // verify that body and shape exist and match
+ CcdPhysicsController* childCtrl = dynamic_cast<CcdPhysicsController*>(child);
+ btRigidBody* rootBody = GetRigidBody();
+ btRigidBody* childBody = childCtrl->GetRigidBody();
+ if (!rootBody || !childBody)
+ return;
+ const btCollisionShape* rootShape = rootBody->getCollisionShape();
+ const btCollisionShape* childShape = childBody->getCollisionShape();
+ if (!rootShape ||
+ !childShape ||
+ rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE ||
+ childShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
+ return;
+ btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
+ // compute relative transformation between parent and child
+ btTransform rootTrans;
+ btTransform childTrans;
+ rootBody->getMotionState()->getWorldTransform(rootTrans);
+ childBody->getMotionState()->getWorldTransform(childTrans);
+ btVector3 rootScale = rootShape->getLocalScaling();
+ rootScale[0] = 1.0/rootScale[0];
+ rootScale[1] = 1.0/rootScale[1];
+ rootScale[2] = 1.0/rootScale[2];
+ // relative scale = child_scale/parent_scale
+ btVector3 relativeScale = childShape->getLocalScaling()*rootScale;
+ btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose();
+ // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale)
+ btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale);
+ // relative rot = parent_rot^-1 * child_rot
+ btMatrix3x3 relativeRot = rootRotInverse*childTrans.getBasis();
+ // create a proxy shape info to store the transformation
+ CcdShapeConstructionInfo* proxyShapeInfo = new CcdShapeConstructionInfo();
+ // store the transformation to this object shapeinfo
+ proxyShapeInfo->m_childTrans.setOrigin(relativePos);
+ proxyShapeInfo->m_childTrans.setBasis(relativeRot);
+ proxyShapeInfo->m_childScale.setValue(relativeScale[0], relativeScale[1], relativeScale[2]);
+ // we will need this to make sure that we remove the right proxy later when unparenting
+ proxyShapeInfo->m_userData = childCtrl;
+ proxyShapeInfo->SetProxy(childCtrl->GetShapeInfo()->AddRef());
+ // add to parent compound shapeinfo (increments ref count)
+ GetShapeInfo()->AddShape(proxyShapeInfo);
+ // create new bullet collision shape from the object shapeinfo and set scaling
+ btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin(), childCtrl->GetConstructionInfo().m_bGimpact, true);
+ newChildShape->setLocalScaling(relativeScale);
+ // add bullet collision shape to parent compound collision shape
+ compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape);
+ // proxyShapeInfo is not needed anymore, release it
+ proxyShapeInfo->Release();
+ // remember we created this shape
+ childCtrl->m_bulletChildShape = newChildShape;
+ // recompute inertia of parent
+ if (!rootBody->isStaticOrKinematicObject())
+ {
+ btVector3 localInertia;
+ float mass = 1.f/rootBody->getInvMass();
+ compoundShape->calculateLocalInertia(mass,localInertia);
+ rootBody->setMassProps(mass,localInertia);
+ }
+ // must update the broadphase cache,
+ GetPhysicsEnvironment()->RefreshCcdPhysicsController(this);
+ // remove the children
+ GetPhysicsEnvironment()->DisableCcdPhysicsController(childCtrl);
+}
+
+/* Reverse function of the above, it will remove a shape from a compound shape
+ * provided that the former was added to the later using AddCompoundChild()
+ */
+void CcdPhysicsController::RemoveCompoundChild(PHY_IPhysicsController* child)
+{
+ if (child == NULL || !IsCompound())
+ return;
+ // other controller must be a bullet controller too
+ // verify that body and shape exist and match
+ CcdPhysicsController* childCtrl = dynamic_cast<CcdPhysicsController*>(child);
+ btRigidBody* rootBody = GetRigidBody();
+ btRigidBody* childBody = childCtrl->GetRigidBody();
+ if (!rootBody || !childBody)
+ return;
+ const btCollisionShape* rootShape = rootBody->getCollisionShape();
+ if (!rootShape ||
+ rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE)
+ return;
+ btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
+ // retrieve the shapeInfo
+ CcdShapeConstructionInfo* childShapeInfo = childCtrl->GetShapeInfo();
+ CcdShapeConstructionInfo* rootShapeInfo = GetShapeInfo();
+ // and verify that the child is part of the parent
+ int i = rootShapeInfo->FindChildShape(childShapeInfo, childCtrl);
+ if (i < 0)
+ return;
+ rootShapeInfo->RemoveChildShape(i);
+ if (childCtrl->m_bulletChildShape)
+ {
+ int numChildren = compoundShape->getNumChildShapes();
+ for (i=0; i<numChildren; i++)
+ {
+ if (compoundShape->getChildShape(i) == childCtrl->m_bulletChildShape)
+ {
+ compoundShape->removeChildShapeByIndex(i);
+ compoundShape->recalculateLocalAabb();
+ break;
+ }
+ }
+ delete childCtrl->m_bulletChildShape;
+ childCtrl->m_bulletChildShape = NULL;
+ }
+ // recompute inertia of parent
+ if (!rootBody->isStaticOrKinematicObject())
+ {
+ btVector3 localInertia;
+ float mass = 1.f/rootBody->getInvMass();
+ compoundShape->calculateLocalInertia(mass,localInertia);
+ rootBody->setMassProps(mass,localInertia);
+ }
+ // must update the broadphase cache,
+ GetPhysicsEnvironment()->RefreshCcdPhysicsController(this);
+ // reactivate the children
+ GetPhysicsEnvironment()->EnableCcdPhysicsController(childCtrl);
+}
+
+PHY_IPhysicsController* CcdPhysicsController::GetReplica()
+{
+ CcdPhysicsController* replica = new CcdPhysicsController(*this);
+ return replica;
+}
-PHY_IPhysicsController* CcdPhysicsController::GetReplica()
+// Keeping this separate for now, maybe we can combine it with GetReplica()...
+PHY_IPhysicsController* CcdPhysicsController::GetReplicaForSensors()
{
// This is used only to replicate Near and Radar sensor controllers
// The replication of object physics controller is done in KX_BulletPhysicsController::GetReplica()
@@ -1460,21 +1636,21 @@ DefaultMotionState::~DefaultMotionState()
}
-void DefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
+void DefaultMotionState::GetWorldPosition(float& posX,float& posY,float& posZ)
{
posX = m_worldTransform.getOrigin().x();
posY = m_worldTransform.getOrigin().y();
posZ = m_worldTransform.getOrigin().z();
}
-void DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
+void DefaultMotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
{
scaleX = m_localScaling.getX();
scaleY = m_localScaling.getY();
scaleZ = m_localScaling.getZ();
}
-void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
+void DefaultMotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
{
btQuaternion quat = m_worldTransform.getRotation();
quatIma0 = quat.x();
@@ -1483,28 +1659,28 @@ void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,flo
quatReal = quat[3];
}
-void DefaultMotionState::getWorldOrientation(float* ori)
+void DefaultMotionState::GetWorldOrientation(float* ori)
{
m_worldTransform.getBasis().getOpenGLSubMatrix(ori);
}
-void DefaultMotionState::setWorldOrientation(const float* ori)
+void DefaultMotionState::SetWorldOrientation(const float* ori)
{
m_worldTransform.getBasis().setFromOpenGLSubMatrix(ori);
}
-void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
+void DefaultMotionState::SetWorldPosition(float posX,float posY,float posZ)
{
btVector3 pos(posX,posY,posZ);
m_worldTransform.setOrigin( pos );
}
-void DefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
+void DefaultMotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
{
btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal);
m_worldTransform.setRotation( orn );
}
-void DefaultMotionState::calculateWorldTransformations()
+void DefaultMotionState::CalculateWorldTransformations()
{
}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index f1f0ca31419..194a47ae2df 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -33,6 +33,7 @@ subject to the following restrictions:
#include "LinearMath/btTransform.h"
#include "PHY_IMotionState.h"
+#include "PHY_ICharacter.h"
extern float gDeactivationTime;
extern float gLinearSleepingTreshold;
@@ -266,6 +267,7 @@ struct CcdConstructionInfo
m_soft_kSHR(1.0f),
m_soft_kAHR(0.7f),
m_collisionFlags(0),
+ m_bDyna(false),
m_bRigid(false),
m_bSoft(false),
m_bSensor(false),
@@ -349,6 +351,7 @@ struct CcdConstructionInfo
int m_collisionFlags;
+ bool m_bDyna;
bool m_bRigid;
bool m_bSoft;
bool m_bSensor;
@@ -396,7 +399,7 @@ class btCollisionObject;
class btSoftBody;
class btPairCachingGhostObject;
-class BlenderBulletCharacterController : public btKinematicCharacterController
+class BlenderBulletCharacterController : public btKinematicCharacterController, public PHY_ICharacter
{
private:
btMotionState* m_motionState;
@@ -419,6 +422,30 @@ public:
virtual void jump();
const btVector3& getWalkDirection();
+
+ // PHY_ICharacter interface
+ virtual void Jump() { jump(); }
+ virtual bool OnGround(){ return onGround(); }
+ virtual float GetGravity() { return getGravity(); }
+ virtual void SetGravity(float gravity) { setGravity(gravity); }
+ virtual int GetMaxJumps() { return getMaxJumps(); }
+ virtual void SetMaxJumps(int maxJumps) { setMaxJumps(maxJumps); }
+ virtual int GetJumpCount() { return getJumpCount(); }
+ virtual void SetWalkDirection(const MT_Vector3& dir)
+ {
+ btVector3 vec = btVector3(dir[0], dir[1], dir[2]);
+ setWalkDirection(vec);
+ }
+ virtual MT_Vector3 GetWalkDirection()
+ {
+ btVector3 vec = getWalkDirection();
+ return MT_Vector3(vec[0], vec[1], vec[2]);
+ }
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ using PHY_ICharacter::operator new;
+ using PHY_ICharacter::operator delete;
+#endif
};
///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
@@ -433,6 +460,7 @@ protected:
btMotionState* m_bulletMotionState;
class btCollisionShape* m_collisionShape;
class CcdShapeConstructionInfo* m_shapeInfo;
+ btCollisionShape* m_bulletChildShape;
friend class CcdPhysicsEnvironment; // needed when updating the controller
@@ -449,6 +477,10 @@ protected:
CcdPhysicsController* m_parentCtrl;
+ int m_savedCollisionFlags;
+ MT_Scalar m_savedMass;
+ bool m_suspended;
+
void GetWorldOrientation(btMatrix3x3& mat);
void CreateRigidbody();
@@ -462,8 +494,8 @@ protected:
return (--m_registerCount == 0) ? true : false;
}
- void setWorldOrientation(const btMatrix3x3& mat);
- void forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos);
+ void SetWorldOrientation(const btMatrix3x3& mat);
+ void ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos);
public:
@@ -477,11 +509,11 @@ protected:
virtual ~CcdPhysicsController();
- CcdConstructionInfo& getConstructionInfo()
+ CcdConstructionInfo& GetConstructionInfo()
{
return m_cci;
}
- const CcdConstructionInfo& getConstructionInfo() const
+ const CcdConstructionInfo& GetConstructionInfo() const
{
return m_cci;
}
@@ -518,42 +550,51 @@ protected:
virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env);
// kinematic methods
- virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
- virtual void SetWalkDirection(float dirX,float dirY,float dirZ,bool local);
- virtual void RelativeRotate(const float drot[9],bool local);
- virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
- virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
- virtual void setPosition(float posX,float posY,float posZ);
- virtual void getPosition(MT_Vector3& pos) const;
-
- virtual void setScaling(float scaleX,float scaleY,float scaleZ);
+ virtual void RelativeTranslate(const MT_Vector3& dloc,bool local);
+ virtual void RelativeRotate(const MT_Matrix3x3&rotval, bool local);
+ virtual MT_Matrix3x3 GetOrientation();
+ virtual void SetOrientation(const MT_Matrix3x3& orn);
+ virtual void SetPosition(const MT_Vector3& pos);
+ virtual void GetPosition(MT_Vector3& pos) const;
+ virtual void SetScaling(const MT_Vector3& scale);
+ virtual void SetTransform();
+
+ virtual MT_Scalar GetMass();
+ virtual void SetMass(MT_Scalar newmass);
// physics methods
- virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local);
- virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local);
- virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
- virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
- virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
+ virtual void ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein);
+ virtual void ApplyTorque(const MT_Vector3& torque,bool local);
+ virtual void ApplyForce(const MT_Vector3& force,bool local);
+ virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
+ virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
virtual void Jump();
virtual void SetActive(bool active);
// reading out information from physics
- virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ);
- virtual void GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ);
- virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ);
- virtual void getReactionForce(float& forceX,float& forceY,float& forceZ);
- virtual void GetWalkDirection(float& dirX,float& dirY,float& dirZ);
+ virtual MT_Vector3 GetLinearVelocity();
+ virtual MT_Vector3 GetAngularVelocity();
+ virtual MT_Vector3 GetVelocity(const MT_Point3& posin);
+ virtual MT_Vector3 GetLocalInertia();
// dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted
- virtual void setRigidBody(bool rigid);
+ virtual void SetRigidBody(bool rigid);
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
+ virtual void ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
+
+ virtual void SuspendDynamics(bool ghost);
+ virtual void RestoreDynamics();
+
+ // Shape control
+ virtual void AddCompoundChild(PHY_IPhysicsController* child);
+ virtual void RemoveCompoundChild(PHY_IPhysicsController* child);
// clientinfo for raycasts for example
- virtual void* getNewClientInfo();
- virtual void setNewClientInfo(void* clientinfo);
+ virtual void* GetNewClientInfo();
+ virtual void SetNewClientInfo(void* clientinfo);
virtual PHY_IPhysicsController* GetReplica();
+ virtual PHY_IPhysicsController* GetReplicaForSensors();
///There should be no 'SetCollisionFilterGroup' method, as changing this during run-time is will result in errors
short int GetCollisionFilterGroup() const
@@ -566,7 +607,7 @@ protected:
return m_cci.m_collisionFilterMask;
}
- virtual void calcXform() {}
+ virtual void CalcXform() {}
virtual void SetMargin(float margin)
{
if (m_collisionShape)
@@ -609,7 +650,7 @@ protected:
return m_cci.m_clamp_vel_max;
}
- bool wantsSleeping();
+ bool WantsSleeping();
void UpdateDeactivation(float timeStep);
@@ -635,24 +676,29 @@ protected:
return m_cci.m_physicsEnv;
}
- void setParentCtrl(CcdPhysicsController* parentCtrl)
+ void SetParentCtrl(CcdPhysicsController* parentCtrl)
{
m_parentCtrl = parentCtrl;
}
- CcdPhysicsController* getParentCtrl()
+ CcdPhysicsController* GetParentCtrl()
{
return m_parentCtrl;
}
- const CcdPhysicsController* getParentCtrl() const
+ const CcdPhysicsController* GetParentCtrl() const
{
return m_parentCtrl;
}
- virtual const char* getName()
+ virtual bool IsDynamic()
+ {
+ return GetConstructionInfo().m_bDyna;
+ }
+
+ virtual bool IsCompound()
{
- return 0;
+ return GetConstructionInfo().m_shapeInfo->m_shapeType == PHY_SHAPE_COMPOUND;
}
#ifdef WITH_CXX_GUARDEDALLOC
@@ -672,16 +718,16 @@ class DefaultMotionState : public PHY_IMotionState
virtual ~DefaultMotionState();
- virtual void getWorldPosition(float& posX,float& posY,float& posZ);
- virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
- virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
+ virtual void GetWorldPosition(float& posX,float& posY,float& posZ);
+ virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
+ virtual void GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
- virtual void setWorldPosition(float posX,float posY,float posZ);
- virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
- virtual void getWorldOrientation(float* ori);
- virtual void setWorldOrientation(const float* ori);
+ virtual void SetWorldPosition(float posX,float posY,float posZ);
+ virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
+ virtual void GetWorldOrientation(float* ori);
+ virtual void SetWorldOrientation(const float* ori);
- virtual void calculateWorldTransformations();
+ virtual void CalculateWorldTransformations();
btTransform m_worldTransform;
btVector3 m_localScaling;
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index e01530f2b11..cddc12cc754 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -83,6 +83,11 @@ public:
{
}
+ ~WrapperVehicle()
+ {
+ delete m_vehicle;
+ }
+
btRaycastVehicle* GetVehicle()
{
return m_vehicle;
@@ -127,8 +132,8 @@ public:
btTransform trans = m_vehicle->getWheelInfo(i).m_worldTransform;
btQuaternion orn = trans.getRotation();
const btVector3& pos = trans.getOrigin();
- motionState->setWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]);
- motionState->setWorldPosition(pos.x(),pos.y(),pos.z());
+ motionState->SetWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]);
+ motionState->SetWorldPosition(pos.x(),pos.y(),pos.z());
}
}
@@ -265,63 +270,6 @@ public:
};
#endif //NEW_BULLET_VEHICLE_SUPPORT
-class CharacterWrapper : public PHY_ICharacter
-{
-private:
- BlenderBulletCharacterController* m_controller;
-
-public:
- CharacterWrapper(BlenderBulletCharacterController* cont)
- : m_controller(cont)
- {}
-
- virtual void Jump()
- {
- m_controller->jump();
- }
-
- virtual bool OnGround()
- {
- return m_controller->onGround();
- }
-
- virtual float GetGravity()
- {
- return m_controller->getGravity();
- }
- virtual void SetGravity(float gravity)
- {
- m_controller->setGravity(gravity);
- }
-
- virtual int GetMaxJumps()
- {
- return m_controller->getMaxJumps();
- }
-
- virtual void SetMaxJumps(int maxJumps)
- {
- m_controller->setMaxJumps(maxJumps);
- }
-
- virtual int GetJumpCount()
- {
- return m_controller->getJumpCount();
- }
-
- virtual void SetWalkDirection(const MT_Vector3& dir)
- {
- btVector3 vec = btVector3(dir[0], dir[1], dir[2]);
- m_controller->setWalkDirection(vec);
- }
-
- virtual MT_Vector3 GetWalkDirection()
- {
- btVector3 vec = m_controller->getWalkDirection();
- return MT_Vector3(vec[0], vec[1], vec[2]);
- }
-};
-
class CcdOverlapFilterCallBack : public btOverlapFilterCallback
{
private:
@@ -339,7 +287,7 @@ public:
};
-void CcdPhysicsEnvironment::setDebugDrawer(btIDebugDraw* debugDrawer)
+void CcdPhysicsEnvironment::SetDebugDrawer(btIDebugDraw* debugDrawer)
{
if (debugDrawer && m_dynamicsWorld)
m_dynamicsWorld->setDebugDrawer(debugDrawer);
@@ -429,17 +377,17 @@ m_scalingPropagated(false)
m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback);
m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_ghostPairCallback);
- setSolverType(1);//issues with quickstep and memory allocations
+ SetSolverType(1);//issues with quickstep and memory allocations
// m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld = new btSoftRigidDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
//m_dynamicsWorld->getSolverInfo().m_linearSlop = 0.01f;
//m_dynamicsWorld->getSolverInfo().m_solverMode= SOLVER_USE_WARMSTARTING + SOLVER_USE_2_FRICTION_DIRECTIONS + SOLVER_RANDMIZE_ORDER + SOLVER_USE_FRICTION_WARMSTARTING;
m_debugDrawer = 0;
- setGravity(0.f,0.f,-9.81f);
+ SetGravity(0.f,0.f,-9.81f);
}
-void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
+void CcdPhysicsEnvironment::AddCcdPhysicsController(CcdPhysicsController* ctrl)
{
btRigidBody* body = ctrl->GetRigidBody();
btCollisionObject* obj = ctrl->GetCollisionObject();
@@ -483,7 +431,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
-bool CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctrl)
{
//also remove constraint
btRigidBody* body = ctrl->GetRigidBody();
@@ -497,6 +445,19 @@ bool CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
//delete con; //might be kept by python KX_ConstraintWrapper
}
m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody());
+
+ // Handle potential vehicle constraints
+ int numVehicles = m_wrapperVehicles.size();
+ int vehicle_constraint = 0;
+ for (int i=0;i<numVehicles;i++)
+ {
+ WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i];
+ if (wrapperVehicle->GetChassis() == ctrl)
+ vehicle_constraint = wrapperVehicle->GetVehicle()->getUserConstraintId();
+ }
+
+ if (vehicle_constraint > 0)
+ RemoveConstraint(vehicle_constraint);
} else
{
//if a softbody
@@ -522,7 +483,7 @@ bool CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
return (m_controllers.erase(ctrl) != 0);
}
-void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask)
+void CcdPhysicsEnvironment::UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask)
{
// this function is used when the collisionning group of a controller is changed
// remove and add the collistioning object
@@ -551,7 +512,7 @@ void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr
ctrl->m_cci.m_collisionFlags = newCollisionFlags;
}
-void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctrl)
+void CcdPhysicsEnvironment::EnableCcdPhysicsController(CcdPhysicsController* ctrl)
{
if (m_controllers.insert(ctrl).second)
{
@@ -568,7 +529,7 @@ void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctr
}
}
-void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ctrl)
+void CcdPhysicsEnvironment::DisableCcdPhysicsController(CcdPhysicsController* ctrl)
{
if (m_controllers.erase(ctrl))
{
@@ -588,7 +549,7 @@ void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ct
}
}
-void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ctrl)
+void CcdPhysicsEnvironment::RefreshCcdPhysicsController(CcdPhysicsController* ctrl)
{
btCollisionObject* obj = ctrl->GetCollisionObject();
if (obj)
@@ -601,15 +562,15 @@ void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ct
}
}
-void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl)
+void CcdPhysicsEnvironment::AddCcdGraphicController(CcdGraphicController* ctrl)
{
- if (m_cullingTree && !ctrl->getBroadphaseHandle())
+ if (m_cullingTree && !ctrl->GetBroadphaseHandle())
{
btVector3 minAabb;
btVector3 maxAabb;
- ctrl->getAabb(minAabb, maxAabb);
+ ctrl->GetAabb(minAabb, maxAabb);
- ctrl->setBroadphaseHandle(m_cullingTree->createProxy(
+ ctrl->SetBroadphaseHandle(m_cullingTree->createProxy(
minAabb,
maxAabb,
INVALID_SHAPE_PROXYTYPE, // this parameter is not used
@@ -619,35 +580,35 @@ void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl)
NULL, // dispatcher => this parameter is not used
0));
- assert(ctrl->getBroadphaseHandle());
+ assert(ctrl->GetBroadphaseHandle());
}
}
-void CcdPhysicsEnvironment::removeCcdGraphicController(CcdGraphicController* ctrl)
+void CcdPhysicsEnvironment::RemoveCcdGraphicController(CcdGraphicController* ctrl)
{
if (m_cullingTree)
{
- btBroadphaseProxy* bp = ctrl->getBroadphaseHandle();
+ btBroadphaseProxy* bp = ctrl->GetBroadphaseHandle();
if (bp)
{
m_cullingTree->destroyProxy(bp,NULL);
- ctrl->setBroadphaseHandle(0);
+ ctrl->SetBroadphaseHandle(0);
}
}
}
-void CcdPhysicsEnvironment::beginFrame()
+void CcdPhysicsEnvironment::BeginFrame()
{
}
-void CcdPhysicsEnvironment::debugDrawWorld()
+void CcdPhysicsEnvironment::DebugDrawWorld()
{
if (m_dynamicsWorld->getDebugDrawer() && m_dynamicsWorld->getDebugDrawer()->getDebugMode() >0)
m_dynamicsWorld->debugDrawWorld();
}
-bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
+bool CcdPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float interval)
{
std::set<CcdPhysicsController*>::iterator it;
int i;
@@ -662,7 +623,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float
//uncomment next line to see where Bullet spend its time (printf in console)
//CProfileManager::dumpAll();
- processFhSprings(curTime,i*subStep);
+ ProcessFhSprings(curTime,i*subStep);
for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
{
@@ -714,7 +675,7 @@ public:
};
-void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
+void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval)
{
std::set<CcdPhysicsController*>::iterator it;
// dynamic of Fh spring is based on a timestep of 1/60
@@ -725,12 +686,12 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
CcdPhysicsController* ctrl = (*it);
btRigidBody* body = ctrl->GetRigidBody();
- if (body && (ctrl->getConstructionInfo().m_do_fh || ctrl->getConstructionInfo().m_do_rot_fh))
+ if (body && (ctrl->GetConstructionInfo().m_do_fh || ctrl->GetConstructionInfo().m_do_rot_fh))
{
//printf("has Fh or RotFh\n");
//re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo()
//send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates
- CcdPhysicsController* parentCtrl = ctrl->getParentCtrl();
+ CcdPhysicsController* parentCtrl = ctrl->GetParentCtrl();
btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0;
btRigidBody* cl_object = parentBody ? parentBody : body;
@@ -756,16 +717,16 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
if (controller)
{
- if (controller->getConstructionInfo().m_fh_distance < SIMD_EPSILON)
+ if (controller->GetConstructionInfo().m_fh_distance < SIMD_EPSILON)
continue;
btRigidBody* hit_object = controller->GetRigidBody();
if (!hit_object)
continue;
- CcdConstructionInfo& hitObjShapeProps = controller->getConstructionInfo();
+ CcdConstructionInfo& hitObjShapeProps = controller->GetConstructionInfo();
- float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->getConstructionInfo().m_radius;
+ float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->GetConstructionInfo().m_radius;
if (distance >= hitObjShapeProps.m_fh_distance)
continue;
@@ -778,7 +739,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
for (int i=0; i<numIter; i++)
{
- if (ctrl->getConstructionInfo().m_do_fh)
+ if (ctrl->GetConstructionInfo().m_do_fh)
{
btVector3 lspot = cl_object->getCenterOfMassPosition() +
rayDirLocal * resultCallback.m_closestHitFraction;
@@ -790,7 +751,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot);
btScalar rel_vel_ray = ray_dir.dot(rel_vel);
btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance;
-
+
btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring;
btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping;
@@ -803,7 +764,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
btVector3 lateral = rel_vel - rel_vel_ray * ray_dir;
- if (ctrl->getConstructionInfo().m_do_anisotropic) {
+ if (ctrl->GetConstructionInfo().m_do_anisotropic) {
//Bullet basis contains no scaling/shear etc.
const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis();
btVector3 loc_lateral = lateral * lcs;
@@ -830,7 +791,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
}
- if (ctrl->getConstructionInfo().m_do_rot_fh) {
+ if (ctrl->GetConstructionInfo().m_do_rot_fh) {
btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2);
btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring;
@@ -850,69 +811,69 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
}
}
-void CcdPhysicsEnvironment::setDebugMode(int debugMode)
+void CcdPhysicsEnvironment::SetDebugMode(int debugMode)
{
if (m_debugDrawer) {
m_debugDrawer->setDebugMode(debugMode);
}
}
-void CcdPhysicsEnvironment::setNumIterations(int numIter)
+void CcdPhysicsEnvironment::SetNumIterations(int numIter)
{
m_numIterations = numIter;
}
-void CcdPhysicsEnvironment::setDeactivationTime(float dTime)
+void CcdPhysicsEnvironment::SetDeactivationTime(float dTime)
{
gDeactivationTime = dTime;
}
-void CcdPhysicsEnvironment::setDeactivationLinearTreshold(float linTresh)
+void CcdPhysicsEnvironment::SetDeactivationLinearTreshold(float linTresh)
{
gLinearSleepingTreshold = linTresh;
}
-void CcdPhysicsEnvironment::setDeactivationAngularTreshold(float angTresh)
+void CcdPhysicsEnvironment::SetDeactivationAngularTreshold(float angTresh)
{
gAngularSleepingTreshold = angTresh;
}
-void CcdPhysicsEnvironment::setContactBreakingTreshold(float contactBreakingTreshold)
+void CcdPhysicsEnvironment::SetContactBreakingTreshold(float contactBreakingTreshold)
{
gContactBreakingThreshold = contactBreakingTreshold;
}
-void CcdPhysicsEnvironment::setCcdMode(int ccdMode)
+void CcdPhysicsEnvironment::SetCcdMode(int ccdMode)
{
m_ccdMode = ccdMode;
}
-void CcdPhysicsEnvironment::setSolverSorConstant(float sor)
+void CcdPhysicsEnvironment::SetSolverSorConstant(float sor)
{
m_dynamicsWorld->getSolverInfo().m_sor = sor;
}
-void CcdPhysicsEnvironment::setSolverTau(float tau)
+void CcdPhysicsEnvironment::SetSolverTau(float tau)
{
m_dynamicsWorld->getSolverInfo().m_tau = tau;
}
-void CcdPhysicsEnvironment::setSolverDamping(float damping)
+void CcdPhysicsEnvironment::SetSolverDamping(float damping)
{
m_dynamicsWorld->getSolverInfo().m_damping = damping;
}
-void CcdPhysicsEnvironment::setLinearAirDamping(float damping)
+void CcdPhysicsEnvironment::SetLinearAirDamping(float damping)
{
//gLinearAirDamping = damping;
}
-void CcdPhysicsEnvironment::setUseEpa(bool epa)
+void CcdPhysicsEnvironment::SetUseEpa(bool epa)
{
//gUseEpa = epa;
}
-void CcdPhysicsEnvironment::setSolverType(int solverType)
+void CcdPhysicsEnvironment::SetSolverType(int solverType)
{
switch (solverType)
@@ -945,7 +906,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType)
-void CcdPhysicsEnvironment::getGravity(MT_Vector3& grav)
+void CcdPhysicsEnvironment::GetGravity(MT_Vector3& grav)
{
const btVector3& gravity = m_dynamicsWorld->getGravity();
grav[0] = gravity.getX();
@@ -954,7 +915,7 @@ void CcdPhysicsEnvironment::getGravity(MT_Vector3& grav)
}
-void CcdPhysicsEnvironment::setGravity(float x,float y,float z)
+void CcdPhysicsEnvironment::SetGravity(float x,float y,float z)
{
m_gravity = btVector3(x,y,z);
m_dynamicsWorld->setGravity(m_gravity);
@@ -967,7 +928,7 @@ void CcdPhysicsEnvironment::setGravity(float x,float y,float z)
static int gConstraintUid = 1;
//Following the COLLADA physics specification for constraints
-int CcdPhysicsEnvironment::createUniversalD6Constraint(
+int CcdPhysicsEnvironment::CreateUniversalD6Constraint(
class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther,
btTransform& frameInA,
btTransform& frameInB,
@@ -1025,7 +986,7 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint(
-void CcdPhysicsEnvironment::removeConstraint(int constraintId)
+void CcdPhysicsEnvironment::RemoveConstraint(int constraintId)
{
int i;
@@ -1041,6 +1002,14 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId)
break;
}
}
+
+ WrapperVehicle *vehicle;
+ if ((vehicle = (WrapperVehicle*)GetVehicleConstraint(constraintId)))
+ {
+ m_dynamicsWorld->removeVehicle(vehicle->GetVehicle());
+ m_wrapperVehicles.erase(std::remove(m_wrapperVehicles.begin(), m_wrapperVehicles.end(), vehicle));
+ delete vehicle;
+ }
}
@@ -1144,7 +1113,7 @@ static bool GetHitTriangle(btCollisionShape* shape, CcdShapeConstructionInfo* sh
return true;
}
-PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
+PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
{
btVector3 rayFrom(fromX,fromY,fromZ);
btVector3 rayTo(toX,toY,toZ);
@@ -1798,7 +1767,7 @@ struct DbvtCullingCallback : btDbvt::ICollide
btBroadphaseProxy* proxy=(btBroadphaseProxy*)leaf->data;
// the client object is a graphic controller
CcdGraphicController* ctrl = static_cast<CcdGraphicController*>(proxy->m_clientObject);
- KX_ClientObjectInfo *info = (KX_ClientObjectInfo*)ctrl->getNewClientInfo();
+ KX_ClientObjectInfo *info = (KX_ClientObjectInfo*)ctrl->GetNewClientInfo();
if (m_ocb)
{
// means we are doing occlusion culling. Check if this object is an occluders
@@ -1846,7 +1815,7 @@ struct DbvtCullingCallback : btDbvt::ICollide
};
static OcclusionBuffer gOcb;
-bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16])
+bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16])
{
if (!m_cullingTree)
return false;
@@ -1876,12 +1845,12 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user
return true;
}
-int CcdPhysicsEnvironment::getNumContactPoints()
+int CcdPhysicsEnvironment::GetNumContactPoints()
{
return 0;
}
-void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
+void CcdPhysicsEnvironment::GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
{
}
@@ -1889,12 +1858,12 @@ void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float&
-btBroadphaseInterface* CcdPhysicsEnvironment::getBroadphase()
+btBroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase()
{
return m_dynamicsWorld->getBroadphase();
}
-btDispatcher* CcdPhysicsEnvironment::getDispatcher()
+btDispatcher* CcdPhysicsEnvironment::GetDispatcher()
{
return m_dynamicsWorld->getDispatcher();
}
@@ -1908,8 +1877,8 @@ void CcdPhysicsEnvironment::MergeEnvironment(CcdPhysicsEnvironment *other)
it= other->m_controllers.begin();
CcdPhysicsController* ctrl= (*it);
- other->removeCcdPhysicsController(ctrl);
- this->addCcdPhysicsController(ctrl);
+ other->RemoveCcdPhysicsController(ctrl);
+ this->AddCcdPhysicsController(ctrl);
}
}
@@ -1961,9 +1930,9 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment()
}
-float CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param)
+float CcdPhysicsEnvironment::GetConstraintParam(int constraintId,int param)
{
- btTypedConstraint* typedConstraint = getConstraintById(constraintId);
+ btTypedConstraint* typedConstraint = GetConstraintById(constraintId);
switch (typedConstraint->getUserConstraintType())
{
case PHY_GENERIC_6DOF_CONSTRAINT:
@@ -2000,9 +1969,9 @@ float CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param)
return 0.f;
}
-void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float value0,float value1)
+void CcdPhysicsEnvironment::SetConstraintParam(int constraintId,int param,float value0,float value1)
{
- btTypedConstraint* typedConstraint = getConstraintById(constraintId);
+ btTypedConstraint* typedConstraint = GetConstraintById(constraintId);
switch (typedConstraint->getUserConstraintType())
{
case PHY_GENERIC_6DOF_CONSTRAINT:
@@ -2110,7 +2079,7 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float
};
}
-btTypedConstraint* CcdPhysicsEnvironment::getConstraintById(int constraintId)
+btTypedConstraint* CcdPhysicsEnvironment::GetConstraintById(int constraintId)
{
int numConstraints = m_dynamicsWorld->getNumConstraints();
@@ -2127,7 +2096,7 @@ btTypedConstraint* CcdPhysicsEnvironment::getConstraintById(int constraintId)
}
-void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
+void CcdPhysicsEnvironment::AddSensor(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ctrl1 = (CcdPhysicsController* )ctrl;
@@ -2137,10 +2106,10 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
//{
// addCcdPhysicsController(ctrl1);
//}
- enableCcdPhysicsController(ctrl1);
+ EnableCcdPhysicsController(ctrl1);
}
-bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::RemoveCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl;
if (!ccdCtrl->Unregister())
@@ -2150,12 +2119,12 @@ bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl
}
-void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl)
+void CcdPhysicsEnvironment::RemoveSensor(PHY_IPhysicsController* ctrl)
{
- disableCcdPhysicsController((CcdPhysicsController*)ctrl);
+ DisableCcdPhysicsController((CcdPhysicsController*)ctrl);
}
-void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
+void CcdPhysicsEnvironment::AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
{
/* printf("addTouchCallback\n(response class = %i)\n",response_class);
@@ -2187,7 +2156,7 @@ void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCal
m_triggerCallbacksUserPtrs[response_class] = user;
}
-bool CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::RequestCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = static_cast<CcdPhysicsController*>(ctrl);
@@ -2270,12 +2239,12 @@ bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0
(KX_ClientObjectInfo*)
((CcdPhysicsController*)
(((btCollisionObject*)proxy0->m_clientObject)->getUserPointer()))
- ->getNewClientInfo());
+ ->GetNewClientInfo());
KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(
(KX_ClientObjectInfo*)
((CcdPhysicsController*)
(((btCollisionObject*)proxy1->m_clientObject)->getUserPointer()))
- ->getNewClientInfo());
+ ->GetNewClientInfo());
// First check the filters. Note that this is called during scene
// conversion, so we can't assume the KX_GameObject instances exist. This
@@ -2324,7 +2293,7 @@ bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0
#ifdef NEW_BULLET_VEHICLE_SUPPORT
//complex constraint for vehicles
-PHY_IVehicle* CcdPhysicsEnvironment::getVehicleConstraint(int constraintId)
+PHY_IVehicle* CcdPhysicsEnvironment::GetVehicleConstraint(int constraintId)
{
int i;
@@ -2342,13 +2311,10 @@ PHY_IVehicle* CcdPhysicsEnvironment::getVehicleConstraint(int constraintId)
#endif //NEW_BULLET_VEHICLE_SUPPORT
-PHY_ICharacter* CcdPhysicsEnvironment::getCharacterController(KX_GameObject *ob)
+PHY_ICharacter* CcdPhysicsEnvironment::GetCharacterController(KX_GameObject *ob)
{
- CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController()->GetUserData();
- if (controller->GetCharacterController())
- return new CharacterWrapper((BlenderBulletCharacterController*)controller->GetCharacterController());
-
- return NULL;
+ CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController();
+ return (controller) ? dynamic_cast<BlenderBulletCharacterController*>(controller->GetCharacterController()) : NULL;
}
@@ -2398,7 +2364,7 @@ int findClosestNode(btSoftBody* sb,const btVector3& worldPoint)
return node;
}
-int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type,
+int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X,float axis1Y,float axis1Z,
@@ -2891,7 +2857,7 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid)
return 0.f;
}
-void CcdPhysicsEnvironment::exportFile(const char* filename)
+void CcdPhysicsEnvironment::ExportFile(const char* filename)
{
btDefaultSerializer* serializer = new btDefaultSerializer();
@@ -2904,7 +2870,7 @@ void CcdPhysicsEnvironment::exportFile(const char* filename)
CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(colObj->getUserPointer());
if (controller)
{
- const char* name = controller->getName();
+ const char* name = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)controller->GetNewClientInfo())->GetName();
if (name)
{
serializer->registerNameForPointer(colObj,name);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 8cf88526969..0e8ac9417f0 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -24,6 +24,7 @@ subject to the following restrictions:
#include "PHY_IPhysicsEnvironment.h"
#include <vector>
#include <set>
+#include <map>
class CcdPhysicsController;
class CcdGraphicController;
#include "LinearMath/btVector3.h"
@@ -83,7 +84,7 @@ protected:
int m_profileTimings;
bool m_enableSatCollisionDetection;
- void processFhSprings(double curTime,float timeStep);
+ void ProcessFhSprings(double curTime,float timeStep);
public:
CcdPhysicsEnvironment(bool useDbvtCulling, btDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0);
@@ -96,54 +97,54 @@ protected:
/// Perform an integration step of duration 'timeStep'.
- virtual void setDebugDrawer(btIDebugDraw* debugDrawer);
+ virtual void SetDebugDrawer(btIDebugDraw* debugDrawer);
- virtual void setNumIterations(int numIter);
- virtual void setNumTimeSubSteps(int numTimeSubSteps)
+ virtual void SetNumIterations(int numIter);
+ virtual void SetNumTimeSubSteps(int numTimeSubSteps)
{
m_numTimeSubSteps = numTimeSubSteps;
}
- virtual void setDeactivationTime(float dTime);
- virtual void setDeactivationLinearTreshold(float linTresh);
- virtual void setDeactivationAngularTreshold(float angTresh);
- virtual void setContactBreakingTreshold(float contactBreakingTreshold);
- virtual void setCcdMode(int ccdMode);
- virtual void setSolverType(int solverType);
- virtual void setSolverSorConstant(float sor);
- virtual void setSolverTau(float tau);
- virtual void setSolverDamping(float damping);
- virtual void setLinearAirDamping(float damping);
- virtual void setUseEpa(bool epa);
-
- int getNumTimeSubSteps()
+ virtual void SetDeactivationTime(float dTime);
+ virtual void SetDeactivationLinearTreshold(float linTresh);
+ virtual void SetDeactivationAngularTreshold(float angTresh);
+ virtual void SetContactBreakingTreshold(float contactBreakingTreshold);
+ virtual void SetCcdMode(int ccdMode);
+ virtual void SetSolverType(int solverType);
+ virtual void SetSolverSorConstant(float sor);
+ virtual void SetSolverTau(float tau);
+ virtual void SetSolverDamping(float damping);
+ virtual void SetLinearAirDamping(float damping);
+ virtual void SetUseEpa(bool epa);
+
+ virtual int GetNumTimeSubSteps()
{
return m_numTimeSubSteps;
}
- virtual void beginFrame();
- virtual void endFrame() {}
+ virtual void BeginFrame();
+ virtual void EndFrame() {}
/// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
-
- virtual void debugDrawWorld();
+ virtual bool ProceedDeltaTime(double curTime,float timeStep,float interval);
+
+ virtual void DebugDrawWorld();
// virtual bool proceedDeltaTimeOneStep(float timeStep);
- virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
+ virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
{
//based on DEFAULT_PHYSICS_TIC_RATE of 60 hertz
- setNumTimeSubSteps((int)(fixedTimeStep / 60.f));
+ SetNumTimeSubSteps((int)(fixedTimeStep / 60.f));
}
//returns 0.f if no fixed timestep is used
- virtual float getFixedTimeStep() { return 0.f; }
+ virtual float GetFixedTimeStep() { return 0.f; }
- virtual void setDebugMode(int debugMode);
+ virtual void SetDebugMode(int debugMode);
- virtual void setGravity(float x,float y,float z);
- virtual void getGravity(MT_Vector3& grav);
+ virtual void SetGravity(float x,float y,float z);
+ virtual void GetGravity(MT_Vector3& grav);
- virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+ virtual int CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X=0,float axis1Y=0,float axis1Z=0,
@@ -152,7 +153,7 @@ protected:
//Following the COLLADA physics specification for constraints
- virtual int createUniversalD6Constraint(
+ virtual int CreateUniversalD6Constraint(
class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther,
btTransform& localAttachmentFrameRef,
btTransform& localAttachmentOther,
@@ -163,11 +164,11 @@ protected:
);
- virtual void setConstraintParam(int constraintId,int param,float value,float value1);
+ virtual void SetConstraintParam(int constraintId,int param,float value,float value1);
- virtual float getConstraintParam(int constraintId,int param);
+ virtual float GetConstraintParam(int constraintId,int param);
- virtual void removeConstraint(int constraintid);
+ virtual void RemoveConstraint(int constraintid);
virtual float getAppliedImpulse(int constraintid);
@@ -177,61 +178,61 @@ protected:
#ifdef NEW_BULLET_VEHICLE_SUPPORT
//complex constraint for vehicles
- virtual PHY_IVehicle* getVehicleConstraint(int constraintId);
+ virtual PHY_IVehicle* GetVehicleConstraint(int constraintId);
#else
- virtual class PHY_IVehicle* getVehicleConstraint(int constraintId)
+ virtual class PHY_IVehicle* GetVehicleConstraint(int constraintId)
{
return 0;
}
#endif /* NEW_BULLET_VEHICLE_SUPPORT */
// Character physics wrapper
- virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob);
+ virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob);
- btTypedConstraint* getConstraintById(int constraintId);
+ btTypedConstraint* GetConstraintById(int constraintId);
- virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]);
+ virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
+ virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]);
//Methods for gamelogic collision/physics callbacks
- virtual void addSensor(PHY_IPhysicsController* ctrl);
- virtual void removeSensor(PHY_IPhysicsController* ctrl);
- virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
- virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual void AddSensor(PHY_IPhysicsController* ctrl);
+ virtual void RemoveSensor(PHY_IPhysicsController* ctrl);
+ virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
+ virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl);
//These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position);
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
- virtual int getNumContactPoints();
+ virtual int GetNumContactPoints();
- virtual void getContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
+ virtual void GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
//////////////////////
//CcdPhysicsEnvironment interface
////////////////////////
- void addCcdPhysicsController(CcdPhysicsController* ctrl);
+ void AddCcdPhysicsController(CcdPhysicsController* ctrl);
- bool removeCcdPhysicsController(CcdPhysicsController* ctrl);
+ bool RemoveCcdPhysicsController(CcdPhysicsController* ctrl);
- void updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask);
+ void UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask);
- void disableCcdPhysicsController(CcdPhysicsController* ctrl);
+ void DisableCcdPhysicsController(CcdPhysicsController* ctrl);
- void enableCcdPhysicsController(CcdPhysicsController* ctrl);
+ void EnableCcdPhysicsController(CcdPhysicsController* ctrl);
- void refreshCcdPhysicsController(CcdPhysicsController* ctrl);
+ void RefreshCcdPhysicsController(CcdPhysicsController* ctrl);
- void addCcdGraphicController(CcdGraphicController* ctrl);
+ void AddCcdGraphicController(CcdGraphicController* ctrl);
- void removeCcdGraphicController(CcdGraphicController* ctrl);
+ void RemoveCcdGraphicController(CcdGraphicController* ctrl);
- btBroadphaseInterface* getBroadphase();
- btDbvtBroadphase* getCullingTree() { return m_cullingTree; }
+ btBroadphaseInterface* GetBroadphase();
+ btDbvtBroadphase* GetCullingTree() { return m_cullingTree; }
- btDispatcher* getDispatcher();
+ btDispatcher* GetDispatcher();
bool IsSatCollisionDetectionEnabled() const
@@ -250,7 +251,7 @@ protected:
void SyncMotionStates(float timeStep);
- class btSoftRigidDynamicsWorld* getDynamicsWorld()
+ class btSoftRigidDynamicsWorld* GetDynamicsWorld()
{
return m_dynamicsWorld;
}
@@ -291,7 +292,7 @@ protected:
bool m_scalingPropagated;
- virtual void exportFile(const char* filename);
+ virtual void ExportFile(const char* filename);
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
index 72450e4307c..1bb5431c749 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
@@ -47,19 +47,19 @@ DummyPhysicsEnvironment::~DummyPhysicsEnvironment()
//destroy physicsengine data
}
-void DummyPhysicsEnvironment::beginFrame()
+void DummyPhysicsEnvironment::BeginFrame()
{
// beginning of logic frame: apply forces
}
-void DummyPhysicsEnvironment::endFrame()
+void DummyPhysicsEnvironment::EndFrame()
{
// end of logic frame: clear forces
}
-bool DummyPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
+bool DummyPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float interval)
{
//step physics simulation, typically perform
@@ -69,11 +69,11 @@ bool DummyPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,f
// return true if an update was done.
return true;
}
-void DummyPhysicsEnvironment::setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
+void DummyPhysicsEnvironment::SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
{
}
-float DummyPhysicsEnvironment::getFixedTimeStep()
+float DummyPhysicsEnvironment::GetFixedTimeStep()
{
return 0.f;
}
@@ -81,18 +81,18 @@ float DummyPhysicsEnvironment::getFixedTimeStep()
-void DummyPhysicsEnvironment::setGravity(float x,float y,float z)
+void DummyPhysicsEnvironment::SetGravity(float x,float y,float z)
{
}
-void DummyPhysicsEnvironment::getGravity(class MT_Vector3& grav)
+void DummyPhysicsEnvironment::GetGravity(class MT_Vector3& grav)
{
}
-int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+int DummyPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ,
float axis1X,float axis1Y,float axis1Z,
float axis2X,float axis2Y,float axis2Z,int flag
@@ -104,14 +104,14 @@ int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ct
}
-void DummyPhysicsEnvironment::removeConstraint(int constraintid)
+void DummyPhysicsEnvironment::RemoveConstraint(int constraintid)
{
if (constraintid)
{
}
}
-PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
+PHY_IPhysicsController* DummyPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
{
//collision detection / raytesting
return NULL;
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index 9f6bc85fced..41462f91840 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -48,57 +48,57 @@ class DummyPhysicsEnvironment : public PHY_IPhysicsEnvironment
public:
DummyPhysicsEnvironment ();
virtual ~DummyPhysicsEnvironment ();
- virtual void beginFrame();
- virtual void endFrame();
+ virtual void BeginFrame();
+ virtual void EndFrame();
// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
- virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
- virtual float getFixedTimeStep();
+ virtual bool ProceedDeltaTime(double curTime,float timeStep,float interval);
+ virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
+ virtual float GetFixedTimeStep();
- virtual void setGravity(float x,float y,float z);
- virtual void getGravity(class MT_Vector3& grav);
+ virtual void SetGravity(float x,float y,float z);
+ virtual void GetGravity(class MT_Vector3& grav);
- virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+ virtual int CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X=0,float axis1Y=0,float axis1Z=0,
float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
);
- virtual void removeConstraint(int constraintid);
+ virtual void RemoveConstraint(int constraintid);
//complex constraint for vehicles
- virtual PHY_IVehicle* getVehicleConstraint(int constraintId)
+ virtual PHY_IVehicle* GetVehicleConstraint(int constraintId)
{
return 0;
}
// Character physics wrapper
- virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob)
+ virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob)
{
return 0;
}
- virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool cullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; }
+ virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
+ virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; }
//gamelogic callbacks
- virtual void addSensor(PHY_IPhysicsController* ctrl) {}
- virtual void removeSensor(PHY_IPhysicsController* ctrl) {}
- virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
+ virtual void AddSensor(PHY_IPhysicsController* ctrl) {}
+ virtual void RemoveSensor(PHY_IPhysicsController* ctrl) {}
+ virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
{
}
- virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; }
- virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) { return false;}
+ virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; }
+ virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl) { return false;}
virtual PHY_IPhysicsController* CreateSphereController(float radius,const class MT_Vector3& position) {return 0;}
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
- virtual void setConstraintParam(int constraintId,int param,float value,float value1)
+ virtual void SetConstraintParam(int constraintId,int param,float value,float value1)
{
}
- virtual float getConstraintParam(int constraintId,int param)
+ virtual float GetConstraintParam(int constraintId,int param)
{
return 0.f;
}
diff --git a/source/gameengine/Physics/common/PHY_IController.h b/source/gameengine/Physics/common/PHY_IController.h
index ae1b2d9ad53..284d77ca221 100644
--- a/source/gameengine/Physics/common/PHY_IController.h
+++ b/source/gameengine/Physics/common/PHY_IController.h
@@ -50,8 +50,8 @@ class PHY_IController
public:
virtual ~PHY_IController(){};
// clientinfo for raycasts for example
- virtual void* getNewClientInfo()=0;
- virtual void setNewClientInfo(void* clientinfo)=0;
+ virtual void* GetNewClientInfo()=0;
+ virtual void SetNewClientInfo(void* clientinfo)=0;
virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0;
diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h
index 5f64e7ccc80..b047edd93eb 100644
--- a/source/gameengine/Physics/common/PHY_IGraphicController.h
+++ b/source/gameengine/Physics/common/PHY_IGraphicController.h
@@ -47,8 +47,8 @@ class PHY_IGraphicController : public PHY_IController
*/
virtual bool SetGraphicTransform()=0;
virtual void Activate(bool active=true)=0;
- virtual void setLocalAabb(const class MT_Vector3& aabbMin,const class MT_Vector3& aabbMax)=0;
- virtual void setLocalAabb(const float* aabbMin,const float* aabbMax)=0;
+ virtual void SetLocalAabb(const class MT_Vector3& aabbMin,const class MT_Vector3& aabbMax)=0;
+ virtual void SetLocalAabb(const float* aabbMin,const float* aabbMax)=0;
virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;}
diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h
index be5b2b54907..d40b8da9451 100644
--- a/source/gameengine/Physics/common/PHY_IMotionState.h
+++ b/source/gameengine/Physics/common/PHY_IMotionState.h
@@ -46,18 +46,18 @@ class PHY_IMotionState
public:
virtual ~PHY_IMotionState(){};
- virtual void getWorldPosition(float& posX,float& posY,float& posZ)=0;
- virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)=0;
- virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0;
+ virtual void GetWorldPosition(float& posX,float& posY,float& posZ)=0;
+ virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)=0;
+ virtual void GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0;
// ori = array 12 floats, [0..3] = first column + 0, [4..7] = second column, [8..11] = third column
- virtual void getWorldOrientation(float* ori)=0;
- virtual void setWorldOrientation(const float* ori)=0;
+ virtual void GetWorldOrientation(float* ori)=0;
+ virtual void SetWorldOrientation(const float* ori)=0;
- virtual void setWorldPosition(float posX,float posY,float posZ)=0;
- virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0;
+ virtual void SetWorldPosition(float posX,float posY,float posZ)=0;
+ virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0;
- virtual void calculateWorldTransformations()=0;
+ virtual void CalculateWorldTransformations()=0;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index 18af42adc15..a1d0972a950 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -37,6 +37,10 @@
class PHY_IMotionState;
class PHY_IPhysicsEnvironment;
+class MT_Vector3;
+class MT_Point3;
+class MT_Matrix3x3;
+
/**
* PHY_IPhysicsController is the abstract simplified Interface to a physical object.
* It contains the IMotionState and IDeformableMesh Interfaces.
@@ -59,37 +63,47 @@ class PHY_IPhysicsController : public PHY_IController
virtual class PHY_IMotionState* GetMotionState() = 0;
// controller replication
virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)=0;
+ virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0;
// kinematic methods
- virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)=0;
- virtual void RelativeRotate(const float drot[12],bool local)=0;
- virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)=0;
- virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)=0;
- virtual void setPosition(float posX,float posY,float posZ)=0;
- virtual void getPosition(class MT_Vector3& pos) const=0;
- virtual void setScaling(float scaleX,float scaleY,float scaleZ)=0;
-
+ virtual void RelativeTranslate(const MT_Vector3& dloc,bool local)=0;
+ virtual void RelativeRotate(const MT_Matrix3x3&,bool local)=0;
+ virtual MT_Matrix3x3 GetOrientation()=0;
+ virtual void SetOrientation(const MT_Matrix3x3& orn)=0;
+ virtual void SetPosition(const MT_Vector3& pos)=0;
+ virtual void GetPosition(MT_Vector3& pos) const=0;
+ virtual void SetScaling(const MT_Vector3& scale)=0;
+ virtual void SetTransform()=0;
+
+ virtual MT_Scalar GetMass()=0;
+ virtual void SetMass(MT_Scalar newmass)=0;
+
// physics methods
- virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)=0;
- virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local)=0;
- virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)=0;
- virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)=0;
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
+ virtual void ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0;
+ virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0;
+ virtual void ApplyForce(const MT_Vector3& force,bool local)=0;
+ virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
+ virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0;
+ virtual void ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
+
+ virtual void SuspendDynamics(bool ghost=false)=0;
+ virtual void RestoreDynamics()=0;
- virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)=0;
virtual void SetActive(bool active)=0;
// reading out information from physics
- virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ)=0;
- virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)=0;
- virtual void getReactionForce(float& forceX,float& forceY,float& forceZ)=0;
+ virtual MT_Vector3 GetLinearVelocity()=0;
+ virtual MT_Vector3 GetAngularVelocity()=0;
+ virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0;
+ virtual MT_Vector3 GetLocalInertia()=0;
// dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted
- virtual void setRigidBody(bool rigid)=0;
+ virtual void SetRigidBody(bool rigid)=0;
virtual PHY_IPhysicsController* GetReplica() {return 0;}
+ virtual PHY_IPhysicsController* GetReplicaForSensors() {return 0;}
- virtual void calcXform() =0;
+ virtual void CalcXform() =0;
virtual void SetMargin(float margin) =0;
virtual float GetMargin() const=0;
virtual float GetRadius() const=0;
@@ -100,7 +114,15 @@ class PHY_IPhysicsController : public PHY_IController
virtual float GetLinVelocityMax() const=0;
virtual void SetLinVelocityMax(float val) = 0;
- class MT_Vector3 GetWorldPosition(class MT_Vector3& localpos);
+ MT_Vector3 GetWorldPosition(MT_Vector3& localpos);
+
+ // Shape control
+ virtual void AddCompoundChild(PHY_IPhysicsController* child) = 0;
+ virtual void RemoveCompoundChild(PHY_IPhysicsController* child) = 0;
+
+
+ virtual bool IsDynamic() = 0;
+ virtual bool IsCompound() = 0;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index 14904a70553..b1a0480ab14 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -105,87 +105,88 @@ public:
class PHY_IPhysicsEnvironment
{
public:
- virtual ~PHY_IPhysicsEnvironment(){};
- virtual void beginFrame() = 0;
- virtual void endFrame() = 0;
+ virtual ~PHY_IPhysicsEnvironment(){}
+ virtual void BeginFrame() = 0;
+ virtual void EndFrame() = 0;
/// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep,float interval)=0;
+ virtual bool ProceedDeltaTime(double curTime,float timeStep,float interval)=0;
///draw debug lines (make sure to call this during the render phase, otherwise lines are not drawn properly)
- virtual void debugDrawWorld() {}
- virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)=0;
+ virtual void DebugDrawWorld() {}
+ virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)=0;
//returns 0.f if no fixed timestep is used
- virtual float getFixedTimeStep()=0;
+ virtual float GetFixedTimeStep()=0;
///setDebugMode is used to support several ways of debug lines, contact point visualization
- virtual void setDebugMode(int debugMode) {}
+ virtual void SetDebugMode(int debugMode) {}
///setNumIterations set the number of iterations for iterative solvers
- virtual void setNumIterations(int numIter) {}
+ virtual void SetNumIterations(int numIter) {}
///setNumTimeSubSteps set the number of divisions of the timestep. Tradeoff quality versus performance.
- virtual void setNumTimeSubSteps(int numTimeSubSteps) {}
+ virtual void SetNumTimeSubSteps(int numTimeSubSteps) {}
+ virtual int GetNumTimeSubSteps() {return 0; }
///setDeactivationTime sets the minimum time that an objects has to stay within the velocity tresholds until it gets fully deactivated
- virtual void setDeactivationTime(float dTime) {}
+ virtual void SetDeactivationTime(float dTime) {}
///setDeactivationLinearTreshold sets the linear velocity treshold, see setDeactivationTime
- virtual void setDeactivationLinearTreshold(float linTresh) {}
+ virtual void SetDeactivationLinearTreshold(float linTresh) {}
///setDeactivationAngularTreshold sets the angular velocity treshold, see setDeactivationTime
- virtual void setDeactivationAngularTreshold(float angTresh) {}
+ virtual void SetDeactivationAngularTreshold(float angTresh) {}
///setContactBreakingTreshold sets tresholds to do with contact point management
- virtual void setContactBreakingTreshold(float contactBreakingTreshold) {}
+ virtual void SetContactBreakingTreshold(float contactBreakingTreshold) {}
///continuous collision detection mode, very experimental for Bullet
- virtual void setCcdMode(int ccdMode) {}
+ virtual void SetCcdMode(int ccdMode) {}
///successive overrelaxation constant, in case PSOR is used, values in between 1 and 2 guarantee converging behavior
- virtual void setSolverSorConstant(float sor) {}
+ virtual void SetSolverSorConstant(float sor) {}
///setSolverType, internal setting, chooses solvertype, PSOR, Dantzig, impulse based, penalty based
- virtual void setSolverType(int solverType) {}
+ virtual void SetSolverType(int solverType) {}
///setTau sets the spring constant of a penalty based solver
- virtual void setSolverTau(float tau) {}
+ virtual void SetSolverTau(float tau) {}
///setDamping sets the damper constant of a penalty based solver
- virtual void setSolverDamping(float damping) {}
+ virtual void SetSolverDamping(float damping) {}
///linear air damping for rigidbodies
- virtual void setLinearAirDamping(float damping) {}
+ virtual void SetLinearAirDamping(float damping) {}
/// penetrationdepth setting
- virtual void setUseEpa(bool epa) {}
+ virtual void SetUseEpa(bool epa) {}
- virtual void setGravity(float x,float y,float z)=0;
- virtual void getGravity(MT_Vector3& grav) = 0;
+ virtual void SetGravity(float x,float y,float z)=0;
+ virtual void GetGravity(MT_Vector3& grav) = 0;
- virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
+ virtual int CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axis0X,float axis0Y,float axis0Z,
float axis1X=0,float axis1Y=0,float axis1Z=0,
float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
)=0;
- virtual void removeConstraint(int constraintid)=0;
- virtual float getAppliedImpulse(int constraintid) { return 0.0f; }
+ virtual void RemoveConstraint(int constraintid)=0;
+ virtual float GetAppliedImpulse(int constraintid) { return 0.0f; }
//complex constraint for vehicles
- virtual PHY_IVehicle* getVehicleConstraint(int constraintId) =0;
+ virtual PHY_IVehicle* GetVehicleConstraint(int constraintId) =0;
// Character physics wrapper
- virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob) =0;
+ virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob) =0;
- virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0;
+ virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0;
//culling based on physical broad phase
// the plane number must be set as follow: near, far, left, right, top, botton
// the near plane must be the first one and must always be present, it is used to get the direction of the view
- virtual bool cullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0;
+ virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0;
//Methods for gamelogic collision/physics callbacks
//todo:
- virtual void addSensor(PHY_IPhysicsController* ctrl)=0;
- virtual void removeSensor(PHY_IPhysicsController* ctrl)=0;
- virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0;
- virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
- virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ virtual void AddSensor(PHY_IPhysicsController* ctrl)=0;
+ virtual void RemoveSensor(PHY_IPhysicsController* ctrl)=0;
+ virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0;
+ virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl)=0;
//These two methods are *solely* used to create controllers for sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position) =0;
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0;
- virtual void setConstraintParam(int constraintId,int param,float value,float value1) = 0;
- virtual float getConstraintParam(int constraintId,int param) = 0;
+ virtual void SetConstraintParam(int constraintId,int param,float value,float value1) = 0;
+ virtual float GetConstraintParam(int constraintId,int param) = 0;
- virtual void exportFile(const char* filename) {};
+ virtual void ExportFile(const char* filename) {};
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt
index 9061532ba5d..879115add47 100644
--- a/source/gameengine/Rasterizer/CMakeLists.txt
+++ b/source/gameengine/Rasterizer/CMakeLists.txt
@@ -47,7 +47,6 @@ set(SRC
RAS_BucketManager.cpp
RAS_FramingManager.cpp
RAS_IPolygonMaterial.cpp
- RAS_IRenderTools.cpp
RAS_MaterialBucket.cpp
RAS_MeshObject.cpp
RAS_Polygon.cpp
@@ -62,7 +61,6 @@ set(SRC
RAS_ICanvas.h
RAS_IPolygonMaterial.h
RAS_IRasterizer.h
- RAS_IRenderTools.h
RAS_LightObject.h
RAS_MaterialBucket.h
RAS_MeshObject.h
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
index a637baa3d09..bb727fe3b29 100644
--- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h
+++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
@@ -32,13 +32,14 @@
#ifndef __RAS_2DFILTERMANAGER_H__
#define __RAS_2DFILTERMANAGER_H__
-#include "RAS_ICanvas.h"
#define MAX_RENDER_PASS 100
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
+class RAS_ICanvas;
+
class RAS_2DFilterManager
{
private:
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
index 713d324bf17..eaa9b3df494 100644
--- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
@@ -35,16 +35,14 @@
#endif
#include "RAS_MaterialBucket.h"
-#include "STR_HashedString.h"
#include "RAS_MeshObject.h"
+#include "RAS_Polygon.h"
+#include "RAS_IPolygonMaterial.h"
#include "RAS_IRasterizer.h"
-#include "RAS_IRenderTools.h"
#include "RAS_BucketManager.h"
#include <algorithm>
-#include <set>
-
/* sorting */
struct RAS_BucketManager::sortedmeshslot
@@ -139,8 +137,7 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList
sort(slots.begin(), slots.end(), fronttoback());
}
-void RAS_BucketManager::RenderAlphaBuckets(
- const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
+void RAS_BucketManager::RenderAlphaBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
{
vector<sortedmeshslot> slots;
vector<sortedmeshslot>::iterator sit;
@@ -154,10 +151,10 @@ void RAS_BucketManager::RenderAlphaBuckets(
OrderBuckets(cameratrans, m_AlphaBuckets, slots, true);
for (sit=slots.begin(); sit!=slots.end(); ++sit) {
- rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj);
+ rasty->SetClientObject(sit->m_ms->m_clientObj);
- while (sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools))
- sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms));
+ while (sit->m_bucket->ActivateMaterial(cameratrans, rasty))
+ sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms));
// make this mesh slot culled automatically for next frame
// it will be culled out by frustrum culling
@@ -167,8 +164,7 @@ void RAS_BucketManager::RenderAlphaBuckets(
rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
}
-void RAS_BucketManager::RenderSolidBuckets(
- const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
+void RAS_BucketManager::RenderSolidBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
{
BucketList::iterator bit;
@@ -180,9 +176,9 @@ void RAS_BucketManager::RenderSolidBuckets(
RAS_MeshSlot* ms;
// remove the mesh slot form the list, it culls them automatically for next frame
while ((ms = bucket->GetNextActiveMeshSlot())) {
- rendertools->SetClientObject(rasty, ms->m_clientObj);
- while (bucket->ActivateMaterial(cameratrans, rasty, rendertools))
- bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *ms);
+ rasty->SetClientObject(ms->m_clientObj);
+ while (bucket->ActivateMaterial(cameratrans, rasty))
+ bucket->RenderMeshSlot(cameratrans, rasty, *ms);
// make this mesh slot culled automatically for next frame
// it will be culled out by frustrum culling
@@ -194,10 +190,10 @@ void RAS_BucketManager::RenderSolidBuckets(
if (mit->IsCulled())
continue;
- rendertools->SetClientObject(rasty, mit->m_clientObj);
+ rasty->SetClientObject(rasty, mit->m_clientObj);
- while ((*bit)->ActivateMaterial(cameratrans, rasty, rendertools))
- (*bit)->RenderMeshSlot(cameratrans, rasty, rendertools, *mit);
+ while ((*bit)->ActivateMaterial(cameratrans, rasty))
+ (*bit)->RenderMeshSlot(cameratrans, rasty, *mit);
// make this mesh slot culled automatically for next frame
// it will be culled out by frustrum culling
@@ -218,20 +214,19 @@ void RAS_BucketManager::RenderSolidBuckets(
for (sit=slots.begin(); sit!=slots.end(); ++sit) {
rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj);
- while (sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools))
- sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms));
+ while (sit->m_bucket->ActivateMaterial(cameratrans, rasty))
+ sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms));
}
#endif
}
-void RAS_BucketManager::Renderbuckets(
- const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
+void RAS_BucketManager::Renderbuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
{
/* beginning each frame, clear (texture/material) caching information */
rasty->ClearCachingInfo();
- RenderSolidBuckets(cameratrans, rasty, rendertools);
- RenderAlphaBuckets(cameratrans, rasty, rendertools);
+ RenderSolidBuckets(cameratrans, rasty);
+ RenderAlphaBuckets(cameratrans, rasty);
/* All meshes should be up to date now */
/* Don't do this while processing buckets because some meshes are split between buckets */
@@ -259,7 +254,7 @@ void RAS_BucketManager::Renderbuckets(
}
- rendertools->SetClientObject(rasty, NULL);
+ rasty->SetClientObject(NULL);
}
RAS_MaterialBucket *RAS_BucketManager::FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated)
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h
index bf88da6f1ba..f8c6375d474 100644
--- a/source/gameengine/Rasterizer/RAS_BucketManager.h
+++ b/source/gameengine/Rasterizer/RAS_BucketManager.h
@@ -51,8 +51,7 @@ public:
RAS_BucketManager();
virtual ~RAS_BucketManager();
- void Renderbuckets(const MT_Transform & cameratrans,
- RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
+ void Renderbuckets(const MT_Transform & cameratrans, RAS_IRasterizer* rasty);
RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated);
void OptimizeBuckets(MT_Scalar distance);
@@ -78,10 +77,10 @@ public:
private:
void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha);
- void RenderSolidBuckets(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
- void RenderAlphaBuckets(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
+ void RenderSolidBuckets(const MT_Transform& cameratrans,
+ RAS_IRasterizer* rasty);
+ void RenderAlphaBuckets(const MT_Transform& cameratrans,
+ RAS_IRasterizer* rasty);
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
index ddadd97b567..47e52318b33 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
@@ -33,8 +33,6 @@
#include "RAS_IPolygonMaterial.h"
#include "RAS_IRasterizer.h"
-#include "DNA_image_types.h"
-#include "DNA_meshdata_types.h"
#include "DNA_material_types.h"
void RAS_IPolyMaterial::Initialize(
@@ -235,6 +233,15 @@ Image *RAS_IPolyMaterial::GetBlenderImage() const
{
return NULL;
}
+MTFace *RAS_IPolyMaterial::GetMTFace() const
+{
+ return NULL;
+}
+
+unsigned int *RAS_IPolyMaterial::GetMCol() const
+{
+ return NULL;
+}
Scene* RAS_IPolyMaterial::GetBlenderScene() const
{
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
index 7aeeb364b47..2db71c3a2fe 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
@@ -35,7 +35,6 @@
#include "STR_HashedString.h"
#include "MT_Vector3.h"
-#include "STR_HashedString.h"
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
@@ -167,6 +166,8 @@ public:
virtual Material* GetBlenderMaterial() const;
virtual Image* GetBlenderImage() const;
+ virtual MTFace* GetMTFace() const;
+ virtual unsigned int* GetMCol() const;
virtual Scene* GetBlenderScene() const;
virtual void ReleaseMaterial();
virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index ace91f6dd51..034ea7f87a9 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -65,6 +65,13 @@ typedef vector< KX_IndexArray* > vecIndexArrays;
class RAS_IRasterizer
{
public:
+ enum RAS_TEXT_RENDER_MODE {
+ RAS_TEXT_RENDER_NODEF = 0,
+ RAS_TEXT_NORMAL,
+ RAS_TEXT_PADDED,
+ RAS_TEXT_MAX
+ };
+
RAS_IRasterizer(RAS_ICanvas* canv) {};
virtual ~RAS_IRasterizer() {};
@@ -247,11 +254,9 @@ public:
/**
* IndexPrimitives_3DText will render text into the polygons.
- * The text to be rendered is from \param rendertools client object's text property.
*/
virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools)=0;
+ class RAS_IPolyMaterial* polymat)=0;
virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0;
/* This one should become our final version, methinks. */
@@ -434,6 +439,78 @@ public:
virtual void SetUsingOverrideShader(bool val)=0;
virtual bool GetUsingOverrideShader()=0;
+ /**
+ * Render Tools
+ */
+ virtual void applyTransform(double* oglmatrix, int drawingmode)=0;
+
+ /**
+ * Renders 2D boxes.
+ * \param xco Position on the screen (origin in lower left corner).
+ * \param yco Position on the screen (origin in lower left corner).
+ * \param width Width of the canvas to draw to.
+ * \param height Height of the canvas to draw to.
+ * \param percentage Percentage of bar.
+ */
+ virtual void RenderBox2D(int xco,
+ int yco,
+ int width,
+ int height,
+ float percentage) = 0;
+
+ /**
+ * Renders 3D text string using BFL.
+ * \param fontid The id of the font.
+ * \param text The string to render.
+ * \param size The size of the text.
+ * \param dpi The resolution of the text.
+ * \param color The color of the object.
+ * \param mat The Matrix of the text object.
+ * \param aspect A scaling factor to compensate for the size.
+ */
+ virtual void RenderText3D(int fontid,
+ const char* text,
+ int size,
+ int dpi,
+ float* color,
+ double* mat,
+ float aspect
+ ) = 0;
+
+
+ /**
+ * Renders 2D text string.
+ * \param mode The type of text
+ * \param text The string to render.
+ * \param xco Position on the screen (origin in lower left corner).
+ * \param yco Position on the screen (origin in lower left corner).
+ * \param width Width of the canvas to draw to.
+ * \param height Height of the canvas to draw to.
+ */
+ virtual void RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height
+ ) = 0;
+
+ virtual void ProcessLighting(bool uselights, const MT_Transform& trans)=0;
+
+ virtual void PushMatrix()=0;
+
+ virtual void PopMatrix()=0;
+
+ virtual void AddLight(struct RAS_LightObject* lightobject)=0;
+
+ virtual void RemoveLight(struct RAS_LightObject* lightobject)=0;
+
+ virtual void MotionBlur()=0;
+
+ virtual void SetClientObject(void* obj)=0;
+
+ virtual void SetAuxilaryClientInfo(void* inf)=0;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer")
#endif
diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp
deleted file mode 100644
index 045373eff85..00000000000
--- a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_IRenderTools.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_IRenderTools.h"
-
-void RAS_IRenderTools::SetClientObject(RAS_IRasterizer* rasty, void *obj)
-{
- if (m_clientobject != obj)
- m_clientobject = obj;
-}
-
-void RAS_IRenderTools::SetAuxilaryClientInfo(void* inf)
-{
- m_auxilaryClientInfo = inf;
-}
-
-void RAS_IRenderTools::AddLight(struct RAS_LightObject* lightobject)
-{
- m_lights.push_back(lightobject);
-}
-
-void RAS_IRenderTools::RemoveLight(struct RAS_LightObject* lightobject)
-{
- std::vector<struct RAS_LightObject*>::iterator lit =
- std::find(m_lights.begin(),m_lights.end(),lightobject);
-
- if (!(lit==m_lights.end()))
- m_lights.erase(lit);
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h
deleted file mode 100644
index 6131abc0650..00000000000
--- a/source/gameengine/Rasterizer/RAS_IRenderTools.h
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_IRenderTools.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_IRENDERTOOLS_H__
-#define __RAS_IRENDERTOOLS_H__
-
-#include "MT_Transform.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_2DFilterManager.h"
-
-#include <vector>
-#include <algorithm>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_IPolyMaterial;
-struct RAS_LightObject;
-
-
-class RAS_IRenderTools
-{
-
-protected:
- void* m_clientobject;
- void* m_auxilaryClientInfo;
-
- std::vector<struct RAS_LightObject*> m_lights;
-
- RAS_2DFilterManager m_filtermanager;
-
-public:
- enum RAS_TEXT_RENDER_MODE {
- RAS_TEXT_RENDER_NODEF = 0,
- RAS_TEXT_NORMAL,
- RAS_TEXT_PADDED,
- RAS_TEXT_MAX
- };
-
- RAS_IRenderTools(
- ) :
- m_clientobject(NULL)
- {
- };
-
- virtual
- ~RAS_IRenderTools(
- ) {};
-
- virtual
- void
- BeginFrame(
- RAS_IRasterizer* rasty
- )=0;
-
- virtual
- void
- EndFrame(
- RAS_IRasterizer* rasty
- )=0;
-
- // the following function was formerly called 'Render'
- // by it doesn't render anymore
- // It only sets the transform for the rasterizer
- // so must be renamed to 'applyTransform' or something
-
- virtual
- void
- applyTransform(
- class RAS_IRasterizer* rasty,
- double* oglmatrix,
- int drawingmode
- )=0;
-
- /**
- * Renders 2D boxes.
- * \param xco Position on the screen (origin in lower left corner).
- * \param yco Position on the screen (origin in lower left corner).
- * \param width Width of the canvas to draw to.
- * \param height Height of the canvas to draw to.
- * \param percentage Percentage of bar.
- */
- virtual
- void
- RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage) = 0;
-
- /**
- * Renders 3D text string using BFL.
- * \param fontid The id of the font.
- * \param text The string to render.
- * \param size The size of the text.
- * \param dpi The resolution of the text.
- * \param color The color of the object.
- * \param mat The Matrix of the text object.
- * \param aspect A scaling factor to compensate for the size.
- */
- virtual
- void
- RenderText3D(int fontid,
- const char* text,
- int size,
- int dpi,
- float* color,
- double* mat,
- float aspect
- ) = 0;
-
-
- /**
- * Renders 2D text string.
- * \param mode The type of text
- * \param text The string to render.
- * \param xco Position on the screen (origin in lower left corner).
- * \param yco Position on the screen (origin in lower left corner).
- * \param width Width of the canvas to draw to.
- * \param height Height of the canvas to draw to.
- */
- virtual
- void
- RenderText2D(
- RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height
- ) = 0;
-
- // 3d text, mapped on polygon
- virtual
- void
- RenderText(
- int mode,
- RAS_IPolyMaterial* polymat,
- float v1[3],
- float v2[3],
- float v3[3],
- float v4[3],
- int glattrib
- )=0;
-
- virtual
- void
- ProcessLighting(
- RAS_IRasterizer *rasty,
- bool uselights,
- const MT_Transform& trans
- )=0;
-
- virtual
- void
- SetClientObject(
- RAS_IRasterizer* rasty,
- void* obj
- );
-
- void
- SetAuxilaryClientInfo(
- void* inf
- );
-
- virtual
- void
- PushMatrix(
- )=0;
-
- virtual
- void
- PopMatrix(
- )=0;
-
- virtual
- void
- AddLight(
- struct RAS_LightObject* lightobject
- );
-
- virtual
- void
- RemoveLight(
- struct RAS_LightObject* lightobject
- );
-
- virtual
- void
- MotionBlur(RAS_IRasterizer* rasterizer)=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRenderTools")
-#endif
-};
-
-#endif /* __RAS_IRENDERTOOLS_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
index 8ea09029a35..0c715524218 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
@@ -40,10 +40,9 @@
#include <windows.h>
#endif // WIN32
-#include "RAS_Polygon.h"
+#include "RAS_IPolygonMaterial.h"
#include "RAS_TexVert.h"
#include "RAS_IRasterizer.h"
-#include "RAS_IRenderTools.h"
#include "RAS_MeshObject.h"
#include "RAS_Deformer.h" // __NLA
@@ -581,8 +580,7 @@ list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msEnd()
return m_meshSlots.end();
}
-bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools *rendertools)
+bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
{
bool uselights;
@@ -593,13 +591,12 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I
return false;
uselights= m_material->UsesLighting(rasty);
- rendertools->ProcessLighting(rasty, uselights, cameratrans);
+ rasty->ProcessLighting(uselights, cameratrans);
return true;
}
-void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools* rendertools, RAS_MeshSlot &ms)
+void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_MeshSlot &ms)
{
m_material->ActivateMeshSlot(ms, rasty);
@@ -613,10 +610,10 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
if (IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix));
- rendertools->PushMatrix();
+ rasty->PushMatrix();
if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform())
{
- rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode());
+ rasty->applyTransform(ms.m_OpenGLMatrix,m_material->GetDrawingMode());
}
if (rasty->QueryLists())
@@ -641,7 +638,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
// for text drawing using faces
if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT)
- rasty->IndexPrimitives_3DText(ms, m_material, rendertools);
+ rasty->IndexPrimitives_3DText(ms, m_material);
// for multitexturing
else if ((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL)))
rasty->IndexPrimitivesMulti(ms);
@@ -649,7 +646,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
else
rasty->IndexPrimitives(ms);
- rendertools->PopMatrix();
+ rasty->PopMatrix();
}
void RAS_MaterialBucket::Optimize(MT_Scalar distance)
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
index 4c72f128817..007fdf240c4 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
@@ -34,17 +34,23 @@
#include "RAS_TexVert.h"
#include "CTR_Map.h"
-#include "STR_HashedString.h"
#include "SG_QList.h"
#include "MT_Transform.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_Deformer.h"
+#include "MT_Matrix4x4.h"
#include <vector>
#include <set>
#include <list>
+
+class RAS_MaterialBucket;
+struct DerivedMesh;
+class CTR_HashedPtr;
+class RAS_Deformer;
+class RAS_IPolyMaterial;
+class RAS_IRasterizer;
+class RAS_MeshObject;
+
using namespace std;
/* Display List Slot */
@@ -69,12 +75,6 @@ public:
virtual void SetModified(bool mod)=0;
};
-class RAS_DisplayArray;
-class RAS_MeshSlot;
-class RAS_MeshMaterial;
-class RAS_MaterialBucket;
-struct DerivedMesh;
-
/* An array with data used for OpenGL drawing */
class RAS_DisplayArray
@@ -219,10 +219,8 @@ public:
bool IsZSort() const;
/* Rendering */
- bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools *rendertools);
- void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools* rendertools, RAS_MeshSlot &ms);
+ bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty);
+ void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_MeshSlot &ms);
/* Mesh Slot Access */
list<RAS_MeshSlot>::iterator msBegin();
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
index 8a9672f0092..ff909b5955f 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
@@ -29,23 +29,19 @@
* \ingroup bgerast
*/
-#include "MEM_guardedalloc.h"
-
-#include "DNA_object_types.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
+
+#include "CTR_HashedPtr.h"
#include "RAS_MeshObject.h"
-#include "RAS_IRasterizer.h"
-#include "MT_MinMax.h"
+#include "RAS_Polygon.h"
+#include "RAS_IPolygonMaterial.h"
+#include "RAS_Deformer.h"
#include "MT_Point3.h"
#include <algorithm>
-extern "C" {
-# include "BKE_deform.h"
-}
/* polygon sorting */
@@ -540,6 +536,16 @@ void RAS_MeshObject::SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transfor
}
+bool RAS_MeshObject::HasColliderPolygon()
+{
+ int numpolys= NumPolygons();
+ for (int p=0; p<numpolys; p++)
+ if (m_Polygons[p]->IsCollider())
+ return true;
+
+ return false;
+}
+
void RAS_MeshObject::SchedulePolygons(int drawingmode)
{
if (m_bModified)
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h
index e5ae78d006e..4f352379d39 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.h
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.h
@@ -38,17 +38,15 @@
#endif
#include <vector>
-#include <set>
#include <list>
-#include "RAS_Polygon.h"
#include "RAS_MaterialBucket.h"
#include "MT_Transform.h"
-
-#include "CTR_HashedPtr.h"
+#include "STR_String.h"
struct Mesh;
class RAS_Deformer;
+class RAS_Polygon;
/* RAS_MeshObject is a mesh used for rendering. It stores polygons,
* but the actual vertices and index arrays are stored in material
@@ -65,7 +63,7 @@ private:
STR_String m_name;
static STR_String s_emptyname;
- vector<class RAS_Polygon*> m_Polygons;
+ vector<RAS_Polygon*> m_Polygons;
/* polygon sorting */
struct polygonSlot;
@@ -150,14 +148,7 @@ public:
void SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform);
- bool HasColliderPolygon() {
- int numpolys= NumPolygons();
- for (int p=0; p<numpolys; p++)
- if (m_Polygons[p]->IsCollider())
- return true;
-
- return false;
- }
+ bool HasColliderPolygon();
/* for construction to find shared vertices */
struct SharedVertex {
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
index 6b53990770f..76ac6316e38 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
@@ -25,9 +25,15 @@
set(INC
..
+ # XXX Remove these <<<
../../BlenderRoutines
+ ../../Expressions
+ ../../GameLogic
../../Ketsji
+ ../../Physics/common
+ # >>>
../../SceneGraph
+ ../../../blender/blenfont
../../../blender/blenkernel
../../../blender/blenlib
../../../blender/gpu
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
index 665053984e6..32cc4ba9fea 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
@@ -32,6 +32,8 @@
#include <iostream>
+#include "GL/glew.h"
+
#include "RAS_GLExtensionManager.h"
namespace bgl
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
index 1b4d3219335..9f2039b4c6f 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
@@ -32,8 +32,6 @@
#ifndef __RAS_GLEXTENSIONMANAGER_H__
#define __RAS_GLEXTENSIONMANAGER_H__
-#include "GL/glew.h"
-
/** Note: this used to have a lot more code, but now extension handling
* is done by GLEW, so it does mostly debug stuff */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h
index f5c16bc8cd8..bfa6e1a6cb7 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h
@@ -28,14 +28,11 @@
#ifndef __KX_STORAGE
#define __KX_STORAGE
-#include "RAS_MaterialBucket.h"
+#ifdef WITH_CXX_GUARDEDALLOC
+ #include "MEM_guardedalloc.h"
+#endif
-enum RAS_STORAGE_TYPE {
- RAS_AUTO_STORAGE,
- RAS_IMMEDIATE,
- RAS_VA,
- RAS_VBO
-};
+class RAS_MeshSlot;
class RAS_IStorage
{
@@ -47,15 +44,13 @@ public:
virtual void Exit()=0;
virtual void IndexPrimitives(RAS_MeshSlot& ms)=0;
- virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0;
+ virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms)=0;
virtual void SetDrawingMode(int drawingmode)=0;
#ifdef WITH_CXX_GUARDEDALLOC
-public:
- void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IStorage"); }
- void operator delete( void *mem ) { MEM_freeN(mem); }
+ MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IStorage")
#endif
};
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index bfc74e0c6dc..2884983a17e 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -37,11 +37,13 @@
#include "GL/glew.h"
+#include "RAS_ICanvas.h"
#include "RAS_Rect.h"
#include "RAS_TexVert.h"
#include "RAS_MeshObject.h"
+#include "RAS_Polygon.h"
+#include "RAS_LightObject.h"
#include "MT_CmMatrix4x4.h"
-#include "RAS_IRenderTools.h" // rendering text
#include "RAS_StorageIM.h"
#include "RAS_StorageVA.h"
@@ -49,18 +51,20 @@
#include "GPU_draw.h"
#include "GPU_material.h"
-#include "GPU_extensions.h"
-
-#include "DNA_image_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_material_types.h"
-#include "DNA_scene_types.h"
extern "C"{
- #include "BLI_utildefines.h"
- #include "BKE_DerivedMesh.h"
+ #include "BLF_api.h"
}
+
+// XXX Clean these up <<<
+#include "Value.h"
+#include "KX_Light.h"
+#include "KX_Scene.h"
+#include "KX_RayCast.h"
+#include "KX_GameObject.h"
+// >>>
+
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
@@ -94,6 +98,8 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage)
m_motionblur(0),
m_motionblurvalue(-1.0),
m_usingoverrideshader(false),
+ m_clientobject(NULL),
+ m_auxilaryClientInfo(NULL),
m_texco_num(0),
m_attrib_num(0),
//m_last_alphablend(GPU_BLEND_SOLID),
@@ -131,6 +137,10 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage)
m_storage = m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer);
m_storage_type = RAS_IMMEDIATE;
}
+
+ glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights);
+ if (m_numgllights < 8)
+ m_numgllights = 8;
}
@@ -350,6 +360,13 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time)
glEnable(GL_MULTISAMPLE_ARB);
m_2DCanvas->BeginFrame();
+
+ // Render Tools
+ m_clientobject = NULL;
+ m_lastlightlayer = -1;
+ m_lastauxinfo = NULL;
+ m_lastlighting = true; /* force disable in DisableOpenGLLights() */
+ DisableOpenGLLights();
return true;
}
@@ -650,13 +667,14 @@ const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewInvMatrix() const
}
void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools)
+ class RAS_IPolyMaterial* polymat)
{
bool obcolor = ms.m_bObjectColor;
MT_Vector4& rgba = ms.m_RGBAcolor;
RAS_MeshSlot::iterator it;
+ const STR_String& mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
+
// handle object color
if (obcolor) {
glDisableClientState(GL_COLOR_ARRAY);
@@ -707,9 +725,8 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
for (unit=0; unit<m_attrib_num; unit++)
if (m_attrib[unit] == RAS_TEXCO_UV)
glattrib = unit;
-
- rendertools->RenderText(polymat->GetDrawingMode(), polymat,
- v[0], v[1], v[2], (numvert == 4)? v[3]: NULL, glattrib);
+
+ GPU_render_text(polymat->GetMTFace(), polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(), v[0], v[1], v[2], v[3], glattrib);
ClearCachingInfo();
}
@@ -1107,3 +1124,440 @@ bool RAS_OpenGLRasterizer::GetUsingOverrideShader()
return m_usingoverrideshader;
}
+/**
+ * Render Tools
+ */
+
+/* ProcessLighting performs lighting on objects. the layer is a bitfield that
+ * contains layer information. There are 20 'official' layers in blender. A
+ * light is applied on an object only when they are in the same layer. OpenGL
+ * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in
+ * a scene. */
+
+void RAS_OpenGLRasterizer::ProcessLighting(bool uselights, const MT_Transform& viewmat)
+{
+ bool enable = false;
+ int layer= -1;
+
+ /* find the layer */
+ if (uselights) {
+ if (m_clientobject)
+ layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
+ }
+
+ /* avoid state switching */
+ if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo)
+ return;
+
+ m_lastlightlayer = layer;
+ m_lastauxinfo = m_auxilaryClientInfo;
+
+ /* enable/disable lights as needed */
+ if (layer >= 0) {
+ //enable = ApplyLights(layer, viewmat);
+ // taken from blender source, incompatibility between Blender Object / GameObject
+ KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo;
+ float glviewmat[16];
+ unsigned int count;
+ std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin();
+
+ for (count=0; count<m_numgllights; count++)
+ glDisable((GLenum)(GL_LIGHT0+count));
+
+ viewmat.getValue(glviewmat);
+
+ glPushMatrix();
+ glLoadMatrixf(glviewmat);
+ for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
+ {
+ RAS_LightObject* lightdata = (*lit);
+ KX_LightObject *kxlight = (KX_LightObject*)lightdata->m_light;
+
+ if (kxlight->ApplyLight(kxscene, layer, count))
+ count++;
+ }
+ glPopMatrix();
+
+ enable = count > 0;
+ }
+
+ if (enable)
+ EnableOpenGLLights();
+ else
+ DisableOpenGLLights();
+}
+
+void RAS_OpenGLRasterizer::EnableOpenGLLights()
+{
+ if (m_lastlighting == true)
+ return;
+
+ glEnable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (GetCameraOrtho())? GL_FALSE: GL_TRUE);
+ if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
+ glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+
+ m_lastlighting = true;
+}
+
+void RAS_OpenGLRasterizer::DisableOpenGLLights()
+{
+ if (m_lastlighting == false)
+ return;
+
+ glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+
+ m_lastlighting = false;
+}
+
+void RAS_OpenGLRasterizer::AddLight(struct RAS_LightObject* lightobject)
+{
+ m_lights.push_back(lightobject);
+}
+
+void RAS_OpenGLRasterizer::RemoveLight(struct RAS_LightObject* lightobject)
+{
+ std::vector<struct RAS_LightObject*>::iterator lit =
+ std::find(m_lights.begin(),m_lights.end(),lightobject);
+
+ if (!(lit==m_lights.end()))
+ m_lights.erase(lit);
+}
+
+bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, void * const data)
+{
+ double* const oglmatrix = (double* const) data;
+
+ RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
+ if (!poly->IsVisible())
+ return false;
+
+ MT_Point3 resultpoint(result->m_hitPoint);
+ MT_Vector3 resultnormal(result->m_hitNormal);
+ MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
+ MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
+ left = (dir.cross(resultnormal)).safe_normalized();
+ // for the up vector, we take the 'resultnormal' returned by the physics
+
+ double maat[16] = {left[0], left[1], left[2], 0,
+ dir[0], dir[1], dir[2], 0,
+ resultnormal[0], resultnormal[1], resultnormal[2], 0,
+ 0, 0, 0, 1};
+
+ glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
+ //glMultMatrixd(oglmatrix);
+ glMultMatrixd(maat);
+ return true;
+}
+
+void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
+{
+ /* FIXME:
+ blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
+ MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed.
+
+ Program received signal SIGABRT, Aborted.
+ [Switching to Thread 16384 (LWP 1519)]
+ 0x40477571 in kill () from /lib/libc.so.6
+ (gdb) bt
+ #7 0x08334368 in MT_Vector3::normalized() const ()
+ #8 0x0833e6ec in RAS_OpenGLRasterizer::applyTransform(RAS_IRasterizer*, double*, int) ()
+ */
+
+ if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
+ objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
+ {
+ // rotate the billboard/halo
+ //page 360/361 3D Game Engine Design, David Eberly for a discussion
+ // on screen aligned and axis aligned billboards
+ // assumed is that the preprocessor transformed all billboard polygons
+ // so that their normal points into the positive x direction (1.0, 0.0, 0.0)
+ // when new parenting for objects is done, this rotation
+ // will be moved into the object
+
+ MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
+ MT_Point3 campos = GetCameraPosition();
+ MT_Vector3 dir = (campos - objpos).safe_normalized();
+ MT_Vector3 up(0,0,1.0);
+
+ KX_GameObject* gameobj = (KX_GameObject*)m_clientobject;
+ // get scaling of halo object
+ MT_Vector3 size = gameobj->GetSGNode()->GetWorldScaling();
+
+ bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
+ if (screenaligned)
+ {
+ up = (up - up.dot(dir) * dir).safe_normalized();
+ } else
+ {
+ dir = (dir - up.dot(dir)*up).safe_normalized();
+ }
+
+ MT_Vector3 left = dir.normalized();
+ dir = (up.cross(left)).normalized();
+
+ // we have calculated the row vectors, now we keep
+ // local scaling into account:
+
+ left *= size[0];
+ dir *= size[1];
+ up *= size[2];
+
+ double maat[16] = {left[0], left[1], left[2], 0,
+ dir[0], dir[1], dir[2], 0,
+ up[0], up[1], up[2], 0,
+ 0, 0, 0, 1};
+
+ glTranslated(objpos[0],objpos[1],objpos[2]);
+ glMultMatrixd(maat);
+
+ }
+ else {
+ if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
+ {
+ // shadow must be cast to the ground, physics system needed here!
+ MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
+ KX_GameObject *gameobj = (KX_GameObject*)m_clientobject;
+ MT_Vector3 direction = MT_Vector3(0,0,-1);
+
+ direction.normalize();
+ direction *= 100000;
+
+ MT_Point3 topoint = frompoint + direction;
+
+ KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
+ PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
+ PHY_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
+
+ KX_GameObject *parent = gameobj->GetParent();
+ if (!physics_controller && parent)
+ physics_controller = parent->GetPhysicsController();
+ if (parent)
+ parent->Release();
+
+ KX_RayCast::Callback<RAS_OpenGLRasterizer> callback(this, physics_controller, oglmatrix);
+ if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
+ {
+ // couldn't find something to cast the shadow on...
+ glMultMatrixd(oglmatrix);
+ }
+ else
+ { // we found the "ground", but the cast matrix doesn't take
+ // scaling in consideration, so we must apply the object scale
+ MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
+ glScalef(size[0], size[1], size[2]);
+ }
+ } else
+ {
+
+ // 'normal' object
+ glMultMatrixd(oglmatrix);
+ }
+ }
+}
+
+static void DisableForText()
+{
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */
+
+ glDisable(GL_BLEND);
+ glDisable(GL_ALPHA_TEST);
+
+ glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+
+ if (GLEW_ARB_multitexture) {
+ for (int i=0; i<RAS_MAX_TEXCO; i++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB+i);
+
+ if (GLEW_ARB_texture_cube_map)
+ glDisable(GL_TEXTURE_CUBE_MAP_ARB);
+
+ glDisable(GL_TEXTURE_2D);
+ }
+
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ }
+ else {
+ if (GLEW_ARB_texture_cube_map)
+ glDisable(GL_TEXTURE_CUBE_MAP_ARB);
+
+ glDisable(GL_TEXTURE_2D);
+ }
+}
+
+void RAS_OpenGLRasterizer::RenderBox2D(int xco,
+ int yco,
+ int width,
+ int height,
+ float percentage)
+{
+ /* This is a rather important line :( The gl-mode hasn't been left
+ * behind quite as neatly as we'd have wanted to. I don't know
+ * what cause it, though :/ .*/
+ glDisable(GL_DEPTH_TEST);
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glOrtho(0, width, 0, height, -100, 100);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ yco = height - yco;
+ int barsize = 50;
+
+ /* draw in black first*/
+ glColor3ub(0, 0, 0);
+ glBegin(GL_QUADS);
+ glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10);
+ glVertex2f(xco + 1, yco - 1 + 10);
+ glVertex2f(xco + 1, yco - 1);
+ glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1);
+ glEnd();
+
+ glColor3ub(255, 255, 255);
+ glBegin(GL_QUADS);
+ glVertex2f(xco + 1 + barsize * percentage, yco + 10);
+ glVertex2f(xco, yco + 10);
+ glVertex2f(xco, yco);
+ glVertex2f(xco + 1 + barsize * percentage, yco);
+ glEnd();
+
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glEnable(GL_DEPTH_TEST);
+}
+
+void RAS_OpenGLRasterizer::RenderText3D(int fontid,
+ const char* text,
+ int size,
+ int dpi,
+ float* color,
+ double* mat,
+ float aspect)
+{
+ /* gl prepping */
+ DisableForText();
+
+ /* the actual drawing */
+ glColor4fv(color);
+
+ /* multiply the text matrix by the object matrix */
+ BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
+ BLF_matrix(fontid, mat);
+
+ /* aspect is the inverse scale that allows you to increase */
+ /* your resolution without sizing the final text size */
+ /* the bigger the size, the smaller the aspect */
+ BLF_aspect(fontid, aspect, aspect, aspect);
+
+ BLF_size(fontid, size, dpi);
+ BLF_position(fontid, 0, 0, 0);
+ BLF_draw(fontid, (char *)text, 65535);
+
+ BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
+}
+
+void RAS_OpenGLRasterizer::RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height)
+{
+ /* This is a rather important line :( The gl-mode hasn't been left
+ * behind quite as neatly as we'd have wanted to. I don't know
+ * what cause it, though :/ .*/
+ DisableForText();
+ glDisable(GL_DEPTH_TEST);
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glOrtho(0, width, 0, height, -100, 100);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ if (mode == RAS_TEXT_PADDED) {
+ /* draw in black first*/
+ glColor3ub(0, 0, 0);
+ BLF_size(blf_mono_font, 11, 72);
+ BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
+ BLF_draw(blf_mono_font, (char *)text, 65535);/* XXX, use real len */
+ }
+
+ /* the actual drawing */
+ glColor3ub(255, 255, 255);
+ BLF_size(blf_mono_font, 11, 72);
+ BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
+ BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */
+
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glEnable(GL_DEPTH_TEST);
+}
+
+void RAS_OpenGLRasterizer::PushMatrix()
+{
+ glPushMatrix();
+}
+
+void RAS_OpenGLRasterizer::PopMatrix()
+{
+ glPopMatrix();
+}
+
+void RAS_OpenGLRasterizer::MotionBlur()
+{
+ int state = GetMotionBlurState();
+ float motionblurvalue;
+ if (state)
+ {
+ motionblurvalue = GetMotionBlurValue();
+ if (state==1)
+ {
+ //bugfix:load color buffer into accum buffer for the first time(state=1)
+ glAccum(GL_LOAD, 1.0);
+ SetMotionBlurState(2);
+ }
+ else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) {
+ glAccum(GL_MULT, motionblurvalue);
+ glAccum(GL_ACCUM, 1-motionblurvalue);
+ glAccum(GL_RETURN, 1.0);
+ glFlush();
+ }
+ }
+}
+
+void RAS_OpenGLRasterizer::SetClientObject(void* obj)
+{
+ if (m_clientobject != obj)
+ {
+ bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling());
+ SetFrontFace(ccw);
+
+ m_clientobject = obj;
+ }
+}
+
+void RAS_OpenGLRasterizer::SetAuxilaryClientInfo(void* inf)
+{
+ m_auxilaryClientInfo = inf;
+}
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
index c638c40d34b..01c42050b36 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
@@ -41,13 +41,22 @@
using namespace std;
#include "RAS_IRasterizer.h"
-#include "RAS_IStorage.h"
#include "RAS_MaterialBucket.h"
-#include "RAS_ICanvas.h"
+#include "RAS_IPolygonMaterial.h"
+
+class RAS_IStorage;
+class RAS_ICanvas;
#define RAS_MAX_TEXCO 8 // match in BL_Material
#define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader
+enum RAS_STORAGE_TYPE {
+ RAS_AUTO_STORAGE,
+ RAS_IMMEDIATE,
+ RAS_VA,
+ RAS_VBO
+};
+
struct OglDebugShape
{
enum SHAPE_TYPE{
@@ -105,6 +114,15 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer
bool m_usingoverrideshader;
+ // Render tools
+ void* m_clientobject;
+ void* m_auxilaryClientInfo;
+ std::vector<struct RAS_LightObject*> m_lights;
+ int m_lastlightlayer;
+ bool m_lastlighting;
+ void *m_lastauxinfo;
+ unsigned int m_numgllights;
+
protected:
int m_drawingmode;
TexCoGen m_texco[RAS_MAX_TEXCO];
@@ -171,10 +189,8 @@ public:
virtual void IndexPrimitives(class RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
- virtual void IndexPrimitives_3DText(
- class RAS_MeshSlot& ms,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools);
+ virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms,
+ class RAS_IPolyMaterial* polymat);
virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat);
virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat);
@@ -330,6 +346,56 @@ public:
virtual void SetUsingOverrideShader(bool val);
virtual bool GetUsingOverrideShader();
+ /**
+ * Render Tools
+ */
+ void EnableOpenGLLights();
+ void DisableOpenGLLights();
+ void ProcessLighting(bool uselights, const MT_Transform& viewmat);
+
+ void RenderBox2D(int xco,
+ int yco,
+ int width,
+ int height,
+ float percentage);
+
+
+ void RenderText3D(int fontid,
+ const char* text,
+ int size,
+ int dpi,
+ float* color,
+ double* mat,
+ float aspect);
+
+ void RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height);
+
+ void applyTransform(double* oglmatrix, int objectdrawmode);
+
+ void PushMatrix();
+ void PopMatrix();
+
+ bool RayHit(struct KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data);
+ bool NeedRayCast(struct KX_ClientObjectInfo*) { return true; }
+
+
+ void AddLight(struct RAS_LightObject* lightobject);
+
+ void RemoveLight(struct RAS_LightObject* lightobject);
+ int ApplyLights(int objectlayer, const MT_Transform& viewmat);
+
+ void MotionBlur();
+
+ void SetClientObject(void* obj);
+
+ void SetAuxilaryClientInfo(void* inf);
+
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_OpenGLRasterizer")
#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp
index 77bd540a039..40afcf04aac 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp
@@ -26,16 +26,15 @@
*/
#include "RAS_StorageIM.h"
+#include "RAS_MaterialBucket.h"
+#include "RAS_IPolygonMaterial.h"
#include "GL/glew.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_material.h"
-#include "DNA_meshdata_types.h"
-
extern "C"{
- #include "BLI_utildefines.h"
#include "BKE_DerivedMesh.h"
}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
index ce2f98b3837..0a7417656c6 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
@@ -13,13 +13,17 @@ incs = [
'#extern/glew/include',
'#intern/moto/include',
'#source/blender/blenkernel',
+ '#source/blender/blenfont',
'#source/blender/blenlib',
'#source/blender/gpu',
'#source/blender/makesdna',
'#source/gameengine/BlenderRoutines',
+ '#source/gameengine/Expressions',
+ '#source/gameengine/GameLogic',
+ '#source/gameengine/Physics/common',
'#source/gameengine/Rasterizer',
'#source/gameengine/SceneGraph',
- '#source/blender/gameengine/Ketsji',
+ '#source/gameengine/Ketsji',
env['BF_OPENGL_INC'],
]
incs = ' '.join(incs)
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp
index 72e09c9667d..1f23df90753 100644
--- a/source/gameengine/Rasterizer/RAS_Polygon.cpp
+++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp
@@ -34,6 +34,7 @@
#endif
#include "RAS_Polygon.h"
+#include "RAS_MaterialBucket.h"
RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
{
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h
index 088bdbd6844..b18477a72d2 100644
--- a/source/gameengine/Rasterizer/RAS_Polygon.h
+++ b/source/gameengine/Rasterizer/RAS_Polygon.h
@@ -32,11 +32,9 @@
#ifndef __RAS_POLYGON_H__
#define __RAS_POLYGON_H__
-#include "RAS_TexVert.h"
-#include "RAS_MaterialBucket.h"
-
-#include <vector>
-using namespace std;
+class RAS_DisplayArray;
+class RAS_MaterialBucket;
+class RAS_TexVert;
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp
index d83cd2dc6fd..6908bc6db9c 100644
--- a/source/gameengine/VideoTexture/ImageRender.cpp
+++ b/source/gameengine/VideoTexture/ImageRender.cpp
@@ -42,6 +42,7 @@
#include "DNA_scene_types.h"
#include "RAS_CameraData.h"
#include "RAS_MeshObject.h"
+#include "RAS_Polygon.h"
#include "BLI_math.h"
#include "ImageRender.h"
@@ -80,7 +81,6 @@ ImageRender::ImageRender (KX_Scene *scene, KX_Camera * camera) :
m_engine = KX_GetActiveEngine();
m_rasterizer = m_engine->GetRasterizer();
m_canvas = m_engine->GetCanvas();
- m_rendertools = m_engine->GetRenderTools();
}
// destructor
@@ -200,9 +200,8 @@ void ImageRender::Render()
m_canvas->ClearColor(m_background[0], m_background[1], m_background[2], m_background[3]);
m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER);
m_rasterizer->BeginFrame(RAS_IRasterizer::KX_TEXTURED,m_engine->GetClockTime());
- m_rendertools->BeginFrame(m_rasterizer);
m_engine->SetWorldSettings(m_scene->GetWorldInfo());
- m_rendertools->SetAuxilaryClientInfo(m_scene);
+ m_rasterizer->SetAuxilaryClientInfo(m_scene);
m_rasterizer->DisplayFog();
// matrix calculation, don't apply any of the stereo mode
m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO);
@@ -275,7 +274,7 @@ void ImageRender::Render()
m_scene->CalculateVisibleMeshes(m_rasterizer,m_camera);
- m_scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
+ m_scene->RenderBuckets(camtrans, m_rasterizer);
m_scene->RenderFonts();
@@ -595,7 +594,6 @@ ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObjec
m_engine = KX_GetActiveEngine();
m_rasterizer = m_engine->GetRasterizer();
m_canvas = m_engine->GetCanvas();
- m_rendertools = m_engine->GetRenderTools();
// locate the vertex assigned to mat and do following calculation in mesh coordinates
for (int meshIndex = 0; meshIndex < mirror->GetMeshCount(); meshIndex++)
{
diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h
index 680e1cc1d89..98dceeaafe1 100644
--- a/source/gameengine/VideoTexture/ImageRender.h
+++ b/source/gameengine/VideoTexture/ImageRender.h
@@ -39,7 +39,6 @@
#include "DNA_screen_types.h"
#include "RAS_ICanvas.h"
#include "RAS_IRasterizer.h"
-#include "RAS_IRenderTools.h"
#include "ImageViewport.h"
@@ -88,8 +87,6 @@ protected:
RAS_ICanvas* m_canvas;
/// rasterizer
RAS_IRasterizer* m_rasterizer;
- /// render tools
- RAS_IRenderTools* m_rendertools;
/// engine
KX_KetsjiEngine* m_engine;
diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp
index 28fff8b9a6c..789b6006f99 100644
--- a/source/gameengine/VideoTexture/ImageViewport.cpp
+++ b/source/gameengine/VideoTexture/ImageViewport.cpp
@@ -36,6 +36,7 @@
#include "GL/glew.h"
#include "KX_PythonInit.h"
+#include "RAS_ICanvas.h"
#include "Texture.h"
#include "ImageBase.h"
#include "VideoBase.h"
diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp
index 1efbc50bfe0..c187f7c41c1 100644
--- a/source/gameengine/VideoTexture/Texture.cpp
+++ b/source/gameengine/VideoTexture/Texture.cpp
@@ -40,7 +40,6 @@
#include "DNA_meshdata_types.h"
#include "DNA_image_types.h"
#include "IMB_imbuf_types.h"
-#include "KX_PolygonMaterial.h"
#include "MEM_guardedalloc.h"
@@ -229,19 +228,12 @@ static int Texture_init(Texture *self, PyObject *args, PyObject *kwds)
{
self->m_imgTexture = static_cast<KX_BlenderMaterial*>(mat)->getImage(texID);
self->m_useMatTexture = false;
- } else if (mat->GetFlag() & RAS_BLENDERMAT)
+ } else
{
// get blender material texture
self->m_matTexture = static_cast<KX_BlenderMaterial*>(mat)->getTex(texID);
self->m_useMatTexture = true;
}
- else
- {
- // get texture pointer from polygon material
- MTFace * tface = static_cast<KX_PolygonMaterial*>(mat)->GetMTFace();
- self->m_imgTexture = (Image*)tface->tpage;
- self->m_useMatTexture = false;
- }
}
else if (lamp != NULL)
{